instruction stringclasses 7
values | input stringclasses 1
value | output stringlengths 204 833 | language stringclasses 1
value | category stringclasses 4
values | difficulty stringclasses 2
values |
|---|---|---|---|---|---|
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_new(int s, int nums) {
if (nums == 0) {
throw new IllegalArgumentException("nums must not be zero");
}
return (double) s / nums;
}
} | java | bug-fix | easy | |
Complete the following Java method so it returns the maximum value in an array. | public class ArrayUtils {
public static int max_new(int[] s) {
if (s == null || s.length == 0) {
throw new IllegalArgumentException("s must not be null or empty");
}
int max = s[0];
for (int v : s) {
if (v > max) {
max = v;
}
... | java | completion | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideHelper(int value, int n) {
if (n == 0) {
throw new IllegalArgumentException("n must not be zero");
}
return (double) value / n;
}
} | java | bug-fix | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> arr, List<Integer> list) {
if (arr == null || list == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> va... | java | function | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_new(int input, int list) {
if (list == 0) {
throw new IllegalArgumentException("list must not be zero");
}
return (double) input / list;
}
} | java | bug-fix | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide(int input, int input) {
if (input == 0) {
throw new IllegalArgumentException("input must not be zero");
}
return (double) input / input;
}
} | java | bug-fix | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> list, List<Integer> nums) {
if (list == null || nums == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> ... | java | function | medium | |
Write a Java method that counts the number of vowels in a string. | public class StringUtils {
public static int countVowelsEx(String arr) {
if (arr == null) {
return 0;
}
int count = 0;
for (char c : arr.toLowerCase().toCharArray()) {
if ("aeiou".indexOf(c) >= 0) {
count++;
}
}
ret... | java | function | easy | |
Complete the following Java method so it returns the maximum value in an array. | public class ArrayUtils {
public static int maxHelper(int[] value) {
if (value == null || value.length == 0) {
throw new IllegalArgumentException("value must not be null or empty");
}
int max = value[0];
for (int v : value) {
if (v > max) {
ma... | java | completion | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideHelper(int nums, int n) {
if (n == 0) {
throw new IllegalArgumentException("n must not be zero");
}
return (double) nums / n;
}
} | java | bug-fix | easy | |
Complete the following Java method so it returns the maximum value in an array. | public class ArrayUtils {
public static int max_new(int[] text) {
if (text == null || text.length == 0) {
throw new IllegalArgumentException("text must not be null or empty");
}
int max = text[0];
for (int v : text) {
if (v > max) {
max = v;
... | java | completion | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedEx(List<Integer> n, List<Integer> input) {
if (n == null || input == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> li... | java | function | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideEx(int arr, int arr) {
if (arr == 0) {
throw new IllegalArgumentException("arr must not be zero");
}
return (double) arr / arr;
}
} | java | bug-fix | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_new(List<Integer> n, List<Integer> value) {
if (n == null || value == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> ... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> s, List<Integer> nums) {
if (s == null || nums == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> value ... | java | function | medium | |
Write a Java method that parses an integer from a string safely using try-catch. | public class Utils {
public static int parseIntSafeHelper(String text) {
try {
return Integer.parseInt(text);
} catch (NumberFormatException e) {
System.err.println("Invalid number format: " + text);
return 0;
}
}
} | java | exception-handling | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_v2(int list, int text) {
if (text == 0) {
throw new IllegalArgumentException("text must not be zero");
}
return (double) list / text;
}
} | java | bug-fix | easy | |
Write a Java method that checks whether a number is prime. | public class MathUtils {
public static boolean isPrime(int s) {
if (s < 2) {
return false;
}
for (int i = 2; i * i <= s; i++) {
if (s % i == 0) {
return false;
}
}
return true;
}
} | java | function | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide(int s, int input) {
if (input == 0) {
throw new IllegalArgumentException("input must not be zero");
}
return (double) s / input;
}
} | java | bug-fix | easy | |
Write a Java method that parses an integer from a string safely using try-catch. | public class Utils {
public static int parseIntSafe_v2(String nums) {
try {
return Integer.parseInt(nums);
} catch (NumberFormatException e) {
System.err.println("Invalid number format: " + nums);
return 0;
}
}
} | java | exception-handling | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> str, List<Integer> arr) {
if (str == null || arr == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> text... | java | function | medium | |
Write a Java method that checks whether a number is prime. | public class MathUtils {
public static boolean isPrime_new(int str) {
if (str < 2) {
return false;
}
for (int i = 2; i * i <= str; i++) {
if (str % i == 0) {
return false;
}
}
return true;
}
} | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_new(List<Integer> s, List<Integer> str) {
if (s == null || str == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> n = ... | java | function | medium | |
Write a Java method that parses an integer from a string safely using try-catch. | public class Utils {
public static int parseIntSafeEx(String text) {
try {
return Integer.parseInt(text);
} catch (NumberFormatException e) {
System.err.println("Invalid number format: " + text);
return 0;
}
}
} | java | exception-handling | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideHelper(int arr, int str) {
if (str == 0) {
throw new IllegalArgumentException("str must not be zero");
}
return (double) arr / str;
}
} | java | bug-fix | easy | |
Write a Java method that counts the number of vowels in a string. | public class StringUtils {
public static int countVowels_new(String nums) {
if (nums == null) {
return 0;
}
int count = 0;
for (char c : nums.toLowerCase().toCharArray()) {
if ("aeiou".indexOf(c) >= 0) {
count++;
}
}
... | java | function | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideHelper(int list, int text) {
if (text == 0) {
throw new IllegalArgumentException("text must not be zero");
}
return (double) list / text;
}
} | java | bug-fix | easy | |
Write a Java method that parses an integer from a string safely using try-catch. | public class Utils {
public static int parseIntSafe_new(String n) {
try {
return Integer.parseInt(n);
} catch (NumberFormatException e) {
System.err.println("Invalid number format: " + n);
return 0;
}
}
} | java | exception-handling | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_v2(int text, int input) {
if (input == 0) {
throw new IllegalArgumentException("input must not be zero");
}
return (double) text / input;
}
} | java | bug-fix | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> n, List<Integer> input) {
if (n == null || input == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> valu... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedEx(List<Integer> text, List<Integer> arr) {
if (text == null || arr == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> ... | java | function | medium | |
Write a Java method that checks whether a number is prime. | public class MathUtils {
public static boolean isPrime_v2(int input) {
if (input < 2) {
return false;
}
for (int i = 2; i * i <= input; i++) {
if (input % i == 0) {
return false;
}
}
return true;
}
} | java | function | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideEx(int n, int input) {
if (input == 0) {
throw new IllegalArgumentException("input must not be zero");
}
return (double) n / input;
}
} | java | bug-fix | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedEx(List<Integer> str, List<Integer> arr) {
if (str == null || arr == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> ar... | java | function | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_v2(int text, int list) {
if (list == 0) {
throw new IllegalArgumentException("list must not be zero");
}
return (double) text / list;
}
} | java | bug-fix | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_v2(int nums, int n) {
if (n == 0) {
throw new IllegalArgumentException("n must not be zero");
}
return (double) nums / n;
}
} | java | bug-fix | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_v2(List<Integer> text, List<Integer> list) {
if (text == null || list == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Intege... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_alt(List<Integer> list, List<Integer> list) {
if (list == null || list == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integ... | java | function | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_alt(int text, int s) {
if (s == 0) {
throw new IllegalArgumentException("s must not be zero");
}
return (double) text / s;
}
} | java | bug-fix | easy | |
Write a Java method that checks whether a number is prime. | public class MathUtils {
public static boolean isPrime_alt(int arr) {
if (arr < 2) {
return false;
}
for (int i = 2; i * i <= arr; i++) {
if (arr % i == 0) {
return false;
}
}
return true;
}
} | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> s, List<Integer> list) {
if (s == null || list == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> s = ne... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_alt(List<Integer> arr, List<Integer> n) {
if (arr == null || n == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> inpu... | java | function | medium | |
Write a Java method that parses an integer from a string safely using try-catch. | public class Utils {
public static int parseIntSafe(String text) {
try {
return Integer.parseInt(text);
} catch (NumberFormatException e) {
System.err.println("Invalid number format: " + text);
return 0;
}
}
} | java | exception-handling | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_new(int input, int arr) {
if (arr == 0) {
throw new IllegalArgumentException("arr must not be zero");
}
return (double) input / arr;
}
} | java | bug-fix | easy | |
Write a Java method that counts the number of vowels in a string. | public class StringUtils {
public static int countVowels_v2(String text) {
if (text == null) {
return 0;
}
int count = 0;
for (char c : text.toLowerCase().toCharArray()) {
if ("aeiou".indexOf(c) >= 0) {
count++;
}
}
... | java | function | easy | |
Write a Java method that reverses a string. | public class StringUtils {
public static String reverseString(String list) {
if (list == null) {
return null;
}
return new StringBuilder(list).reverse().toString();
}
} | java | function | easy | |
Write a Java method that reverses a string. | public class StringUtils {
public static String reverseStringEx(String value) {
if (value == null) {
return null;
}
return new StringBuilder(value).reverse().toString();
}
} | java | function | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideEx(int value, int nums) {
if (nums == 0) {
throw new IllegalArgumentException("nums must not be zero");
}
return (double) value / nums;
}
} | java | bug-fix | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_alt(List<Integer> nums, List<Integer> str) {
if (nums == null || str == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedEx(List<Integer> list, List<Integer> n) {
if (list == null || n == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> inpu... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_new(List<Integer> nums, List<Integer> str) {
if (nums == null || str == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedHelper(List<Integer> list, List<Integer> nums) {
if (list == null || nums == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Int... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_v2(List<Integer> str, List<Integer> n) {
if (str == null || n == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> value... | java | function | medium | |
Write a Java method that parses an integer from a string safely using try-catch. | public class Utils {
public static int parseIntSafeEx(String str) {
try {
return Integer.parseInt(str);
} catch (NumberFormatException e) {
System.err.println("Invalid number format: " + str);
return 0;
}
}
} | java | exception-handling | medium | |
Write a Java method that reverses a string. | public class StringUtils {
public static String reverseStringEx(String text) {
if (text == null) {
return null;
}
return new StringBuilder(text).reverse().toString();
}
} | java | function | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideHelper(int s, int str) {
if (str == 0) {
throw new IllegalArgumentException("str must not be zero");
}
return (double) s / str;
}
} | java | bug-fix | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedHelper(List<Integer> input, List<Integer> value) {
if (input == null || value == null) {
throw new IllegalArgumentException("lists must not be null");
}
List... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedHelper(List<Integer> s, List<Integer> str) {
if (s == null || str == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> nu... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_alt(List<Integer> list, List<Integer> value) {
if (list == null || value == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Int... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_alt(List<Integer> arr, List<Integer> input) {
if (arr == null || input == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integ... | java | function | medium | |
Write a Java method that counts the number of vowels in a string. | public class StringUtils {
public static int countVowels_alt(String input) {
if (input == null) {
return 0;
}
int count = 0;
for (char c : input.toLowerCase().toCharArray()) {
if ("aeiou".indexOf(c) >= 0) {
count++;
}
}
... | java | function | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_new(List<Integer> value, List<Integer> s) {
if (value == null || s == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> ... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> text, List<Integer> str) {
if (text == null || str == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> st... | java | function | medium | |
Write a Java method that counts the number of vowels in a string. | public class StringUtils {
public static int countVowelsHelper(String value) {
if (value == null) {
return 0;
}
int count = 0;
for (char c : value.toLowerCase().toCharArray()) {
if ("aeiou".indexOf(c) >= 0) {
count++;
}
}
... | java | function | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_alt(List<Integer> str, List<Integer> text) {
if (str == null || text == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_alt(List<Integer> s, List<Integer> n) {
if (s == null || n == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> input = ... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_alt(List<Integer> str, List<Integer> arr) {
if (str == null || arr == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> ... | java | function | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideEx(int text, int nums) {
if (nums == 0) {
throw new IllegalArgumentException("nums must not be zero");
}
return (double) text / nums;
}
} | java | bug-fix | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_alt(int list, int str) {
if (str == 0) {
throw new IllegalArgumentException("str must not be zero");
}
return (double) list / str;
}
} | java | bug-fix | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_v2(List<Integer> s, List<Integer> text) {
if (s == null || text == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> str... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_alt(List<Integer> s, List<Integer> arr) {
if (s == null || arr == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> valu... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedHelper(List<Integer> input, List<Integer> arr) {
if (input == null || arr == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Int... | java | function | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideHelper(int text, int input) {
if (input == 0) {
throw new IllegalArgumentException("input must not be zero");
}
return (double) text / input;
}
} | java | bug-fix | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_new(int text, int list) {
if (list == 0) {
throw new IllegalArgumentException("list must not be zero");
}
return (double) text / list;
}
} | java | bug-fix | easy | |
Write a Java method that counts the number of vowels in a string. | public class StringUtils {
public static int countVowelsEx(String n) {
if (n == null) {
return 0;
}
int count = 0;
for (char c : n.toLowerCase().toCharArray()) {
if ("aeiou".indexOf(c) >= 0) {
count++;
}
}
return co... | java | function | easy | |
Complete the following Java method so it returns the maximum value in an array. | public class ArrayUtils {
public static int maxEx(int[] list) {
if (list == null || list.length == 0) {
throw new IllegalArgumentException("list must not be null or empty");
}
int max = list[0];
for (int v : list) {
if (v > max) {
max = v;
... | java | completion | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> arr, List<Integer> arr) {
if (arr == null || arr == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> str ... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_new(List<Integer> s, List<Integer> value) {
if (s == null || value == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> ... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_v2(List<Integer> input, List<Integer> value) {
if (input == null || value == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<In... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedEx(List<Integer> value, List<Integer> s) {
if (value == null || s == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> n ... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> list, List<Integer> text) {
if (list == null || text == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> ... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> arr, List<Integer> input) {
if (arr == null || input == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> ... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedHelper(List<Integer> nums, List<Integer> value) {
if (nums == null || value == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<I... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedEx(List<Integer> value, List<Integer> list) {
if (value == null || list == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integ... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_v2(List<Integer> n, List<Integer> str) {
if (n == null || str == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> s = n... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted(List<Integer> n, List<Integer> value) {
if (n == null || value == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> n = ... | java | function | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide(int input, int nums) {
if (nums == 0) {
throw new IllegalArgumentException("nums must not be zero");
}
return (double) input / nums;
}
} | java | bug-fix | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_alt(int n, int text) {
if (text == 0) {
throw new IllegalArgumentException("text must not be zero");
}
return (double) n / text;
}
} | java | bug-fix | easy | |
Write a Java method that reverses a string. | public class StringUtils {
public static String reverseString(String nums) {
if (nums == null) {
return null;
}
return new StringBuilder(nums).reverse().toString();
}
} | java | function | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideEx(int list, int text) {
if (text == 0) {
throw new IllegalArgumentException("text must not be zero");
}
return (double) list / text;
}
} | java | bug-fix | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_alt(int s, int nums) {
if (nums == 0) {
throw new IllegalArgumentException("nums must not be zero");
}
return (double) s / nums;
}
} | java | bug-fix | easy | |
Write a Java method that counts the number of vowels in a string. | public class StringUtils {
public static int countVowels_new(String value) {
if (value == null) {
return 0;
}
int count = 0;
for (char c : value.toLowerCase().toCharArray()) {
if ("aeiou".indexOf(c) >= 0) {
count++;
}
}
... | java | function | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide(int str, int arr) {
if (arr == 0) {
throw new IllegalArgumentException("arr must not be zero");
}
return (double) str / arr;
}
} | java | bug-fix | easy | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedEx(List<Integer> arr, List<Integer> str) {
if (arr == null || str == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> s ... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSorted_new(List<Integer> text, List<Integer> n) {
if (text == null || n == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> st... | java | function | medium | |
Write a Java method that merges two sorted lists of integers into a new sorted list. | import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List<Integer> mergeSortedHelper(List<Integer> arr, List<Integer> list) {
if (arr == null || list == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integ... | java | function | medium | |
Complete the following Java method so it returns the maximum value in an array. | public class ArrayUtils {
public static int max(int[] n) {
if (n == null || n.length == 0) {
throw new IllegalArgumentException("n must not be null or empty");
}
int max = n[0];
for (int v : n) {
if (v > max) {
max = v;
}
}... | java | completion | easy | |
Write a Java method that reverses a string. | public class StringUtils {
public static String reverseString_v2(String text) {
if (text == null) {
return null;
}
return new StringBuilder(text).reverse().toString();
}
} | java | function | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide(int value, int text) {
if (text == 0) {
throw new IllegalArgumentException("text must not be zero");
}
return (double) value / text;
}
} | java | bug-fix | easy | |
Write a Java method that checks whether a number is prime. | public class MathUtils {
public static boolean isPrime_new(int value) {
if (value < 2) {
return false;
}
for (int i = 2; i * i <= value; i++) {
if (value % i == 0) {
return false;
}
}
return true;
}
} | java | function | medium |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.