code stringlengths 146 466k | prompt stringlengths 54 1.5k |
|---|---|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return length of given string
>>> strlen("")
0
>>> strlen("abc")
3
*/
public int strlen(String string) {
return string.length();
}
}
```
Hope this helps! | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return length of given string
>>> strlen("")
0
>>> strlen("abc")
3
*/
public int strlen(String string) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
For a given number n, find the largest number that divides n evenly, smaller than n
>>> largestDivisor(15)
5
*/
public int largestDivisor(int n) {
for (int i = n - 1; i > 0; i-... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
For a given number n, find the largest number that divides n evenly, smaller than n
>>> largestDivisor(15)
5
*/
public int largestDivisor(int n) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return list of prime factors of given integer in the order from smallest to largest.
Each of the factors should be listed number of times corresponding to how many times it appeares in fact... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return list of prime factors of given integer in the order from smallest to largest.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;
class Solution {
/**
From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
>>> removeDuplicates(Ar... | Make method to complete this class:
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;
class Solution {
/**
From a list of integers, remove all elements that occur more than once.
Keep order of elements left the same as in the input.
>>> removeDuplicates(Array.asList(1, 2, 3, 2... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
>>> flipCase("Hello")
"hELLO"
*/
public String flipCase(String string) {
StringBuilder sb... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
>>> flipCase("Hello")
"hELLO"
*/
public String flipCase(String string) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Concatenate list of strings into a single string
>>> concatenate(List.of())
""
>>> concatenate(Arrays.asList("a", "b", "c"))
"abc"
*/
public String concatenate(List<Str... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Concatenate list of strings into a single string
>>> concatenate(List.of())
""
>>> concatenate(Arrays.asList("a", "b", "c"))
"abc"
*/
public String concatenate(List<String> strings) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;
class Solution {
/**
Filter an input list of strings only for ones that start with a given prefix.
>>> filterByPrefix(List.of(), "a")
[]
>>> filterByPrefix(Arrays.asL... | Make method to complete this class:
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;
class Solution {
/**
Filter an input list of strings only for ones that start with a given prefix.
>>> filterByPrefix(List.of(), "a")
[]
>>> filterByPrefix(Arrays.asList("abc", "bcd", "cd... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;
class Solution {
/**
Return only positive numbers in the list.
>>> getPositive(Arrays.asList(-1, 2, -4, 5, 6))
[2, 5, 6]
>>> getPositive(Arrays.asList(5, 3, -5, 2, -3... | Make method to complete this class:
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;
class Solution {
/**
Return only positive numbers in the list.
>>> getPositive(Arrays.asList(-1, 2, -4, 5, 6))
[2, 5, 6]
>>> getPositive(Arrays.asList(5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -1... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return true if a given number is prime, and false otherwise.
>>> isPrime(6)
false
>>> isPrime(101)
true
>>> isPrime(11)
true
>>> isPrime(13441)
true
>>> isPr... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return true if a given number is prime, and false otherwise.
>>> isPrime(6)
false
>>> isPrime(101)
true
>>> isPrime(11)
true
>>> isPrime(13441)
true
>>> isPrime(61)
true
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
*/
public double poly(List<Double> xs, double x) {
double re... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Evaluates polynomial with coefficients xs at point x.
return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
*/
public double poly(List<Double> xs, double x) {
double result = 0;
for... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
This function takes a list l and returns a list l' such that
l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by thr... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
This function takes a list l and returns a list l' such that
l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
to t... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return sorted unique elements in a list
>>> unique(Arrays.asList(5, 3, 5, 2, 3, 3, 9, 0, 123))
[0, 2, 3, 5, 9, 123]
*/
public List<Integer> unique(List<Integer> l) {
List<Integ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return sorted unique elements in a list
>>> unique(Arrays.asList(5, 3, 5, 2, 3, 3, 9, 0, 123))
[0, 2, 3, 5, 9, 123]
*/
public List<Integer> unique(List<Integer> l) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return maximum element in the list.
>>> maxElement(Arrays.asList(1, 2, 3))
3
>>> maxElement(Arrays.asList(5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10))
123
*/
public int maxE... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return maximum element in the list.
>>> maxElement(Arrays.asList(1, 2, 3))
3
>>> maxElement(Arrays.asList(5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10))
123
*/
public int maxElement(List<Integer> ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
>>> fizzBuzz(50)
0
>>> fizzBuzz(78)
2
>>> fizzBuzz(79)
3
*/
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
>>> fizzBuzz(50)
0
>>> fizzBuzz(78)
2
>>> fizzBuzz(79)
3
*/
public int fizzBu... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
This function takes a list l and returns a list l' such that
l' is identical to l in the odd indicies, while its values at the even indicies are equal
to the values of the even indicies... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
This function takes a list l and returns a list l' such that
l' is identical to l in the odd indicies, while its values at the even indicies are equal
to the values of the even indicies of l, but sorted.
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
returns encoded string by cycling groups of three characters.
*/
public String encodeCyclic(String s) {
// split string to groups. Each of length 3.
List<String> groups... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
returns encoded string by cycling groups of three characters.
*/
public String encodeCyclic(String s) {
// split string to groups. Each of length 3.
List<String> groups = new ArrayList<>();... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
primeFib returns n-th number that is a Fibonacci number and it's also prime.
>>> primeFib(1)
2
>>> primeFib(2)
3
>>> primeFib(3)
5
>>> primeFib(4)
13
>>> pri... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
primeFib returns n-th number that is a Fibonacci number and it's also prime.
>>> primeFib(1)
2
>>> primeFib(2)
3
>>> primeFib(3)
5
>>> primeFib(4)
13
>>> primeFib(5)
89
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
triplesSumToZero takes a list of integers as an input.
it returns True if there are three distinct elements in the list that
sum to zero, and False otherwise.
>>> triplesSumToZero(... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
triplesSumToZero takes a list of integers as an input.
it returns True if there are three distinct elements in the list that
sum to zero, and False otherwise.
>>> triplesSumToZero(Arrays.asList(1, 3, 5... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Imagine a road that's a perfectly straight infinitely long line.
n cars are driving left to right; simultaneously, a different set of n cars
are driving right to left. The two sets o... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Imagine a road that's a perfectly straight infinitely long line.
n cars are driving left to right; simultaneously, a different set of n cars
are driving right to left. The two sets of cars start out bein... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;
class Solution {
/**
Return list with elements incremented by 1.
>>> incrList(Arrays.asList(1, 2, 3))
[2, 3, 4]
>>> incrList(Arrays.asList(5, 3, 5, 2, 3, 3, 9, 0, 123... | Make method to complete this class:
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;
class Solution {
/**
Return list with elements incremented by 1.
>>> incrList(Arrays.asList(1, 2, 3))
[2, 3, 4]
>>> incrList(Arrays.asList(5, 3, 5, 2, 3, 3, 9, 0, 123))
[6, 4, 6, 3, 4... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
pairsSumToZero takes a list of integers as an input.
it returns True if there are two distinct elements in the list that
sum to zero, and False otherwise.
>>> pairsSumToZero(Arrays.... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
pairsSumToZero takes a list of integers as an input.
it returns True if there are two distinct elements in the list that
sum to zero, and False otherwise.
>>> pairsSumToZero(Arrays.asList(1, 3, 5, 0))
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Change numerical base of input number x to base.
return string representation after the conversion.
base numbers are less than 10.
>>> changeBase(8, 3)
"22"
>>> changeBase(8... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Change numerical base of input number x to base.
return string representation after the conversion.
base numbers are less than 10.
>>> changeBase(8, 3)
"22"
>>> changeBase(8, 2)
"1000"
>... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given length of a side and high return area for a triangle.
>>> triangleArea(5, 3)
7.5
*/
public double triangleArea(double a, double h) {
return a * h / 2;
}
}
```
Hope t... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given length of a side and high return area for a triangle.
>>> triangleArea(5, 3)
7.5
*/
public double triangleArea(double a, double h) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fib4(0) -> 0
fib4(1) -> 0
fib4(2) -> 2
fib4(3) -> 0
fib4(n) -> fib4(n-1)... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fib4(0) -> 0
fib4(1) -> 0
fib4(2) -> 2
fib4(3) -> 0
fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return median of elements in the list l.
>>> median(Arrays.asList(3, 1, 2, 4, 5))
3
>>> median(Arrays.asList(-10, 4, 6, 1000, 10, 20))
15.0
*/
public double median(List... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return median of elements in the list l.
>>> median(Arrays.asList(3, 1, 2, 4, 5))
3
>>> median(Arrays.asList(-10, 4, 6, 1000, 10, 20))
15.0
*/
public double median(List<Integer> l) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Checks if given string is a palindrome
>>> isPalindrome("")
true
>>> isPalindrome("aba")
true
>>> isPalindrome("aaaaa")
true
>>> isPalindrome("zbcd")
false
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Checks if given string is a palindrome
>>> isPalindrome("")
true
>>> isPalindrome("aba")
true
>>> isPalindrome("aaaaa")
true
>>> isPalindrome("zbcd")
false
*/
public boolean... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return 2^n modulo p (be aware of numerics).
>>> modp(3, 5)
3
>>> modp(1101, 101)
2
>>> modp(0, 101)
1
>>> modp(3, 11)
8
>>> modp(100, 101)
1
*/
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return 2^n modulo p (be aware of numerics).
>>> modp(3, 5)
3
>>> modp(1101, 101)
2
>>> modp(0, 101)
1
>>> modp(3, 11)
8
>>> modp(100, 101)
1
*/
public int modp(int n... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
returns encoded string by shifting every character by 5 in the alphabet.
*/
public String encodeShift(String s) {
StringBuilder sb = new StringBuilder();
for (char ch :... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
returns encoded string by shifting every character by 5 in the alphabet.
*/
public String encodeShift(String s) {
StringBuilder sb = new StringBuilder();
for (char ch : s.toCharArray()) {
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
removeVowels is a function that takes string and returns string without vowels.
>>> removeVowels("")
""
>>> removeVowels("abcdef\nghijklm")
"bcdf\nghjklm"
>>> removeVowels("... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
removeVowels is a function that takes string and returns string without vowels.
>>> removeVowels("")
""
>>> removeVowels("abcdef\nghijklm")
"bcdf\nghjklm"
>>> removeVowels("abcdef")
"bcdf"
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return True if all numbers in the list l are below threshold t.
>>> belowThreshold(Arrays.asList(1, 2, 4, 10), 100)
true
>>> belowThreshold(Arrays.asList(1, 20, 4, 10), 5)
false... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return True if all numbers in the list l are below threshold t.
>>> belowThreshold(Arrays.asList(1, 2, 4, 10), 100)
true
>>> belowThreshold(Arrays.asList(1, 20, 4, 10), 5)
false
*/
public b... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Add two numbers x and y
>>> add(2, 3)
5
>>> add(5, 7)
12
*/
public int add(int x, int y) {
return x + y;
}
}
```
Hope this helps! | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Add two numbers x and y
>>> add(2, 3)
5
>>> add(5, 7)
12
*/
public int add(int x, int y) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Check if two words have the same characters.
>>> sameChars("eabcdzzzz", "dddzzzzzzzddeddabc")
true
>>> sameChars("abcd", "dddddddabc")
true
>>> sameChars("dddddddabc", "abcd... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Check if two words have the same characters.
>>> sameChars("eabcdzzzz", "dddzzzzzzzddeddabc")
true
>>> sameChars("abcd", "dddddddabc")
true
>>> sameChars("dddddddabc", "abcd")
true
>>> s... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
*/
public int fib(int n) {
if (n == 0) {
return 0;
}
if (n =... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
*/
public int fib(int n) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
brackets is a string of "<" and ">".
return True if every opening bracket has a corresponding closing bracket.
>>> correctBracketing("<")
false
>>> correctBracketing("<>")
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
brackets is a string of "<" and ">".
return True if every opening bracket has a corresponding closing bracket.
>>> correctBracketing("<")
false
>>> correctBracketing("<>")
true
>>> corr... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return True is list elements are monotonically increasing or decreasing.
>>> monotonic(Arrays.asList(1, 2, 4, 20))
true
>>> monotonic(Arrays.asList(1, 20, 4, 10))
false
>>> ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return True is list elements are monotonically increasing or decreasing.
>>> monotonic(Arrays.asList(1, 2, 4, 20))
true
>>> monotonic(Arrays.asList(1, 20, 4, 10))
false
>>> monotonic(Arrays.asLi... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return sorted unique common elements for two lists.
>>> common(Arrays.asList(1, 4, 3, 34, 653, 2, 5), Arrays.asList(5, 7, 1, 5, 9, 653, 121))
[1, 5, 653]
>>> common(Arrays.asList(5,... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return sorted unique common elements for two lists.
>>> common(Arrays.asList(1, 4, 3, 34, 653, 2, 5), Arrays.asList(5, 7, 1, 5, 9, 653, 121))
[1, 5, 653]
>>> common(Arrays.asList(5, 3, 2, 8), Arrays.asL... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return the largest prime factor of n. Assume n > 1 and is not a prime.
>>> largestPrimeFactor(13195)
29
>>> largestPrimeFactor(2048)
2
*/
public int largestPrimeFactor(... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return the largest prime factor of n. Assume n > 1 and is not a prime.
>>> largestPrimeFactor(13195)
29
>>> largestPrimeFactor(2048)
2
*/
public int largestPrimeFactor(int n) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
sumToN is a function that sums numbers from 1 to n.
>>> sumToN(30)
465
>>> sumToN(100)
5050
>>> sumToN(5)
15
>>> sumToN(10)
55
>>> sumToN(1)
1
*/
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
sumToN is a function that sums numbers from 1 to n.
>>> sumToN(30)
465
>>> sumToN(100)
5050
>>> sumToN(5)
15
>>> sumToN(10)
55
>>> sumToN(1)
1
*/
public int sumToN(i... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
brackets is a string of "(" and ")".
return True if every opening bracket has a corresponding closing bracket.
>>> correctBracketing("(")
false
>>> correctBracketing("()")
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
brackets is a string of "(" and ")".
return True if every opening bracket has a corresponding closing bracket.
>>> correctBracketing("(")
false
>>> correctBracketing("()")
true
>>> correctB... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
Return derivative of this polynomial in the same form.
>>> derivative(Arrays.asList(3, 1, 2, 4, 5)... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
xs represent coefficients of a polynomial.
xs[0] + xs[1] * x + xs[2] * x^2 + ....
Return derivative of this polynomial in the same form.
>>> derivative(Arrays.asList(3, 1, 2, 4, 5))
[1, 4, 12, 20]
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fi... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
fibfib(0) == 0
fibfib(1) == 0
fibfib(2) == 1
fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function vowelsCount which takes a string representing
a word as input and returns the number of vowels in the string.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y'... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function vowelsCount which takes a string representing
a word as input and returns the number of vowels in the string.
Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
vowel,... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Circular shift the digits of the integer x, shift the digits right by shift
and return the result as a string.
If shift > number of digits, return digits reversed.
>>> circularShift... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Circular shift the digits of the integer x, shift the digits right by shift
and return the result as a string.
If shift > number of digits, return digits reversed.
>>> circularShift(12, 1)
"21"
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes a string as input and returns the sum of the upper characters only'
ASCII codes.
Examples:
digitSum("") => 0
digitSum("abAB") => 131
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes a string as input and returns the sum of the upper characters only'
ASCII codes.
Examples:
digitSum("") => 0
digitSum("abAB") => 131
digitSum("abcCd") =>... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits.... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
In this task, you will be given a string that represents a number of apples and oranges
that are distributed in a basket of fruit this basket contains
apples, oranges, and mango fruits. Given the string tha... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node with the sm... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
"Given an array representing a branch of a tree that has non-negative integer nodes
your task is to pluck one of the nodes and return it.
The plucked node should be the node with the smallest even value.
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a non-empty list of positive integers. Return the greatest integer that is greater than
zero, and has a frequency greater than or equal to the value of the integer itself.
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a non-empty list of positive integers. Return the greatest integer that is greater than
zero, and has a frequency greater than or equal to the value of the integer itself.
The frequency of an ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given list of integers, return list in strange order.
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Exa... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given list of integers, return list in strange order.
Strange sorting, is when you start with the minimum value,
then maximum of the remaining integers, then minimum and so on.
Examples:
strangeSor... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given the lengths of the three sides of a triangle. Return the area of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Otherwise return -1
Three s... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given the lengths of the three sides of a triangle. Return the area of
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
Otherwise return -1
Three sides make a valid tri... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that returns True if the object q will fly, and False otherwise.
The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that returns True if the object q will fly, and False otherwise.
The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an array arr of integers, find the minimum number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backward... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an array arr of integers, find the minimum number of elements that
need to be changed to make the array palindromic. A palindromic array is an array that
is read the same backwards and forwards. In on... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list less than the other list.
if the two lists have th... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that accepts two lists of strings and returns the list that has
total number of chars in the all strings of the list less than the other list.
if the two lists have the same number of char... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that returns true if the given number is the multiplication of 3 prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
isMultiplyPrime(... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that returns true if the given number is the multiplication of 3 prime numbers
and false otherwise.
Knowing that (a) is less then 100.
Example:
isMultiplyPrime(30) == true
30 = ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Your task is to write a function that returns true if a number x is a simple
power of n and false in other cases.
x is a simple power of n if n**int=x
For example:
isSimplePower... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Your task is to write a function that returns true if a number x is a simple
power of n and false in other cases.
x is a simple power of n if n**int=x
For example:
isSimplePower(1, 4) => true
is... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes an integer a and returns true
if this ingeger is a cube of some integer number.
Note: you may assume the input is always valid.
Examples:
iscube(1) =... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes an integer a and returns true
if this ingeger is a cube of some integer number.
Note: you may assume the input is always valid.
Examples:
iscube(1) ==> true
iscube(2)... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You have been tasked to write a function that receives
a hexadecimal number as a string and counts the number of hexadecimal
digits that are primes (prime number, or a prime, is a natur... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You have been tasked to write a function that receives
a hexadecimal number as a string and counts the number of hexadecimal
digits that are primes (prime number, or a prime, is a natural number
greater... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each c... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You will be given a number in decimal form and your task is to convert it to
binary format. The function should return a string, with each character representing a binary
number. Each character in the strin... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
For example... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a string s.
Your task is to check if the string is happy or not.
A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
For example:
isHappy(a) => f... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
It is the last week of the semester and the teacher has to give the grades
to students. The teacher has been making her own algorithm for grading.
The only problem is, she has lost the code she used for gra... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes a string and returns true if the string
length is a prime number or false otherwise
Examples
primeLength("Hello") == true
primeLength("abcdcba") == t... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes a string and returns true if the string
length is a prime number or false otherwise
Examples
primeLength("Hello") == true
primeLength("abcdcba") == true
primeLength("... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer n, return the count of the numbers of n-digit
positive integers that start or end with 1.
*/
public int startsOneEnds(int n) {
if (n == 1) {
re... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer n, return the count of the numbers of n-digit
positive integers that start or end with 1.
*/
public int startsOneEnds(int n) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer N, return the total sum of its digits in binary.
Example
For N = 1000, the sum of digits will be 1 the output should be "1".
For N = 150, the sum o... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer N, return the total sum of its digits in binary.
Example
For N = 1000, the sum of digits will be 1 the output should be "1".
For N = 150, the sum of digits will be 6 th... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a non-empty list of integers lst. add the even elements that are at odd indices..
Examples:
add(Arrays.asList(4, 2, 6, 7)) ==> 2
*/
public int add(List<Integer> lst)... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a non-empty list of integers lst. add the even elements that are at odd indices..
Examples:
add(Arrays.asList(4, 2, 6, 7)) ==> 2
*/
public int add(List<Integer> lst) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes a string and returns an ordered version of it.
Ordered version of string, is a string where all words (separated by space)
are replaced by a new word where a... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes a string and returns an ordered version of it.
Ordered version of string, is a string where all words (separated by space)
are replaced by a new word where all the characters arr... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a 2 dimensional data, as a nested lists,
which is similar to matrix, however, unlike matrices,
each row may contain a different number of columns.
Given lst, and integ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a 2 dimensional data, as a nested lists,
which is similar to matrix, however, unlike matrices,
each row may contain a different number of columns.
Given lst, and integer x, find integers x... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an array of non-negative integers, return a copy of the given array after sorting,
you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
or sort it ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function encrypt that takes a string as an argument and
returns a string encrypted with the alphabet being rotated.
The alphabet should be rotated in a manner such that the let... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function encrypt that takes a string as an argument and
returns a string encrypted with the alphabet being rotated.
The alphabet should be rotated in a manner such that the letters
shift down b... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a list of integers.
Write a function nextSmallest() that returns the 2nd smallest element of the list.
Return null if there is no such element.
<p>
nextSmallest(Ar... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a list of integers.
Write a function nextSmallest() that returns the 2nd smallest element of the list.
Return null if there is no such element.
<p>
nextSmallest(Arrays.asList(1, 2, 3, ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You'll be given a string of words, and your task is to count the number
of boredoms. A boredom is a sentence that starts with the word "I".
Sentences are delimited by '.', '?' or '!'.
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You'll be given a string of words, and your task is to count the number
of boredoms. A boredom is a sentence that starts with the word "I".
Sentences are delimited by '.', '?' or '!'.
For example:
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that takes 3 numbers.
Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
Returns false in any other cases.
Exa... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that takes 3 numbers.
Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
Returns false in any other cases.
Examples
anyInt(5, 2... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes a message, and encodes in such a
way that it swaps case of all letters, replaces all vowels in
the message with the letter that appears 2 places ahead of tha... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes a message, and encodes in such a
way that it swaps case of all letters, replaces all vowels in
the message with the letter that appears 2 places ahead of that
vowel in the en... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a list of integers.
You need to find the largest prime value and return the sum of its digits.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a list of integers.
You need to find the largest prime value and return the sum of its digits.
Examples:
For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should b... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a map, return True if all keys are strings in lower
case or all keys are strings in upper case, else return False.
The function should return False is the given map is empty.
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a map, return True if all keys are strings in lower
case or all keys are strings in upper case, else return False.
The function should return False is the given map is empty.
Examples:
checkDi... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Implement a function that takes an non-negative integer and returns an array of the first n
integers that are prime numbers and less than n.
for example:
countUpTo(5) => [2,3]
c... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Implement a function that takes an non-negative integer and returns an array of the first n
integers that are prime numbers and less than n.
for example:
countUpTo(5) => [2,3]
countUpTo(11) => [2,3,... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Complete the function that takes two integers and returns
the product of their unit digits.
Assume the input is always valid.
Examples:
multiply(148, 412) should return 16.
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Complete the function that takes two integers and returns
the product of their unit digits.
Assume the input is always valid.
Examples:
multiply(148, 412) should return 16.
multiply(19, 28) shou... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string s, count the number of uppercase vowels in even indices.
For example:
countUpper("aBCdEf") returns 1
countUpper("abcdefg") returns 0
countUpper("dBBE") retur... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string s, count the number of uppercase vowels in even indices.
For example:
countUpper("aBCdEf") returns 1
countUpper("abcdefg") returns 0
countUpper("dBBE") returns 0
*/
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that takes a value (string) representing a number
and returns the closest integer to it. If the number is equidistant
from two integers, round it away from zero.
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that takes a value (string) representing a number
and returns the closest integer to it. If the number is equidistant
from two integers, round it away from zero.
Examples
>>> clos... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer n, you have to make a pile of n levels of stones.
The first level has n stones.
The number of stones in the next level is:
- the next odd number if n is... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer n, you have to make a pile of n levels of stones.
The first level has n stones.
The number of stones in the next level is:
- the next odd number if n is odd.
- the n... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You will be given a string of words separated by commas or spaces. Your task is
to split the string into words and return an array of the words.
For example:
words_string("Hi, ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You will be given a string of words separated by commas or spaces. Your task is
to split the string into words and return an array of the words.
For example:
words_string("Hi, my name is John").equ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
This function takes two positive numbers x and y and returns the
biggest even integer number that is in the range [x, y] inclusive. If
there's no such number, then the function should r... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
This function takes two positive numbers x and y and returns the
biggest even integer number that is in the range [x, y] inclusive. If
there's no such number, then the function should return -1.
Fo... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given two positive integers n and m, and your task is to compute the
average of the integers from n through m (including n and m).
Round the answer to the nearest integer and co... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given two positive integers n and m, and your task is to compute the
average of the integers from n through m (including n and m).
Round the answer to the nearest integer and convert that to binary.... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a list of positive integers x. return a sorted list of all
elements that hasn't any even digit.
Note: Returned list should be sorted in increasing order.
For example:
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a list of positive integers x. return a sorted list of all
elements that hasn't any even digit.
Note: Returned list should be sorted in increasing order.
For example:
>>> uniqueDigits(Ar... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an array of integers, sort the integers that are between 1 and 9 inclusive,
reverse the resulting array, and then replace each digit by its corresponding name from
"One", "Two", "... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an array of integers, sort the integers that are between 1 and 9 inclusive,
reverse the resulting array, and then replace each digit by its corresponding name from
"One", "Two", "Three", "Four", "Five... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Implement the function f that takes n as a parameter,
and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even
or the sum of number... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Implement the function f that takes n as a parameter,
and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even
or the sum of numbers from 1 to i otherwi... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer n, return a tuple that has the number of even and odd
integer palindromes that fall within the range(1, n), inclusive.
Example 1:
Input: 3
Out... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer n, return a tuple that has the number of even and odd
integer palindromes that fall within the range(1, n), inclusive.
Example 1:
Input: 3
Output: (1, 2)
E... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function countNums which takes an array of integers and returns
the number of elements which has a sum of digits > 0.
If a number is negative, then its first signed digit will b... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function countNums which takes an array of integers and returns
the number of elements which has a sum of digits > 0.
If a number is negative, then its first signed digit will be negative:
e.g. ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
numbers in the array will be randomly ordered. Your task is to determine if
it is possible to get an array sorted in... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
numbers in the array will be randomly ordered. Your task is to determine if
it is possible to get an array sorted in non-decreasing order... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
In this problem, you will implement a function that takes two lists of numbers,
and determines whether it is possible to perform an exchange of elements
between them to make lst1 a list... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
In this problem, you will implement a function that takes two lists of numbers,
and determines whether it is possible to perform an exchange of elements
between them to make lst1 a list of only even numbers... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string representing a space separated lowercase letters, return a dictionary
of the letter with the most repetition and containing the corresponding count.
If several letters ha... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string representing a space separated lowercase letters, return a dictionary
of the letter with the most repetition and containing the corresponding count.
If several letters have the same occurrenc... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Task
We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
then check if the result string is palindrome.
A string is ca... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Task
We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
then check if the result string is palindrome.
A string is called palindrome if it... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a list of strings, where each string consists of only digits, return a list.
Each element i of the output should be "the number of odd elements in the
string i of the input." wher... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a list of strings, where each string consists of only digits, return a list.
Each element i of the output should be "the number of odd elements in the
string i of the input." where all the i's should ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an array of integers nums, find the minimum sum of any non-empty sub-array
of nums.
Example
minSubArraySum(Arrays.asList(2, 3, 4, 1, 2, 4)) == 1
minSubArraySum(Arrays.asLi... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an array of integers nums, find the minimum sum of any non-empty sub-array
of nums.
Example
minSubArraySum(Arrays.asList(2, 3, 4, 1, 2, 4)) == 1
minSubArraySum(Arrays.asList(-1, -2, -3)) == -6... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a rectangular grid of wells. Each row represents a single well,
and each 1 in a row represents a single unit of water.
Each well has a corresponding bucket that can be use... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a rectangular grid of wells. Each row represents a single well,
and each 1 in a row represents a single unit of water.
Each well has a corresponding bucket that can be used to extract water fr... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
In this Kata, you have to sort an array of non-negative integers according to
number of ones in their binary representation in ascending order.
For similar number of ones, sort based on... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
In this Kata, you have to sort an array of non-negative integers according to
number of ones in their binary representation in ascending order.
For similar number of ones, sort based on decimal value.
<... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string s and a natural number n, you have been tasked to implement
a function that returns a list of all words from string s that contain exactly
n consonants, in order these wo... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string s and a natural number n, you have been tasked to implement
a function that returns a list of all words from string s that contain exactly
n consonants, in order these words appear in the str... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a word. Your task is to find the closest vowel that stands between
two consonants from the right side of the word (case sensitive).
Vowels in the beginning and ending doe... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a word. Your task is to find the closest vowel that stands between
two consonants from the right side of the word (case sensitive).
Vowels in the beginning and ending doesn't count. Return em... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a list of two strings, both strings consist of open
parentheses "(" or close parentheses ")" only.
Your job is to check if it is possible to concatenate the two strings in... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a list of two strings, both strings consist of open
parentheses "(" or close parentheses ")" only.
Your job is to check if it is possible to concatenate the two strings in
some order, that... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an array arr of integers and a positive integer k, return a sorted list
of length k with the maximum k numbers in arr.
Example 1:
Input: arr = [-3, -4, 5], k = 3
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an array arr of integers and a positive integer k, return a sorted list
of length k with the maximum k numbers in arr.
Example 1:
Input: arr = [-3, -4, 5], k = 3
Output: [-4, -3, 5]
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
Examples
solution(Arrays.asList(5, 8, 7, 1)) ==> 12
solution(Arrays.asList... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
Examples
solution(Arrays.asList(5, 8, 7, 1)) ==> 12
solution(Arrays.asList(3, 3, 3, 3, 3)) ==> ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a non-empty array of integers arr and an integer k, return
the sum of the elements with at most two digits from the first k elements of arr.
Example:
Input: arr = [111,2... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a non-empty array of integers arr and an integer k, return
the sum of the elements with at most two digits from the first k elements of arr.
Example:
Input: arr = [111,21,3,4000,5,6,7,8,9], ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.