bump java-kit

master
io42630 3 days ago
parent 1890db68dd
commit 81f70fccfe

@ -0,0 +1,25 @@
package com.olexyn.field.kit.hacker.rank.problems;
public class CatMouseABC {
public static void main(String[] args) {
}
static String catAndMouse(int x, int y, int z) {
int dx = Math.abs(x - z);
int dy = Math.abs(y - z);
if (dx == dy) {
return "Mouse C";
}
if (dx < dy) {
return "Cat A";
}
return "Cat B";
}
}

@ -0,0 +1,30 @@
package com.olexyn.field.kit.hacker.rank.problems;
public class KeysBudget {
public static void main(String[] args) {
}
static int getMoneySpent(int[] keyboards, int[] drives, int b) {
int max = -1;
for (int k : keyboards) {
for (int d : drives) {
int sum = k + d;
if (sum <= b && sum > max) {
max = sum;
}
if (max == b) {
return max;
}
}
}
return max;
}
}

@ -5,26 +5,27 @@ public class Valleys {
public static void main(String[] args) {
countingValleys(
8,
"UDDDUDUU"
12,
"DDUUDDUDUUUD"
);
System.out.println("hi");
}
public static int countingValleys(int steps, String path) {
// Write your code here
int prevLevel = 0;
int level = 0;
int valleys = 0;
String[] paths = path.split("");
for (int i = 0; i < paths.length; i++) {
if (paths[i].equals("U")) {
for (String s : path.split("")) {
if (s.equals("U")) {
prevLevel = level;
level++;
} else {
prevLevel = level;
level--;
}
if (i != 0 && level == 0 && paths[i - 1].equals("U")) {
if (prevLevel == -1 && level == 0 && s.equals("U")) {
valleys++;
}
}

@ -1,13 +0,0 @@
package org.example;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}
Loading…
Cancel
Save