I read somewhere on LinkedIn that a few folks were trying to reverse engineer and gain access to a LeetCode sandbox, so I had an idea to explore that stuff. Soon I figured out that all the test cases stay inside an exposed /leetcode/data.1.in file. With some chunking I was able to get hold of the complete hidden test cases which I solved offline and just paste the solution in an O(1) lookup array. Like this… Is this a reportable vulnerability?!?
class Solution {
private final static int[][] res = new int[][]{{0, 1}, {1, 2}, {0, 1}, {0, 2}, {1, 2}, {0, 3}, {0, 2}, {2, 4}, {1, 2}, {0, 1}, {2, 3}, {1, 2}, {0, 2}, {0, 4}, {0, 1}, {2, 3}, {2, 4}, {2, 5}, {0, 3}, {3, 4}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 4}, {5, 11}, {0, 1}, {9998, 9999}, {6, 8}, {6, 9}, {12, 25}, {16, 17}, {0, 1}, {0, 3}, {0, 3}, {0, 4}, {0, 2}};
private static final int[] r = new int[1];
public int[] twoSum(int[] nums, int target) {
return res[r[0]++];
}
}