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 {
/**
Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
as... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
as follows: start with ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You have to write a function which validates a given date string and
returns true if the date is valid otherwise false.
The date is valid if all of the following rules are satisfied:
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You have to write a function which validates a given date string and
returns true if the date is valid otherwise false.
The date is valid if all of the following rules are satisfied:
1. The date string ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
should split on commas ',' if no commas exists you should return the number of ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
should split on commas ',' if no commas exists you should return the number of lower-case letters wi... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a list of numbers, return whether or not they are sorted
in ascending order. If list has more than 1 duplicate of the same
number, return false. Assume no negative numbers and onl... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a list of numbers, return whether or not they are sorted
in ascending order. If list has more than 1 duplicate of the same
number, return false. Assume no negative numbers and only integers.
Exam... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given two intervals,
where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
The given intervals are closed which means that the interval (star... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given two intervals,
where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
The given intervals are closed which means that the interval (start, end)
includes ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given an array arr of integers and you need to return
sum of magnitudes of integers multiplied by product of all signs
of each number in the array, represented by 1, -1 or 0.
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given an array arr of integers and you need to return
sum of magnitudes of integers multiplied by product of all signs
of each number in the array, represented by 1, -1 or 0.
Note: return None f... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a grid with N rows and N columns (N >= 2) and a positive integer k,
each cell of the grid contains a value. Every integer in the range [1, N * N]
inclusive appears exactly once on... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a grid with N rows and N columns (N >= 2) and a positive integer k,
each cell of the grid contains a value. Every integer in the range [1, N * N]
inclusive appears exactly once on the cells of the gri... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
the last couple centuries. However, what people don't know is Tribonacci sequence.
Tribonacci sequence is d... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
the last couple centuries. However, what people don't know is Tribonacci sequence.
Tribonacci sequence is defined by the recurre... |
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 product of the odd digits.
Return 0 if all digits are even.
For example:
digits(1) == 1
digits(4) == 0
digits(235) == 15
*/
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer n, return the product of the odd digits.
Return 0 if all digits are even.
For example:
digits(1) == 1
digits(4) == 0
digits(235) == 15
*/
public int digits(in... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that takes a string as input which contains only square brackets.
The function should return true if and only if there is a valid subsequence of brackets
where at leas... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that takes a string as input which contains only square brackets.
The function should return true if and only if there is a valid subsequence of brackets
where at least one bracket in the ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a list of numbers.
You need to return the sum of squared numbers in the given list,
round each element in the list to the upper int(Ceiling) first.
Examples:
For l... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a list of numbers.
You need to return the sum of squared numbers in the given list,
round each element in the list to the upper int(Ceiling) first.
Examples:
For lst = [1,2,3] the outp... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that returns true if the last character
of a given string is an alphabetical character and is not
a part of a word, and false otherwise.
Note: "word" is a group of... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that returns true if the last character
of a given string is an alphabetical character and is not
a part of a word, and false otherwise.
Note: "word" is a group of characters separated... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function which returns the largest index of an element which
is not greater than or equal to the element immediately preceding it. If
no such element exists then return -1. The... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function which returns the largest index of an element which
is not greater than or equal to the element immediately preceding it. If
no such element exists then return -1. The given array will not... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that returns a tuple (a, b), where 'a' is
the largest of negative integers, and 'b' is the smallest
of positive integers in a list.
If there is no negative or posi... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that returns a tuple (a, b), where 'a' is
the largest of negative integers, and 'b' is the smallest
of positive integers in a list.
If there is no negative or positive integers, return... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that takes integers, floats, or strings representing
real numbers, and returns the larger variable in its given variable type.
Return None if the values are equal.
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function that takes integers, floats, or strings representing
real numbers, and returns the larger variable in its given variable type.
Return None if the values are equal.
Note: If a real numb... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
Example
isEqualToSumEven(4) == false
isEqualToSumEven(6) == false
isEqualToSumEv... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
Example
isEqualToSumEven(4) == false
isEqualToSumEven(6) == false
isEqualToSumEven(8) == true
*/... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
The Brazilian factorial is defined as:
brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
where n > 0
For example:
>>> specialFactorial(4)
288
The function will ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
The Brazilian factorial is defined as:
brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
where n > 0
For example:
>>> specialFactorial(4)
288
The function will receive an integer as... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string text, replace all spaces in it with underscores,
and if a string has more than 2 consecutive spaces,
then replace all consecutive spaces with -
fixSpaces("Example") ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string text, replace all spaces in it with underscores,
and if a string has more than 2 consecutive spaces,
then replace all consecutive spaces with -
fixSpaces("Example") == "Example"
fixS... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function which takes a string representing a file's name, and returns
"Yes" if the the file's name is valid, and returns "No" otherwise.
A file's name is considered to be valid... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Create a function which takes a string representing a file's name, and returns
"Yes" if the the file's name is valid, and returns "No" otherwise.
A file's name is considered to be valid if and only if all t... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a
multiple of 3 and will cube the integer entry if its i... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a
multiple of 3 and will cube the integer entry if its index is a multiple of... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a string representing a sentence,
the sentence contains some words separated by a space,
and you have to return a string that contains the words from the original sentence... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a string representing a sentence,
the sentence contains some words separated by a space,
and you have to return a string that contains the words from the original sentence,
whose lengths a... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Your task is to implement a function that will simplify the expression
x * n. The function returns true if x * n evaluates to a whole number and false
otherwise. Both x and n, are strin... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Your task is to implement a function that will simplify the expression
x * n. The function returns true if x * n evaluates to a whole number and false
otherwise. Both x and n, are string representation of a... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function which sorts the given list of integers
in ascending order according to the sum of their digits.
Note: if there are several items with similar sum of their digits,
o... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function which sorts the given list of integers
in ascending order according to the sum of their digits.
Note: if there are several items with similar sum of their digits,
order them based on th... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes an array of numbers as input and returns
the number of elements in the array that are greater than 10 and both
first and last digits of a number are odd (1, ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that takes an array of numbers as input and returns
the number of elements in the array that are greater than 10 and both
first and last digits of a number are odd (1, 3, 5, 7, 9).
For ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a positive integer n. You have to create an integer array a of length n.
For each i (1 <= i <= n), the value of a[i] = i * i - i + 1.
Return the number of triples ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a positive integer n. You have to create an integer array a of length n.
For each i (1 <= i <= n), the value of a[i] = i * i - i + 1.
Return the number of triples (a[i], a[j], a[k]) of... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
There are eight planets in our solar system: the closerst to the Sun
is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
Uranus, Neptune.
Write a function that tak... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
There are eight planets in our solar system: the closerst to the Sun
is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
Uranus, Neptune.
Write a function that takes two planet names a... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that accepts a list of strings as a parameter,
deletes the strings that have odd lengths from it,
and returns the resulted list with a sorted order,
The list is alw... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that accepts a list of strings as a parameter,
deletes the strings that have odd lengths from it,
and returns the resulted list with a sorted order,
The list is always a list of strings... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
A simple program which should return the value of x if n is
a prime number and should return the value of y otherwise.
Examples:
for xOrY(7, 34, 12) == 34
for xOrY(15, 8, 5) ==... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
A simple program which should return the value of x if n is
a prime number and should return the value of y otherwise.
Examples:
for xOrY(7, 34, 12) == 34
for xOrY(15, 8, 5) == 5
*/
public... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a list of numbers, return the sum of squares of the numbers
in the list that are odd. Ignore numbers that are negative or not integers.
doubleTheDifference(Arrays.asList(1, 3, 2,... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a list of numbers, return the sum of squares of the numbers
in the list that are odd. Ignore numbers that are negative or not integers.
doubleTheDifference(Arrays.asList(1, 3, 2, 0)) == 1 + 9 + 0 + 0... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
I think we all remember that feeling when the result of some long-awaited
event is finally known. The feelings and thoughts you have at that moment are
definitely worth noting down and ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
I think we all remember that feeling when the result of some long-awaited
event is finally known. The feelings and thoughts you have at that moment are
definitely worth noting down and comparing.
Your t... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You will be given the name of a class (a string) and a list of extensions.
The extensions are to be used to load additional classes to the class. The
strength of the extension is as fol... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You will be given the name of a class (a string) and a list of extensions.
The extensions are to be used to load additional classes to the class. The
strength of the extension is as follows: Let CAP be the ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given 2 words. You need to return true if the second word or any of its rotations is a substring in the first word
cycpatternCheck("abcd","abd") => false
cycpatternCheck("hello"... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given 2 words. You need to return true if the second word or any of its rotations is a substring in the first word
cycpatternCheck("abcd","abd") => false
cycpatternCheck("hello","ell") => true
c... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an integer. return a tuple that has the number of even and odd digits respectively.
Example:
evenOddCount(-12) ==> (1, 1)
evenOddCount(123) ==> (1, 2)
*/
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given an integer. return a tuple that has the number of even and odd digits respectively.
Example:
evenOddCount(-12) ==> (1, 1)
evenOddCount(123) ==> (1, 2)
*/
public List<Integer... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer, obtain its roman numeral equivalent as a string,
and return it in lowercase.
Restrictions: 1 <= num <= 1000
Examples:
>>> intToMiniRoman(19) == "xix"
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive integer, obtain its roman numeral equivalent as a string,
and return it in lowercase.
Restrictions: 1 <= num <= 1000
Examples:
>>> intToMiniRoman(19) == "xix"
>>> intToMiniRoma... |
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 true if the three
sides form a right-angled triangle, false otherwise.
A right-angled triangle is a triangle in which one angl... | 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 true if the three
sides form a right-angled triangle, false otherwise.
A right-angled triangle is a triangle in which one angle is right angle or
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that accepts a list of strings.
The list contains different words. Return the word with maximum number
of unique characters. If multiple strings have maximum number of ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Write a function that accepts a list of strings.
The list contains different words. Return the word with maximum number
of unique characters. If multiple strings have maximum number of unique
characters... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You're a hungry rabbit, and you already have eaten a certain number of carrots,
but now you need to eat more carrots to complete the day's meals.
you should return an array of [ total n... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You're a hungry rabbit, and you already have eaten a certain number of carrots,
but now you need to eat more carrots to complete the day's meals.
you should return an array of [ total number of eaten carrot... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given two lists operator, and operand. The first list has basic algebra operations, and
the second list is a list of integers. Use the two given lists to build the algebric
expression a... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given two lists operator, and operand. The first list has basic algebra operations, and
the second list is a list of integers. Use the two given lists to build the algebric
expression and return the evaluat... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a string s.
if s[i] is a letter, reverse its case from lower to upper or vise versa,
otherwise keep it as it is.
If the string contains no letters, reverse the string.... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You are given a string s.
if s[i] is a letter, reverse its case from lower to upper or vise versa,
otherwise keep it as it is.
If the string contains no letters, reverse the string.
The function sho... |
Of course, here is the Java code you requested:
```java
import java.math.BigInteger;
import java.security.*;
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string "text", return its md5 hash equivalent string with length being 32.
If "text" is an empty string, return Optional.empty()... | Make method to complete this class:
import java.math.BigInteger;
import java.security.*;
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string "text", return its md5 hash equivalent string with length being 32.
If "text" is an empty string, return Optional.empty().
>>> string... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given two positive integers a and b, return the even digits between a
and b, in ascending order.
For example:
generateIntegers(2, 8) => [2, 4, 6, 8]
generateIntegers(8, 2) => [... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given two positive integers a and b, return the even digits between a
and b, in ascending order.
For example:
generateIntegers(2, 8) => [2, 4, 6, 8]
generateIntegers(8, 2) => [2, 4, 6, 8]
gener... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.