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(int str, int str) {
if (str == 0) {
throw new IllegalArgumentException("str must not be zero");
}
return (double) str / 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_v2(String n) {
if (n == null) {
return 0;
}
int count = 0;
for (char c : n.toLowerCase().toCharArray()) {
if ("aeiou".indexOf(c) >= 0) {
count++;
}
}
return c... | java | function | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide_new(int input, int n) {
if (n == 0) {
throw new IllegalArgumentException("n must not be zero");
}
return (double) input / 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> str, List<Integer> arr) {
if (str == null || arr == 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_v2(List<Integer> input, List<Integer> text) {
if (input == null || text == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Inte... | 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> list, List<Integer> arr) {
if (list == 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 divideHelper(int nums, int arr) {
if (arr == 0) {
throw new IllegalArgumentException("arr must not be zero");
}
return (double) nums / arr;
}
} | java | bug-fix | easy | |
Write a Java method that checks whether a number is prime. | public class MathUtils {
public static boolean isPrimeHelper(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 checks whether a number is prime. | public class MathUtils {
public static boolean isPrime_alt(int list) {
if (list < 2) {
return false;
}
for (int i = 2; i * i <= list; i++) {
if (list % 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 divideHelper(int str, int input) {
if (input == 0) {
throw new IllegalArgumentException("input must not be zero");
}
return (double) str / 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> value, List<Integer> nums) {
if (value == null || nums == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integ... | java | function | medium | |
Write a Java method that reverses a string. | public class StringUtils {
public static String reverseString_v2(String n) {
if (n == null) {
return null;
}
return new StringBuilder(n).reverse().toString();
}
} | java | function | easy | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divide(int arr, int text) {
if (text == 0) {
throw new IllegalArgumentException("text must not be zero");
}
return (double) arr / text;
}
} | 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> input, List<Integer> nums) {
if (input == null || nums == 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> str, List<Integer> str) {
if (str == null || str == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer> nums... | java | function | medium | |
Fix the following Java method so it avoids division by zero. | public class MathUtils {
public static double divideHelper(int list, int arr) {
if (arr == 0) {
throw new IllegalArgumentException("arr must not be zero");
}
return (double) list / 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> str, List<Integer> nums) {
if (str == null || nums == 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_new(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 divide_new(int input, int value) {
if (value == 0) {
throw new IllegalArgumentException("value must not be zero");
}
return (double) input / value;
}
} | 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> text, List<Integer> str) {
if (text == null || str == null) {
throw new IllegalArgumentException("lists must not be null");
}
List<Integer... | java | function | medium |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.