LeetCode Username
1337c0d3r
Problem Number, Title, and Link
- Add Two Numbers https://leetcode.com/problems/add-two-numbers
Bug Category
Problem examples
Bug Description
test
Language Used for Code
Java
Code used for Submit/Run operation
class Solution {
private static int testcase = 0;
public int[] twoSum(int[] nums, int target) {
NavigableMap<Integer,Integer> treeMap = new TreeMap<>();
Optional<String> value = Optional.of("Hello");
testcase++;
//java.util.Optional<String> value = java.util.Optional.of("Hello");
System.out.println(value);
Runtime.Version version = Runtime.version();
System.out.println(version);
// if (testcase == 3) {
// return new int[]{3,4,5};
// }
// while (true) {
// System.out.print("Test");
// //if (testcase == 1000000) break;
// }
Map<Integer, Integer> map = new HashMap<>();
System.out.println("Test " + testcase);
for (int i = 0; i < nums.length; i++) {
int complement = target - nums[i];
if (map.containsKey(complement)) {
return new int[] { map.get(complement), i };
}
map.put(nums[i], i + 2);
}
// In case there is no solution, we'll just return null
return null;
}
}
Expected behavior
test
Screenshots
No response
Additional context
No response
LeetCode Username
1337c0d3r
Problem Number, Title, and Link
Bug Category
Problem examples
Bug Description
test
Language Used for Code
Java
Code used for Submit/Run operation
class Solution { private static int testcase = 0; public int[] twoSum(int[] nums, int target) { NavigableMap<Integer,Integer> treeMap = new TreeMap<>(); Optional<String> value = Optional.of("Hello"); testcase++; //java.util.Optional<String> value = java.util.Optional.of("Hello"); System.out.println(value); Runtime.Version version = Runtime.version(); System.out.println(version); // if (testcase == 3) { // return new int[]{3,4,5}; // } // while (true) { // System.out.print("Test"); // //if (testcase == 1000000) break; // } Map<Integer, Integer> map = new HashMap<>(); System.out.println("Test " + testcase); for (int i = 0; i < nums.length; i++) { int complement = target - nums[i]; if (map.containsKey(complement)) { return new int[] { map.get(complement), i }; } map.put(nums[i], i + 2); } // In case there is no solution, we'll just return null return null; } }Expected behavior
test
Screenshots
No response
Additional context
No response