id,comefrom,code,masked 0,011_Container_With_Most_Water_1.java,"public int maxArea(int[] height) { int maxArea = 0; int left = 0; int right = height.length - 1; while (left < right) { maxArea = Math.max(maxArea, (right - left) * Math.min(height[left], height[right])); if (height[left] < height[right]) left++; else right--; } return maxArea; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 ; int var_3 = 0 ; int var_6 = var_0 . length - 1 ; while ( var_3 < var_6 ) { var_2 = Math . max ( var_2 , ( var_6 - var_3 ) * Math . min ( var_0 [ var_3 ] , var_0 [ var_6 ] ) ) ; if ( var_0 [ var_3 ] < var_0 [ var_6 ] ) var_3 ++ ; else var_6 -- ; } return var_2 ; } " 1,415_Add_Strings_1.java,"public String addStrings(String num1, String num2) { StringBuilder sb = new StringBuilder(); int carry = 0; for(int i = num1.length() - 1, j = num2.length() - 1; i >= 0 || j >= 0 || carry == 1; i--, j--){ int x = i < 0 ? 0 : num1.charAt(i) - '0'; int y = j < 0 ? 0 : num2.charAt(j) - '0'; sb.append((x + y + carry) % 10); carry = (x + y + carry) / 10; } return sb.reverse().toString(); }","public String var_0 ( String var_2 , String var_3 ) { StringBuilder var_5 = new StringBuilder ( ) ; int var_7 = 0 ; for ( int var_10 = var_2 . length ( ) - 1 , var_11 = var_3 . length ( ) - 1 ; var_10 >= 0 || var_11 >= 0 || var_7 == 1 ; var_10 -- , var_11 -- ) { int var_14 = var_10 < 0 ? 0 : var_2 . charAt ( var_10 ) - '0' ; int var_15 = var_11 < 0 ? 0 : var_3 . charAt ( var_11 ) - '0' ; var_5 . append ( ( var_14 + var_15 + var_7 ) % 10 ) ; var_7 = ( var_14 + var_15 + var_7 ) / 10 ; } return var_5 . reverse ( ) . toString ( ) ; } " 2,005_Longest_Palindromic_Substring_3.java,"private static char[] removeBoundaries(char[] cs) { if (cs==null || cs.length<3) return """".toCharArray(); char[] cs2 = new char[(cs.length-1)/2]; for (int i = 0; i804_Unique_Morse_Code_Words_1.java,"public int uniqueMorseRepresentations(String[] words) { String[] MORSE = new String[]{"".-"",""-..."",""-.-."",""-.."",""."",""..-."",""--."", ""...."","".."","".---"",""-.-"","".-.."",""--"",""-."", ""---"","".--."",""--.-"","".-."",""..."",""-"",""..-"", ""...-"","".--"",""-..-"",""-.--"",""--..""}; Set seen = new HashSet(); for (String word: words) { StringBuilder code = new StringBuilder(); for (char c: word.toCharArray()) code.append(MORSE[c - 'a']); seen.add(code.toString()); } return seen.size(); }","public int sample_funcname ( String [ ] var_1 ) { String [ ] var_28 = new String [ ] { "".-"" , ""-..."" , ""-.-."" , ""-.."" , ""."" , ""..-."" , ""--."" , ""...."" , "".."" , "".---"" , ""-.-"" , "".-.."" , ""--"" , ""-."" , ""---"" , "".--."" , ""--.-"" , "".-."" , ""..."" , ""-"" , ""..-"" , ""...-"" , "".--"" , ""-..-"" , ""-.--"" , ""--.."" }; Set < String > var_31 = new HashSet ( ) ; for ( String var_32 : var_1 ) { StringBuilder var_34 = new StringBuilder ( ) ; for ( char var_36 : var_32 . toCharArray ( ) ) var_34 . append ( var_28 [ var_36 - 'a' ] ) ; var_31 . add ( var_34 . toString ( ) ) ; } return var_31 . size ( ) ; } " 4,654_Maximum_Binary_Tree_1.java,"public int max(int[] nums, int l, int r) { int max_i = l; for (int i = l; i < r; i++) { if (nums[max_i] < nums[i]) max_i = i; } return max_i; }","public int sample_funcname ( int [ ] var_0 , int var_1 , int var_2 ) { int var_3 = var_1 ; for ( int var_4 = var_1 ; var_4 < var_2 ; var_4 ++ ) { if ( var_0 [ var_3 ] < var_0 [ var_4 ] ) var_3 = var_4 ; } return var_3 ; } " 5,1323_Maximum_69_Number_1.java,"public int maximum69Number (int num) { return Integer.valueOf(String.valueOf(num).replaceFirst(""6"", ""9"")); }","public int sample_funcname ( int var_0 ) { return Integer . valueOf ( String . valueOf ( var_0 ) . replaceFirst ( ""6"" , ""9"" ) ) ; } " 6,692_Top_K_Frequent_Words_2.java,"public List topKFrequent(String[] words, int k) { Map count = new HashMap(); for (String word: words) { count.put(word, count.getOrDefault(word, 0) + 1); } PriorityQueue heap = new PriorityQueue( (w1, w2) -> count.get(w1).equals(count.get(w2)) ? w2.compareTo(w1) : count.get(w1) - count.get(w2) ); for (String word: count.keySet()) { heap.offer(word); if (heap.size() > k) heap.poll(); } List ans = new ArrayList(); while (!heap.isEmpty()) ans.add(heap.poll()); Collections.reverse(ans); return ans; }","public List < String > var_1 ( String [ ] var_2 , int var_3 ) { Map < String , Integer > var_7 = new HashMap ( ) ; for ( String var_8 : var_2 ) { var_7 . put ( var_8 , var_7 . getOrDefault ( var_8 , 0 ) + 1 ) ; } PriorityQueue < String > var_19 = new PriorityQueue < String > ( ( var_14 , var_17 ) -> var_7 . get ( var_14 ) . equals ( var_7 . get ( var_17 ) ) ? var_17 . compareTo ( var_14 ) : var_7 . get ( var_14 ) - var_7 . get ( var_17 ) ) ; for ( String var_8 : var_7 . keySet ( ) ) { var_19 . offer ( var_8 ) ; if ( var_19 . size ( ) > var_3 ) var_19 . poll ( ) ; } List < String > var_26 = new ArrayList ( ) ; while ( ! var_19 . isEmpty ( ) ) var_26 . add ( var_19 . poll ( ) ) ; Collections . reverse ( var_26 ) ; return var_26 ; } " 7,204_Count_Primes_1.java,"public int countPrimes(int n) { boolean[] isPrime = new boolean[n]; int count = 0; Arrays.fill(isPrime, true); for (int i = 2; i < n; i++) { if (i * i >= n) break; if (!isPrime[i]) continue; for (int j = i * i; j < n; j += i) isPrime[j] = false; } for (int i = 2; i < n; i++) if (isPrime[i]) count++; return count; }","public int sample_funcname ( int var_0 ) { boolean [ ] var_2 = new boolean [ var_0 ] ; int var_4 = 0 ; Arrays . fill ( var_2 , true ) ; for ( int var_8 = 2 ; var_8 < var_0 ; var_8 ++ ) { if ( var_8 * var_8 >= var_0 ) break ; if ( ! var_2 [ var_8 ] ) continue ; for ( int var_9 = var_8 * var_8 ; var_9 < var_0 ; var_9 += var_8 ) var_2 [ var_9 ] = false ; } for ( int var_8 = 2 ; var_8 < var_0 ; var_8 ++ ) if ( var_2 [ var_8 ] ) var_4 ++ ; return var_4 ; } " 8,007_Reverse_Integer_1.java,"public int reverse(int x) { if (x == 0) return 0; long res = 0; while (x != 0) { res = res * 10 + x % 10; if (res > Integer.MAX_VALUE || res < Integer.MIN_VALUE) return 0; x /= 10; } return (int) res; }","public int sample_funcname ( int var_0 ) { if ( var_0 == 0 ) return 0 ; long var_2 = 0 ; while ( var_0 != 0 ) { var_2 = var_2 * 10 + var_0 % 10 ; if ( var_2 > Integer . MAX_VALUE || var_2 < Integer . MIN_VALUE ) return 0 ; var_0 /= 10 ; } return ( int ) var_2 ; } " 9,003_Longest_Substring_Without_Repeating_Characters_2.java,"public int lengthOfLongestSubstring(String s) { int[] charMap = new int[256]; Arrays.fill(charMap, -1); int i = 0, maxLen = 0; for (int j = 0; j < s.length(); j++) { if (charMap[s.charAt(j)] >= i) { i = charMap[s.charAt(j)] + 1; } charMap[s.charAt(j)] = j; maxLen = Math.max(j - i + 1, maxLen); } return maxLen; }","public int sample_funcname ( String var_1 ) { int [ ] var_3 = new int [ 256 ] ; Arrays . fill ( var_3 , - 1 ) ; int var_8 = 0 , var_9 = 0 ; for ( int var_10 = 0 ; var_10 < var_1 . length ( ) ; var_10 ++ ) { if ( var_3 [ var_1 . charAt ( var_10 ) ] >= var_8 ) { var_8 = var_3 [ var_1 . charAt ( var_10 ) ] + 1 ; } var_3 [ var_1 . charAt ( var_10 ) ] = var_10 ; var_9 = Math . max ( var_10 - var_8 + 1 , var_9 ) ; } return var_9 ; } " 10,013_Roman_to_Integer_1.java,"public int romanToInt(String s) { int[] arr = new int['A' + 26]; arr['I'] = 1; arr['V'] = 5; arr['X'] = 10; arr['L'] = 50; arr['C'] = 100; arr['D'] = 500; arr['M'] = 1000; int result = 0; int prev = 0; for (int i = s.length() - 1; i >= 0; i--) { int current = arr[s.charAt(i)]; result += prev > current ? -current : current; prev = current; } return result; }","public int sample_funcname ( String var_1 ) { int [ ] var_4 = new int [ 'A' + 26 ] ; var_4 [ 'I' ] = 1 ; var_4 [ 'V' ] = 5 ; var_4 [ 'X' ] = 10 ; var_4 [ 'L' ] = 50 ; var_4 [ 'C' ] = 100 ; var_4 [ 'D' ] = 500 ; var_4 [ 'M' ] = 1000 ; int var_20 = 0 ; int var_21 = 0 ; for ( int var_23 = var_1 . length ( ) - 1 ; var_23 >= 0 ; var_23 -- ) { int var_25 = var_4 [ var_1 . charAt ( var_23 ) ] ; var_20 += var_21 > var_25 ? - var_25 : var_25 ; var_21 = var_25 ; } return var_20 ; } " 11,238_Product_of_Array_Except_Self_1.java,"public int[] productExceptSelf(int[] nums) { int n = nums.length; int[] res = new int[n]; res[0] = 1; for (int i = 1; i < n; i++) { res[i] = res[i - 1] * nums[i - 1]; } int right = 1; for (int i = n - 1; i >= 0; i--) { res[i] *= right; right *= nums[i]; } return res; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; int [ ] var_3 = new int [ var_2 ] ; var_3 [ 0 ] = 1 ; for ( int var_6 = 1 ; var_6 < var_2 ; var_6 ++ ) { var_3 [ var_6 ] = var_3 [ var_6 - 1 ] * var_0 [ var_6 - 1 ] ; } int var_7 = 1 ; for ( int var_6 = var_2 - 1 ; var_6 >= 0 ; var_6 -- ) { var_3 [ var_6 ] *= var_7 ; var_7 *= var_0 [ var_6 ] ; } return var_3 ; } " 12,581_Shortest_Unsorted_Continuous_Subarray_1.java,"public int findUnsortedSubarray(int[] nums) { Stack < Integer > stack = new Stack < Integer > (); int l = nums.length, r = 0; for (int i = 0; i < nums.length; i++) { while (!stack.isEmpty() && nums[stack.peek()] > nums[i]) l = Math.min(l, stack.pop()); stack.push(i); } stack.clear(); for (int i = nums.length - 1; i >= 0; i--) { while (!stack.isEmpty() && nums[stack.peek()] < nums[i]) r = Math.max(r, stack.pop()); stack.push(i); } return r - l > 0 ? r - l + 1 : 0; }","public int sample_funcname ( int [ ] var_0 ) { Stack < Integer > var_3 = new Stack < Integer > ( ) ; int var_5 = var_0 . length , var_7 = 0 ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { while ( ! var_3 . isEmpty ( ) && var_0 [ var_3 . peek ( ) ] > var_0 [ var_8 ] ) var_5 = Math . min ( var_5 , var_3 . pop ( ) ) ; var_3 . push ( var_8 ) ; } var_3 . clear ( ) ; for ( int var_8 = var_0 . length - 1 ; var_8 >= 0 ; var_8 -- ) { while ( ! var_3 . isEmpty ( ) && var_0 [ var_3 . peek ( ) ] < var_0 [ var_8 ] ) var_7 = Math . max ( var_7 , var_3 . pop ( ) ) ; var_3 . push ( var_8 ) ; } return var_7 - var_5 > 0 ? var_7 - var_5 + 1 : 0 ; } " 13,929_Unique_Email_Addresses_1.java,"public int numUniqueEmails(String[] emails) { HashSet emailSet = new HashSet<>(); for (String email: emails) { String firstSplit[] = email.split(""@""); String secondSplit[] = firstSplit[0].replaceAll(""."", """").split(""[+]""); emailSet.add(secondSplit[0] + firstSplit[1]); } return emailSet.size(); }","public int sample_funcname ( String [ ] var_1 ) { HashSet < String > var_3 = new HashSet < > ( ) ; for ( String var_4 : var_1 ) { String var_7 [ ] = var_4 . split ( ""@"" ) ; String var_13 [ ] = var_7 [ 0 ] . replaceAll ( ""."" , """" ) . split ( ""[+]"" ) ; var_3 . add ( var_13 [ 0 ] + var_7 [ 1 ] ) ; } return var_3 . size ( ) ; } " 14,724_Find_Pivot_Index_1.java,"public int pivotIndex(int[] nums) { int totalsum = 0, leftsum = 0; for (int i = 0; i < nums.length; i++) totalsum += nums[i]; for (int i = 0; i < nums.length; i++) { if (leftsum == totalsum - leftsum - nums[i]) return i; leftsum += nums[i]; } return -1; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 , var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) var_2 += var_0 [ var_4 ] ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { if ( var_3 == var_2 - var_3 - var_0 [ var_4 ] ) return var_4 ; var_3 += var_0 [ var_4 ] ; } return - 1 ; } " 15,560_Subarray_Sum_Equals_K_2.java,"public int subarraySum(int[] nums, int k) { int count = 0, sum = 0; HashMap < Integer, Integer > map = new HashMap < > (); map.put(0, 1); for (int i = 0; i < nums.length; i++) { sum += nums[i]; if (map.containsKey(sum - k)) count += map.get(sum - k); map.put(sum, map.getOrDefault(sum, 0) + 1); } return count; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = 0 , var_4 = 0 ; HashMap < Integer , Integer > var_7 = new HashMap < > ( ) ; var_7 . put ( 0 , 1 ) ; for ( int var_10 = 0 ; var_10 < var_0 . length ; var_10 ++ ) { var_4 += var_0 [ var_10 ] ; if ( var_7 . containsKey ( var_4 - var_1 ) ) var_3 += var_7 . get ( var_4 - var_1 ) ; var_7 . put ( var_4 , var_7 . getOrDefault ( var_4 , 0 ) + 1 ) ; } return var_3 ; } " 16,434_Number_of_Segments_in_a_String_2.java,"public int countSegments(String s) { int segmentCount = 0; for (int i = 0; i < s.length(); i++) { if ((i == 0 || s.charAt(i-1) == ' ') && s.charAt(i) != ' ') { segmentCount++; } } return segmentCount; }","public int sample_funcname ( String var_1 ) { int var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_1 . length ( ) ; var_4 ++ ) { if ( ( var_4 == 0 || var_1 . charAt ( var_4 - 1 ) == ' ' ) && var_1 . charAt ( var_4 ) != ' ' ) { var_3 ++ ; } } return var_3 ; } " 17,179_Largest_Number_1.java,"public int compare(String a, String b) { String order1 = a + b; String order2 = b + a; return order2.compareTo(order1); }","public int sample_funcname ( String var_1 , String var_2 ) { String var_3 = var_1 + var_2 ; String var_4 = var_2 + var_1 ; return var_4 . compareTo ( var_3 ) ; } " 18,784_Letter_Case_Permutation_2.java,"public List letterCasePermutation(String S) { int B = 0; for (char c: S.toCharArray()) if (Character.isLetter(c)) B++; List ans = new ArrayList(); for (int bits = 0; bits < 1<> b++) & 1) == 1) word.append(Character.toLowerCase(letter)); else word.append(Character.toUpperCase(letter)); } else { word.append(letter); } } ans.add(word.toString()); } return ans; }","public List < String > var_1 ( String var_2 ) { int var_4 = 0 ; for ( char var_6 : var_2 . toCharArray ( ) ) if ( Character . isLetter ( var_6 ) ) var_4 ++ ; List < String > var_11 = new ArrayList ( ) ; for ( int var_12 = 0 ; var_12 < 1 << var_4 ; var_12 ++ ) { int var_14 = 0 ; StringBuilder var_16 = new StringBuilder ( ) ; for ( char var_17 : var_2 . toCharArray ( ) ) { if ( Character . isLetter ( var_17 ) ) { if ( ( ( var_12 >> var_14 ++ ) & 1 ) == 1 ) var_16 . append ( Character . toLowerCase ( var_17 ) ) ; else var_16 . append ( Character . toUpperCase ( var_17 ) ) ; } else { var_16 . append ( var_17 ) ; } } var_11 . add ( var_16 . toString ( ) ) ; } return var_11 ; } " 19,438_Find_All_Anagrams_in_a_String_2.java,"public List findAnagrams(String s, String p) { List list = new ArrayList(); int ls = s.length(), lp = p.length(); for (int i = 0; i <= ls - lp; i++) { boolean flag = true; String sub = s.substring(i, i + lp); int[] charCnt = new int[256]; for (int j = 0; j < sub.length(); j++) { charCnt[sub.charAt(j)]++; } for (int j = 0; j < lp; j++) { charCnt[p.charAt(j)]--; } for (int j = 0; j < charCnt.length; j++) { if (charCnt[j] != 0) { flag = false; break; } } if (flag) { list.add(i); } } return list; }","public List < Integer > var_1 ( String var_3 , String var_4 ) { List < Integer > var_7 = new ArrayList < Integer > ( ) ; int var_9 = var_3 . length ( ) , var_10 = var_4 . length ( ) ; for ( int var_12 = 0 ; var_12 <= var_9 - var_10 ; var_12 ++ ) { boolean var_20 = true ; String var_15 = var_3 . substring ( var_12 , var_12 + var_10 ) ; int [ ] var_17 = new int [ 256 ] ; for ( int var_18 = 0 ; var_18 < var_15 . length ( ) ; var_18 ++ ) { var_17 [ var_15 . charAt ( var_18 ) ] ++ ; } for ( int var_18 = 0 ; var_18 < var_10 ; var_18 ++ ) { var_17 [ var_4 . charAt ( var_18 ) ] -- ; } for ( int var_18 = 0 ; var_18 < var_17 . length ; var_18 ++ ) { if ( var_17 [ var_18 ] != 0 ) { var_20 = false ; break ; } } if ( var_20 ) { var_7 . add ( var_12 ) ; } } return var_7 ; } " 20,479_Largest_Palindrome_Product_1.java,"private long createPalindrom(long num) { String str = num + new StringBuilder().append(num).reverse().toString(); return Long.parseLong(str); }","private long sample_funcname ( long var_0 ) { String var_6 = var_0 + new StringBuilder ( ) . append ( var_0 ) . reverse ( ) . toString ( ) ; return Long . parseLong ( var_6 ) ; } " 21,811_Subdomain_Visit_Count_1.java,"public List subdomainVisits(String[] cpdomains) { Map map = new HashMap(); for (String cpdomain : cpdomains) { int i = cpdomain.indexOf(' '); int n = Integer.valueOf(cpdomain.substring(0, i)); String domain = cpdomain.substring(i + 1); for (i = 0; i < domain.length(); ++i) { if (domain.charAt(i) == '.') { String d = domain.substring(i + 1); map.put(d, map.getOrDefault(d, 0) + n); } } map.put(domain, map.getOrDefault(domain, 0) + n); } List res = new ArrayList(); for (String domain : map.keySet()) res.add(map.get(domain) + "" "" + domain); return res; }","public List < String > var_1 ( String [ ] var_2 ) { Map < String , Integer > var_6 = new HashMap ( ) ; for ( String var_7 : var_2 ) { int var_10 = var_7 . indexOf ( ' ' ) ; int var_14 = Integer . valueOf ( var_7 . substring ( 0 , var_10 ) ) ; String var_16 = var_7 . substring ( var_10 + 1 ) ; for ( var_10 = 0 ; var_10 < var_16 . length ( ) ; ++ var_10 ) { if ( var_16 . charAt ( var_10 ) == '.' ) { String var_20 = var_16 . substring ( var_10 + 1 ) ; var_6 . put ( var_20 , var_6 . getOrDefault ( var_20 , 0 ) + var_14 ) ; } } var_6 . put ( var_16 , var_6 . getOrDefault ( var_16 , 0 ) + var_14 ) ; } List < String > var_25 = new ArrayList ( ) ; for ( String var_16 : var_6 . keySet ( ) ) var_25 . add ( var_6 . get ( var_16 ) + "" "" + var_16 ) ; return var_25 ; } " 22,1539_Kth_Missing_Positive_Number_1.java,"public int findKthPositive(int[] a, int k) { int B[] = new int[a.length]; for (int i = 0; i < a.length; i++) B[i] = a[i] - i - 1; // -1 is done as here missing numbers start from 1 and not 0 int lo = 0, hi = B.length - 1; while (lo <= hi) { int mid = lo + (hi - lo) / 2; if (B[mid] >= k) hi = mid - 1; else lo = mid + 1; } return lo + k; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 [ ] = new int [ var_0 . length ] ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) var_3 [ var_5 ] = var_0 [ var_5 ] - var_5 - 1 ; int var_8 = 0 , var_9 = var_3 . length - 1 ; while ( var_8 <= var_9 ) { int var_11 = var_8 + ( var_9 - var_8 ) / 2 ; if ( var_3 [ var_11 ] >= var_1 ) var_9 = var_11 - 1 ; else var_8 = var_11 + 1 ; } return var_8 + var_1 ; } " 23,412_Fizz_Buzz_1.java,"public List fizzBuzz(int n) { List res = new ArrayList<>(); for (int i = 1; i <= n; i++) { String tmp = """"; if (i % 3 == 0) tmp += ""Fizz""; if (i % 5 == 0) tmp += ""Buzz""; if (tmp.length() == 0) tmp += String.valueOf(i); res.add(tmp); } return res; }","public List < String > var_1 ( int var_2 ) { List < String > var_5 = new ArrayList < > ( ) ; for ( int var_7 = 1 ; var_7 <= var_2 ; var_7 ++ ) { String var_9 = """" ; if ( var_7 % 3 == 0 ) var_9 += ""Fizz"" ; if ( var_7 % 5 == 0 ) var_9 += ""Buzz"" ; if ( var_9 . length ( ) == 0 ) var_9 += String . valueOf ( var_7 ) ; var_5 . add ( var_9 ) ; } return var_5 ; } " 24,547_Friend_Circles_1.java,"public void dfs(int[][] M, int[] visited, int i) { for (int j = 0; j < M.length; j++) { if (M[i][j] == 1 && visited[j] == 0) { visited[j] = 1; dfs(M, visited, j); } } }","public void sample_funcname ( int [ ] [ ] M , int [ ] visited , int i ) { for ( int j = 0 ; j < M . length ; j ++ ) { if ( M [ i ] [ j ] == 1 && visited [ j ] == 0 ) { visited [ j ] = 1 ; dfs ( M , visited , j ) ; } } } " 25,973_K_Closest_Points_to_Origin_1.java,"private int dist(int[] point) { return point[0] * point[0] + point[1] * point[1]; }","private int sample_funcname ( int [ ] var_0 ) { return var_0 [ 0 ] * var_0 [ 0 ] + var_0 [ 1 ] * var_0 [ 1 ] ; } " 26,1089_Duplicate_Zeros_1.java,"public void duplicateZeros(int[] arr) { int movePos = 0; int lastPos = arr.length - 1; for (int i = 0; i <= lastPos - movePos; i++) { if (arr[i] == 0) { if (i == lastPos - movePos) { arr[lastPos] = 0; lastPos--; break; } movePos++; } } lastPos = lastPos - movePos; for (int i = lastPos; i >= 0; i--) { if (arr[i] == 0) { arr[i + movePos] = 0; movePos--; arr[i + movePos] = 0; } else { arr[i + movePos] = arr[i]; } } }","public void var_0 ( int [ ] var_1 ) { int var_3 = 0 ; int var_6 = var_1 . length - 1 ; for ( int var_7 = 0 ; var_7 <= var_6 - var_3 ; var_7 ++ ) { if ( var_1 [ var_7 ] == 0 ) { if ( var_7 == var_6 - var_3 ) { var_1 [ var_6 ] = 0 ; var_6 -- ; break ; } var_3 ++ ; } } var_6 = var_6 - var_3 ; for ( int var_7 = var_6 ; var_7 >= 0 ; var_7 -- ) { if ( var_1 [ var_7 ] == 0 ) { var_1 [ var_7 + var_3 ] = 0 ; var_3 -- ; var_1 [ var_7 + var_3 ] = 0 ; } else { var_1 [ var_7 + var_3 ] = var_1 [ var_7 ] ; } } } " 27,387_First_Unique_Character_in_a_String_1.java,"public int firstUniqChar(String s) { int freq [] = new int[26]; for(int i = 0; i < s.length(); i ++) freq [s.charAt(i) - 'a'] ++; for(int i = 0; i < s.length(); i ++) if(freq [s.charAt(i) - 'a'] == 1) return i; return -1; }","public int sample_funcname ( String var_1 ) { int var_3 [ ] = new int [ 26 ] ; for ( int var_5 = 0 ; var_5 < var_1 . length ( ) ; var_5 ++ ) var_3 [ var_1 . charAt ( var_5 ) - 'a' ] ++ ; for ( int var_5 = 0 ; var_5 < var_1 . length ( ) ; var_5 ++ ) if ( var_3 [ var_1 . charAt ( var_5 ) - 'a' ] == 1 ) return var_5 ; return - 1 ; } " 28,771_Jewels_and_Stones_1.java,"public int numJewelsInStones(String J, String S) { int result = 0; HashSet jHash = new HashSet<>(); for (int j = 0; j < J.length(); j++) { jHash.add(J.charAt(j)); } for (int s = 0; s < S.length(); s++) { if (jHash.contains(S.charAt(s))) { result++; } } return result; }","public int sample_funcname ( String var_1 , String var_2 ) { int var_4 = 0 ; HashSet var_6 = new HashSet < > ( ) ; for ( int var_7 = 0 ; var_7 < var_1 . length ( ) ; var_7 ++ ) { var_6 . add ( var_1 . charAt ( var_7 ) ) ; } for ( int var_11 = 0 ; var_11 < var_2 . length ( ) ; var_11 ++ ) { if ( var_6 . contains ( var_2 . charAt ( var_11 ) ) ) { var_4 ++ ; } } return var_4 ; } " 29,665_Non-decreasing_Array_1.java,"public boolean checkPossibility(int[] nums) { int brokenPoint = 0; for (int i = 0; i < nums.length - 1; i++) { if (nums[i] > nums[i + 1]) { brokenPoint++; if (brokenPoint >= 2) return false; if (i - 1 < 0 || nums[i - 1] <= nums[i + 1]) nums[i] = nums[i + 1]; else nums[i + 1] = nums[i]; } } return true; }","public boolean var_0 ( int [ ] var_1 ) { int var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_1 . length - 1 ; var_4 ++ ) { if ( var_1 [ var_4 ] > var_1 [ var_4 + 1 ] ) { var_3 ++ ; if ( var_3 >= 2 ) return false ; if ( var_4 - 1 < 0 || var_1 [ var_4 - 1 ] <= var_1 [ var_4 + 1 ] ) var_1 [ var_4 ] = var_1 [ var_4 + 1 ] ; else var_1 [ var_4 + 1 ] = var_1 [ var_4 ] ; } } return true ; } " 30,009_Palindrome_Number_1.java,"public boolean isPalindrome(int x) { if (x < 0) return false; int temp = x; int len = 0; while (temp != 0) { temp /= 10; len ++; } temp = x; int left, right; for (int i = 0; i < len / 2; i++) { right = temp % 10; left = temp / (int) Math.pow(10, len - 2 * i - 1); left = left % 10; if (left != right) return false; temp /= 10; } return true; }","public boolean var_0 ( int var_1 ) { if ( var_1 < 0 ) return false ; int var_3 = var_1 ; int var_4 = 0 ; while ( var_3 != 0 ) { var_3 /= 10 ; var_4 ++ ; } var_3 = var_1 ; int var_6 , var_7 ; for ( int var_8 = 0 ; var_8 < var_4 / 2 ; var_8 ++ ) { var_7 = var_3 % 10 ; var_6 = var_3 / ( int ) Math . pow ( 10 , var_4 - 2 * var_8 - 1 ) ; var_6 = var_6 % 10 ; if ( var_6 != var_7 ) return false ; var_3 /= 10 ; } return true ; } " 31,668_Kth_Smallest_Number_in_Multiplication_Table_1.java,"public boolean enough(int x, int m, int n, int k) { int count = 0; for (int i = 1; i <= m; i++) { count += Math.min(x / i, n); } return count >= k; }","public boolean var_0 ( int var_1 , int var_2 , int var_3 , int var_4 ) { int var_6 = 0 ; for ( int var_8 = 1 ; var_8 <= var_2 ; var_8 ++ ) { var_6 += Math . min ( var_1 / var_8 , var_3 ) ; } return var_6 >= var_4 ; } " 32,760_Find_Anagram_Mappings_1.java,"public int[] anagramMappings(int[] A, int[] B) { int[] ans = new int[A.length]; HashMap valIndex = new HashMap<>(); for (int i = 0; i < B.length; i++) valIndex.put(B[i], i); for (int i = 0; i < A.length; i++) ans[i] = valIndex.get(A[i]); return ans; }","public int [ ] sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { int [ ] var_3 = new int [ var_0 . length ] ; HashMap < Integer , Integer > var_6 = new HashMap < > ( ) ; for ( int var_8 = 0 ; var_8 < var_1 . length ; var_8 ++ ) var_6 . put ( var_1 [ var_8 ] , var_8 ) ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) var_3 [ var_8 ] = var_6 . get ( var_0 [ var_8 ] ) ; return var_3 ; } " 33,709_To_Lower_Case_2.java,"public String toLowerCase(String str) { char[] a = str.toCharArray(); for (int i = 0; i < a.length; i++) if ('A' <= a[i] && a[i] <= 'Z') a[i] = (char) (a[i] - 'A' + 'a'); return new String(a); }","public String var_0 ( String var_2 ) { char [ ] var_4 = var_2 . toCharArray ( ) ; for ( int var_6 = 0 ; var_6 < var_4 . length ; var_6 ++ ) if ( 'A' <= var_4 [ var_6 ] && var_4 [ var_6 ] <= 'Z' ) var_4 [ var_6 ] = ( char ) ( var_4 [ var_6 ] - 'A' + 'a' ) ; return new String ( var_4 ) ; } " 34,005_Longest_Palindromic_Substring_2.java,"private static char[] addBoundaries(char[] cs) { if (cs==null || cs.length==0) return ""||"".toCharArray(); char[] cs2 = new char[cs.length*2+1]; for (int i = 0; i<(cs2.length-1); i = i+2) { cs2[i] = '|'; cs2[i+1] = cs[i/2]; } cs2[cs2.length-1] = '|'; return cs2; }","private static char [ ] sample_funcname ( char [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return ""||"" . toCharArray ( ) ; char [ ] var_8 = new char [ var_0 . length * 2 + 1 ] ; for ( int var_9 = 0 ; var_9 < ( var_8 . length - 1 ) ; var_9 = var_9 + 2 ) { var_8 [ var_9 ] = '|' ; var_8 [ var_9 + 1 ] = var_0 [ var_9 / 2 ] ; } var_8 [ var_8 . length - 1 ] = '|' ; return var_8 ; } " 35,1108_Defanging_an_IP_Address_1.java,"public String defangIPaddr(String address) { return address.replace(""."", ""[.]""); }","public String var_0 ( String var_2 ) { return var_2 . replace ( ""."" , ""[.]"" ) ; } " 36,1064_Fixed_Point_1.java,"public int fixedPoint(int[] A) { int l = 0; int h = A.length; while (l <= h) { int mid = (l + h) / 2; if (A[mid] > mid) h = mid - 1; else if (A[mid] < mid) l = mid + 1; else return mid; } return -1; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 ; int var_4 = var_0 . length ; while ( var_2 <= var_4 ) { int var_6 = ( var_2 + var_4 ) / 2 ; if ( var_0 [ var_6 ] > var_6 ) var_4 = var_6 - 1 ; else if ( var_0 [ var_6 ] < var_6 ) var_2 = var_6 + 1 ; else return var_6 ; } return - 1 ; } " 37,962_Maximum_Width_Ramp_1.java,"public int maxWidthRamp(int[] A) { int N = A.length; Integer[] B = new Integer[N]; for (int i = 0; i < N; ++i) B[i] = i; Arrays.sort(B, (i, j) -> ((Integer) A[i]).compareTo(A[j])); int ans = 0; int m = N; for (int i: B) { ans = Math.max(ans, i - m); m = Math.min(m, i); } return ans; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; Integer [ ] var_4 = new Integer [ var_2 ] ; for ( int var_6 = 0 ; var_6 < var_2 ; ++ var_6 ) var_4 [ var_6 ] = var_6 ; Arrays . sort ( var_4 , ( var_6 , var_9 ) -> ( ( Integer ) var_0 [ var_6 ] ) . compareTo ( var_0 [ var_9 ] ) ) ; int var_11 = 0 ; int var_12 = var_2 ; for ( int var_6 : var_4 ) { var_11 = Math . max ( var_11 , var_6 - var_12 ) ; var_12 = Math . min ( var_12 , var_6 ) ; } return var_11 ; } " 38,937_Reorder_Log_Files_1.java,"public String[] reorderLogFiles(String[] logs) { Arrays.sort(logs, (log1, log2) -> { String[] split1 = log1.split("" "", 2); String[] split2 = log2.split("" "", 2); boolean isDigit1 = Character.isDigit(split1[1].charAt(0)); boolean isDigit2 = Character.isDigit(split2[1].charAt(0)); if (!isDigit1 && !isDigit2) { int cmp = split1[1].compareTo(split2[1]); if (cmp != 0) return cmp; return split1[0].compareTo(split2[0]); } return isDigit1 ? (isDigit2 ? 0 : 1) : -1; }); return logs; }","public String [ ] var_0 ( String [ ] var_2 ) { Arrays . sort ( var_2 , ( var_5 , var_6 ) -> { String [ ] var_10 = var_5 . split ( "" "" , 2 ) ; String [ ] var_11 = var_6 . split ( "" "" , 2 ) ; boolean var_18 = Character . isDigit ( var_10 [ 1 ] . charAt ( 0 ) ) ; boolean var_19 = Character . isDigit ( var_11 [ 1 ] . charAt ( 0 ) ) ; if ( ! var_18 && ! var_19 ) { int var_21 = var_10 [ 1 ] . compareTo ( var_11 [ 1 ] ) ; if ( var_21 != 0 ) return var_21 ; return var_10 [ 0 ] . compareTo ( var_11 [ 0 ] ) ; } return var_18 ? ( var_19 ? 0 : 1 ) : - 1 ; } ) ; return var_2 ; } " 39,852_Peak_Index_in_a_Mountain_Array_2.java,"public int peakIndexInMountainArray(int[] A) { int lo = 0, hi = A.length - 1; while (lo < hi) { int mid = (lo + hi) / 2; if (A[mid] < A[mid + 1]) lo = mid + 1; else hi = mid; } return lo; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 , var_5 = var_0 . length - 1 ; while ( var_2 < var_5 ) { int var_7 = ( var_2 + var_5 ) / 2 ; if ( var_0 [ var_7 ] < var_0 [ var_7 + 1 ] ) var_2 = var_7 + 1 ; else var_5 = var_7 ; } return var_2 ; } " 40,961_N-Repeated_Element_in_Size_2N_Array_1.java,"public int repeatedNTimes(int[] A) { HashMap hash = new HashMap<>(); int ans = A[0]; for (int n: A) { int count = hash.getOrDefault(n, 0) + 1; hash.put(n, count); if (count >= hash.get(ans)) ans = n; } return ans; }","public int sample_funcname ( int [ ] var_0 ) { HashMap < Integer , Integer > var_3 = new HashMap < > ( ) ; int var_5 = var_0 [ 0 ] ; for ( int var_6 : var_0 ) { int var_9 = var_3 . getOrDefault ( var_6 , 0 ) + 1 ; var_3 . put ( var_6 , var_9 ) ; if ( var_9 >= var_3 . get ( var_5 ) ) var_5 = var_6 ; } return var_5 ; } " 41,215_Kth_Largest_Element_in_an_Array_1.java,"private void exch(int[] a, int i, int j) { final int tmp = a[i]; a[i] = a[j]; a[j] = tmp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { final int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 42,720_Longest_Word_in_Dictionary_1.java,"public String longestWord(String[] words) { String ans = """"; Set wordset = new HashSet(); for (String word: words) wordset.add(word); for (String word: words) { if (word.length() > ans.length() || word.length() == ans.length() && word.compareTo(ans) < 0) { boolean good = true; for (int k = 1; k < word.length(); ++k) { if (!wordset.contains(word.substring(0, k))) { good = false; break; } } if (good) ans = word; } } return ans; }","public String var_0 ( String [ ] var_2 ) { String var_4 = """" ; Set < String > var_7 = new HashSet ( ) ; for ( String var_8 : var_2 ) var_7 . add ( var_8 ) ; for ( String var_8 : var_2 ) { if ( var_8 . length ( ) > var_4 . length ( ) || var_8 . length ( ) == var_4 . length ( ) && var_8 . compareTo ( var_4 ) < 0 ) { boolean var_18 = true ; for ( int var_15 = 1 ; var_15 < var_8 . length ( ) ; ++ var_15 ) { if ( ! var_7 . contains ( var_8 . substring ( 0 , var_15 ) ) ) { var_18 = false ; break ; } } if ( var_18 ) var_4 = var_8 ; } } return var_4 ; } " 43,728_Self_Dividing_Numbers_1.java,"public boolean isSelfDiving(int num) { int digit = num % 10; int temp = num; boolean isTrue = true; while(temp != 0) { if(digit == 0 || num % digit != 0) { isTrue = false; break; } else { temp /= 10; digit = temp % 10; } } return isTrue; }","public boolean var_0 ( int var_1 ) { int var_3 = var_1 % 10 ; int var_4 = var_1 ; boolean var_7 = true ; while ( var_4 != 0 ) { if ( var_3 == 0 || var_1 % var_3 != 0 ) { var_7 = false ; break ; } else { var_4 /= 10 ; var_3 = var_4 % 10 ; } } return var_7 ; } " 44,945_Minimum_Increment_to_Make_Array_Unique_1.java,"public int minIncrementForUnique(int[] A) { if (A.length == 0) return 0; HashSet numSet = new HashSet<>(); List duplicated = new ArrayList<>(); int res = 0; Arrays.sort(A); int left = A[0]; int right = A[A.length - 1]; int holes = right - left + 1; for (int v: A) { if (numSet.contains(v)) duplicated.add(v); else numSet.add(v); } holes -= numSet.size(); for (int i = left + 1; i < right; i++) { if (holes == 0 || duplicated.size() == 0) break; if (!numSet.contains(i) && i > duplicated.get(0)) { res += i - duplicated.get(0); holes --; duplicated.remove(0); } } if (duplicated.size() == 0) return res; while (duplicated.size() != 0) { right += 1; res += right - duplicated.get(0); duplicated.remove(0); } return res; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; HashSet < Integer > var_5 = new HashSet < > ( ) ; List < Integer > var_8 = new ArrayList < > ( ) ; int var_9 = 0 ; Arrays . sort ( var_0 ) ; int var_12 = var_0 [ 0 ] ; int var_14 = var_0 [ var_0 . length - 1 ] ; int var_15 = var_14 - var_12 + 1 ; for ( int var_16 : var_0 ) { if ( var_5 . contains ( var_16 ) ) var_8 . add ( var_16 ) ; else var_5 . add ( var_16 ) ; } var_15 -= var_5 . size ( ) ; for ( int var_20 = var_12 + 1 ; var_20 < var_14 ; var_20 ++ ) { if ( var_15 == 0 || var_8 . size ( ) == 0 ) break ; if ( ! var_5 . contains ( var_20 ) && var_20 > var_8 . get ( 0 ) ) { var_9 += var_20 - var_8 . get ( 0 ) ; var_15 -- ; var_8 . remove ( 0 ) ; } } if ( var_8 . size ( ) == 0 ) return var_9 ; while ( var_8 . size ( ) != 0 ) { var_14 += 1 ; var_9 += var_14 - var_8 . get ( 0 ) ; var_8 . remove ( 0 ) ; } return var_9 ; } " 45,751_IP_to_CIDR_3.java,"private int bitLength(long x) { if (x == 0) return 1; int ans = 0; while (x > 0) { x >>= 1; ans++; } return ans; }","private int sample_funcname ( long var_0 ) { if ( var_0 == 0 ) return 1 ; int var_3 = 0 ; while ( var_0 > 0 ) { var_0 >>= 1 ; var_3 ++ ; } return var_3 ; } " 46,1480_Running_Sum_of_1d_Array_1.java,"public int[] runningSum(int[] nums) { if (nums.length <= 1) return nums; for (int i = 1; i < nums.length; i++) nums[i] += nums[i - 1]; return nums; }","public int [ ] sample_funcname ( int [ ] var_0 ) { if ( var_0 . length <= 1 ) return var_0 ; for ( int var_3 = 1 ; var_3 < var_0 . length ; var_3 ++ ) var_0 [ var_3 ] += var_0 [ var_3 - 1 ] ; return var_0 ; } " 47,223_Rectangle_Area_1.java,"public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { int left = Math.max(A, E), right = Math.max(Math.min(C, G), left); int bottom = Math.max(B, F), top = Math.max(Math.min(D, H), bottom); return (C - A) * (D - B) - (right - left) * (top - bottom) + (G - E) * (H - F); }","public int sample_funcname ( int var_0 , int var_1 , int var_2 , int var_3 , int var_4 , int var_5 , int var_6 , int var_7 ) { int var_10 = Math . max ( var_0 , var_4 ) , var_12 = Math . max ( Math . min ( var_2 , var_6 ) , var_10 ) ; int var_13 = Math . max ( var_1 , var_5 ) , var_14 = Math . max ( Math . min ( var_3 , var_7 ) , var_13 ) ; return ( var_2 - var_0 ) * ( var_3 - var_1 ) - ( var_12 - var_10 ) * ( var_14 - var_13 ) + ( var_6 - var_4 ) * ( var_7 - var_5 ) ; } " 48,680_Valid_Palindrome_II_1.java,"public boolean isPalindromeRange(String s, int i, int j) { for (int k = i; k <= i + (j - i) / 2; k++) { if (s.charAt(k) != s.charAt(j - k + i)) return false; } return true; }","public boolean var_0 ( String var_2 , int var_3 , int var_4 ) { for ( int var_5 = var_3 ; var_5 <= var_3 + ( var_4 - var_3 ) / 2 ; var_5 ++ ) { if ( var_2 . charAt ( var_5 ) != var_2 . charAt ( var_4 - var_5 + var_3 ) ) return false ; } return true ; } " 49,628_Maximum_Product_of_Three_Numbers_2.java,"public int maximumProduct(int[] nums) { int min1 = Integer.MAX_VALUE, min2 = Integer.MAX_VALUE; int max1 = Integer.MIN_VALUE, max2 = Integer.MIN_VALUE, max3 = Integer.MIN_VALUE; for (int n: nums) { if (n <= min1) { min2 = min1; min1 = n; } else if (n <= min2) { // n lies between min1 and min2 min2 = n; } if (n >= max1) { // n is greater than max1, max2 and max3 max3 = max2; max2 = max1; max1 = n; } else if (n >= max2) { // n lies betweeen max1 and max2 max3 = max2; max2 = n; } else if (n >= max3) { // n lies betwen max2 and max3 max3 = n; } } return Math.max(min1 * min2 * max1, max1 * max2 * max3); }","public int sample_funcname ( int [ ] var_0 ) { int var_3 = Integer . MAX_VALUE , var_4 = Integer . MAX_VALUE ; int var_6 = Integer . MIN_VALUE , var_7 = Integer . MIN_VALUE , var_8 = Integer . MIN_VALUE ; for ( int var_9 : var_0 ) { if ( var_9 <= var_3 ) { var_4 = var_3 ; var_3 = var_9 ; } else if ( var_9 <= var_4 ) { var_4 = var_9 ; } if ( var_9 >= var_6 ) { var_8 = var_7 ; var_7 = var_6 ; var_6 = var_9 ; } else if ( var_9 >= var_7 ) { var_8 = var_7 ; var_7 = var_9 ; } else if ( var_9 >= var_8 ) { var_8 = var_9 ; } } return Math . max ( var_3 * var_4 * var_6 , var_6 * var_7 * var_8 ) ; } " 50,485_Max_Consecutive_Ones_1.java,"public int findMaxConsecutiveOnes(int[] nums) { int ans = 0; int curr = 0; for (int i = 0; i < nums.length; i++) { if (nums[i] == 1) { curr++; if (curr > ans) ans = curr; } else { curr = 0; } } return ans; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 ; int var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { if ( var_0 [ var_4 ] == 1 ) { var_3 ++ ; if ( var_3 > var_2 ) var_2 = var_3 ; } else { var_3 = 0 ; } } return var_2 ; } " 51,400_Nth_Digit_1.java,"public int findNthDigit(int n) { int len = 1; long count = 9; int start = 1; while (n > len * count) { n -= len * count; len += 1; count *= 10; start *= 10; } start += (n - 1) / len; String s = Integer.toString(start); return Character.getNumericValue(s.charAt((n - 1) % len)); }","public int sample_funcname ( int var_0 ) { int var_2 = 1 ; long var_4 = 9 ; int var_5 = 1 ; while ( var_0 > var_2 * var_4 ) { var_0 -= var_2 * var_4 ; var_2 += 1 ; var_4 *= 10 ; var_5 *= 10 ; } var_5 += ( var_0 - 1 ) / var_2 ; String var_10 = Integer . toString ( var_5 ) ; return Character . getNumericValue ( var_10 . charAt ( ( var_0 - 1 ) % var_2 ) ) ; } " 52,954_Array_of_Doubled_Pairs_1.java,"public boolean canReorderDoubled(int[] A) { HashMap valueMap = new HashMap<>(); A = Arrays.stream(A). boxed(). sorted((a, b) -> Integer.compare(Math.abs(a), Math.abs(b))). mapToInt(i -> i). toArray(); for (int n: A) valueMap.put(n, valueMap.getOrDefault(n, 0) + 1); for (int n: A) { if (valueMap.get(n) <= 0) continue; if (valueMap.containsKey(2 * n) && valueMap.get(2 * n) > 0) { valueMap.put(n, valueMap.get(n) - 1); valueMap.put(2 * n, valueMap.get(2 * n) - 1); } else { return false; } } return true; }","public boolean var_0 ( int [ ] var_1 ) { HashMap < Integer , Integer > var_4 = new HashMap < > ( ) ; var_1 = Arrays . stream ( var_1 ) . boxed ( ) . sorted ( ( var_8 , var_6 ) -> Integer . compare ( Math . abs ( var_8 ) , Math . abs ( var_6 ) ) ) . mapToInt ( var_7 -> var_7 ) . toArray ( ) ; for ( int var_17 : var_1 ) var_4 . put ( var_17 , var_4 . getOrDefault ( var_17 , 0 ) + 1 ) ; for ( int var_17 : var_1 ) { if ( var_4 . get ( var_17 ) <= 0 ) continue ; if ( var_4 . containsKey ( 2 * var_17 ) && var_4 . get ( 2 * var_17 ) > 0 ) { var_4 . put ( var_17 , var_4 . get ( var_17 ) - 1 ) ; var_4 . put ( 2 * var_17 , var_4 . get ( 2 * var_17 ) - 1 ) ; } else { return false ; } } return true ; } " 53,697_Degree_of_an_Array_1.java,"public int findShortestSubArray(int[] nums) { Map left = new HashMap(), right = new HashMap(), count = new HashMap(); for (int i = 0; i < nums.length; i++) { int x = nums[i]; if (left.get(x) == null) left.put(x, i); right.put(x, i); count.put(x, count.getOrDefault(x, 0) + 1); } int ans = nums.length; int degree = Collections.max(count.values()); for (int x: count.keySet()) { if (count.get(x) == degree) { ans = Math.min(ans, right.get(x) - left.get(x) + 1); } } return ans; }","public int sample_funcname ( int [ ] var_0 ) { Map < Integer , Integer > var_4 = new HashMap ( ) , var_5 = new HashMap ( ) , var_6 = new HashMap ( ) ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { int var_10 = var_0 [ var_8 ] ; if ( var_4 . get ( var_10 ) == null ) var_4 . put ( var_10 , var_8 ) ; var_5 . put ( var_10 , var_8 ) ; var_6 . put ( var_10 , var_6 . getOrDefault ( var_10 , 0 ) + 1 ) ; } int var_16 = var_0 . length ; int var_20 = Collections . max ( var_6 . values ( ) ) ; for ( int var_10 : var_6 . keySet ( ) ) { if ( var_6 . get ( var_10 ) == var_20 ) { var_16 = Math . min ( var_16 , var_5 . get ( var_10 ) - var_4 . get ( var_10 ) + 1 ) ; } } return var_16 ; } " 54,268_Missing_Number_1.java,"public int missingNumber(int[] nums) { int res = nums.length; for (int i = 0; i < nums.length; i++) { res ^= i; res ^= nums[i]; } return res; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { var_2 ^= var_4 ; var_2 ^= var_0 [ var_4 ] ; } return var_2 ; } " 55,605_Can_Place_Flowers_1.java,"public boolean canPlaceFlowers(int[] flowerbed, int n) { int i = 0, count = 0; while (i < flowerbed.length) { if (flowerbed[i] == 0 && (i == 0 || flowerbed[i - 1] == 0) && (i == flowerbed.length - 1 || flowerbed[i + 1] == 0)) { flowerbed[i++] = 1; count++; } if(count >= n) return true; i++; } return false; }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { int var_4 = 0 , var_5 = 0 ; while ( var_4 < var_1 . length ) { if ( var_1 [ var_4 ] == 0 && ( var_4 == 0 || var_1 [ var_4 - 1 ] == 0 ) && ( var_4 == var_1 . length - 1 || var_1 [ var_4 + 1 ] == 0 ) ) { var_1 [ var_4 ++ ] = 1 ; var_5 ++ ; } if ( var_5 >= var_2 ) return true ; var_4 ++ ; } return false ; } " 56,867_Transpose_Matrix_1.java,"public int[][] transpose(int[][] A) { int R = A.length, C = A[0].length; int[][] ans = new int[C][R]; for (int r = 0; r < R; ++r) for (int c = 0; c < C; ++c) { ans[c][r] = A[r][c]; } return ans; }","public int [ ] [ ] sample_funcname ( int [ ] [ ] var_0 ) { int var_2 = var_0 . length , var_4 = var_0 [ 0 ] . length ; int [ ] [ ] var_5 = new int [ var_4 ] [ var_2 ] ; for ( int var_6 = 0 ; var_6 < var_2 ; ++ var_6 ) for ( int var_7 = 0 ; var_7 < var_4 ; ++ var_7 ) { var_5 [ var_7 ] [ var_6 ] = var_0 [ var_6 ] [ var_7 ] ; } return var_5 ; } " 57,946_Validate_Stack_Sequences_1.java,"public boolean validateStackSequences(int[] pushed, int[] popped) { Stack inStack = new Stack<>(); int posPush = 0, posPop = 0; while (posPush != pushed.length) { int curr = pushed[posPush]; while (!inStack.empty() && popped.length > 0 && inStack.peek() == popped[posPop]) { inStack.pop(); posPop++; } if (popped.length == 0) break; if (curr == popped[posPop]) posPop++; else inStack.push(curr); posPush++; } while (!inStack.empty() && popped.length > 0 && inStack.peek() == popped[posPop]) { inStack.pop(); posPop++; } if (inStack.empty()) return true; return false; }","public boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { Stack < Integer > var_5 = new Stack < > ( ) ; int var_7 = 0 , var_8 = 0 ; while ( var_7 != var_1 . length ) { int var_10 = var_1 [ var_7 ] ; while ( ! var_5 . empty ( ) && var_2 . length > 0 && var_5 . peek ( ) == var_2 [ var_8 ] ) { var_5 . pop ( ) ; var_8 ++ ; } if ( var_2 . length == 0 ) break ; if ( var_10 == var_2 [ var_8 ] ) var_8 ++ ; else var_5 . push ( var_10 ) ; var_7 ++ ; } while ( ! var_5 . empty ( ) && var_2 . length > 0 && var_5 . peek ( ) == var_2 [ var_8 ] ) { var_5 . pop ( ) ; var_8 ++ ; } if ( var_5 . empty ( ) ) return true ; return false ; } " 58,1337_The_K_Weakest_Rows_in_a_Matrix_1.java,"public int[] kWeakestRows(int[][] mat, int k) { List res = new ArrayList<>(); int col = 0; boolean flag = true; while (col < mat[0].length && flag) { for (int i = 0; i < mat.length; i++) { if (res.contains(i)) continue; if (mat[i][col] == 0) res.add(i); if (res.size() == k) { flag = false; break; } } col += 1; } if (flag) { for (int i = 0; i < mat.length; i++) { if (res.contains(i)) continue; res.add(i); if (res.size() == k) break; } } int[] ret = new int[k]; for (int i = 0; i < k; i++) ret[i] = res.get(i); return ret; }","public int [ ] sample_funcname ( int [ ] [ ] var_0 , int var_1 ) { List < Integer > var_5 = new ArrayList < > ( ) ; int var_7 = 0 ; boolean var_10 = true ; while ( var_7 < var_0 [ 0 ] . length && var_10 ) { for ( int var_11 = 0 ; var_11 < var_0 . length ; var_11 ++ ) { if ( var_5 . contains ( var_11 ) ) continue ; if ( var_0 [ var_11 ] [ var_7 ] == 0 ) var_5 . add ( var_11 ) ; if ( var_5 . size ( ) == var_1 ) { var_10 = false ; break ; } } var_7 += 1 ; } if ( var_10 ) { for ( int var_11 = 0 ; var_11 < var_0 . length ; var_11 ++ ) { if ( var_5 . contains ( var_11 ) ) continue ; var_5 . add ( var_11 ) ; if ( var_5 . size ( ) == var_1 ) break ; } } int [ ] var_16 = new int [ var_1 ] ; for ( int var_11 = 0 ; var_11 < var_1 ; var_11 ++ ) var_16 [ var_11 ] = var_5 . get ( var_11 ) ; return var_16 ; } " 59,844_Backspace_String_Compare_1.java,"public boolean backspaceCompare(String S, String T) { int i = S.length() - 1, j = T.length() - 1; while (true) { for (int back = 0; i >= 0 && (back > 0 || S.charAt(i) == '#'); --i) back += S.charAt(i) == '#' ? 1 : -1; for (int back = 0; j >= 0 && (back > 0 || T.charAt(j) == '#'); --j) back += T.charAt(j) == '#' ? 1 : -1; if (i >= 0 && j >= 0 && S.charAt(i) == T.charAt(j)) { i--; j--; } else return i == -1 && j == -1; } }","public boolean var_0 ( String var_2 , String var_3 ) { int var_6 = var_2 . length ( ) - 1 , var_7 = var_3 . length ( ) - 1 ; while ( true ) { for ( int var_9 = 0 ; var_6 >= 0 && ( var_9 > 0 || var_2 . charAt ( var_6 ) == '#' ) ; -- var_6 ) var_9 += var_2 . charAt ( var_6 ) == '#' ? 1 : - 1 ; for ( int var_9 = 0 ; var_7 >= 0 && ( var_9 > 0 || var_3 . charAt ( var_7 ) == '#' ) ; -- var_7 ) var_9 += var_3 . charAt ( var_7 ) == '#' ? 1 : - 1 ; if ( var_6 >= 0 && var_7 >= 0 && var_2 . charAt ( var_6 ) == var_3 . charAt ( var_7 ) ) { var_6 -- ; var_7 -- ; } else return var_6 == - 1 && var_7 == - 1 ; } } " 60,751_IP_to_CIDR_2.java,"private String longToIP(long x) { return String.format(""%s.%s.%s.%s"", x >> 24, (x >> 16) % 256, (x >> 8) % 256, x % 256); }","private String var_0 ( long var_1 ) { return String . format ( ""%s.%s.%s.%s"" , var_1 >> 24 , ( var_1 >> 16 ) % 256 , ( var_1 >> 8 ) % 256 , var_1 % 256 ) ; } " 61,409_Longest_Palindrome_1.java,"public int longestPalindrome(String s) { int[] count = new int[128]; for (char c: s.toCharArray()) count[c]++; int ans = 0; for (int v: count) { ans += v / 2 * 2; if (ans % 2 == 0 && v % 2 == 1) ans++; } return ans; }","public int sample_funcname ( String var_1 ) { int [ ] var_3 = new int [ 128 ] ; for ( char var_5 : var_1 . toCharArray ( ) ) var_3 [ var_5 ] ++ ; int var_7 = 0 ; for ( int var_8 : var_3 ) { var_7 += var_8 / 2 * 2 ; if ( var_7 % 2 == 0 && var_8 % 2 == 1 ) var_7 ++ ; } return var_7 ; } " 62,463_Island_Perimeter_1.java,"public int islandPerimeter(int[][] grid) { int islands = 0, neighbours = 0; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[i].length; j++) { if (grid[i][j] == 1) { islands++; // count islands if (i < grid.length - 1 && grid[i + 1][j] == 1) neighbours++; // count down neighbours if (j < grid[i].length - 1 && grid[i][j + 1] == 1) neighbours++; // count right neighbours } } } return islands * 4 - neighbours * 2; }","public int sample_funcname ( int [ ] [ ] var_0 ) { int var_2 = 0 , var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { for ( int var_6 = 0 ; var_6 < var_0 [ var_4 ] . length ; var_6 ++ ) { if ( var_0 [ var_4 ] [ var_6 ] == 1 ) { var_2 ++ ; if ( var_4 < var_0 . length - 1 && var_0 [ var_4 + 1 ] [ var_6 ] == 1 ) var_3 ++ ; if ( var_6 < var_0 [ var_4 ] . length - 1 && var_0 [ var_4 ] [ var_6 + 1 ] == 1 ) var_3 ++ ; } } } return var_2 * 4 - var_3 * 2 ; } " 63,836_Rectangle_Overlap_1.java,"public boolean isRectangleOverlap(int[] rec1, int[] rec2) { return !(rec1[2] <= rec2[0] || // left rec1[3] <= rec2[1] || // bottom rec1[0] >= rec2[2] || // right rec1[1] >= rec2[3]); // top }","public boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { return ! ( var_1 [ 2 ] <= var_2 [ 0 ] || var_1 [ 3 ] <= var_2 [ 1 ] || var_1 [ 0 ] >= var_2 [ 2 ] || var_1 [ 1 ] >= var_2 [ 3 ] ) ; } " 64,905_Sort_Array_By_Parity_1.java,"public int[] sortArrayByParity(int[] A) { int[] ans = new int[A.length]; int pos = 0; for (int num: A) if (num % 2 == 0) ans[pos++] = num; for (int num: A) if (num % 2 == 1) ans[pos++] = num; return ans; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int [ ] var_2 = new int [ var_0 . length ] ; int var_4 = 0 ; for ( int var_5 : var_0 ) if ( var_5 % 2 == 0 ) var_2 [ var_4 ++ ] = var_5 ; for ( int var_5 : var_0 ) if ( var_5 % 2 == 1 ) var_2 [ var_4 ++ ] = var_5 ; return var_2 ; } " 65,695_Max_Area_of_Island_1.java,"public int maxAreaOfIsland(int[][] grid) { int[] dr = new int[]{1, -1, 0, 0}; int[] dc = new int[]{0, 0, 1, -1}; int ans = 0; for (int r0 = 0; r0 < grid.length; r0++) { for (int c0 = 0; c0 < grid[0].length; c0++) { if (grid[r0][c0] == 1) { int shape = 0; Stack stack = new Stack(); stack.push(new int[]{r0, c0}); grid[r0][c0] = 0; while (!stack.empty()) { int[] node = stack.pop(); int r = node[0], c = node[1]; shape++; for (int k = 0; k < 4; k++) { int nr = r + dr[k]; int nc = c + dc[k]; if (0 <= nr && nr < grid.length && 0 <= nc && nc < grid[0].length && grid[nr][nc] == 1) { stack.push(new int[]{nr, nc}); grid[nr][nc] = 0; } } } ans = Math.max(ans, shape); } } } return ans; }","public int sample_funcname ( int [ ] [ ] var_0 ) { int [ ] var_3 = new int [ ] { 1 , - 1 , 0 , 0 }; int [ ] var_4 = new int [ ] { 0 , 0 , 1 , - 1 }; int var_5 = 0 ; for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { for ( int var_8 = 0 ; var_8 < var_0 [ 0 ] . length ; var_8 ++ ) { if ( var_0 [ var_6 ] [ var_8 ] == 1 ) { int var_9 = 0 ; Stack < int [ ] > var_11 = new Stack ( ) ; var_11 . push ( new int [ ] { var_6 , var_8 } ) ; var_0 [ var_6 ] [ var_8 ] = 0 ; while ( ! var_11 . empty ( ) ) { int [ ] var_15 = var_11 . pop ( ) ; int var_16 = var_15 [ 0 ] , var_17 = var_15 [ 1 ] ; var_9 ++ ; for ( int var_18 = 0 ; var_18 < 4 ; var_18 ++ ) { int var_20 = var_16 + var_3 [ var_18 ] ; int var_21 = var_17 + var_4 [ var_18 ] ; if ( 0 <= var_20 && var_20 < var_0 . length && 0 <= var_21 && var_21 < var_0 [ 0 ] . length && var_0 [ var_20 ] [ var_21 ] == 1 ) { var_11 . push ( new int [ ] { var_20 , var_21 } ) ; var_0 [ var_20 ] [ var_21 ] = 0 ; } } } var_5 = Math . max ( var_5 , var_9 ) ; } } } return var_5 ; } " 66,453_Minimum_Moves_to_Equal_Array_Elements_1.java,"public int minMoves(int[] nums) { if (nums.length == 0) return 0; Arrays.sort(nums); int min_num = nums[0]; int ans = 0; for (int num : nums) { ans += num - min_num; } return ans; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; Arrays . sort ( var_0 ) ; int var_5 = var_0 [ 0 ] ; int var_6 = 0 ; for ( int var_7 : var_0 ) { var_6 += var_7 - var_5 ; } return var_6 ; } " 67,922_Sort_Array_By_Parity_II_1.java,"public int[] sortArrayByParityII(int[] A) { int N = A.length; int[] ans = new int[N]; int t = 0; for (int x: A) if (x % 2 == 0) { ans[t] = x; t += 2; } t = 1; for (int x: A) if (x % 2 == 1) { ans[t] = x; t += 2; } return ans; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; int [ ] var_3 = new int [ var_2 ] ; int var_5 = 0 ; for ( int var_6 : var_0 ) if ( var_6 % 2 == 0 ) { var_3 [ var_5 ] = var_6 ; var_5 += 2 ; } var_5 = 1 ; for ( int var_6 : var_0 ) if ( var_6 % 2 == 1 ) { var_3 [ var_5 ] = var_6 ; var_5 += 2 ; } return var_3 ; } " 68,482_License_Key_Formatting_1.java,"public String licenseKeyFormatting(String s, int k) { StringBuilder sb = new StringBuilder(); for (int i = s.length() - 1; i >= 0; i--) if (s.charAt(i) != '-') sb.append(sb.length() % (k + 1) == k ? '-' : """").append(s.charAt(i)); return sb.reverse().toString().toUpperCase(); }","public String var_0 ( String var_2 , int var_3 ) { StringBuilder var_5 = new StringBuilder ( ) ; for ( int var_8 = var_2 . length ( ) - 1 ; var_8 >= 0 ; var_8 -- ) if ( var_2 . charAt ( var_8 ) != '-' ) var_5 . append ( var_5 . length ( ) % ( var_3 + 1 ) == var_3 ? '-' : """" ) . append ( var_2 . charAt ( var_8 ) ) ; return var_5 . reverse ( ) . toString ( ) . toUpperCase ( ) ; } " 69,1260_Shift_2D_Grid_1.java,"public List> shiftGrid(int[][] grid, int k) { int[][] newGrid = new int[grid.length][grid[0].length]; int m = grid.length; int n = grid[0].length; int true_k = k % (m * n); int move_i = true_k / n; int move_j = true_k % n; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[i].length; j++) { int new_i = i + move_i; int new_j = (j + move_j) % n; if (move_j + j >= n) new_i ++; new_i %= m; newGrid[new_i][new_j] = grid[i][j]; } } List> result = new ArrayList<>(); for (int[] row : newGrid) { List listRow = new ArrayList<>(); result.add(listRow); for (int v : row) listRow.add(v); } return result; }","public List < List < Integer >> var_2 ( int [ ] [ ] var_3 , int var_4 ) { int [ ] [ ] var_7 = new int [ var_3 . length ] [ var_3 [ 0 ] . length ] ; int var_8 = var_3 . length ; int var_9 = var_3 [ 0 ] . length ; int var_10 = var_4 % ( var_8 * var_9 ) ; int var_11 = var_10 / var_9 ; int var_12 = var_10 % var_9 ; for ( int var_13 = 0 ; var_13 < var_3 . length ; var_13 ++ ) { for ( int var_14 = 0 ; var_14 < var_3 [ var_13 ] . length ; var_14 ++ ) { int var_15 = var_13 + var_11 ; int var_16 = ( var_14 + var_12 ) % var_9 ; if ( var_12 + var_14 >= var_9 ) var_15 ++ ; var_15 %= var_8 ; var_7 [ var_15 ] [ var_16 ] = var_3 [ var_13 ] [ var_14 ] ; } } List < List < Integer >> var_18 = new ArrayList < > ( ) ; for ( int [ ] var_19 : var_7 ) { List < Integer > var_20 = new ArrayList < > ( ) ; var_18 . add ( var_20 ) ; for ( int var_22 : var_19 ) var_20 . add ( var_22 ) ; } return var_18 ; } " 70,836_Rectangle_Overlap_2.java,"public boolean isRectangleOverlap(int[] rec1, int[] rec2) { int left = Math.max(rec1[0], rec2[0]), right = Math.max(Math.min(rec1[2], rec2[2]), left); int bottom = Math.max(rec1[1], rec2[1]), top = Math.max(Math.min(rec1[3], rec2[3]), bottom); return (right - left) * (top - bottom) != 0; }","public boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { int var_6 = Math . max ( var_1 [ 0 ] , var_2 [ 0 ] ) , var_9 = Math . max ( Math . min ( var_1 [ 2 ] , var_2 [ 2 ] ) , var_6 ) ; int var_11 = Math . max ( var_1 [ 1 ] , var_2 [ 1 ] ) , var_13 = Math . max ( Math . min ( var_1 [ 3 ] , var_2 [ 3 ] ) , var_11 ) ; return ( var_9 - var_6 ) * ( var_13 - var_11 ) != 0 ; } " 71,905_Sort_Array_By_Parity_2.java,"public int[] sortArrayByParity(int[] A) { int lo = 0, hi = A.length - 1; while (lo < hi) { if (A[lo] % 2 > A[hi] % 2) { int tmp = A[hi]; A[hi] = A[lo]; A[lo] = tmp; } if (A[lo] % 2 == 0) lo++; if (A[hi] % 2 == 1) hi--; } return A; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int var_2 = 0 , var_5 = var_0 . length - 1 ; while ( var_2 < var_5 ) { if ( var_0 [ var_2 ] % 2 > var_0 [ var_5 ] % 2 ) { int var_7 = var_0 [ var_5 ] ; var_0 [ var_5 ] = var_0 [ var_2 ] ; var_0 [ var_2 ] = var_7 ; } if ( var_0 [ var_2 ] % 2 == 0 ) var_2 ++ ; if ( var_0 [ var_5 ] % 2 == 1 ) var_5 -- ; } return var_0 ; } " 72,922_Sort_Array_By_Parity_II_2.java,"public int[] sortArrayByParityII(int[] A) { int j = 1; for (int i = 0; i < A.length; i += 2) if (A[i] % 2 == 1) { while (A[j] % 2 == 1) j += 2; int tmp = A[i]; A[i] = A[j]; A[j] = tmp; } return A; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int var_2 = 1 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 += 2 ) if ( var_0 [ var_4 ] % 2 == 1 ) { while ( var_0 [ var_2 ] % 2 == 1 ) var_2 += 2 ; int var_7 = var_0 [ var_4 ] ; var_0 [ var_4 ] = var_0 [ var_2 ] ; var_0 [ var_2 ] = var_7 ; } return var_0 ; } " 73,868_Binary_Gap_1.java,"public int binaryGap(int N) { int last = -1, ans = 0; for (int i = 0; i < 32; ++i) if (((N >> i) & 1) > 0) { if (last >= 0) ans = Math.max(ans, i - last); last = i; } return ans; }","public int sample_funcname ( int var_0 ) { int var_2 = - 1 , var_4 = 0 ; for ( int var_5 = 0 ; var_5 < 32 ; ++ var_5 ) if ( ( ( var_0 >> var_5 ) & 1 ) > 0 ) { if ( var_2 >= 0 ) var_4 = Math . max ( var_4 , var_5 - var_2 ) ; var_2 = var_5 ; } return var_4 ; } " 74,605_Can_Place_Flowers_2.java,"public boolean canPlaceFlowers(int[] flowerbed, int n) { int count = 0, curr; for (int i = 0; i < flowerbed.length; i++) { curr = flowerbed[i]; if (i - 1 >= 0) curr += flowerbed[i - 1]; if (i + 1 < flowerbed.length) curr += flowerbed[i + 1]; if (curr == 0) { count++; flowerbed[i] = 1; } if (count >= n) return true; } return false; }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { int var_4 = 0 , var_5 ; for ( int var_6 = 0 ; var_6 < var_1 . length ; var_6 ++ ) { var_5 = var_1 [ var_6 ] ; if ( var_6 - 1 >= 0 ) var_5 += var_1 [ var_6 - 1 ] ; if ( var_6 + 1 < var_1 . length ) var_5 += var_1 [ var_6 + 1 ] ; if ( var_5 == 0 ) { var_4 ++ ; var_1 [ var_6 ] = 1 ; } if ( var_4 >= var_2 ) return true ; } return false ; } " 75,389_Find_the_Difference_1.java,"public char findTheDifference(String s, String t) { int total = t.charAt(s.length()); for (int i = 0; i < s.length(); i++) total += (t.charAt(i) - s.charAt(i)); return (char) total; }","public char sample_funcname ( String var_1 , String var_2 ) { int var_5 = var_2 . charAt ( var_1 . length ( ) ) ; for ( int var_7 = 0 ; var_7 < var_1 . length ( ) ; var_7 ++ ) var_5 += ( var_2 . charAt ( var_7 ) - var_1 . charAt ( var_7 ) ) ; return ( char ) var_5 ; } " 76,401_Binary_Watch_1.java,"public List readBinaryWatch(int num) { List times = new ArrayList<>(); for (int h = 0; h < 12; h++) for (int m = 0; m < 60; m++) if (Integer.bitCount(h * 64 + m) == num) times.add(String.format(""%d:%02d"", h, m)); return times; }","public List < String > var_1 ( int var_2 ) { List < String > var_5 = new ArrayList < > ( ) ; for ( int var_7 = 0 ; var_7 < 12 ; var_7 ++ ) for ( int var_9 = 0 ; var_9 < 60 ; var_9 ++ ) if ( Integer . bitCount ( var_7 * 64 + var_9 ) == var_2 ) var_5 . add ( String . format ( ""%d:%02d"" , var_7 , var_9 ) ) ; return var_5 ; } " 77,383_Ransom_Note_1.java,"public boolean canConstruct(String ransomNote, String magazine) { int[] table = new int[128]; for (char c : magazine.toCharArray()) table[c]++; for (char c : ransomNote.toCharArray()) if (--table[c] < 0) return false; return true; }","public boolean var_0 ( String var_2 , String var_3 ) { int [ ] var_5 = new int [ 128 ] ; for ( char var_7 : var_3 . toCharArray ( ) ) var_5 [ var_7 ] ++ ; for ( char var_7 : var_2 . toCharArray ( ) ) if ( -- var_5 [ var_7 ] < 0 ) return false ; return true ; } " 78,844_Backspace_String_Compare_2.java,"private String trans(String str) { StringBuilder sb = new StringBuilder(); for (char c : str.toCharArray()) { if (c != '#') { sb.append(c); } // if not '#', append it at the end of sb. else if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } // remove last char in sb, if sb is not empty. } return sb.toString(); }","private String var_0 ( String var_2 ) { StringBuilder var_4 = new StringBuilder ( ) ; for ( char var_6 : var_2 . toCharArray ( ) ) { if ( var_6 != '#' ) { var_4 . append ( var_6 ) ; } else if ( var_4 . length ( ) > 0 ) { var_4 . deleteCharAt ( var_4 . length ( ) - 1 ) ; } } return var_4 . toString ( ) ; } " 79,751_IP_to_CIDR_1.java,"private long ipToLong(String ip) { long ans = 0; for (String x: ip.split(""\\."")) { ans = 256 * ans + Integer.valueOf(x); } return ans; }","private long sample_funcname ( String var_1 ) { long var_3 = 0 ; for ( String var_6 : var_1 . split ( ""\\."" ) ) { var_3 = 256 * var_3 + Integer . valueOf ( var_6 ) ; } return var_3 ; } " 80,1310_XOR_Queries_of_a_Subarray_1.java,"public int[] xorQueries(int[] arr, int[][] queries) { int[] res = new int[queries.length], q; for (int i = 1; i < arr.length; i++) arr[i] ^= arr[i - 1]; for (int i = 0; i < queries.length; i++) { q = queries[i]; res[i] = q[0] > 0 ? arr[q[0] - 1] ^ arr[q[1]] : arr[q[1]]; } return res; }","public int [ ] sample_funcname ( int [ ] var_0 , int [ ] [ ] var_1 ) { int [ ] var_3 = new int [ var_1 . length ] , var_4 ; for ( int var_6 = 1 ; var_6 < var_0 . length ; var_6 ++ ) var_0 [ var_6 ] ^= var_0 [ var_6 - 1 ] ; for ( int var_6 = 0 ; var_6 < var_1 . length ; var_6 ++ ) { var_4 = var_1 [ var_6 ] ; var_3 [ var_6 ] = var_4 [ 0 ] > 0 ? var_0 [ var_4 [ 0 ] - 1 ] ^ var_0 [ var_4 [ 1 ] ] : var_0 [ var_4 [ 1 ] ] ; } return var_3 ; } " 81,443_String_Compression_1.java,"public int compress(char[] chars) { int anchor = 0, write = 0; for (int read = 0; read < chars.length; read++) { if (read + 1 == chars.length || chars[read + 1] != chars[read]) { chars[write++] = chars[anchor]; if (read > anchor) { for (char c: ("""" + (read - anchor + 1)).toCharArray()) { chars[write++] = c; } } anchor = read + 1; } } return write; }","public int sample_funcname ( char [ ] var_0 ) { int var_2 = 0 , var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { if ( var_4 + 1 == var_0 . length || var_0 [ var_4 + 1 ] != var_0 [ var_4 ] ) { var_0 [ var_3 ++ ] = var_0 [ var_2 ] ; if ( var_4 > var_2 ) { for ( char var_9 : ( """" + ( var_4 - var_2 + 1 ) ) . toCharArray ( ) ) { var_0 [ var_3 ++ ] = var_9 ; } } var_2 = var_4 + 1 ; } } return var_3 ; } " 82,557_Reverse_Words_in_a_String_III_1.java,"public String reverseWords(String s) { String words[] = s.split("" ""); StringBuilder ans = new StringBuilder(); for (String word: words) ans.append(new StringBuffer(word).reverse().toString() + "" ""); return ans.toString().trim(); }","public String var_0 ( String var_2 ) { String var_5 [ ] = var_2 . split ( "" "" ) ; StringBuilder var_7 = new StringBuilder ( ) ; for ( String var_8 : var_5 ) var_7 . append ( new StringBuffer ( var_8 ) . reverse ( ) . toString ( ) + "" "" ) ; return var_7 . toString ( ) . trim ( ) ; } " 83,509_Fibonacci_Number_1.java,"public int fib(int N) { if (N == 0) return 0; if (N == 1) return 1; return fib(N - 1) + fib(N - 2); }","public int sample_funcname ( int N ) { if ( N == 0 ) return 0 ; if ( N == 1 ) return 1 ; return fib ( N - 1 ) + fib ( N - 2 ) ; } " 84,628_Maximum_Product_of_Three_Numbers_1.java,"public int maximumProduct(int[] nums) { Arrays.sort(nums); return Math.max(nums[0] * nums[1] * nums[nums.length - 1], nums[nums.length - 1] * nums[nums.length - 2] * nums[nums.length - 3]); }","public int sample_funcname ( int [ ] var_0 ) { Arrays . sort ( var_0 ) ; return Math . max ( var_0 [ 0 ] * var_0 [ 1 ] * var_0 [ var_0 . length - 1 ] , var_0 [ var_0 . length - 1 ] * var_0 [ var_0 . length - 2 ] * var_0 [ var_0 . length - 3 ] ) ; } " 85,367_Valid_Perfect_Square_1.java,"public boolean isPerfectSquare(int num) { int low = 1; int high = num; while (low <= high) { long mid = (low + high) >>> 1; if (mid * mid == num) { return true; } else if (mid * mid < num) { low = (int) mid + 1; } else { high = (int) mid - 1; } } return false; }","public boolean var_0 ( int var_1 ) { int var_3 = 1 ; int var_4 = var_1 ; while ( var_3 <= var_4 ) { long var_5 = ( var_3 + var_4 ) >>> 1 ; if ( var_5 * var_5 == var_1 ) { return true ; } else if ( var_5 * var_5 < var_1 ) { var_3 = ( int ) var_5 + 1 ; } else { var_4 = ( int ) var_5 - 1 ; } } return false ; } " 86,832_Flipping_an_Image_1.java,"public int[][] flipAndInvertImage(int[][] A) { int C = A[0].length; for (int[] row: A) for (int i = 0; i < (C + 1) / 2; ++i) { int tmp = row[i] ^ 1; row[i] = row[C - 1 - i] ^ 1; row[C - 1 - i] = tmp; } return A; }","public int [ ] [ ] sample_funcname ( int [ ] [ ] var_0 ) { int var_3 = var_0 [ 0 ] . length ; for ( int [ ] var_4 : var_0 ) for ( int var_5 = 0 ; var_5 < ( var_3 + 1 ) / 2 ; ++ var_5 ) { int var_8 = var_4 [ var_5 ] ^ 1 ; var_4 [ var_5 ] = var_4 [ var_3 - 1 - var_5 ] ^ 1 ; var_4 [ var_3 - 1 - var_5 ] = var_8 ; } return var_0 ; } " 87,336_Palindrome_Pairs_1.java,"private boolean isPalindrome(String word, int i, int j) { while (i < j) { if (word.charAt(i++) != word.charAt(j--)) return false; } return true; }","private boolean var_0 ( String var_2 , int var_3 , int var_4 ) { while ( var_3 < var_4 ) { if ( var_2 . charAt ( var_3 ++ ) != var_2 . charAt ( var_4 -- ) ) return false ; } return true ; } " 88,962_Maximum_Width_Ramp_2.java,"public int maxWidthRamp(int[] A) { int N = A.length; int ans = 0; List candidates = new ArrayList(); candidates.add(new Point(A[N-1], N-1)); for (int i = N-2; i >= 0; --i) { int lo = 0, hi = candidates.size(); while (lo < hi) { int mi = lo + (hi - lo) / 2; if (candidates.get(mi).x < A[i]) lo = mi + 1; else hi = mi; } if (lo < candidates.size()) { int j = candidates.get(lo).y; ans = Math.max(ans, j - i); } else { candidates.add(new Point(A[i], i)); } } return ans; }","public int sample_funcname ( int [ ] A ) { int N = A . length ; int ans = 0 ; List < Point > candidates = new ArrayList ( ) ; candidates . add ( new Point ( A [ N - 1 ] , N - 1 ) ) ; for ( int i = N - 2 ; i >= 0 ; -- i ) { int lo = 0 , hi = candidates . size ( ) ; while ( lo < hi ) { int mi = lo + ( hi - lo ) / 2 ; if ( candidates . get ( mi ) . x < A [ i ] ) lo = mi + 1 ; else hi = mi ; } if ( lo < candidates . size ( ) ) { int j = candidates . get ( lo ) . y ; ans = Math . max ( ans , j - i ) ; } else { candidates . add ( new Point ( A [ i ] , i ) ) ; } } return ans ; } " 89,674_Longest_Continuous_Increasing_Subsequence_1.java,"public int findLengthOfLCIS(int[] nums) { if (nums.length == 0) return 0; int curr = 1, ans = 1; for (int i = 0; i < nums.length - 1; i++) { if (nums[i] < nums[i + 1]) { curr ++; if (curr >= ans) ans = curr; } else { curr = 1; } } return ans; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int var_4 = 1 , var_5 = 1 ; for ( int var_6 = 0 ; var_6 < var_0 . length - 1 ; var_6 ++ ) { if ( var_0 [ var_6 ] < var_0 [ var_6 + 1 ] ) { var_4 ++ ; if ( var_4 >= var_5 ) var_5 = var_4 ; } else { var_4 = 1 ; } } return var_5 ; } " 90,852_Peak_Index_in_a_Mountain_Array_1.java,"public int peakIndexInMountainArray(int[] A) { int i = 0; for (; A[i] < A[i + 1]; i++); return i; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 ; for ( ; var_0 [ var_2 ] < var_0 [ var_2 + 1 ] ; var_2 ++ ) ; return var_2 ; } " 91,836_Rectangle_Overlap_3.java,"public boolean isRectangleOverlap(int[] rec1, int[] rec2) { return (Math.min(rec1[2], rec2[2]) > Math.max(rec1[0], rec2[0]) && // width > 0 Math.min(rec1[3], rec2[3]) > Math.max(rec1[1], rec2[1])); // height > 0 }","public boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { return ( Math . min ( var_1 [ 2 ] , var_2 [ 2 ] ) > Math . max ( var_1 [ 0 ] , var_2 [ 0 ] ) && Math . min ( var_1 [ 3 ] , var_2 [ 3 ] ) > Math . max ( var_1 [ 1 ] , var_2 [ 1 ] ) ) ; } " 92,215_Kth_Largest_Element_in_an_Array_2.java,"private boolean less(int v, int w) { return v < w; }","private boolean var_0 ( int var_1 , int var_2 ) { return var_1 < var_2 ; } " 93,475_Heaters_1.java,"public int findRadius(int[] houses, int[] heaters) { Arrays.sort(heaters); int result = Integer.MIN_VALUE; for (int house : houses) { int index = Arrays.binarySearch(heaters, house); if (index < 0) index = -(index + 1); int dist1 = index - 1 >= 0 ? house - heaters[index - 1] : Integer.MAX_VALUE; int dist2 = index < heaters.length ? heaters[index] - house : Integer.MAX_VALUE; result = Math.max(result, Math.min(dist1, dist2)); } return result; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { Arrays . sort ( var_1 ) ; int var_6 = Integer . MIN_VALUE ; for ( int var_7 : var_0 ) { int var_9 = Arrays . binarySearch ( var_1 , var_7 ) ; if ( var_9 < 0 ) var_9 = - ( var_9 + 1 ) ; int var_13 = var_9 - 1 >= 0 ? var_7 - var_1 [ var_9 - 1 ] : Integer . MAX_VALUE ; int var_15 = var_9 < var_1 . length ? var_1 [ var_9 ] - var_7 : Integer . MAX_VALUE ; var_6 = Math . max ( var_6 , Math . min ( var_13 , var_15 ) ) ; } return var_6 ; } " 94,009_Palindrome_Number_2.java,"public boolean isPalindrome(int x) { if (x < 0) return false; int div = 1; while ( x / div >= 10) { div *= 10; } while (x !=0) { int l = x / div; int r = x % 10; if (l != r) return false; x = (x % div) / 10; div /= 100; } return true; }","public boolean var_0 ( int var_1 ) { if ( var_1 < 0 ) return false ; int var_4 = 1 ; while ( var_1 / var_4 >= 10 ) { var_4 *= 10 ; } while ( var_1 != 0 ) { int var_6 = var_1 / var_4 ; int var_7 = var_1 % 10 ; if ( var_6 != var_7 ) return false ; var_1 = ( var_1 % var_4 ) / 10 ; var_4 /= 100 ; } return true ; } " 95,717_1-bit_and_2-bit_Characters_1.java,"public boolean isOneBitCharacter(int[] bits) { int pos = 0; while (pos < bits.length - 1) { pos += bits[pos] + 1; } return pos == bits.length - 1; }","public boolean var_0 ( int [ ] var_1 ) { int var_3 = 0 ; while ( var_3 < var_1 . length - 1 ) { var_3 += var_1 [ var_3 ] + 1 ; } return var_3 == var_1 . length - 1 ; } " 96,541_Reverse_String_II_1.java,"public String reverseStr(String s, int k) { char[] a = s.toCharArray(); for (int start = 0; start < a.length; start += 2 * k) { int i = start, j = Math.min(start + k - 1, a.length - 1); while (i < j) { char tmp = a[i]; a[i++] = a[j]; a[j--] = tmp; } } return new String(a); }","public String var_0 ( String var_2 , int var_3 ) { char [ ] var_5 = var_2 . toCharArray ( ) ; for ( int var_7 = 0 ; var_7 < var_5 . length ; var_7 += 2 * var_3 ) { int var_10 = var_7 , var_14 = Math . min ( var_7 + var_3 - 1 , var_5 . length - 1 ) ; while ( var_10 < var_14 ) { char var_15 = var_5 [ var_10 ] ; var_5 [ var_10 ++ ] = var_5 [ var_14 ] ; var_5 [ var_14 -- ] = var_15 ; } } return new String ( var_5 ) ; } " 97,709_To_Lower_Case_1.java,"public String toLowerCase(String str) { return str.toLowerCase(); }","public String var_0 ( String var_2 ) { return var_2 . toLowerCase ( ) ; } " 98,819_Most_Common_Word_1.java,"public String mostCommonWord(String paragraph, String[] banned) { paragraph += "".""; Set banset = new HashSet(); for (String word: banned) banset.add(word); Map count = new HashMap(); String ans = """"; int ansfreq = 0; StringBuilder word = new StringBuilder(); for (char c: paragraph.toCharArray()) { if (Character.isLetter(c)) { word.append(Character.toLowerCase(c)); } else if (word.length() > 0) { String finalword = word.toString(); if (!banset.contains(finalword)) { count.put(finalword, count.getOrDefault(finalword, 0) + 1); if (count.get(finalword) > ansfreq) { ans = finalword; ansfreq = count.get(finalword); } } word = new StringBuilder(); } } return ans; }","public String var_0 ( String var_2 , String [ ] var_3 ) { var_2 += ""."" ; Set < String > var_7 = new HashSet ( ) ; for ( String var_8 : var_3 ) var_7 . add ( var_8 ) ; Map < String , Integer > var_13 = new HashMap ( ) ; String var_15 = """" ; int var_17 = 0 ; StringBuilder var_8 = new StringBuilder ( ) ; for ( char var_20 : var_2 . toCharArray ( ) ) { if ( Character . isLetter ( var_20 ) ) { var_8 . append ( Character . toLowerCase ( var_20 ) ) ; } else if ( var_8 . length ( ) > 0 ) { String var_27 = var_8 . toString ( ) ; if ( ! var_7 . contains ( var_27 ) ) { var_13 . put ( var_27 , var_13 . getOrDefault ( var_27 , 0 ) + 1 ) ; if ( var_13 . get ( var_27 ) > var_17 ) { var_15 = var_27 ; var_17 = var_13 . get ( var_27 ) ; } } var_8 = new StringBuilder ( ) ; } } return var_15 ; } " 99,1304_Find_N_Unique_Integers_Sum_up_to_Zero_1.java,"public int[] sumZero(int n) { int[] res = new int[n]; for (int i = 1; i < n; i++) { res[i] = i; res[0] -= i; } return res; }","public int [ ] sample_funcname ( int var_0 ) { int [ ] var_1 = new int [ var_0 ] ; for ( int var_3 = 1 ; var_3 < var_0 ; var_3 ++ ) { var_1 [ var_3 ] = var_3 ; var_1 [ 0 ] -= var_3 ; } return var_1 ; } " 100,005_Longest_Palindromic_Substring_1.java,"private int expandAroundCenter(String s, int left, int right) { int L = left, R = right; while (L >= 0 && R < s.length() && s.charAt(L) == s.charAt(R)) { L--; R++; } return R - L - 1; }","private int sample_funcname ( String var_1 , int var_2 , int var_3 ) { int var_4 = var_2 , var_5 = var_3 ; while ( var_4 >= 0 && var_5 < var_1 . length ( ) && var_1 . charAt ( var_4 ) == var_1 . charAt ( var_5 ) ) { var_4 -- ; var_5 ++ ; } return var_5 - var_4 - 1 ; } " 101,347_Top_K_Frequent_Elements_1.java,"public List topKFrequent(int[] nums, int k) { HashMap count = new HashMap(); for (int n: nums) { count.put(n, count.getOrDefault(n, 0) + 1); } PriorityQueue heap = new PriorityQueue((n1, n2) -> count.get(n1) - count.get(n2)); for (int n: count.keySet()) { heap.add(n); if (heap.size() > k) heap.poll(); } List top_k = new LinkedList(); while (!heap.isEmpty()) top_k.add(heap.poll()); Collections.reverse(top_k); return top_k; }","public List < Integer > var_1 ( int [ ] var_2 , int var_3 ) { HashMap < Integer , Integer > var_5 = new HashMap ( ) ; for ( int var_6 : var_2 ) { var_5 . put ( var_6 , var_5 . getOrDefault ( var_6 , 0 ) + 1 ) ; } PriorityQueue < Integer > var_15 = new PriorityQueue < Integer > ( ( var_13 , var_14 ) -> var_5 . get ( var_13 ) - var_5 . get ( var_14 ) ) ; for ( int var_6 : var_5 . keySet ( ) ) { var_15 . add ( var_6 ) ; if ( var_15 . size ( ) > var_3 ) var_15 . poll ( ) ; } List < Integer > var_22 = new LinkedList ( ) ; while ( ! var_15 . isEmpty ( ) ) var_22 . add ( var_15 . poll ( ) ) ; Collections . reverse ( var_22 ) ; return var_22 ; } " 102,1365_How_Many_Numbers_Are_Smaller_Than_the_Current_Number_1.java,"public int[] smallerNumbersThanCurrent(int[] nums) { int[] countList = new int[101]; int[] res = new int[nums.length]; for (int i = 0; i < nums.length; i++) countList[nums[i]]++; for (int i = 1; i < 101; i++) countList[i] += countList[i-1]; for (int i = 0; i < nums.length; i++) { if (nums[i] == 0) res[i] = 0; else res[i] = countList[nums[i]-1]; } return res; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int [ ] var_2 = new int [ 101 ] ; int [ ] var_4 = new int [ var_0 . length ] ; for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) var_2 [ var_0 [ var_6 ] ] ++ ; for ( int var_6 = 1 ; var_6 < 101 ; var_6 ++ ) var_2 [ var_6 ] += var_2 [ var_6 - 1 ] ; for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { if ( var_0 [ var_6 ] == 0 ) var_4 [ var_6 ] = 0 ; else var_4 [ var_6 ] = var_2 [ var_0 [ var_6 ] - 1 ] ; } return var_4 ; } " 103,438_Find_All_Anagrams_in_a_String_1.java,"public List findAnagrams(String s, String p) { List list = new ArrayList<>(); if (s == null || s.length() == 0 || p == null || p.length() == 0) return list; int[] hash = new int[256]; //character hash for (char c : p.toCharArray()) { hash[c]++; } int left = 0, right = 0, count = p.length(); while (right < s.length()) { if (hash[s.charAt(right++)]-- >= 1) count--; if (count == 0) list.add(left); if (right - left == p.length() && hash[s.charAt(left++)]++ >= 0) count++; } return list; }","public List < Integer > var_1 ( String var_3 , String var_4 ) { List < Integer > var_7 = new ArrayList < > ( ) ; if ( var_3 == null || var_3 . length ( ) == 0 || var_4 == null || var_4 . length ( ) == 0 ) return var_7 ; int [ ] var_12 = new int [ 256 ] ; for ( char var_15 : var_4 . toCharArray ( ) ) { var_12 [ var_15 ] ++ ; } int var_16 = 0 , var_17 = 0 , var_18 = var_4 . length ( ) ; while ( var_17 < var_3 . length ( ) ) { if ( var_12 [ var_3 . charAt ( var_17 ++ ) ] -- >= 1 ) var_18 -- ; if ( var_18 == 0 ) var_7 . add ( var_16 ) ; if ( var_17 - var_16 == var_4 . length ( ) && var_12 [ var_3 . charAt ( var_16 ++ ) ] ++ >= 0 ) var_18 ++ ; } return var_7 ; } " 104,733_Flood_Fill_1.java,"private void dfs(int[][] image, int r, int c, int color, int newColor) { if (image[r][c] == color) { image[r][c] = newColor; if (r - 1 >= 0) dfs(image, r - 1, c, color, newColor); if (r + 1 < image.length) dfs(image, r + 1, c, color, newColor); if (c - 1 >= 0) dfs(image, r, c - 1, color, newColor); if (c + 1 < image[0].length) dfs(image, r, c + 1, color, newColor); } }","private void sample_funcname ( int [ ] [ ] image , int r , int c , int color , int newColor ) { if ( image [ r ] [ c ] == color ) { image [ r ] [ c ] = newColor ; if ( r - 1 >= 0 ) dfs ( image , r - 1 , c , color , newColor ) ; if ( r + 1 < image . length ) dfs ( image , r + 1 , c , color , newColor ) ; if ( c - 1 >= 0 ) dfs ( image , r , c - 1 , color , newColor ) ; if ( c + 1 < image [ 0 ] . length ) dfs ( image , r , c + 1 , color , newColor ) ; } } " 105,1189_Maximum_Number_of_Balloons_1.java,"public int maxNumberOfBalloons(String text) { HashMap map = new HashMap<>(); for (char ch : text.toCharArray()) { map.put(ch, map.getOrDefault(ch, 0) + 1); } int res = Integer.MAX_VALUE; res = Math.min(res, map.getOrDefault('b', 0)); res = Math.min(res, map.getOrDefault('a', 0)); res = Math.min(res, map.getOrDefault('n', 0)); res = Math.min(res, map.getOrDefault('l', 0) / 2); res = Math.min(res, map.getOrDefault('o', 0) / 2); return res; }","public int sample_funcname ( String var_1 ) { HashMap < Character , Integer > var_5 = new HashMap < > ( ) ; for ( char var_7 : var_1 . toCharArray ( ) ) { var_5 . put ( var_7 , var_5 . getOrDefault ( var_7 , 0 ) + 1 ) ; } int var_13 = Integer . MAX_VALUE ; var_13 = Math . min ( var_13 , var_5 . getOrDefault ( 'b' , 0 ) ) ; var_13 = Math . min ( var_13 , var_5 . getOrDefault ( 'a' , 0 ) ) ; var_13 = Math . min ( var_13 , var_5 . getOrDefault ( 'n' , 0 ) ) ; var_13 = Math . min ( var_13 , var_5 . getOrDefault ( 'l' , 0 ) / 2 ) ; var_13 = Math . min ( var_13 , var_5 . getOrDefault ( 'o' , 0 ) / 2 ) ; return var_13 ; } " 106,547_Friend_Circles_2.java,"public int findCircleNum(int[][] M) { int[] visited = new int[M.length]; int count = 0; Queue < Integer > queue = new LinkedList < > (); for (int i = 0; i < M.length; i++) { if (visited[i] == 0) { queue.add(i); while (!queue.isEmpty()) { int s = queue.remove(); visited[s] = 1; for (int j = 0; j < M.length; j++) { if (M[s][j] == 1 && visited[j] == 0) queue.add(j); } } count++; } } return count; }","public int sample_funcname ( int [ ] [ ] var_0 ) { int [ ] var_2 = new int [ var_0 . length ] ; int var_4 = 0 ; Queue < Integer > var_8 = new LinkedList < > ( ) ; for ( int var_9 = 0 ; var_9 < var_0 . length ; var_9 ++ ) { if ( var_2 [ var_9 ] == 0 ) { var_8 . add ( var_9 ) ; while ( ! var_8 . isEmpty ( ) ) { int var_13 = var_8 . remove ( ) ; var_2 [ var_13 ] = 1 ; for ( int var_15 = 0 ; var_15 < var_0 . length ; var_15 ++ ) { if ( var_0 [ var_13 ] [ var_15 ] == 1 && var_2 [ var_15 ] == 0 ) var_8 . add ( var_15 ) ; } } var_4 ++ ; } } return var_4 ; } " 107,012_Integer_to_Roman_1.java,"public String intToRoman(int num) { Map map = new HashMap(); map.put(1, ""I""); map.put(5, ""V""); map.put(10, ""X""); map.put(50, ""L""); map.put(100, ""C""); map.put(500, ""D""); map.put(1000, ""M""); map.put(4, ""IV""); map.put(9, ""IX""); map.put(40, ""XL""); map.put(90, ""XC""); map.put(400, ""CD""); map.put(900, ""CM""); int[] sequence = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; StringBuffer sb = new StringBuffer(); for (int i = 0; i= base) { sb.append(map.get(base)); num -= base; } } return sb.toString(); }","public String var_0 ( int var_1 ) { Map < Integer , String > var_6 = new HashMap ( ) ; var_6 . put ( 1 , ""I"" ) ; var_6 . put ( 5 , ""V"" ) ; var_6 . put ( 10 , ""X"" ) ; var_6 . put ( 50 , ""L"" ) ; var_6 . put ( 100 , ""C"" ) ; var_6 . put ( 500 , ""D"" ) ; var_6 . put ( 1000 , ""M"" ) ; var_6 . put ( 4 , ""IV"" ) ; var_6 . put ( 9 , ""IX"" ) ; var_6 . put ( 40 , ""XL"" ) ; var_6 . put ( 90 , ""XC"" ) ; var_6 . put ( 400 , ""CD"" ) ; var_6 . put ( 900 , ""CM"" ) ; int [ ] var_34 = { 1000 , 900 , 500 , 400 , 100 , 90 , 50 , 40 , 10 , 9 , 5 , 4 , 1 }; StringBuffer var_36 = new StringBuffer ( ) ; for ( int var_38 = 0 ; var_38 < var_34 . length ; var_38 ++ ) { int var_40 = var_34 [ var_38 ] ; while ( var_1 >= var_40 ) { var_36 . append ( var_6 . get ( var_40 ) ) ; var_1 -= var_40 ; } } return var_36 . toString ( ) ; } " 108,766_Toeplitz_Matrix_1.java,"public boolean isToeplitzMatrix(int[][] matrix) { for (int r = 1; r < matrix.length; ++r) for (int c = 1; c < matrix[0].length; ++c) if (matrix[r-1][c-1] != matrix[r][c]) return false; return true; }","public boolean var_0 ( int [ ] [ ] var_1 ) { for ( int var_3 = 1 ; var_3 < var_1 . length ; ++ var_3 ) for ( int var_5 = 1 ; var_5 < var_1 [ 0 ] . length ; ++ var_5 ) if ( var_1 [ var_3 - 1 ] [ var_5 - 1 ] != var_1 [ var_3 ] [ var_5 ] ) return false ; return true ; } " 109,003_Longest_Substring_Without_Repeating_Characters_1.java,"public int lengthOfLongestSubstring(String s) { boolean[] exist = new boolean[256]; int i = 0, maxLen = 0; for (int j = 0; j < s.length(); j++) { while (exist[s.charAt(j)]){ exist[s.charAt(i)] = false; i++; } exist[s.charAt(j)] = true; maxLen = Math.max(j - i + 1, maxLen); } return maxLen; }","public int sample_funcname ( String var_1 ) { boolean [ ] var_4 = new boolean [ 256 ] ; int var_6 = 0 , var_7 = 0 ; for ( int var_8 = 0 ; var_8 < var_1 . length ( ) ; var_8 ++ ) { while ( var_4 [ var_1 . charAt ( var_8 ) ] ) { var_4 [ var_1 . charAt ( var_6 ) ] = false ; var_6 ++ ; } var_4 [ var_1 . charAt ( var_8 ) ] = true ; var_7 = Math . max ( var_8 - var_6 + 1 , var_7 ) ; } return var_7 ; } " 110,458_Poor_Pigs_1.java,"public int poorPigs(int buckets, int minutesToDie, int minutesToTest) { int n = minutesToTest / minutesToDie + 1; int pigs = 0; while (Math.pow(n, pigs) < buckets) pigs++; return pigs; }","public int sample_funcname ( int var_0 , int var_1 , int var_2 ) { int var_4 = var_2 / var_1 + 1 ; int var_6 = 0 ; while ( Math . pow ( var_4 , var_6 ) < var_0 ) var_6 ++ ; return var_6 ; } " 111,001_Two_Sum_1.java,"public int[] twoSum(int[] nums, int target) { Map map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { int x = nums[i]; if (map.containsKey(target - x)) { return new int[]{map.get(target - x), i}; } map.put(x, i); } throw new IllegalArgumentException(""No two sum solution""); }","public int [ ] sample_funcname ( int [ ] var_0 , int var_1 ) { Map < Integer , Integer > var_5 = new HashMap < > ( ) ; for ( int var_7 = 0 ; var_7 < var_0 . length ; var_7 ++ ) { int var_9 = var_0 [ var_7 ] ; if ( var_5 . containsKey ( var_1 - var_9 ) ) { return new int [ ] { var_5 . get ( var_1 - var_9 ) , var_7 }; } var_5 . put ( var_9 , var_7 ) ; } throw new IllegalArgumentException ( ""No two sum solution"" ) ; } " 112,004_Median_of_Two_Sorted_Arrays_1.java,"public double findMedianSortedArrays(int[] nums1, int[] nums2) { int p1 = 0, p2 = 0, pos = 0; int ls1 = nums1.length, ls2 = nums2.length; int[] all_nums = new int[ls1+ls2]; double median = 0.0; while (p1 < ls1 && p2 < ls2){ if (nums1[p1] <= nums2[p2]) all_nums[pos++] = nums1[p1++]; else all_nums[pos++] = nums2[p2++]; } while (p1 < ls1) all_nums[pos++] = nums1[p1++]; while (p2 < ls2) all_nums[pos++] = nums2[p2++]; if ((ls1 + ls2) % 2 == 1) median = all_nums[(ls1 + ls2) / 2]; else median = (all_nums[(ls1 + ls2) / 2] + all_nums[(ls1 + ls2) / 2 - 1]) / 2.0; return median; }","public double sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { int var_3 = 0 , var_4 = 0 , var_5 = 0 ; int var_7 = var_0 . length , var_8 = var_1 . length ; int [ ] var_9 = new int [ var_7 + var_8 ] ; double var_11 = 0.0 ; while ( var_3 < var_7 && var_4 < var_8 ) { if ( var_0 [ var_3 ] <= var_1 [ var_4 ] ) var_9 [ var_5 ++ ] = var_0 [ var_3 ++ ] ; else var_9 [ var_5 ++ ] = var_1 [ var_4 ++ ] ; } while ( var_3 < var_7 ) var_9 [ var_5 ++ ] = var_0 [ var_3 ++ ] ; while ( var_4 < var_8 ) var_9 [ var_5 ++ ] = var_1 [ var_4 ++ ] ; if ( ( var_7 + var_8 ) % 2 == 1 ) var_11 = var_9 [ ( var_7 + var_8 ) / 2 ] ; else var_11 = ( var_9 [ ( var_7 + var_8 ) / 2 ] + var_9 [ ( var_7 + var_8 ) / 2 - 1 ] ) / 2.0 ; return var_11 ; } " 113,066_Plus_One_1.java,"private int[] addToDigit(int[] digits, int index) { if (index == -1) { int[] newDigits = new int[digits.length + 1]; newDigits[0] = 1; for (int i = 0; i < digits.length; i++) { newDigits[i + 1] = digits[i]; } return newDigits; } if (digits[index] == 9) { digits[index] = 0; return addToDigit(digits, index - 1); } else { digits[index]++; return digits; } }","private int [ ] sample_funcname ( int [ ] digits , int index ) { if ( index == - 1 ) { int [ ] newDigits = new int [ digits . length + 1 ] ; newDigits [ 0 ] = 1 ; for ( int i = 0 ; i < digits . length ; i ++ ) { newDigits [ i + 1 ] = digits [ i ] ; } return newDigits ; } if ( digits [ index ] == 9 ) { digits [ index ] = 0 ; return addToDigit ( digits , index - 1 ) ; } else { digits [ index ] ++ ; return digits ; } } " 114,434_Number_of_Segments_in_a_String_1.java,"public int countSegments(String s) { String trimmed = s.trim(); if (trimmed.equals("""")) { return 0; } return trimmed.split(""\\s+"").length; }","public int sample_funcname ( String var_1 ) { String var_3 = var_1 . trim ( ) ; if ( var_3 . equals ( """" ) ) { return 0 ; } return var_3 . split ( ""\\s+"" ) . length ; } " 115,560_Subarray_Sum_Equals_K_1.java,"public int subarraySum(int[] nums, int k) { int count = 0; for (int start = 0; start < nums.length; start++) { int sum = 0; for (int end = start; end < nums.length; end++) { sum += nums[end]; if (sum == k) count++; } } return count; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { int var_6 = 0 ; for ( int var_7 = var_4 ; var_7 < var_0 . length ; var_7 ++ ) { var_6 += var_0 [ var_7 ] ; if ( var_6 == var_1 ) var_3 ++ ; } } return var_3 ; } " 116,784_Letter_Case_Permutation_1.java,"public List letterCasePermutation(String S) { List ans = new ArrayList(); ans.add(new StringBuilder()); for (char c: S.toCharArray()) { int n = ans.size(); if (Character.isLetter(c)) { for (int i = 0; i < n; ++i) { ans.add(new StringBuilder(ans.get(i))); ans.get(i).append(Character.toLowerCase(c)); ans.get(n + i).append(Character.toUpperCase(c)); } } else { for (int i = 0; i < n; ++i) ans.get(i).append(c); } } List finalans = new ArrayList(); for (StringBuilder sb: ans) finalans.add(sb.toString()); return finalans; }","public List < String > var_1 ( String var_2 ) { List < StringBuilder > var_6 = new ArrayList ( ) ; var_6 . add ( new StringBuilder ( ) ) ; for ( char var_9 : var_2 . toCharArray ( ) ) { int var_11 = var_6 . size ( ) ; if ( Character . isLetter ( var_9 ) ) { for ( int var_15 = 0 ; var_15 < var_11 ; ++ var_15 ) { var_6 . add ( new StringBuilder ( var_6 . get ( var_15 ) ) ) ; var_6 . get ( var_15 ) . append ( Character . toLowerCase ( var_9 ) ) ; var_6 . get ( var_11 + var_15 ) . append ( Character . toUpperCase ( var_9 ) ) ; } } else { for ( int var_15 = 0 ; var_15 < var_11 ; ++ var_15 ) var_6 . get ( var_15 ) . append ( var_9 ) ; } } List < String > var_20 = new ArrayList ( ) ; for ( StringBuilder var_21 : var_6 ) var_20 . add ( var_21 . toString ( ) ) ; return var_20 ; } " 117,414_Third_Maximum_Number_1.java,"public int thirdMax(int[] nums) { PriorityQueue pq = new PriorityQueue<>(3); Set set = new HashSet<>(); for (int i : nums) { if (set.contains(i)) continue; pq.offer(i); set.add(i); if (pq.size() > 3) set.remove(pq.poll()); } while (pq.size() < 3 && pq.size() > 1) { pq.poll(); } return pq.peek(); }","public int sample_funcname ( int [ ] var_0 ) { PriorityQueue < Integer > var_4 = new PriorityQueue < > ( 3 ) ; Set < Integer > var_7 = new HashSet < > ( ) ; for ( int var_8 : var_0 ) { if ( var_7 . contains ( var_8 ) ) continue ; var_4 . offer ( var_8 ) ; var_7 . add ( var_8 ) ; if ( var_4 . size ( ) > 3 ) var_7 . remove ( var_4 . poll ( ) ) ; } while ( var_4 . size ( ) < 3 && var_4 . size ( ) > 1 ) { var_4 . poll ( ) ; } return var_4 . peek ( ) ; } " 118,448_Find_All_Numbers_Disappeared_in_an_Array_1.java,"public List findDisappearedNumbers(int[] nums) { List ret = new ArrayList(); for(int i = 0; i < nums.length; i++) { int val = Math.abs(nums[i]) - 1; if(nums[val] > 0) { nums[val] = -nums[val]; } } for(int i = 0; i < nums.length; i++) { if(nums[i] > 0) { ret.add(i+1); } } return ret; }","public List < Integer > var_1 ( int [ ] var_2 ) { List < Integer > var_5 = new ArrayList < Integer > ( ) ; for ( int var_7 = 0 ; var_7 < var_2 . length ; var_7 ++ ) { int var_12 = Math . abs ( var_2 [ var_7 ] ) - 1 ; if ( var_2 [ var_12 ] > 0 ) { var_2 [ var_12 ] = - var_2 [ var_12 ] ; } } for ( int var_7 = 0 ; var_7 < var_2 . length ; var_7 ++ ) { if ( var_2 [ var_7 ] > 0 ) { var_5 . add ( var_7 + 1 ) ; } } return var_5 ; } " 119,461_Hamming_Distance_1.java,"public int hammingDistance(int x, int y) { return Integer.bitCount(x ^ y); }","public int sample_funcname ( int var_0 , int var_1 ) { return Integer . bitCount ( var_0 ^ var_1 ) ; } " 120,977_Squares_of_a_Sorted_Array_1.java,"public int[] sortedSquares(int[] A) { int pos = 0; int[] res = new int[A.length]; int curr = 0; while (pos < A.length && A[pos] < 0) pos++; int npos = pos - 1; while (pos < A.length && npos >= 0) { if (A[pos] * A[pos] < A[npos] * A[npos]) { res[curr++] = A[pos] * A[pos]; pos++; } else { res[curr++] = A[npos] * A[npos]; npos--; } } while (npos >= 0) { res[curr++] = A[npos] * A[npos]; npos--; } while (pos < A.length) { res[curr++] = A[pos] * A[pos]; pos++; } return res; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int var_2 = 0 ; int [ ] var_4 = new int [ var_0 . length ] ; int var_5 = 0 ; while ( var_2 < var_0 . length && var_0 [ var_2 ] < 0 ) var_2 ++ ; int var_7 = var_2 - 1 ; while ( var_2 < var_0 . length && var_7 >= 0 ) { if ( var_0 [ var_2 ] * var_0 [ var_2 ] < var_0 [ var_7 ] * var_0 [ var_7 ] ) { var_4 [ var_5 ++ ] = var_0 [ var_2 ] * var_0 [ var_2 ] ; var_2 ++ ; } else { var_4 [ var_5 ++ ] = var_0 [ var_7 ] * var_0 [ var_7 ] ; var_7 -- ; } } while ( var_7 >= 0 ) { var_4 [ var_5 ++ ] = var_0 [ var_7 ] * var_0 [ var_7 ] ; var_7 -- ; } while ( var_2 < var_0 . length ) { var_4 [ var_5 ++ ] = var_0 [ var_2 ] * var_0 [ var_2 ] ; var_2 ++ ; } return var_4 ; } " 121,692_Top_K_Frequent_Words_1.java,"public List topKFrequent(String[] words, int k) { Map count = new HashMap(); for (String word: words) { count.put(word, count.getOrDefault(word, 0) + 1); } List candidates = new ArrayList(count.keySet()); Collections.sort(candidates, (w1, w2) -> count.get(w1).equals(count.get(w2)) ? w1.compareTo(w2) : count.get(w2) - count.get(w1)); return candidates.subList(0, k); }","public List < String > var_1 ( String [ ] var_2 , int var_3 ) { Map < String , Integer > var_7 = new HashMap ( ) ; for ( String var_8 : var_2 ) { var_7 . put ( var_8 , var_7 . getOrDefault ( var_8 , 0 ) + 1 ) ; } List < String > var_16 = new ArrayList ( var_7 . keySet ( ) ) ; Collections . sort ( var_16 , ( var_19 , var_20 ) -> var_7 . get ( var_19 ) . equals ( var_7 . get ( var_20 ) ) ? var_19 . compareTo ( var_20 ) : var_7 . get ( var_20 ) - var_7 . get ( var_19 ) ) ; return var_16 . subList ( 0 , var_3 ) ; } " 122,009_Palindrome_Number_3.java,"public boolean isPalindrome(int x) { int r,s=0,number=x; if(number<0){ return false; } while (number!=0){ r=number%10; s= s*10 +r; number/=10; } if (s==x){ return true; } else { return false; } }","public boolean var_0 ( int var_1 ) { int var_2 , var_4 = 0 , var_5 = var_1 ; if ( var_5 < 0 ) { return false ; } while ( var_5 != 0 ) { var_2 = var_5 % 10 ; var_4 = var_4 * 10 + var_2 ; var_5 /= 10 ; } if ( var_4 == var_1 ) { return true ; } else { return false ; } } " 123,Total Hamming Distance_1.java,"private void populateBinaryCount(int[] countZero, int[] countOne, int num) { for (int i = 0; i < 32; i++){ if ((num & 1) == 1) countOne[i]++; else countZero[i]++; num = (num >> 1); } }","private void var_0 ( int [ ] var_1 , int [ ] var_2 , int var_3 ) { for ( int var_5 = 0 ; var_5 < 32 ; var_5 ++ ) { if ( ( var_3 & 1 ) == 1 ) var_2 [ var_5 ] ++ ; else var_1 [ var_5 ] ++ ; var_3 = ( var_3 >> 1 ) ; } } " 124,Wood Cut_1.java,"private boolean validate(int size, int k, int[] L) { int count = 0; for (int length : L) { count += length / size; } return count >= k; }","private boolean var_0 ( int var_1 , int var_2 , int [ ] var_3 ) { int var_5 = 0 ; for ( int var_6 : var_3 ) { var_5 += var_6 / var_1 ; } return var_5 >= var_2 ; } " 125,Single Number III_1.java,"public List singleNumberIII(int[] A) { if (A == null || A.length == 0) { return null; } List rst = new ArrayList(); int xor = 0; for (int i = 0; i < A.length; i++) { xor ^= A[i]; } int bitOnePos = 0; for (int i = 0; i < 32; i++) { if ((xor >> i & 1) == 1) { bitOnePos = i; } } int rstA = 0; int rstB = 0; for (int i = 0; i < A.length; i++) { if ((A[i] >> bitOnePos & 1) == 1) { rstA ^= A[i]; } else { rstB ^= A[i]; } } rst.add(rstA); rst.add(rstB); return rst; }","public List < Integer > var_1 ( int [ ] var_2 ) { if ( var_2 == null || var_2 . length == 0 ) { return null ; } List < Integer > var_8 = new ArrayList < Integer > ( ) ; int var_9 = 0 ; for ( int var_10 = 0 ; var_10 < var_2 . length ; var_10 ++ ) { var_9 ^= var_2 [ var_10 ] ; } int var_11 = 0 ; for ( int var_10 = 0 ; var_10 < 32 ; var_10 ++ ) { if ( ( var_9 >> var_10 & 1 ) == 1 ) { var_11 = var_10 ; } } int var_14 = 0 ; int var_15 = 0 ; for ( int var_10 = 0 ; var_10 < var_2 . length ; var_10 ++ ) { if ( ( var_2 [ var_10 ] >> var_11 & 1 ) == 1 ) { var_14 ^= var_2 [ var_10 ] ; } else { var_15 ^= var_2 [ var_10 ] ; } } var_8 . add ( var_14 ) ; var_8 . add ( var_15 ) ; return var_8 ; } " 126,62. Unique Path_1.java,"public int uniquePaths(int m, int n) { if (m == 0 || n == 0) return 0; int[][] dp = new int[m][n]; for (int i = 0; i < m; i++) dp[i][0] = 1; for (int i = 0; i < n; i++) dp[0][i] = 1; for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; } } return dp[m-1][n-1]; }","public int sample_funcname ( int var_0 , int var_1 ) { if ( var_0 == 0 || var_1 == 0 ) return 0 ; int [ ] [ ] var_3 = new int [ var_0 ] [ var_1 ] ; for ( int var_4 = 0 ; var_4 < var_0 ; var_4 ++ ) var_3 [ var_4 ] [ 0 ] = 1 ; for ( int var_4 = 0 ; var_4 < var_1 ; var_4 ++ ) var_3 [ 0 ] [ var_4 ] = 1 ; for ( int var_4 = 1 ; var_4 < var_0 ; var_4 ++ ) { for ( int var_6 = 1 ; var_6 < var_1 ; var_6 ++ ) { var_3 [ var_4 ] [ var_6 ] = var_3 [ var_4 - 1 ] [ var_6 ] + var_3 [ var_4 ] [ var_6 - 1 ] ; } } return var_3 [ var_0 - 1 ] [ var_1 - 1 ] ; } " 127,Max Sum of Rectangle No Larger Than K_1.java,"public int maxSumSubmatrix(int[][] matrix, int k) { if (matrix == null || matrix.length == 0 || matrix[0] == null || matrix[0].length == 0) { return -1; } int m = Math.min(matrix.length, matrix[0].length); int n = Math.max(matrix.length, matrix[0].length); boolean rowFirst = matrix.length < matrix[0].length; int max = Integer.MIN_VALUE; for (int row = 0; row < m; row++) { int[] preSum = new int[n]; for (int i = row; i < m; i++) { TreeSet areaSet = new TreeSet<>(); int newSum = 0; for (int j = 0; j < n; j++) { preSum[j] += rowFirst? matrix[i][j] : matrix[j][i]; newSum += preSum[j]; if (newSum <= k) max = Math.max(max, newSum); Integer extraArea = areaSet.ceiling(newSum - k); if (extraArea != null) { max = Math.max(max, newSum - extraArea); } areaSet.add(newSum); } } } return max == Integer.MIN_VALUE ? -1 : max; }","public int sample_funcname ( int [ ] [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return - 1 ; } int var_8 = Math . min ( var_0 . length , var_0 [ 0 ] . length ) ; int var_10 = Math . max ( var_0 . length , var_0 [ 0 ] . length ) ; boolean var_12 = var_0 . length < var_0 [ 0 ] . length ; int max = Integer . MIN_VALUE ; for ( int var_15 = 0 ; var_15 < var_8 ; var_15 ++ ) { int [ ] var_16 = new int [ var_10 ] ; for ( int var_17 = var_15 ; var_17 < var_8 ; var_17 ++ ) { TreeSet < Integer > var_19 = new TreeSet < > ( ) ; int var_20 = 0 ; for ( int var_21 = 0 ; var_21 < var_10 ; var_21 ++ ) { var_16 [ var_21 ] += var_12 ? var_0 [ var_17 ] [ var_21 ] : var_0 [ var_21 ] [ var_17 ] ; var_20 += var_16 [ var_21 ] ; if ( var_20 <= var_1 ) max = Math . max ( max , var_20 ) ; Integer var_23 = var_19 . ceiling ( var_20 - var_1 ) ; if ( var_23 != null ) { max = Math . max ( max , var_20 - var_23 ) ; } var_19 . add ( var_20 ) ; } } } return max == Integer . MIN_VALUE ? - 1 : max ; } " 128,64. Minimum Path Sum_4.java,"public int minPathSum(int[][] grid) { if (grid == null || grid.length == 0 || grid[0] == null || grid[0].length == 0) return 0; int m = grid.length, n = grid[0].length; int[][] dp = new int[2][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { dp[i%2][j] = grid[i][j]; if (i == 0 && j == 0) continue; if (i == 0 && j > 0) dp[i%2][j] += dp[i%2][j - 1]; else if (i > 0 && j == 0) dp[i%2][j] += dp[(i - 1)%2][j]; else dp[i%2][j] += Math.min(dp[(i - 1)%2][j], dp[i%2][j - 1]); } } return dp[(m - 1)%2][n - 1]; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_7 = new int [ 2 ] [ var_5 ] ; for ( int var_8 = 0 ; var_8 < var_4 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 < var_5 ; var_9 ++ ) { var_7 [ var_8 % 2 ] [ var_9 ] = var_0 [ var_8 ] [ var_9 ] ; if ( var_8 == 0 && var_9 == 0 ) continue ; if ( var_8 == 0 && var_9 > 0 ) var_7 [ var_8 % 2 ] [ var_9 ] += var_7 [ var_8 % 2 ] [ var_9 - 1 ] ; else if ( var_8 > 0 && var_9 == 0 ) var_7 [ var_8 % 2 ] [ var_9 ] += var_7 [ ( var_8 - 1 ) % 2 ] [ var_9 ] ; else var_7 [ var_8 % 2 ] [ var_9 ] += Math . min ( var_7 [ ( var_8 - 1 ) % 2 ] [ var_9 ] , var_7 [ var_8 % 2 ] [ var_9 - 1 ] ) ; } } return var_7 [ ( var_4 - 1 ) % 2 ] [ var_5 - 1 ] ; } " 129,443. String Compression_1.java,"private int assignChar(char[] chars, int index, int count) { String s = String.valueOf(count); for (char c : s.toCharArray()) { chars[index++] = c; } return index; }","private int sample_funcname ( char [ ] var_0 , int var_1 , int var_2 ) { String var_5 = String . valueOf ( var_2 ) ; for ( char var_7 : var_5 . toCharArray ( ) ) { var_0 [ var_1 ++ ] = var_7 ; } return var_1 ; } " 130,332. Reconstruct Itinerary_1.java,"private Map> buildMap(List> tickets) { Map> map = new HashMap<>(); for (List ticket : tickets) { map.putIfAbsent(ticket.get(0), new LinkedList<>()); map.get(ticket.get(0)).add(ticket.get(1)); } for (String key : map.keySet()) Collections.sort(map.get(key)); return map; }","private Map < String , List < String >> var_2 ( List < List < String >> var_3 ) { Map < String , List < String >> var_6 = new HashMap < > ( ) ; for ( List < String > var_7 : var_3 ) { var_6 . putIfAbsent ( var_7 . get ( 0 ) , new LinkedList < > ( ) ) ; var_6 . get ( var_7 . get ( 0 ) ) . add ( var_7 . get ( 1 ) ) ; } for ( String var_15 : var_6 . keySet ( ) ) Collections . sort ( var_6 . get ( var_15 ) ) ; return var_6 ; } " 131,"Pow(x, n)_1.java","public double helper(double x, int n) { if (n == 0) { return 1; } if (n == 1) { return x; } double val = helper(x, n / 2); if (n % 2 == 0) { return val * val; } else { return val * val * x; } }","public double sample_funcname ( double x , int n ) { if ( n == 0 ) { return 1 ; } if ( n == 1 ) { return x ; } double val = helper ( x , n / 2 ) ; if ( n % 2 == 0 ) { return val * val ; } else { return val * val * x ; } } " 132,Backpack_4.java,"public int backPack(int m, int[] A) { if (A == null || A.length < 0) { return 0; } int n = A.length; boolean[][] dp = new boolean[2][m + 1]; int curr = 0; int pre = 1; dp[curr][0] = true; for (int j = 1; j <= m; j++) { dp[curr][j] = false; } for (int i = 1; i <= n; i++) { curr = pre; pre = 1 - curr; for (int j = 0; j <= m; j++) { dp[curr][j] = dp[pre][j]; if (j - A[i - 1] >= 0) { dp[curr][j] |= dp[pre][j - A[i - 1]]; } } } for (int j = m; j >= 0; j--) { if (dp[curr][j]) { return j; } } return 0; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length < 0 ) { return 0 ; } int var_5 = var_1 . length ; boolean [ ] [ ] var_9 = new boolean [ 2 ] [ var_0 + 1 ] ; int var_10 = 0 ; int var_11 = 1 ; var_9 [ var_10 ] [ 0 ] = true ; for ( int var_12 = 1 ; var_12 <= var_0 ; var_12 ++ ) { var_9 [ var_10 ] [ var_12 ] = false ; } for ( int var_13 = 1 ; var_13 <= var_5 ; var_13 ++ ) { var_10 = var_11 ; var_11 = 1 - var_10 ; for ( int var_12 = 0 ; var_12 <= var_0 ; var_12 ++ ) { var_9 [ var_10 ] [ var_12 ] = var_9 [ var_11 ] [ var_12 ] ; if ( var_12 - var_1 [ var_13 - 1 ] >= 0 ) { var_9 [ var_10 ] [ var_12 ] |= var_9 [ var_11 ] [ var_12 - var_1 [ var_13 - 1 ] ] ; } } } for ( int var_12 = var_0 ; var_12 >= 0 ; var_12 -- ) { if ( var_9 [ var_10 ] [ var_12 ] ) { return var_12 ; } } return 0 ; } " 133,Triangles_3.java,"public int minimumTotal(List> triangle) { if (triangle == null || triangle.size() == 0) { return 0; } int n = triangle.size(); int[] dp = new int[n]; for (int j = 0; j < n; j++) { dp[j] = triangle.get(n - 1).get(j); } for (int i = n - 2; i >= 0; i--) { for (int j = 0; j <= i; j++) { dp[j] = Math.min(dp[j], dp[j + 1]) + triangle.get(i).get(j); } } return dp[0]; }","public int sample_funcname ( List < List < Integer >> var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return 0 ; } int var_6 = var_2 . size ( ) ; int [ ] var_7 = new int [ var_6 ] ; for ( int var_8 = 0 ; var_8 < var_6 ; var_8 ++ ) { var_7 [ var_8 ] = var_2 . get ( var_6 - 1 ) . get ( var_8 ) ; } for ( int var_12 = var_6 - 2 ; var_12 >= 0 ; var_12 -- ) { for ( int var_8 = 0 ; var_8 <= var_12 ; var_8 ++ ) { var_7 [ var_8 ] = Math . min ( var_7 [ var_8 ] , var_7 [ var_8 + 1 ] ) + var_2 . get ( var_12 ) . get ( var_8 ) ; } } return var_7 [ 0 ] ; } " 134,31. Next Permutation_1.java,"private int findLow(int[] nums) { int end = nums.length - 1; while (end > 0) { if (nums[end - 1] < nums[end]) return end - 1; end--; } return -1; }","private int sample_funcname ( int [ ] var_0 ) { int var_3 = var_0 . length - 1 ; while ( var_3 > 0 ) { if ( var_0 [ var_3 - 1 ] < var_0 [ var_3 ] ) return var_3 - 1 ; var_3 -- ; } return - 1 ; } " 135,5. Longest Palindromic Substring_1.java,"public String longestPalindrome(String s) { if (s == null || s.length() <= 1) return s; int n = s.length(); boolean dp[][] = new boolean[n][n]; String str = String.valueOf(s.charAt(n - 1)); for (int i = n - 1; i >= 0; i--) { dp[i][i] = true; for (int j = i + 1; j < n; j++) { if (s.charAt(i) == s.charAt(j) && (i + 1 == j || dp[i + 1][j - 1])) { dp[i][j] = true; str = str.length() <= (j - i + 1) ? s.substring(i, j + 1) : str; } } } return str; }","public String var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) <= 1 ) return var_2 ; int var_6 = var_2 . length ( ) ; boolean var_8 [ ] [ ] = new boolean [ var_6 ] [ var_6 ] ; String var_11 = String . valueOf ( var_2 . charAt ( var_6 - 1 ) ) ; for ( int var_12 = var_6 - 1 ; var_12 >= 0 ; var_12 -- ) { var_8 [ var_12 ] [ var_12 ] = true ; for ( int var_14 = var_12 + 1 ; var_14 < var_6 ; var_14 ++ ) { if ( var_2 . charAt ( var_12 ) == var_2 . charAt ( var_14 ) && ( var_12 + 1 == var_14 || var_8 [ var_12 + 1 ] [ var_14 - 1 ] ) ) { var_8 [ var_12 ] [ var_14 ] = true ; var_11 = var_11 . length ( ) <= ( var_14 - var_12 + 1 ) ? var_2 . substring ( var_12 , var_14 + 1 ) : var_11 ; } } } return var_11 ; } " 136,1048. Longest String Chain_2.java,"private List[] buildBucket(String[] words) { List[] bucket = new List[17]; for (String w : words) { int len = w.length(); if (bucket[len] == null) bucket[len] = new ArrayList<>(); bucket[len].add(w); } return bucket; }","private List [ ] var_0 ( String [ ] var_2 ) { List [ ] var_5 = new List [ 17 ] ; for ( String var_6 : var_2 ) { int var_8 = var_6 . length ( ) ; if ( var_5 [ var_8 ] == null ) var_5 [ var_8 ] = new ArrayList < > ( ) ; var_5 [ var_8 ] . add ( var_6 ) ; } return var_5 ; } " 137,1007. Minimum Domino Rotations For Equal Row_2.java,"private int checkRotation(int[] A, int[] B, int candidate) { int rotationA = 0, rotationB = 0; for (int i = 0; i < A.length; i++) { if (A[i] != candidate && B[i] != candidate) return -1; else if (A[i] != candidate) rotationA++; else if (B[i] != candidate) rotationB++; } return Math.min(rotationA, rotationB); }","private int sample_funcname ( int [ ] var_0 , int [ ] var_1 , int var_2 ) { int var_4 = 0 , var_5 = 0 ; for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { if ( var_0 [ var_6 ] != var_2 && var_1 [ var_6 ] != var_2 ) return - 1 ; else if ( var_0 [ var_6 ] != var_2 ) var_4 ++ ; else if ( var_1 [ var_6 ] != var_2 ) var_5 ++ ; } return Math . min ( var_4 , var_5 ) ; } " 138,Longest Increasing Continuous subsequence_1.java,"public int longestIncreasingContinuousSubsequence(int[] A) { if (A == null || A.length == 0) { return 0; } int leftRun = 1; int rightRun = 1; int ans = 1; for (int i = 1; i < A.length; i++) { if (A[i] > A[i - 1]) { leftRun++; } else { leftRun = 1; } ans = Math.max(ans, leftRun); } for (int i = A.length - 2; i >= 0; i--) { if (A[i] > A[i + 1]) { rightRun++; } else { rightRun = 1; } ans = Math.max(ans, rightRun); } return ans; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = 1 ; int var_6 = 1 ; int var_7 = 1 ; for ( int var_8 = 1 ; var_8 < var_0 . length ; var_8 ++ ) { if ( var_0 [ var_8 ] > var_0 [ var_8 - 1 ] ) { var_5 ++ ; } else { var_5 = 1 ; } var_7 = Math . max ( var_7 , var_5 ) ; } for ( int var_8 = var_0 . length - 2 ; var_8 >= 0 ; var_8 -- ) { if ( var_0 [ var_8 ] > var_0 [ var_8 + 1 ] ) { var_6 ++ ; } else { var_6 = 1 ; } var_7 = Math . max ( var_7 , var_6 ) ; } return var_7 ; } " 139,Perfect Squares_3.java,"public int numSquares(int n) { if (n <= 0) { return 0; } Queue queue = new LinkedList<>(); Set set = new HashSet<>(); queue.offer(n); int level = 1; while (!queue.isEmpty()) { int size = queue.size(); for (int x = 0; x < size; x++) { int num = queue.poll(); for (int i = 1; i <= num; i++) { int remain = num - i * i; if (remain == 0) { return level; } else if (remain > 0 && !set.contains(remain)) { queue.offer(remain); set.add(remain); } else if (remain < 0) { break; } } } level++; } return level; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 0 ) { return 0 ; } Queue < Integer > var_5 = new LinkedList < > ( ) ; Set < Integer > var_8 = new HashSet < > ( ) ; var_5 . offer ( var_0 ) ; int var_11 = 1 ; while ( ! var_5 . isEmpty ( ) ) { int size = var_5 . size ( ) ; for ( int var_14 = 0 ; var_14 < size ; var_14 ++ ) { int var_16 = var_5 . poll ( ) ; for ( int var_17 = 1 ; var_17 <= var_16 ; var_17 ++ ) { int var_18 = var_16 - var_17 * var_17 ; if ( var_18 == 0 ) { return var_11 ; } else if ( var_18 > 0 && ! var_8 . contains ( var_18 ) ) { var_5 . offer ( var_18 ) ; var_8 . add ( var_18 ) ; } else if ( var_18 < 0 ) { break ; } } } var_11 ++ ; } return var_11 ; } " 140,Best Time to Buy and Sell Stock with Cooldown_1.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length <= 1) { return 0; } int n = prices.length; int[][] dp = new int[n][2]; dp[0][0] = - prices[0]; dp[0][1] = 0; for (int i = 1; i < n; i++) { dp[i][1] = Math.max(dp[i - 1][1], dp[i - 1][0] + prices[i]); dp[i][0] = dp[i - 1][0]; if (i >= 2) { dp[i][0] = Math.max(dp[i][0], dp[i - 2][1] - prices[i]); } else { dp[i][0] = Math.max(dp[i][0], - prices[i]); } } return dp[n - 1][1]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length <= 1 ) { return 0 ; } int var_5 = var_0 . length ; int [ ] [ ] var_7 = new int [ var_5 ] [ 2 ] ; var_7 [ 0 ] [ 0 ] = - var_0 [ 0 ] ; var_7 [ 0 ] [ 1 ] = 0 ; for ( int var_8 = 1 ; var_8 < var_5 ; var_8 ++ ) { var_7 [ var_8 ] [ 1 ] = Math . max ( var_7 [ var_8 - 1 ] [ 1 ] , var_7 [ var_8 - 1 ] [ 0 ] + var_0 [ var_8 ] ) ; var_7 [ var_8 ] [ 0 ] = var_7 [ var_8 - 1 ] [ 0 ] ; if ( var_8 >= 2 ) { var_7 [ var_8 ] [ 0 ] = Math . max ( var_7 [ var_8 ] [ 0 ] , var_7 [ var_8 - 2 ] [ 1 ] - var_0 [ var_8 ] ) ; } else { var_7 [ var_8 ] [ 0 ] = Math . max ( var_7 [ var_8 ] [ 0 ] , - var_0 [ var_8 ] ) ; } } return var_7 [ var_5 - 1 ] [ 1 ] ; } " 141,Decode String_2.java,"private String popStack(Stack stack) { StringBuffer sb = new StringBuffer(); Stack buffer = new Stack<>(); while (!stack.isEmpty() && (stack.peek() instanceof String)) { buffer.push((String) stack.pop()); } while (!buffer.isEmpty()) { sb.append(buffer.pop()); } return sb.toString(); }","private String var_0 ( Stack < Object > var_3 ) { StringBuffer var_5 = new StringBuffer ( ) ; Stack < String > var_7 = new Stack < > ( ) ; while ( ! var_3 . isEmpty ( ) && ( var_3 . peek ( ) instanceof String ) ) { var_7 . push ( ( String ) var_3 . pop ( ) ) ; } while ( ! var_7 . isEmpty ( ) ) { var_5 . append ( var_7 . pop ( ) ) ; } return var_5 . toString ( ) ; } " 142,Interleaving String_2.java,"public boolean isInterleave(String s1, String s2, String s3) { if (s1 == null || s2 == null || s1.length() + s2.length() != s3.length()) { return false; } int m = s1.length(); int n = s2.length(); boolean[][] dp = new boolean[2][n + 1]; int curr = 0; int prev = 0; for (int i = 0; i <= m; i++) { prev = curr; curr = 1 - prev; for (int j = 0; j <= n; j++) { if (i == 0 && j == 0) { dp[curr][j] = true; continue; } dp[curr][j] = false; if (i > 0 && s1.charAt(i - 1) == s3.charAt(i + j - 1)) { dp[curr][j] |= dp[prev][j]; } if (j > 0 && s2.charAt(j - 1) == s3.charAt(i + j - 1)) { dp[curr][j] |= dp[curr][j - 1]; } } } return dp[curr][n]; }","public boolean var_0 ( String var_2 , String var_3 , String var_4 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) + var_3 . length ( ) != var_4 . length ( ) ) { return false ; } int var_7 = var_2 . length ( ) ; int var_8 = var_3 . length ( ) ; boolean [ ] [ ] var_12 = new boolean [ 2 ] [ var_8 + 1 ] ; int var_14 = 0 ; int var_15 = 0 ; for ( int var_16 = 0 ; var_16 <= var_7 ; var_16 ++ ) { var_15 = var_14 ; var_14 = 1 - var_15 ; for ( int var_17 = 0 ; var_17 <= var_8 ; var_17 ++ ) { if ( var_16 == 0 && var_17 == 0 ) { var_12 [ var_14 ] [ var_17 ] = true ; continue ; } var_12 [ var_14 ] [ var_17 ] = false ; if ( var_16 > 0 && var_2 . charAt ( var_16 - 1 ) == var_4 . charAt ( var_16 + var_17 - 1 ) ) { var_12 [ var_14 ] [ var_17 ] |= var_12 [ var_15 ] [ var_17 ] ; } if ( var_17 > 0 && var_3 . charAt ( var_17 - 1 ) == var_4 . charAt ( var_16 + var_17 - 1 ) ) { var_12 [ var_14 ] [ var_17 ] |= var_12 [ var_14 ] [ var_17 - 1 ] ; } } } return var_12 [ var_14 ] [ var_8 ] ; } " 143,Find Peak Element II_1.java,"private List find(int x1, int x2, int y1, int y2, int[][] A) { int midX = x1 + ((x2 - x1) >> 1); int midY = y1 + ((y2 - y1) >> 1); int x = midX, y = midY; int max = A[x][y]; for (int j = y1; j <= y2; j++) { if (A[midX][j] > max) { max = A[midX][j]; x = midX; y = j; } } for (int i = x1; i <= x2; i++) { if (A[i][midY] > max) { max = A[i][midY]; y = midY; x = i; } } if (A[x - 1][y] > max) { return find(x1, midX - 1, y1, y2, A); } else if (A[x + 1][y] > max) { return find(x1 + 1, midX, y1, y2, A); } else if (A[x][y - 1] > max) { return find(x1, x2, y1, midY - 1, A); } else if (A[x][y + 1] > max) { return find(x1, x2, midY + 1, y2, A); } return new ArrayList<>(Arrays.asList(x, y)); }","private List < Integer > sample_funcname ( int x1 , int x2 , int y1 , int y2 , int [ ] [ ] A ) { int midX = x1 + ( ( x2 - x1 ) >> 1 ) ; int midY = y1 + ( ( y2 - y1 ) >> 1 ) ; int x = midX , y = midY ; int max = A [ x ] [ y ] ; for ( int j = y1 ; j <= y2 ; j ++ ) { if ( A [ midX ] [ j ] > max ) { max = A [ midX ] [ j ] ; x = midX ; y = j ; } } for ( int i = x1 ; i <= x2 ; i ++ ) { if ( A [ i ] [ midY ] > max ) { max = A [ i ] [ midY ] ; y = midY ; x = i ; } } if ( A [ x - 1 ] [ y ] > max ) { return find ( x1 , midX - 1 , y1 , y2 , A ) ; } else if ( A [ x + 1 ] [ y ] > max ) { return find ( x1 + 1 , midX , y1 , y2 , A ) ; } else if ( A [ x ] [ y - 1 ] > max ) { return find ( x1 , x2 , y1 , midY - 1 , A ) ; } else if ( A [ x ] [ y + 1 ] > max ) { return find ( x1 , x2 , midY + 1 , y2 , A ) ; } return new ArrayList < > ( Arrays . asList ( x , y ) ) ; } " 144,Ugly Number_1.java,"public boolean isUgly(int num) { if (num == 0) { return false; } while (num % 2 == 0) num /= 2; while (num % 3 == 0) num /= 3; while (num % 5 == 0) num /= 5; return num == 1; }","public boolean var_0 ( int var_1 ) { if ( var_1 == 0 ) { return false ; } while ( var_1 % 2 == 0 ) var_1 /= 2 ; while ( var_1 % 3 == 0 ) var_1 /= 3 ; while ( var_1 % 5 == 0 ) var_1 /= 5 ; return var_1 == 1 ; } " 145,125. Valid Palindrome_1.java,"private boolean isValid(char c) { if (c >= '0' && c <= '9') return true; if (c >= 'a' && c <= 'z') return true; if (c >= 'A' && c <= 'Z') return true; return false; }","private boolean var_0 ( char var_1 ) { if ( var_1 >= '0' && var_1 <= '9' ) return true ; if ( var_1 >= 'a' && var_1 <= 'z' ) return true ; if ( var_1 >= 'A' && var_1 <= 'Z' ) return true ; return false ; } " 146,Summary Ranges_1.java,"public List summaryRanges(int[] nums) { List rst = new ArrayList<>(); if (nums == null || nums.length == 0) { return rst; } List list = new ArrayList<>(); for (int i = 0; i < nums.length; i++) { list.add(nums[i]); if (i + 1 == nums.length || nums[i] + 1 != nums[i + 1]) { if (list.size() == 1) { rst.add(list.get(0) + """"); } else { rst.add(list.get(0) + ""->"" + list.get(list.size() - 1)); } list = new ArrayList(); } } return rst; }","public List < String > var_1 ( int [ ] var_2 ) { List < String > var_5 = new ArrayList < > ( ) ; if ( var_2 == null || var_2 . length == 0 ) { return var_5 ; } List < Integer > var_10 = new ArrayList < > ( ) ; for ( int var_11 = 0 ; var_11 < var_2 . length ; var_11 ++ ) { var_10 . add ( var_2 [ var_11 ] ) ; if ( var_11 + 1 == var_2 . length || var_2 [ var_11 ] + 1 != var_2 [ var_11 + 1 ] ) { if ( var_10 . size ( ) == 1 ) { var_5 . add ( var_10 . get ( 0 ) + """" ) ; } else { var_5 . add ( var_10 . get ( 0 ) + ""->"" + var_10 . get ( var_10 . size ( ) - 1 ) ) ; } var_10 = new ArrayList < Integer > ( ) ; } } return var_5 ; } " 147,Backpack III_2.java,"public int backPackIII(int[] A, int[] V, int m) { if (A == null || A.length == 0 || V == null || V.length == 0 || m <= 0) { return 0; } int n = A.length; int[][] dp = new int[n + 1][m + 1]; dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= m; j++) { dp[i][j] = dp[i - 1][j]; if (j >= A[i - 1]) { dp[i][j] = Math.max(dp[i][j], dp[i][j - A[i - 1]] + V[i - 1]); } } } return dp[n][m]; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 , int var_2 ) { if ( var_0 == null || var_0 . length == 0 || var_1 == null || var_1 . length == 0 || var_2 <= 0 ) { return 0 ; } int var_6 = var_0 . length ; int [ ] [ ] var_8 = new int [ var_6 + 1 ] [ var_2 + 1 ] ; var_8 [ 0 ] [ 0 ] = 0 ; for ( int var_9 = 1 ; var_9 <= var_6 ; var_9 ++ ) { for ( int var_10 = 0 ; var_10 <= var_2 ; var_10 ++ ) { var_8 [ var_9 ] [ var_10 ] = var_8 [ var_9 - 1 ] [ var_10 ] ; if ( var_10 >= var_0 [ var_9 - 1 ] ) { var_8 [ var_9 ] [ var_10 ] = Math . max ( var_8 [ var_9 ] [ var_10 ] , var_8 [ var_9 ] [ var_10 - var_0 [ var_9 - 1 ] ] + var_1 [ var_9 - 1 ] ) ; } } } return var_8 [ var_6 ] [ var_2 ] ; } " 148,Word Ladder_2.java,"public int ladderLength(String start, String end, Set dict) { if (start == null || end == null || dict == null || start.length() != end.length()) { return 0; } Queue q = new LinkedList(); HashSet set = new HashSet(); int level = 1; int len = Integer.MAX_VALUE; q.offer(start); set.add(start); while(!q.isEmpty()) { int size = q.size(); level++; for (int k = 0; k < size; k++) { String str = q.poll(); for (int i = 0; i < str.length(); i++) { for (int j = 0; j < 26; j++) { String newStr; if (i == 0 && str.length() == 1) { newStr = """" + (char)('a' + j); } else if (i == str.length() - 1) { newStr = str.substring(0, i) + (char)('a' + j); } else { newStr = str.substring(0, i) + (char)('a' + j) + str.substring(i + 1); } if (!set.contains(newStr) && dict.contains(newStr)) { if (newStr.equals(end)) { len = Math.min(len, level); } else { set.add(newStr); q.offer(newStr); } } } } } } return len; }","public int sample_funcname ( String var_1 , String var_2 , Set < String > var_4 ) { if ( var_1 == null || var_2 == null || var_4 == null || var_1 . length ( ) != var_2 . length ( ) ) { return 0 ; } Queue < String > var_10 = new LinkedList < String > ( ) ; HashSet < String > var_12 = new HashSet < String > ( ) ; int var_14 = 1 ; int var_17 = Integer . MAX_VALUE ; var_10 . offer ( var_1 ) ; var_12 . add ( var_1 ) ; while ( ! var_10 . isEmpty ( ) ) { int size = var_10 . size ( ) ; var_14 ++ ; for ( int var_22 = 0 ; var_22 < size ; var_22 ++ ) { String var_24 = var_10 . poll ( ) ; for ( int var_25 = 0 ; var_25 < var_24 . length ( ) ; var_25 ++ ) { for ( int var_26 = 0 ; var_26 < 26 ; var_26 ++ ) { String var_28 ; if ( var_25 == 0 && var_24 . length ( ) == 1 ) { var_28 = """" + ( char ) ( 'a' + var_26 ) ; } else if ( var_25 == var_24 . length ( ) - 1 ) { var_28 = var_24 . substring ( 0 , var_25 ) + ( char ) ( 'a' + var_26 ) ; } else { var_28 = var_24 . substring ( 0 , var_25 ) + ( char ) ( 'a' + var_26 ) + var_24 . substring ( var_25 + 1 ) ; } if ( ! var_12 . contains ( var_28 ) && var_4 . contains ( var_28 ) ) { if ( var_28 . equals ( var_2 ) ) { var_17 = Math . min ( var_17 , var_14 ) ; } else { var_12 . add ( var_28 ) ; var_10 . offer ( var_28 ) ; } } } } } } return var_17 ; } " 149,Wildcard Matching_2.java,"public boolean isMatch(String s, String p) { if (s == null || p == null) { return false; } int m = s.length(); int n = p.length(); boolean[][] dp = new boolean[2][n + 1]; char[] ss = s.toCharArray(); char[] pp = p.toCharArray(); int curr = 0; int prev = 1; for (int i = 0; i <= m; i++) { prev = curr; curr = 1 - prev; for (int j = 0; j <= n; j++) { if (i == 0 && j == 0) { dp[curr][j] = true; continue; } if (j == 0) { dp[curr][j] = false; continue; } dp[curr][j] = false; if (pp[j - 1] != '*') { if (i >= 1 && (ss[i - 1] == pp[j - 1] || pp[j - 1] == '?')) { dp[curr][j] = dp[prev][j - 1]; } } else { dp[curr][j] |= dp[curr][j - 1]; if (i >= 1) { dp[curr][j] |= dp[prev][j]; } } } } return dp[curr][n]; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null ) { return false ; } int var_6 = var_2 . length ( ) ; int var_7 = var_3 . length ( ) ; boolean [ ] [ ] var_11 = new boolean [ 2 ] [ var_7 + 1 ] ; char [ ] var_13 = var_2 . toCharArray ( ) ; char [ ] var_14 = var_3 . toCharArray ( ) ; int var_16 = 0 ; int var_17 = 1 ; for ( int var_18 = 0 ; var_18 <= var_6 ; var_18 ++ ) { var_17 = var_16 ; var_16 = 1 - var_17 ; for ( int var_19 = 0 ; var_19 <= var_7 ; var_19 ++ ) { if ( var_18 == 0 && var_19 == 0 ) { var_11 [ var_16 ] [ var_19 ] = true ; continue ; } if ( var_19 == 0 ) { var_11 [ var_16 ] [ var_19 ] = false ; continue ; } var_11 [ var_16 ] [ var_19 ] = false ; if ( var_14 [ var_19 - 1 ] != '*' ) { if ( var_18 >= 1 && ( var_13 [ var_18 - 1 ] == var_14 [ var_19 - 1 ] || var_14 [ var_19 - 1 ] == '?' ) ) { var_11 [ var_16 ] [ var_19 ] = var_11 [ var_17 ] [ var_19 - 1 ] ; } } else { var_11 [ var_16 ] [ var_19 ] |= var_11 [ var_16 ] [ var_19 - 1 ] ; if ( var_18 >= 1 ) { var_11 [ var_16 ] [ var_19 ] |= var_11 [ var_17 ] [ var_19 ] ; } } } } return var_11 [ var_16 ] [ var_7 ] ; } " 150,Walls and Gates_3.java,"private boolean validateCoordinate(int[][] rooms, int x, int y) { return x < 0 || x >= rooms.length || y < 0 || y >= rooms[0].length || rooms[x][y] == -1 || rooms[x][y] == 0; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 < 0 || var_2 >= var_1 . length || var_3 < 0 || var_3 >= var_1 [ 0 ] . length || var_1 [ var_2 ] [ var_3 ] == - 1 || var_1 [ var_2 ] [ var_3 ] == 0 ; } " 151,Maximum Vacation Days_1.java,"public int maxVacationDays(int[][] flights, int[][] days) { int m = days[0].length; int n = days.length; int[][] dp = new int[m][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (i == 0) { dp[i][j] = j == 0 || flights[0][j] != 0 ? days[j][i]: Integer.MIN_VALUE; continue; } dp[i][j] = Integer.MIN_VALUE; for (int k = 0; k < m; k++) { if ((k == j || flights[k][j] == 1) && dp[i - 1][k] != Integer.MIN_VALUE) { dp[i][j] = Math.max(dp[i - 1][k] + days[j][i], dp[i][j]); } } } } int max = 0; for (int i = 0; i < n; i++) { max = Math.max(max, dp[m - 1][i]); } return max; }","public int sample_funcname ( int [ ] [ ] var_0 , int [ ] [ ] var_1 ) { int var_4 = var_1 [ 0 ] . length ; int var_5 = var_1 . length ; int [ ] [ ] var_6 = new int [ var_4 ] [ var_5 ] ; for ( int var_7 = 0 ; var_7 < var_4 ; var_7 ++ ) { for ( int var_8 = 0 ; var_8 < var_5 ; var_8 ++ ) { if ( var_7 == 0 ) { var_6 [ var_7 ] [ var_8 ] = var_8 == 0 || var_0 [ 0 ] [ var_8 ] != 0 ? var_1 [ var_8 ] [ var_7 ] : Integer . MIN_VALUE ; continue ; } var_6 [ var_7 ] [ var_8 ] = Integer . MIN_VALUE ; for ( int var_11 = 0 ; var_11 < var_4 ; var_11 ++ ) { if ( ( var_11 == var_8 || var_0 [ var_11 ] [ var_8 ] == 1 ) && var_6 [ var_7 - 1 ] [ var_11 ] != Integer . MIN_VALUE ) { var_6 [ var_7 ] [ var_8 ] = Math . max ( var_6 [ var_7 - 1 ] [ var_11 ] + var_1 [ var_8 ] [ var_7 ] , var_6 [ var_7 ] [ var_8 ] ) ; } } } } int max = 0 ; for ( int var_7 = 0 ; var_7 < var_5 ; var_7 ++ ) { max = Math . max ( max , var_6 [ var_4 - 1 ] [ var_7 ] ) ; } return max ; } " 152,Palindrome Partitioning II_1.java,"private boolean[][] calcPalindrome(char[] s) { int n = s.length; boolean[][] palindrome = new boolean[n][n]; for (int mid = 0; mid < n; mid++) { int i = mid, j = mid; while (i >= 0 && j < n && s[i] == s[j]) { palindrome[i][j] = true; i--; j++; } i = mid; j = mid + 1; while (i >= 0 && j < n && s[i] == s[j]) { palindrome[i][j] = true; i--; j++; } } return palindrome; }","private boolean [ ] [ ] var_0 ( char [ ] var_1 ) { int var_3 = var_1 . length ; boolean [ ] [ ] var_5 = new boolean [ var_3 ] [ var_3 ] ; for ( int var_7 = 0 ; var_7 < var_3 ; var_7 ++ ) { int var_8 = var_7 , var_9 = var_7 ; while ( var_8 >= 0 && var_9 < var_3 && var_1 [ var_8 ] == var_1 [ var_9 ] ) { var_5 [ var_8 ] [ var_9 ] = true ; var_8 -- ; var_9 ++ ; } var_8 = var_7 ; var_9 = var_7 + 1 ; while ( var_8 >= 0 && var_9 < var_3 && var_1 [ var_8 ] == var_1 [ var_9 ] ) { var_5 [ var_8 ] [ var_9 ] = true ; var_8 -- ; var_9 ++ ; } } return var_5 ; } " 153,Friends Of Appropriate Ages_1.java,"public int numFriendRequests(int[] ages) { int[] count = new int[121]; for (int age: ages) { count[age]++; } int rst = 0; for (int i = 15; i < 121; i++) { for (int j = (int)(i * 0.5 + 8); j <= i; j++) { rst += i == j ? count[j] * (count[i] - 1) : count[j] * count[i]; } } return rst; }","public int sample_funcname ( int [ ] var_0 ) { int [ ] var_2 = new int [ 121 ] ; for ( int var_3 : var_0 ) { var_2 [ var_3 ] ++ ; } int var_5 = 0 ; for ( int var_7 = 15 ; var_7 < 121 ; var_7 ++ ) { for ( int var_10 = ( int ) ( var_7 * 0.5 + 8 ) ; var_10 <= var_7 ; var_10 ++ ) { var_5 += var_7 == var_10 ? var_2 [ var_10 ] * ( var_2 [ var_7 ] - 1 ) : var_2 [ var_10 ] * var_2 [ var_7 ] ; } } return var_5 ; } " 154,229. Majority Element II_1.java,"public List majorityElement(int[] nums) { List result = new ArrayList<>(); if (nums == null || nums.length == 0) { return result; } int valA = 0, valB = 0, countA = 0, countB = 0; for (int num : nums) { if (num == valA) { countA++; } else if (num == valB) { countB++; } else if (countA == 0) { valA = num; countA++; } else if (countB == 0){ valB = num; countB++; } else { countA--; countB--; } } countA = 0; countB = 0; for (int num : nums) { if (num == valA) { countA++; } else if (num == valB) { countB++; } } if (countA > nums.length / 3) result.add(valA); if (countB > nums.length / 3) result.add(valB); return result; }","public List < Integer > var_1 ( int [ ] var_2 ) { List < Integer > var_5 = new ArrayList < > ( ) ; if ( var_2 == null || var_2 . length == 0 ) { return var_5 ; } int var_9 = 0 , var_10 = 0 , var_11 = 0 , var_12 = 0 ; for ( int var_13 : var_2 ) { if ( var_13 == var_9 ) { var_11 ++ ; } else if ( var_13 == var_10 ) { var_12 ++ ; } else if ( var_11 == 0 ) { var_9 = var_13 ; var_11 ++ ; } else if ( var_12 == 0 ) { var_10 = var_13 ; var_12 ++ ; } else { var_11 -- ; var_12 -- ; } } var_11 = 0 ; var_12 = 0 ; for ( int var_13 : var_2 ) { if ( var_13 == var_9 ) { var_11 ++ ; } else if ( var_13 == var_10 ) { var_12 ++ ; } } if ( var_11 > var_2 . length / 3 ) var_5 . add ( var_9 ) ; if ( var_12 > var_2 . length / 3 ) var_5 . add ( var_10 ) ; return var_5 ; } " 155,274.H-Index_3.java,"public int hIndex(int[] citations) { if (citations == null || citations.length == 0) { return 0; } int n = citations.length; Arrays.sort(citations); int index = n; for (int i = n - 1; i >= 0; i--) { if (citations[i] >= n - i) { index = i; continue; } break; } return n - index; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; Arrays . sort ( var_0 ) ; int var_7 = var_4 ; for ( int var_9 = var_4 - 1 ; var_9 >= 0 ; var_9 -- ) { if ( var_0 [ var_9 ] >= var_4 - var_9 ) { var_7 = var_9 ; continue ; } break ; } return var_4 - var_7 ; } " 156,561. Array Partition I_1.java,"public int arrayPairSum(int[] nums) { if (nums == null || nums.length <= 1) { return 0; } Arrays.sort(nums); long result = 0; for (int i = 0; i < nums.length; i++) { result += i % 2 == 0 ? nums[i] : 0; } return (int)result; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length <= 1 ) { return 0 ; } Arrays . sort ( var_0 ) ; long var_7 = 0 ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { var_7 += var_8 % 2 == 0 ? var_0 [ var_8 ] : 0 ; } return ( int ) var_7 ; } " 157,Group Shifted Strings_1.java,"private String convert(String s) { StringBuffer sb = new StringBuffer(); int offset = s.charAt(0) - 'a'; for (char c : s.toCharArray()) { char newChar = (char)(c - offset); if (newChar < 'a') newChar += 26; sb.append(newChar); } return sb.toString(); }","private String var_0 ( String var_2 ) { StringBuffer var_4 = new StringBuffer ( ) ; int var_8 = var_2 . charAt ( 0 ) - 'a' ; for ( char var_10 : var_2 . toCharArray ( ) ) { char var_11 = ( char ) ( var_10 - var_8 ) ; if ( var_11 < 'a' ) var_11 += 26 ; var_4 . append ( var_11 ) ; } return var_4 . toString ( ) ; } " 158,Power of Three_1.java,"public boolean isPowerOfThree(int n) { if (n <= 0) { return false; } int start = 0; int end = n; while (start + 1 < end) { int mid = start + (end - start)/2; long powerOfThree = (long) Math.pow(3, mid); if (powerOfThree == n) { return true; } if (powerOfThree < n) { start = mid; } else { end = mid; } } return Math.pow(3, start) == n; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 0 ) { return false ; } int var_3 = 0 ; int var_4 = var_1 ; while ( var_3 + 1 < var_4 ) { int var_7 = var_3 + ( var_4 - var_3 ) / 2 ; long var_11 = ( long ) Math . pow ( 3 , var_7 ) ; if ( var_11 == var_1 ) { return true ; } if ( var_11 < var_1 ) { var_3 = var_7 ; } else { var_4 = var_7 ; } } return Math . pow ( 3 , var_3 ) == var_1 ; } " 159,119. Pascal's Triangle II_1.java,"public List getRow(int rowIndex) { List result = new ArrayList<>(); if (rowIndex == 0) result.add(1); if (rowIndex >= 1) result.add(1); for (int row = 1; row <= rowIndex; row++) { List list = new ArrayList<>(Arrays.asList(1, 1)); List lastRow = result; int end = row - 1; for (int i = 1; i <= end; i++) { list.add(i, lastRow.get(i) + lastRow.get(i - 1)); } result = list; } return result; }","public List < Integer > var_1 ( int var_2 ) { List < Integer > var_5 = new ArrayList < > ( ) ; if ( var_2 == 0 ) var_5 . add ( 1 ) ; if ( var_2 >= 1 ) var_5 . add ( 1 ) ; for ( int var_9 = 1 ; var_9 <= var_2 ; var_9 ++ ) { List < Integer > var_12 = new ArrayList < > ( Arrays . asList ( 1 , 1 ) ) ; List < Integer > var_13 = var_5 ; int var_14 = var_9 - 1 ; for ( int var_15 = 1 ; var_15 <= var_14 ; var_15 ++ ) { var_12 . add ( var_15 , var_13 . get ( var_15 ) + var_13 . get ( var_15 - 1 ) ) ; } var_5 = var_12 ; } return var_5 ; } " 160,169. Majority Element_1.java,"public int majorityElement(int[] nums) { if (nums == null || nums.length == 0) { return -1; } Map map = new HashMap<>(); for (int num : nums) { if (!map.containsKey(num)) { map.put(num, 0); } map.put(num, map.get(num) + 1); } int halfLen = nums.length / 2; for (Map.Entry entry : map.entrySet()) { if (entry.getValue() > halfLen) { return entry.getKey(); } } return -1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } Map < Integer , Integer > var_8 = new HashMap < > ( ) ; for ( int var_9 : var_0 ) { if ( ! var_8 . containsKey ( var_9 ) ) { var_8 . put ( var_9 , 0 ) ; } var_8 . put ( var_9 , var_8 . get ( var_9 ) + 1 ) ; } int var_14 = var_0 . length / 2 ; for ( Map . Entry < Integer , Integer > var_16 : var_8 . entrySet ( ) ) { if ( var_16 . getValue ( ) > var_14 ) { return var_16 . getKey ( ) ; } } return - 1 ; } " 161,Rotate Image_1.java,"public void rotate(int[][] matrix) { if (matrix == null || matrix.length == 0 || matrix[0].length == 0) { return; } int width = matrix.length; for (int i = 0; i < width/2; i++) { for (int j = 0; j < Math.ceil(width/2.0); j++) { int temp = matrix[i][j]; matrix[i][j] = matrix[width - 1 - j][i]; matrix[width - 1 - j][i] = matrix[width - 1 - i][width - 1 - j]; matrix[width - 1 - i][width - 1 - j] = matrix[j][width - 1 - i]; matrix[j][width - 1 - i] = temp; } } }","public void var_0 ( int [ ] [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 || var_1 [ 0 ] . length == 0 ) { return ; } int var_5 = var_1 . length ; for ( int var_6 = 0 ; var_6 < var_5 / 2 ; var_6 ++ ) { for ( int var_8 = 0 ; var_8 < Math . ceil ( var_5 / 2.0 ) ; var_8 ++ ) { int var_12 = var_1 [ var_6 ] [ var_8 ] ; var_1 [ var_6 ] [ var_8 ] = var_1 [ var_5 - 1 - var_8 ] [ var_6 ] ; var_1 [ var_5 - 1 - var_8 ] [ var_6 ] = var_1 [ var_5 - 1 - var_6 ] [ var_5 - 1 - var_8 ] ; var_1 [ var_5 - 1 - var_6 ] [ var_5 - 1 - var_8 ] = var_1 [ var_8 ] [ var_5 - 1 - var_6 ] ; var_1 [ var_8 ] [ var_5 - 1 - var_6 ] = var_12 ; } } } " 162,305. Number of Islands II_1.java,"private boolean validateBorder(int[][] grid, int x, int y, int m, int n) { return x >= 0 && x < m && y >= 0 && y < n && grid[x][y] == 1; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 , int var_4 , int var_5 ) { return var_2 >= 0 && var_2 < var_4 && var_3 >= 0 && var_3 < var_5 && var_1 [ var_2 ] [ var_3 ] == 1 ; } " 163,Backpack VI_1.java,"public int backPackVI(int[] nums, int target) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int[] dp = new int[target + 1]; dp[0] = 1; for (int i = 1; i <= target; i++) { for (int j = 0; j < n; j++) { if (i - nums[j] >= 0) { dp[i] += dp[i - nums[j]]; } } } return dp[target]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = var_0 . length ; int [ ] var_7 = new int [ var_1 + 1 ] ; var_7 [ 0 ] = 1 ; for ( int var_8 = 1 ; var_8 <= var_1 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 < var_5 ; var_9 ++ ) { if ( var_8 - var_0 [ var_9 ] >= 0 ) { var_7 [ var_8 ] += var_7 [ var_8 - var_0 [ var_9 ] ] ; } } } return var_7 [ var_1 ] ; } " 164,Letter Combinations of a Phone Number_3.java,"public List letterCombinations(String digits) { List rst = new ArrayList(); if (digits == null || digits.length() == 0) { return rst; } HashMap map = new HashMap(); map.put(2, ""abc"");map.put(3, ""def""); map.put(4, ""ghi"");map.put(5, ""jkl"");map.put(6, ""mno""); map.put(7, ""pqrs"");map.put(8,""tuv"");map.put(9,""wxyz""); Queue queue = new LinkedList(); int index = 0; int digit = Integer.parseInt(digits.substring(index, index + 1)); String keys = map.get(digit); index++; for (int i = 0; i < keys.length(); i++) { queue.offer(keys.substring(i,i+1)); } int size = queue.size(); while (index < digits.length() && !queue.isEmpty()) { String str = queue.poll(); digit = Integer.parseInt(digits.substring(index, index + 1)); keys = map.get(digit); for (int i = 0; i < keys.length(); i++) { queue.offer(str + keys.substring(i,i+1)); } size--; if (size == 0 && index < digits.length() - 1) { index++; size = queue.size(); } } while (!queue.isEmpty()) { rst.add(queue.poll()); } return rst; }","public List < String > var_1 ( String var_2 ) { List < String > var_5 = new ArrayList < String > ( ) ; if ( var_2 == null || var_2 . length ( ) == 0 ) { return var_5 ; } HashMap < Integer , String > var_11 = new HashMap < Integer , String > ( ) ; var_11 . put ( 2 , ""abc"" ) ; var_11 . put ( 3 , ""def"" ) ; var_11 . put ( 4 , ""ghi"" ) ; var_11 . put ( 5 , ""jkl"" ) ; var_11 . put ( 6 , ""mno"" ) ; var_11 . put ( 7 , ""pqrs"" ) ; var_11 . put ( 8 , ""tuv"" ) ; var_11 . put ( 9 , ""wxyz"" ) ; Queue < String > var_31 = new LinkedList < String > ( ) ; int var_32 = 0 ; int var_36 = Integer . parseInt ( var_2 . substring ( var_32 , var_32 + 1 ) ) ; String var_38 = var_11 . get ( var_36 ) ; var_32 ++ ; for ( int var_39 = 0 ; var_39 < var_38 . length ( ) ; var_39 ++ ) { var_31 . offer ( var_38 . substring ( var_39 , var_39 + 1 ) ) ; } int size = var_31 . size ( ) ; while ( var_32 < var_2 . length ( ) && ! var_31 . isEmpty ( ) ) { String var_44 = var_31 . poll ( ) ; var_36 = Integer . parseInt ( var_2 . substring ( var_32 , var_32 + 1 ) ) ; var_38 = var_11 . get ( var_36 ) ; for ( int var_39 = 0 ; var_39 < var_38 . length ( ) ; var_39 ++ ) { var_31 . offer ( var_44 + var_38 . substring ( var_39 , var_39 + 1 ) ) ; } size -- ; if ( size == 0 && var_32 < var_2 . length ( ) - 1 ) { var_32 ++ ; size = var_31 . size ( ) ; } } while ( ! var_31 . isEmpty ( ) ) { var_5 . add ( var_31 . poll ( ) ) ; } return var_5 ; } " 165,Shuffle an Array_2.java,"private void swap(int[] nums, int x, int y) { int temp = nums[y]; nums[y] = nums[x]; nums[x] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_4 ; } " 166,243. Shortest Word Distance_1.java,"public int shortestDistance(String[] words, String word1, String word2) { Integer p1 = null, p2 = null; int min = Integer.MAX_VALUE; for (int i = 0; i < words.length; i++) { if (words[i].equals(word1)) p1 = i; if (words[i].equals(word2)) p2 = i; if (p1 != null && p2 != null) min = Math.min(min, Math.abs(p1 - p2)); } return min; }","public int sample_funcname ( String [ ] var_1 , String var_2 , String var_3 ) { Integer var_6 = null , var_7 = null ; int min = Integer . MAX_VALUE ; for ( int var_11 = 0 ; var_11 < var_1 . length ; var_11 ++ ) { if ( var_1 [ var_11 ] . equals ( var_2 ) ) var_6 = var_11 ; if ( var_1 [ var_11 ] . equals ( var_3 ) ) var_7 = var_11 ; if ( var_6 != null && var_7 != null ) min = Math . min ( min , Math . abs ( var_6 - var_7 ) ) ; } return min ; } " 167,15. 3Sum_1.java,"public List> threeSum(int[] nums) { List> result = new ArrayList<>(); Arrays.sort(nums); int n = nums.length; for (int i = 0; i < n - 2; i++) { if (i > 0 && nums[i] == nums[i - 1]) continue; int lo = i + 1, hi = n - 1; while (lo < hi) { int sum = nums[i] + nums[lo] + nums[hi]; if (sum == 0) { result.add(Arrays.asList(nums[i], nums[lo], nums[hi])); while (lo < hi && nums[lo] == nums[lo + 1]) lo++; while (lo < hi && nums[hi] == nums[hi - 1]) hi--; lo++; hi--; } else if (sum < 0) { lo++; } else { hi--; } } } return result; }","public List < List < Integer >> var_2 ( int [ ] var_3 ) { List < List < Integer >> var_5 = new ArrayList < > ( ) ; Arrays . sort ( var_3 ) ; int var_9 = var_3 . length ; for ( int var_11 = 0 ; var_11 < var_9 - 2 ; var_11 ++ ) { if ( var_11 > 0 && var_3 [ var_11 ] == var_3 [ var_11 - 1 ] ) continue ; int var_14 = var_11 + 1 , var_15 = var_9 - 1 ; while ( var_14 < var_15 ) { int var_16 = var_3 [ var_11 ] + var_3 [ var_14 ] + var_3 [ var_15 ] ; if ( var_16 == 0 ) { var_5 . add ( Arrays . asList ( var_3 [ var_11 ] , var_3 [ var_14 ] , var_3 [ var_15 ] ) ) ; while ( var_14 < var_15 && var_3 [ var_14 ] == var_3 [ var_14 + 1 ] ) var_14 ++ ; while ( var_14 < var_15 && var_3 [ var_15 ] == var_3 [ var_15 - 1 ] ) var_15 -- ; var_14 ++ ; var_15 -- ; } else if ( var_16 < 0 ) { var_14 ++ ; } else { var_15 -- ; } } } return var_5 ; } " 168,43. Multiply Strings_2.java,"private int toInt(String s, int x) { return s.charAt(x) - '0'; }","private int sample_funcname ( String var_1 , int var_2 ) { return var_1 . charAt ( var_2 ) - '0' ; } " 169,496. Next Greater Element I_2.java,"private int check(int[] nums, int index, int val) { for (int i = index; i < nums.length; i++) { if (nums[i] > val) return nums[i]; } return -1; }","private int sample_funcname ( int [ ] var_0 , int var_1 , int var_2 ) { for ( int var_3 = var_1 ; var_3 < var_0 . length ; var_3 ++ ) { if ( var_0 [ var_3 ] > var_2 ) return var_0 [ var_3 ] ; } return - 1 ; } " 170,Reverse String_1.java,"public void reverseString(char[] s) { if (s == null || s.length <= 1) { return; } int n = s.length; for (int i = 0; i < n / 2; i++) { char temp = s[i]; s[i] = s[n - i - 1]; s[n - i - 1] = temp; } }","public void var_0 ( char [ ] var_1 ) { if ( var_1 == null || var_1 . length <= 1 ) { return ; } int var_5 = var_1 . length ; for ( int var_7 = 0 ; var_7 < var_5 / 2 ; var_7 ++ ) { char var_9 = var_1 [ var_7 ] ; var_1 [ var_7 ] = var_1 [ var_5 - var_7 - 1 ] ; var_1 [ var_5 - var_7 - 1 ] = var_9 ; } } " 171,Matrix Zigzag Traversal_1.java,"public int[] printZMatrix(int[][] matrix) { int[] rst = null; if (matrix == null || matrix.length == 0 || matrix[0] == null || matrix[0].length == 0) { return rst; } int n = matrix.length; int m = matrix[0].length; rst = new int[n * m]; if (matrix.length == 1) { return matrix[0]; } int i = 0, j = 0; int ind = 0; rst[ind] = matrix[i][j]; ind++; while (ind < rst.length) { if (j + 1 < m || i + 1 < n) { if (j + 1 < m) j++; else if (i + 1 < n) i++; rst[ind++] = matrix[i][j]; } while (j - 1 >= 0 && i + 1 < n) { rst[ind++] = matrix[++i][--j]; } if (j + 1 < m || i + 1 < n) { if (i + 1 < n) i++; else if (j + 1 < m) j++; rst[ind++] = matrix[i][j]; } while (j + 1 < m && i - 1 >= 0) { rst[ind++] = matrix[--i][++j]; } } return rst; }","public int [ ] sample_funcname ( int [ ] [ ] var_0 ) { int [ ] var_2 = null ; if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return var_2 ; } int var_5 = var_0 . length ; int var_6 = var_0 [ 0 ] . length ; var_2 = new int [ var_5 * var_6 ] ; if ( var_0 . length == 1 ) { return var_0 [ 0 ] ; } int var_8 = 0 , var_9 = 0 ; int var_10 = 0 ; var_2 [ var_10 ] = var_0 [ var_8 ] [ var_9 ] ; var_10 ++ ; while ( var_10 < var_2 . length ) { if ( var_9 + 1 < var_6 || var_8 + 1 < var_5 ) { if ( var_9 + 1 < var_6 ) var_9 ++ ; else if ( var_8 + 1 < var_5 ) var_8 ++ ; var_2 [ var_10 ++ ] = var_0 [ var_8 ] [ var_9 ] ; } while ( var_9 - 1 >= 0 && var_8 + 1 < var_5 ) { var_2 [ var_10 ++ ] = var_0 [ ++ var_8 ] [ -- var_9 ] ; } if ( var_9 + 1 < var_6 || var_8 + 1 < var_5 ) { if ( var_8 + 1 < var_5 ) var_8 ++ ; else if ( var_9 + 1 < var_6 ) var_9 ++ ; var_2 [ var_10 ++ ] = var_0 [ var_8 ] [ var_9 ] ; } while ( var_9 + 1 < var_6 && var_8 - 1 >= 0 ) { var_2 [ var_10 ++ ] = var_0 [ -- var_8 ] [ ++ var_9 ] ; } } return var_2 ; } " 172,1213. Intersection of Three Sorted Arrays_3.java,"public List arraysIntersection(int[] arr1, int[] arr2, int[] arr3) { List rst = new LinkedList<>(); int i = 0, j = 0, k = 0; while (i < arr1.length && j < arr2.length && k < arr3.length) { if (arr1[i] == arr2[j] && arr2[j] == arr3[k]) { if (rst.isEmpty() || arr1[i] != rst.get(rst.size() - 1)) rst.add(arr1[i]); i++; j++; k++; } else if (arr1[i] < arr2[j]) i++; else if (arr2[j] < arr3[k]) j++; else k++; } return rst; }","public List < Integer > var_1 ( int [ ] var_2 , int [ ] var_3 , int [ ] var_4 ) { List < Integer > var_7 = new LinkedList < > ( ) ; int var_9 = 0 , var_10 = 0 , var_11 = 0 ; while ( var_9 < var_2 . length && var_10 < var_3 . length && var_11 < var_4 . length ) { if ( var_2 [ var_9 ] == var_3 [ var_10 ] && var_3 [ var_10 ] == var_4 [ var_11 ] ) { if ( var_7 . isEmpty ( ) || var_2 [ var_9 ] != var_7 . get ( var_7 . size ( ) - 1 ) ) var_7 . add ( var_2 [ var_9 ] ) ; var_9 ++ ; var_10 ++ ; var_11 ++ ; } else if ( var_2 [ var_9 ] < var_3 [ var_10 ] ) var_9 ++ ; else if ( var_3 [ var_10 ] < var_4 [ var_11 ] ) var_10 ++ ; else var_11 ++ ; } return var_7 ; } " 173,219. Contains Duplicate II_1.java,"public boolean containsNearbyDuplicate(int[] nums, int k) { if (nums == null || nums.length == 0 || k <= 0) { return false; } Set set = new HashSet<>(); for (int i = 0; i < nums.length; i++) { if (i > k) { set.remove(nums[i - k - 1]); } if (!set.add(nums[i])) { return true; } } return false; }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { if ( var_1 == null || var_1 . length == 0 || var_2 <= 0 ) { return false ; } Set < Integer > var_9 = new HashSet < > ( ) ; for ( int var_10 = 0 ; var_10 < var_1 . length ; var_10 ++ ) { if ( var_10 > var_2 ) { var_9 . remove ( var_1 [ var_10 - var_2 - 1 ] ) ; } if ( ! var_9 . add ( var_1 [ var_10 ] ) ) { return true ; } } return false ; } " 174,67. Add Binary_1.java,"public String addBinary(String a, String b) { StringBuilder sb = new StringBuilder(); int i = a.length() - 1, j = b.length() -1, carry = 0; while (i >= 0 || j >= 0) { int sum = carry; if (i >= 0) sum += a.charAt(i--) - '0'; if (j >= 0) sum += b.charAt(j--) - '0'; sb.insert(0, sum % 2); carry = sum / 2; } if (carry != 0) sb.insert(0, carry); return sb.toString(); }","public String var_0 ( String var_2 , String var_3 ) { StringBuilder var_5 = new StringBuilder ( ) ; int var_8 = var_2 . length ( ) - 1 , var_9 = var_3 . length ( ) - 1 , var_11 = 0 ; while ( var_8 >= 0 || var_9 >= 0 ) { int var_12 = var_11 ; if ( var_8 >= 0 ) var_12 += var_2 . charAt ( var_8 -- ) - '0' ; if ( var_9 >= 0 ) var_12 += var_3 . charAt ( var_9 -- ) - '0' ; var_5 . insert ( 0 , var_12 % 2 ) ; var_11 = var_12 / 2 ; } if ( var_11 != 0 ) var_5 . insert ( 0 , var_11 ) ; return var_5 . toString ( ) ; } " 175,70. Climbing Stairs_1.java,"public int climbStairs(int n) { if (n <= 1) { return 1; } int[] dp = new int[n + 1]; dp[0] = 1; dp[1] = 1; for (int i = 2; i <= n; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[n]; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 1 ) { return 1 ; } int [ ] var_2 = new int [ var_0 + 1 ] ; var_2 [ 0 ] = 1 ; var_2 [ 1 ] = 1 ; for ( int var_5 = 2 ; var_5 <= var_0 ; var_5 ++ ) { var_2 [ var_5 ] = var_2 [ var_5 - 1 ] + var_2 [ var_5 - 2 ] ; } return var_2 [ var_0 ] ; } " 176,Construct Binary Tree from Inorder and Postorder Traversal_1.java,"public int findMid(int[] arr, int start, int end, int key) { for (int i = start; i <= end; i++) { if (arr[i] == key) { return i; } } return -1; }","public int sample_funcname ( int [ ] var_0 , int var_1 , int var_2 , int var_3 ) { for ( int var_4 = var_1 ; var_4 <= var_2 ; var_4 ++ ) { if ( var_0 [ var_4 ] == var_3 ) { return var_4 ; } } return - 1 ; } " 177,[lint]. Compare Strings_1.java,"public boolean compareStrings(String A, String B) { if (A == null || B == null || A.length() < B.length()) { return false; } int[] count = new int[26]; for (char c : A.toCharArray()) { count[c - 'A']++; } for (char c : B.toCharArray()) { count[c - 'A']--; if (count[c - 'A'] < 0) { return false; } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) < var_3 . length ( ) ) { return false ; } int [ ] var_7 = new int [ 26 ] ; for ( char var_9 : var_2 . toCharArray ( ) ) { var_7 [ var_9 - 'A' ] ++ ; } for ( char var_9 : var_3 . toCharArray ( ) ) { var_7 [ var_9 - 'A' ] -- ; if ( var_7 [ var_9 - 'A' ] < 0 ) { return false ; } } return true ; } " 178,42. Trapping Rain Water_3.java,"public int trap(int[] heights) { if (heights == null || heights.length == 0) return 0; int maxIndex = 0; for (int i = 0; i < heights.length; i++) { if (heights[i] > heights[maxIndex]) maxIndex = i; } int sum = 0, prev = 0; for (int i = 0; i < maxIndex; i++) { if (heights[i] > prev) { sum += (maxIndex - i) * (heights[i] - prev); prev = heights[i]; } sum -= heights[i]; } prev = 0; for (int i = heights.length - 1; i > maxIndex; i--) { if (heights[i] > prev) { sum += (i - maxIndex) * (heights[i] - prev); prev = heights[i]; } sum -= heights[i]; } return sum; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = 0 ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { if ( var_0 [ var_5 ] > var_0 [ var_4 ] ) var_4 = var_5 ; } int var_6 = 0 , var_7 = 0 ; for ( int var_5 = 0 ; var_5 < var_4 ; var_5 ++ ) { if ( var_0 [ var_5 ] > var_7 ) { var_6 += ( var_4 - var_5 ) * ( var_0 [ var_5 ] - var_7 ) ; var_7 = var_0 [ var_5 ] ; } var_6 -= var_0 [ var_5 ] ; } var_7 = 0 ; for ( int var_5 = var_0 . length - 1 ; var_5 > var_4 ; var_5 -- ) { if ( var_0 [ var_5 ] > var_7 ) { var_6 += ( var_5 - var_4 ) * ( var_0 [ var_5 ] - var_7 ) ; var_7 = var_0 [ var_5 ] ; } var_6 -= var_0 [ var_5 ] ; } return var_6 ; } " 179,202. Happy Number_1.java,"private long process(long n) { long sum = 0; while (n != 0) { long mod = n % 10; sum += mod * mod; n /= 10; } return sum; }","private long sample_funcname ( long var_0 ) { long var_2 = 0 ; while ( var_0 != 0 ) { long var_4 = var_0 % 10 ; var_2 += var_4 * var_4 ; var_0 /= 10 ; } return var_2 ; } " 180,Subsets II_1.java,"private void dfs(List> result, List list, int[] nums, int depth) { for (int i = depth; i < nums.length; i++) { if (i > depth && nums[i] == nums[i - 1]) continue; list.add(nums[i]); result.add(new ArrayList<>(list)); dfs(result, list, nums, i + 1); list.remove(list.size() - 1); } }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int [ ] nums , int depth ) { for ( int i = depth ; i < nums . length ; i ++ ) { if ( i > depth && nums [ i ] == nums [ i - 1 ] ) continue ; list . add ( nums [ i ] ) ; result . add ( new ArrayList < > ( list ) ) ; dfs ( result , list , nums , i + 1 ) ; list . remove ( list . size ( ) - 1 ) ; } } " 181,String Permutation_1.java,"public boolean Permutation(String A, String B) { if (A == null || B == null || A.length() != B.length()) { return false; } final Map strMap = new HashMap<>(); for (int i = 0; i < A.length(); i++) { final char charA = A.charAt(i); final char charB = B.charAt(i); if (!strMap.containsKey(charA)) { strMap.put(charA, 0); } strMap.put(charA, strMap.get(charA) + 1); if (!strMap.containsKey(charB)) { strMap.put(charB, 0); } strMap.put(charB, strMap.get(charB) - 1); } for (Map.Entry entry : strMap.entrySet()) { if (entry.getValue() != 0) { return false; } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) != var_3 . length ( ) ) { return false ; } final Map < Character , Integer > var_10 = new HashMap < > ( ) ; for ( int var_12 = 0 ; var_12 < var_2 . length ( ) ; var_12 ++ ) { final char var_14 = var_2 . charAt ( var_12 ) ; final char var_15 = var_3 . charAt ( var_12 ) ; if ( ! var_10 . containsKey ( var_14 ) ) { var_10 . put ( var_14 , 0 ) ; } var_10 . put ( var_14 , var_10 . get ( var_14 ) + 1 ) ; if ( ! var_10 . containsKey ( var_15 ) ) { var_10 . put ( var_15 , 0 ) ; } var_10 . put ( var_15 , var_10 . get ( var_15 ) - 1 ) ; } for ( Map . Entry < Character , Integer > var_21 : var_10 . entrySet ( ) ) { if ( var_21 . getValue ( ) != 0 ) { return false ; } } return true ; } " 182,416. Partition Equal Subset Sum_1.java,"public boolean canPartition(int[] nums) { if (nums == null || nums.length < 2) return false; int sum = 0; for (int num : nums) sum += num; if (sum % 2 != 0) return false; sum /= 2; boolean[] dp = new boolean[sum + 1]; dp[0] = true; for (int i = 0; i < nums.length; i++) { int num = nums[i]; for (int j = sum; j >= num; j--) { dp[j] = dp[j] || dp[j - num]; } } return dp[sum]; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length < 2 ) return false ; int var_6 = 0 ; for ( int var_7 : var_1 ) var_6 += var_7 ; if ( var_6 % 2 != 0 ) return false ; var_6 /= 2 ; boolean [ ] var_10 = new boolean [ var_6 + 1 ] ; var_10 [ 0 ] = true ; for ( int var_11 = 0 ; var_11 < var_1 . length ; var_11 ++ ) { int var_7 = var_1 [ var_11 ] ; for ( int var_12 = var_6 ; var_12 >= var_7 ; var_12 -- ) { var_10 [ var_12 ] = var_10 [ var_12 ] || var_10 [ var_12 - var_7 ] ; } } return var_10 [ var_6 ] ; } " 183,26.Remove Duplicates from Sorted Array_2.java,"public int removeDuplicates(int[] nums) { if (nums == null) { return 0; } if (nums.length <= 1) { return nums.length; } int currPos = 0; int movingPos = 1; while (movingPos < nums.length) { while(movingPos < nums.length && nums[currPos] == nums[movingPos]) { movingPos++; } if (movingPos < nums.length && nums[currPos] != nums[movingPos]) { nums[currPos + 1] = nums[movingPos]; currPos++; movingPos++; } } return currPos + 1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null ) { return 0 ; } if ( var_0 . length <= 1 ) { return var_0 . length ; } int var_5 = 0 ; int var_6 = 1 ; while ( var_6 < var_0 . length ) { while ( var_6 < var_0 . length && var_0 [ var_5 ] == var_0 [ var_6 ] ) { var_6 ++ ; } if ( var_6 < var_0 . length && var_0 [ var_5 ] != var_0 [ var_6 ] ) { var_0 [ var_5 + 1 ] = var_0 [ var_6 ] ; var_5 ++ ; var_6 ++ ; } } return var_5 + 1 ; } " 184,340. Longest Substring with At Most K Distinct Characters_2.java,"public int lengthOfLongestSubstringKDistinct(String s, int k) { if (s == null || s.length() == 0) return 0; int n = s.length(); Map lastOccurMap = new HashMap<>(); int left = 0, right = 0, max = 0; while (right < n) { if (lastOccurMap.size() <= k) { lastOccurMap.put(s.charAt(right), right++); } if (lastOccurMap.size() > k) { int leftMost = right; for (int index : lastOccurMap.values()) { leftMost = Math.min(leftMost, index); } lastOccurMap.remove(s.charAt(leftMost)); left = leftMost + 1; } max = Math.max(max, right - left); } return max; }","public int sample_funcname ( String var_1 , int var_2 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) return 0 ; int var_6 = var_1 . length ( ) ; Map < Character , Integer > var_11 = new HashMap < > ( ) ; int var_12 = 0 , var_13 = 0 , max = 0 ; while ( var_13 < var_6 ) { if ( var_11 . size ( ) <= var_2 ) { var_11 . put ( var_1 . charAt ( var_13 ) , var_13 ++ ) ; } if ( var_11 . size ( ) > var_2 ) { int var_18 = var_13 ; for ( int var_20 : var_11 . values ( ) ) { var_18 = Math . min ( var_18 , var_20 ) ; } var_11 . remove ( var_1 . charAt ( var_18 ) ) ; var_12 = var_18 + 1 ; } max = Math . max ( max , var_13 - var_12 ) ; } return max ; } " 185,Longest Substring Without Repeating Characters_4.java,"public int lengthOfLongestSubstring(String s) { if (s == null || s.length() == 0) { return 0; } HashMap map = new HashMap(); int count = 0; int max = 0; for (int i = 0; i < s.length(); i++) { if (!map.containsKey(s.charAt(i))) { map.put(s.charAt(i), i); count++; } else { i = map.get(s.charAt(i)); map = new HashMap(); count = 0; } max = Math.max(max, count); } return max; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } HashMap < Character , Integer > var_8 = new HashMap < Character , Integer > ( ) ; int var_9 = 0 ; int max = 0 ; for ( int var_11 = 0 ; var_11 < var_1 . length ( ) ; var_11 ++ ) { if ( ! var_8 . containsKey ( var_1 . charAt ( var_11 ) ) ) { var_8 . put ( var_1 . charAt ( var_11 ) , var_11 ) ; var_9 ++ ; } else { var_11 = var_8 . get ( var_1 . charAt ( var_11 ) ) ; var_8 = new HashMap < Character , Integer > ( ) ; var_9 = 0 ; } max = Math . max ( max , var_9 ) ; } return max ; } " 186,Missing Ranges_1.java,"public String printRange(int from, int to) { return (from == to) ? String.valueOf(from) : from + ""->"" + to; }","public String var_0 ( int var_1 , int var_2 ) { return ( var_1 == var_2 ) ? String . valueOf ( var_1 ) : var_1 + ""->"" + var_2 ; } " 187,741. Cherry Pickup_1.java,"private String getKey(int i, int j) { return i + ""@"" + j; }","private String var_0 ( int var_1 , int var_2 ) { return var_1 + ""@"" + var_2 ; } " 188,Closest Number in Sorted Array_1.java,"public int closestNumber(int[] A, int target) { if (A == null || A.length == 0) { return -1; } int start = 0; int end = A.length - 1; int mid; while (start + 1 < end) { mid = start + (end - start) / 2; if (A[mid] == target) { return mid; } else if (mid - 1 >= 0 && A[mid - 1] <= target && target < A[mid]) { return (target - A[mid - 1]) < (A[mid] - target) ? (mid - 1) : mid; } else if (mid + 1 < A.length && A[mid] < target && target <= A[mid + 1]) { return (target - A[mid]) < (A[mid + 1] - target) ? mid : mid + 1; } else if (A[mid] < target) { start = mid; } else { end = mid; } } return (target - A[start]) < (A[end] - target) ? start : end; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int var_6 = 0 ; int var_7 = var_0 . length - 1 ; int var_8 ; while ( var_6 + 1 < var_7 ) { var_8 = var_6 + ( var_7 - var_6 ) / 2 ; if ( var_0 [ var_8 ] == var_1 ) { return var_8 ; } else if ( var_8 - 1 >= 0 && var_0 [ var_8 - 1 ] <= var_1 && var_1 < var_0 [ var_8 ] ) { return ( var_1 - var_0 [ var_8 - 1 ] ) < ( var_0 [ var_8 ] - var_1 ) ? ( var_8 - 1 ) : var_8 ; } else if ( var_8 + 1 < var_0 . length && var_0 [ var_8 ] < var_1 && var_1 <= var_0 [ var_8 + 1 ] ) { return ( var_1 - var_0 [ var_8 ] ) < ( var_0 [ var_8 + 1 ] - var_1 ) ? var_8 : var_8 + 1 ; } else if ( var_0 [ var_8 ] < var_1 ) { var_6 = var_8 ; } else { var_7 = var_8 ; } } return ( var_1 - var_0 [ var_6 ] ) < ( var_0 [ var_7 ] - var_1 ) ? var_6 : var_7 ; } " 189,218. The Skyline Problem_1.java,"private boolean isInvalid(int[][] buildings) { return buildings == null || buildings.length == 0 || buildings[0] == null || buildings[0].length == 0; }","private boolean var_0 ( int [ ] [ ] var_1 ) { return var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 ; } " 190,Sort Letters by Case_1.java,"private void swap(char[] chars, int x, int y) { char temp = chars[x]; chars[x] = chars[y]; chars[y] = temp; }","private void var_0 ( char [ ] var_1 , int var_2 , int var_3 ) { char var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 191,69. Sqrt(x)_1.java,"public int mySqrt(int x) { long start = 0; long end = x; while (start + 1 < end) { long mid = (start + end) >> 1; if (mid * mid < x) { start = mid; } else if (mid * mid > x) { end = mid; } else { return (int)mid; } } if (end * end <= x) { return (int)end; } else { return (int)start; } }","public int sample_funcname ( int var_0 ) { long var_2 = 0 ; long var_3 = var_0 ; while ( var_2 + 1 < var_3 ) { long var_5 = ( var_2 + var_3 ) >> 1 ; if ( var_5 * var_5 < var_0 ) { var_2 = var_5 ; } else if ( var_5 * var_5 > var_0 ) { var_3 = var_5 ; } else { return ( int ) var_5 ; } } if ( var_3 * var_3 <= var_0 ) { return ( int ) var_3 ; } else { return ( int ) var_2 ; } } " 192,Partition Array_1.java,"public void swap(int[] nums, int x, int y){ int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","public void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 193,72. Edit Distance_6.java,"public int minDistance(String word1, String word2) { if (word1 == null && word2 != null) { return word2.length(); } else if (word1 != null && word2 == null) { return word1.length(); } else if (word1 == null && word2 == null) { return 0; } int[][] DP = new int[word1.length() + 1][word2.length() + 1]; for (int i = 1; i <= word1.length(); i++) { DP[i][0] = i; } for (int j = 1; j <= word2.length(); j++) { DP[0][j] = j; } for (int i = 1; i <= word1.length(); i++) { for (int j = 1; j <= word2.length(); j++) { DP[i][j] = Math.min(Math.min(DP[i - 1][j] + 1, DP[i][j - 1] + 1), word1.charAt(i - 1) == word2.charAt(j - 1) ? DP[i - 1][j - 1] : DP[i - 1][j - 1] + 1); } } return DP[word1.length()][word2.length()]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null && var_2 != null ) { return var_2 . length ( ) ; } else if ( var_1 != null && var_2 == null ) { return var_1 . length ( ) ; } else if ( var_1 == null && var_2 == null ) { return 0 ; } int [ ] [ ] var_7 = new int [ var_1 . length ( ) + 1 ] [ var_2 . length ( ) + 1 ] ; for ( int var_8 = 1 ; var_8 <= var_1 . length ( ) ; var_8 ++ ) { var_7 [ var_8 ] [ 0 ] = var_8 ; } for ( int var_9 = 1 ; var_9 <= var_2 . length ( ) ; var_9 ++ ) { var_7 [ 0 ] [ var_9 ] = var_9 ; } for ( int var_8 = 1 ; var_8 <= var_1 . length ( ) ; var_8 ++ ) { for ( int var_9 = 1 ; var_9 <= var_2 . length ( ) ; var_9 ++ ) { var_7 [ var_8 ] [ var_9 ] = Math . min ( Math . min ( var_7 [ var_8 - 1 ] [ var_9 ] + 1 , var_7 [ var_8 ] [ var_9 - 1 ] + 1 ) , var_1 . charAt ( var_8 - 1 ) == var_2 . charAt ( var_9 - 1 ) ? var_7 [ var_8 - 1 ] [ var_9 - 1 ] : var_7 [ var_8 - 1 ] [ var_9 - 1 ] + 1 ) ; } } return var_7 [ var_1 . length ( ) ] [ var_2 . length ( ) ] ; } " 194,78. Subsets_2.java,"private void dfs(List> result, List list, int[] nums, int depth) { for (int i = depth; i < nums.length; i++) { list.add(nums[i]); result.add(new ArrayList<>(list)); dfs(result, list, nums, i + 1); list.remove(list.size() - 1); } }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int [ ] nums , int depth ) { for ( int i = depth ; i < nums . length ; i ++ ) { list . add ( nums [ i ] ) ; result . add ( new ArrayList < > ( list ) ) ; dfs ( result , list , nums , i + 1 ) ; list . remove ( list . size ( ) - 1 ) ; } } " 195,House Robber II_2.java,"public int rob(int[] nums) { if (nums == null || nums.length == 0) { return 0; } else if (nums.length == 1) { return nums[0]; } int n = nums.length; long[][] dp = new long[2][2]; dp[0][0] = 0; dp[1][0] = 0; dp[1][1] = nums[0]; for (int i = 2; i < n; i++) { dp[i % 2][0] = Math.max(dp[(i - 1) % 2][0], dp[(i - 2) % 2][0] + nums[i - 1]); dp[i % 2][1] = Math.max(dp[(i - 1) % 2][1], dp[(i - 2) % 2][1] + nums[i - 1]); } dp[n % 2][0] = Math.max(dp[(n - 1) % 2][0], dp[(n - 2) % 2][0] + nums[n - 1]); dp[n % 2][1] = dp[(n - 1) % 2][1]; return (int) Math.max(dp[n % 2][0], dp[n % 2][1]); }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } else if ( var_0 . length == 1 ) { return var_0 [ 0 ] ; } int var_5 = var_0 . length ; long [ ] [ ] var_7 = new long [ 2 ] [ 2 ] ; var_7 [ 0 ] [ 0 ] = 0 ; var_7 [ 1 ] [ 0 ] = 0 ; var_7 [ 1 ] [ 1 ] = var_0 [ 0 ] ; for ( int var_8 = 2 ; var_8 < var_5 ; var_8 ++ ) { var_7 [ var_8 % 2 ] [ 0 ] = Math . max ( var_7 [ ( var_8 - 1 ) % 2 ] [ 0 ] , var_7 [ ( var_8 - 2 ) % 2 ] [ 0 ] + var_0 [ var_8 - 1 ] ) ; var_7 [ var_8 % 2 ] [ 1 ] = Math . max ( var_7 [ ( var_8 - 1 ) % 2 ] [ 1 ] , var_7 [ ( var_8 - 2 ) % 2 ] [ 1 ] + var_0 [ var_8 - 1 ] ) ; } var_7 [ var_5 % 2 ] [ 0 ] = Math . max ( var_7 [ ( var_5 - 1 ) % 2 ] [ 0 ] , var_7 [ ( var_5 - 2 ) % 2 ] [ 0 ] + var_0 [ var_5 - 1 ] ) ; var_7 [ var_5 % 2 ] [ 1 ] = var_7 [ ( var_5 - 1 ) % 2 ] [ 1 ] ; return ( int ) Math . max ( var_7 [ var_5 % 2 ] [ 0 ] , var_7 [ var_5 % 2 ] [ 1 ] ) ; } " 196,Ones and Zeroes_3.java,"public int findMaxForm(String[] strs, int m, int n) { if (strs == null || strs.length == 0 || (m == 0 && n == 0)) { return 0; } int len = strs.length; int[][][] dp = new int[m + 1][n + 1][len + 1]; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { for (int k = 0; k <= len; k++) { if (k == 0 || (i == 0 && j == 0)) { dp[i][j][k] = 0; continue; } char[] ss = strs[k - 1].toCharArray(); int countOne = 0; int countZero = 0; for (char c : ss) { countOne += c == '1' ? 1 : 0; countZero += c == '0' ? 1 : 0; } dp[i][j][k] = dp[i][j][k - 1]; if (i >= countZero && j >= countOne) { dp[i][j][k] = Math.max(dp[i][j][k], dp[i - countZero][j - countOne][k - 1] + 1); } } } } return dp[m][n][len]; }","public int sample_funcname ( String [ ] var_1 , int var_2 , int var_3 ) { if ( var_1 == null || var_1 . length == 0 || ( var_2 == 0 && var_3 == 0 ) ) { return 0 ; } int var_7 = var_1 . length ; int [ ] [ ] [ ] var_9 = new int [ var_2 + 1 ] [ var_3 + 1 ] [ var_7 + 1 ] ; for ( int var_10 = 0 ; var_10 <= var_2 ; var_10 ++ ) { for ( int var_11 = 0 ; var_11 <= var_3 ; var_11 ++ ) { for ( int var_12 = 0 ; var_12 <= var_7 ; var_12 ++ ) { if ( var_12 == 0 || ( var_10 == 0 && var_11 == 0 ) ) { var_9 [ var_10 ] [ var_11 ] [ var_12 ] = 0 ; continue ; } char [ ] var_14 = var_1 [ var_12 - 1 ] . toCharArray ( ) ; int var_15 = 0 ; int var_16 = 0 ; for ( char var_17 : var_14 ) { var_15 += var_17 == '1' ? 1 : 0 ; var_16 += var_17 == '0' ? 1 : 0 ; } var_9 [ var_10 ] [ var_11 ] [ var_12 ] = var_9 [ var_10 ] [ var_11 ] [ var_12 - 1 ] ; if ( var_10 >= var_16 && var_11 >= var_15 ) { var_9 [ var_10 ] [ var_11 ] [ var_12 ] = Math . max ( var_9 [ var_10 ] [ var_11 ] [ var_12 ] , var_9 [ var_10 - var_16 ] [ var_11 - var_15 ] [ var_12 - 1 ] + 1 ) ; } } } } return var_9 [ var_2 ] [ var_3 ] [ var_7 ] ; } " 197,747. Largest Number At Least Twice of Others_1.java,"public int dominantIndex(int[] nums) { if (nums == null || nums.length <= 1) { return 0; } int max = -1; int leastMax = -1; int index = 0; for (int i = 0; i < nums.length; i++) { if (nums[i] >= max) { leastMax = max; max = nums[i]; index = i; } else { leastMax = Math.max(leastMax, nums[i]); } } return max >= leastMax * 2 ? index : -1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length <= 1 ) { return 0 ; } int max = - 1 ; int var_6 = - 1 ; int var_7 = 0 ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { if ( var_0 [ var_8 ] >= max ) { var_6 = max ; max = var_0 [ var_8 ] ; var_7 = var_8 ; } else { var_6 = Math . max ( var_6 , var_0 [ var_8 ] ) ; } } return max >= var_6 * 2 ? var_7 : - 1 ; } " 198,849. Maximize Distance to Closest Person_1.java,"public int maxDistToClosest(int[] seats) { if (seats == null || seats.length == 0) return -1; int n = seats.length, dist = 0; int start = seats[0] == 1 ? 0 : -1; for (int end = 1; end < n; end++) { if (seats[end] == 1) { if (start == -1) dist = end; else dist = Math.max(dist, (end - start) / 2); start = end; } } if (seats[n - 1] == 0) dist = Math.max(dist, n - 1 - start); return dist; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return - 1 ; int var_5 = var_0 . length , var_6 = 0 ; int var_7 = var_0 [ 0 ] == 1 ? 0 : - 1 ; for ( int var_8 = 1 ; var_8 < var_5 ; var_8 ++ ) { if ( var_0 [ var_8 ] == 1 ) { if ( var_7 == - 1 ) var_6 = var_8 ; else var_6 = Math . max ( var_6 , ( var_8 - var_7 ) / 2 ) ; var_7 = var_8 ; } } if ( var_0 [ var_5 - 1 ] == 0 ) var_6 = Math . max ( var_6 , var_5 - 1 - var_7 ) ; return var_6 ; } " 199,7. Reverse Integer_2.java,"public int reverse(int x) { long rst = 0; while (x != 0) { rst = rst * 10 + x % 10; x /= 10; if (rst > Integer.MAX_VALUE || rst < Integer.MIN_VALUE) return 0; } return (int) rst; }","public int sample_funcname ( int var_0 ) { long var_2 = 0 ; while ( var_0 != 0 ) { var_2 = var_2 * 10 + var_0 % 10 ; var_0 /= 10 ; if ( var_2 > Integer . MAX_VALUE || var_2 < Integer . MIN_VALUE ) return 0 ; } return ( int ) var_2 ; } " 200,Maximum Subarray II_4.java,"public int maxTwoSubArrays(ArrayList nums) { if (nums == null || nums.size() == 0) { return 0; } int preSum = 0; int minPreSum = 0; int max = Integer.MIN_VALUE; int n = nums.size(); int[] left = new int[n]; int[] right = new int[n]; for (int i = 0; i < n; i++) { preSum += nums.get(i); max = Math.max(max, preSum - minPreSum); minPreSum = Math.min(minPreSum, preSum); left[i] = max; } preSum = 0; minPreSum = 0; max = Integer.MIN_VALUE; for (int i = n - 1; i >= 0; i--) { preSum += nums.get(i); max = Math.max(max, preSum - minPreSum); minPreSum = Math.min(minPreSum, preSum); right[i] = max; } max = Integer.MIN_VALUE; for (int i = 0; i < n - 1; i++) { int rst = left[i] + right[i + 1]; max = Math.max(max, rst); } return max; }","public int sample_funcname ( ArrayList < Integer > var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return 0 ; } int var_6 = 0 ; int var_7 = 0 ; int max = Integer . MIN_VALUE ; int var_10 = var_2 . size ( ) ; int [ ] var_11 = new int [ var_10 ] ; int [ ] var_12 = new int [ var_10 ] ; for ( int var_13 = 0 ; var_13 < var_10 ; var_13 ++ ) { var_6 += var_2 . get ( var_13 ) ; max = Math . max ( max , var_6 - var_7 ) ; var_7 = Math . min ( var_7 , var_6 ) ; var_11 [ var_13 ] = max ; } var_6 = 0 ; var_7 = 0 ; max = Integer . MIN_VALUE ; for ( int var_13 = var_10 - 1 ; var_13 >= 0 ; var_13 -- ) { var_6 += var_2 . get ( var_13 ) ; max = Math . max ( max , var_6 - var_7 ) ; var_7 = Math . min ( var_7 , var_6 ) ; var_12 [ var_13 ] = max ; } max = Integer . MIN_VALUE ; for ( int var_13 = 0 ; var_13 < var_10 - 1 ; var_13 ++ ) { int var_18 = var_11 [ var_13 ] + var_12 [ var_13 + 1 ] ; max = Math . max ( max , var_18 ) ; } return max ; } " 201,256. Paint House_3.java,"public int minCost(int[][] costs) { if (costs == null || costs.length == 0) return 0; int n = costs.length, m = costs[0].length; int[][] dp = new int[2][m]; for (int i = 1; i <= n; i++) { int curr = i % 2, last = (i - 1) % 2; for (int j = 0; j < m; j++) { dp[curr][j] = Integer.MAX_VALUE; for (int k = 0; k < m; k++) { if (j == k) continue; dp[curr][j] = Math.min(dp[curr][j], dp[last][k] + costs[i - 1][j]); } } } int min = Integer.MAX_VALUE; for (int j = 0; j < m; j++) min = Math.min(min, dp[n%2][j]); return min; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_7 = new int [ 2 ] [ var_5 ] ; for ( int var_9 = 1 ; var_9 <= var_4 ; var_9 ++ ) { int var_10 = var_9 % 2 , var_11 = ( var_9 - 1 ) % 2 ; for ( int var_12 = 0 ; var_12 < var_5 ; var_12 ++ ) { var_7 [ var_10 ] [ var_12 ] = Integer . MAX_VALUE ; for ( int var_15 = 0 ; var_15 < var_5 ; var_15 ++ ) { if ( var_12 == var_15 ) continue ; var_7 [ var_10 ] [ var_12 ] = Math . min ( var_7 [ var_10 ] [ var_12 ] , var_7 [ var_11 ] [ var_15 ] + var_0 [ var_9 - 1 ] [ var_12 ] ) ; } } } int min = Integer . MAX_VALUE ; for ( int var_12 = 0 ; var_12 < var_5 ; var_12 ++ ) min = Math . min ( min , var_7 [ var_4 % 2 ] [ var_12 ] ) ; return min ; } " 202,1203. Sort Items by Groups Respecting Dependencies_2.java,"private List topoSort(Map> graph, Set set) { Map indegree = new HashMap<>(); for (int item : set) { indegree.put(item, 0); } for (int node : graph.keySet()) { if (!set.contains(node)) continue; for (int parent : graph.get(node)) { indegree.put(parent, indegree.get(parent) + 1); } } Queue queue = new LinkedList<>(); for (int key : indegree.keySet()) { if (indegree.get(key) == 0) queue.offer(key); } List rst = new ArrayList<>(); while (!queue.isEmpty()) { int node = queue.poll(); rst.add(node); if (!graph.containsKey(node)) continue; for (int parent : graph.get(node)) { indegree.put(parent, indegree.get(parent) - 1); if (indegree.get(parent) == 0) queue.offer(parent); } } return rst; }","private List < Integer > var_1 ( Map < Integer , List < Integer >> var_4 , Set < Integer > var_6 ) { Map < Integer , Integer > var_8 = new HashMap < > ( ) ; for ( int var_9 : var_6 ) { var_8 . put ( var_9 , 0 ) ; } for ( int var_13 : var_4 . keySet ( ) ) { if ( ! var_6 . contains ( var_13 ) ) continue ; for ( int var_16 : var_4 . get ( var_13 ) ) { var_8 . put ( var_16 , var_8 . get ( var_16 ) + 1 ) ; } } Queue < Integer > var_20 = new LinkedList < > ( ) ; for ( int var_21 : var_8 . keySet ( ) ) { if ( var_8 . get ( var_21 ) == 0 ) var_20 . offer ( var_21 ) ; } List < Integer > var_24 = new ArrayList < > ( ) ; while ( ! var_20 . isEmpty ( ) ) { int var_13 = var_20 . poll ( ) ; var_24 . add ( var_13 ) ; if ( ! var_4 . containsKey ( var_13 ) ) continue ; for ( int var_16 : var_4 . get ( var_13 ) ) { var_8 . put ( var_16 , var_8 . get ( var_16 ) - 1 ) ; if ( var_8 . get ( var_16 ) == 0 ) var_20 . offer ( var_16 ) ; } } return var_24 ; } " 203,Search a 2D Matrix_1.java,"public boolean searchMatrix(int[][] matrix, int target) { if (matrix == null || matrix.length == 0 || matrix[0].length == 0) { return false; } int row = matrix.length; int col = matrix[0].length; int start = 0; int end = row * col - 1; int mid; while (start + 1 < end) { mid = start + (end - start)/2; int num = matrix[mid/col][mid%col]; if (target == num) { return true; } else if (num < target) { start = mid; } else { end = mid; } } return (matrix[start/col][start%col] == target || matrix[end/col][end%col] == target); }","public boolean var_0 ( int [ ] [ ] var_1 , int var_2 ) { if ( var_1 == null || var_1 . length == 0 || var_1 [ 0 ] . length == 0 ) { return false ; } int var_6 = var_1 . length ; int var_7 = var_1 [ 0 ] . length ; int var_8 = 0 ; int var_10 = var_6 * var_7 - 1 ; int var_11 ; while ( var_8 + 1 < var_10 ) { var_11 = var_8 + ( var_10 - var_8 ) / 2 ; int var_13 = var_1 [ var_11 / var_7 ] [ var_11 % var_7 ] ; if ( var_2 == var_13 ) { return true ; } else if ( var_13 < var_2 ) { var_8 = var_11 ; } else { var_10 = var_11 ; } } return ( var_1 [ var_8 / var_7 ] [ var_8 % var_7 ] == var_2 || var_1 [ var_10 / var_7 ] [ var_10 % var_7 ] == var_2 ) ; } " 204,1106. Parsing A Boolean Expression_2.java,"private boolean evalList(List list, char op) { if (op == '&') { for (boolean b : list) { if (!b) return false; } return true; } for (boolean b : list) { if (b) return true; } return false; }","private boolean var_0 ( List < Boolean > var_3 , char var_4 ) { if ( var_4 == '&' ) { for ( boolean var_6 : var_3 ) { if ( ! var_6 ) return false ; } return true ; } for ( boolean var_6 : var_3 ) { if ( var_6 ) return true ; } return false ; } " 205,13. Roman to Integer_2.java,"private int getPlainSum(String s) { int sum = 0; for (int i = 0; i < s.length(); i++) { switch(s.charAt(i)) { case 'I': sum += 1; break; case 'V': sum += 5; break; case 'X': sum += 10; break; case 'L': sum += 50; break; case 'C': sum += 100; break; case 'D': sum += 500; break; case 'M': sum += 1000; break; default: return 0; } } return sum; }","private int sample_funcname ( String var_1 ) { int var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_1 . length ( ) ; var_4 ++ ) { switch ( var_1 . charAt ( var_4 ) ) { case 'I' : var_3 += 1 ; break ; case 'V' : var_3 += 5 ; break ; case 'X' : var_3 += 10 ; break ; case 'L' : var_3 += 50 ; break ; case 'C' : var_3 += 100 ; break ; case 'D' : var_3 += 500 ; break ; case 'M' : var_3 += 1000 ; break ; default : return 0 ; } } return var_3 ; } " 206,560. Subarray Sum Equals K_2.java,"private int[] calcPreSum(int[] nums) { int[] preSum = new int[nums.length + 1]; for (int i = 1; i <= nums.length; i++) { preSum[i] += preSum[i - 1] + nums[i - 1]; } return preSum; }","private int [ ] sample_funcname ( int [ ] var_0 ) { int [ ] var_3 = new int [ var_0 . length + 1 ] ; for ( int var_4 = 1 ; var_4 <= var_0 . length ; var_4 ++ ) { var_3 [ var_4 ] += var_3 [ var_4 - 1 ] + var_0 [ var_4 - 1 ] ; } return var_3 ; } " 207,Backpack V_3.java,"public int backPackV(int[] nums, int target) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int[] dp = new int [target + 1]; dp[0] = 1; for (int j = 1; j <= target; j++) { dp[j] = 0; } for (int i = 1; i <= n; i++) { for (int j = target; j >= 0; j--) { if (j - nums[i - 1] >= 0) { dp[j] += dp[j - nums[i - 1]]; } } } return dp[target]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = var_0 . length ; int [ ] var_7 = new int [ var_1 + 1 ] ; var_7 [ 0 ] = 1 ; for ( int var_8 = 1 ; var_8 <= var_1 ; var_8 ++ ) { var_7 [ var_8 ] = 0 ; } for ( int var_9 = 1 ; var_9 <= var_5 ; var_9 ++ ) { for ( int var_8 = var_1 ; var_8 >= 0 ; var_8 -- ) { if ( var_8 - var_0 [ var_9 - 1 ] >= 0 ) { var_7 [ var_8 ] += var_7 [ var_8 - var_0 [ var_9 - 1 ] ] ; } } } return var_7 [ var_1 ] ; } " 208,242. Valid Anagram_2.java,"private void countChars(String s, Map count, int val) { for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); count.putIfAbsent(c, 0); count.put(c, count.get(c) + val); } }","private void var_0 ( String var_2 , Map < Character , Integer > var_6 , int var_7 ) { for ( int var_9 = 0 ; var_9 < var_2 . length ( ) ; var_9 ++ ) { char var_12 = var_2 . charAt ( var_9 ) ; var_6 . putIfAbsent ( var_12 , 0 ) ; var_6 . put ( var_12 , var_6 . get ( var_12 ) + var_7 ) ; } } " 209,345. Reverse Vowels of a String_2.java,"public String reverseVowels(String s) { if (s == null || s.length() == 0) { return s; } List vowels = Arrays.asList('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'); List matches = new ArrayList<>(); for (int i = 0; i < s.length(); i++) { if (vowels.contains(s.charAt(i))) { matches.add(s.charAt(i)); } } StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char letter = s.charAt(i); if (vowels.contains(letter)) { int lastMatchIndex = matches.size() - 1; sb.append(matches.get(lastMatchIndex)); matches.remove(lastMatchIndex); } else { sb.append(letter); } } return sb.toString(); }","public String var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) { return var_2 ; } List < Character > var_20 = Arrays . asList ( 'a' , 'e' , 'i' , 'o' , 'u' , 'A' , 'E' , 'I' , 'O' , 'U' ) ; List < Character > var_22 = new ArrayList < > ( ) ; for ( int var_23 = 0 ; var_23 < var_2 . length ( ) ; var_23 ++ ) { if ( var_20 . contains ( var_2 . charAt ( var_23 ) ) ) { var_22 . add ( var_2 . charAt ( var_23 ) ) ; } } StringBuffer var_28 = new StringBuffer ( ) ; for ( int var_23 = 0 ; var_23 < var_2 . length ( ) ; var_23 ++ ) { char var_29 = var_2 . charAt ( var_23 ) ; if ( var_20 . contains ( var_29 ) ) { int var_32 = var_22 . size ( ) - 1 ; var_28 . append ( var_22 . get ( var_32 ) ) ; var_22 . remove ( var_32 ) ; } else { var_28 . append ( var_29 ) ; } } return var_28 . toString ( ) ; } " 210,Wiggle Sort_2.java,"private void swap(int[] nums, int x, int y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 211,Redundant Connection_1.java,"private boolean hasCycle(Map> graph, int curr, int target, int pre) { if (graph.get(curr).contains(target)) return true; for (int num : graph.get(curr)) { if (num == pre) continue; if (hasCycle(graph, num, target, curr)) return true; } return false; }","private boolean sample_funcname ( Map < Integer , Set < Integer >> graph , int curr , int target , int pre ) { if ( graph . get ( curr ) . contains ( target ) ) return true ; for ( int num : graph . get ( curr ) ) { if ( num == pre ) continue ; if ( hasCycle ( graph , num , target , curr ) ) return true ; } return false ; } " 212,953. Verifying an Alien Dictionary_1.java,"private boolean compareStr(String s1, String s2, int[] orderIndex) { if (s1.indexOf(s2) >= 0) return false; int size = Math.min(s1.length(), s2.length()); for (int i = 0; i < size; i++) { int c1 = s1.charAt(i), c2 = s2.charAt(i); if (orderIndex[c1] == orderIndex[c2]) continue; return orderIndex[c1] < orderIndex[c2]; } return true; }","private boolean var_0 ( String var_2 , String var_3 , int [ ] var_4 ) { if ( var_2 . indexOf ( var_3 ) >= 0 ) return false ; int var_10 = Math . min ( var_2 . length ( ) , var_3 . length ( ) ) ; for ( int var_11 = 0 ; var_11 < var_10 ; var_11 ++ ) { int var_13 = var_2 . charAt ( var_11 ) , var_14 = var_3 . charAt ( var_11 ) ; if ( var_4 [ var_13 ] == var_4 [ var_14 ] ) continue ; return var_4 [ var_13 ] < var_4 [ var_14 ] ; } return true ; } " 213,287. Find the Duplicate Number_1.java,"public int findDuplicate(int[] nums) { int slow = nums[0], fast = nums[nums[0]]; while (slow != fast) { slow = nums[slow]; fast = nums[nums[fast]]; } int finder = 0; while (slow != finder) { slow = nums[slow]; finder = nums[finder]; } return slow; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 [ 0 ] , var_3 = var_0 [ var_0 [ 0 ] ] ; while ( var_2 != var_3 ) { var_2 = var_0 [ var_2 ] ; var_3 = var_0 [ var_0 [ var_3 ] ] ; } int var_4 = 0 ; while ( var_2 != var_4 ) { var_2 = var_0 [ var_2 ] ; var_4 = var_0 [ var_4 ] ; } return var_2 ; } " 214,Backpack II_7.java,"public int backPackII(int m, int[] A, int V[]) { if (A == null || V == null || A.length == 0 || V.length == 0 || A.length != V.length || m <= 0) { return 0; } int[][] dp = new int[A.length + 1][m + 1]; dp[0][0] = 0; for (int i = 1; i <= A.length; i++) { for (int j = 0; j <= m; j++) { if (j - A[i - 1] >= 0) { dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - A[i - 1]] + V[i - 1]); } else { dp[i][j] = dp[i - 1][j]; } } } return dp[A.length][m]; }","public int sample_funcname ( int var_0 , int [ ] var_1 , int var_2 [ ] ) { if ( var_1 == null || var_2 == null || var_1 . length == 0 || var_2 . length == 0 || var_1 . length != var_2 . length || var_0 <= 0 ) { return 0 ; } int [ ] [ ] var_7 = new int [ var_1 . length + 1 ] [ var_0 + 1 ] ; var_7 [ 0 ] [ 0 ] = 0 ; for ( int var_8 = 1 ; var_8 <= var_1 . length ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 <= var_0 ; var_9 ++ ) { if ( var_9 - var_1 [ var_8 - 1 ] >= 0 ) { var_7 [ var_8 ] [ var_9 ] = Math . max ( var_7 [ var_8 - 1 ] [ var_9 ] , var_7 [ var_8 - 1 ] [ var_9 - var_1 [ var_8 - 1 ] ] + var_2 [ var_8 - 1 ] ) ; } else { var_7 [ var_8 ] [ var_9 ] = var_7 [ var_8 - 1 ] [ var_9 ] ; } } } return var_7 [ var_1 . length ] [ var_0 ] ; } " 215,Coins in a Line III_1.java,"public boolean firstWillWin(int[] values) { if (values == null || values.length == 0) { return false; } int n = values.length; int[][] dp = new int[n][n]; for (int i = 0; i < n; i++) { dp[i][i] = values[i]; } for (int len = 2; len <= n; len++) { for (int i = 0; i <= n - len; i++) { int j = len + i - 1; dp[i][j] = Math.max(values[i] - dp[i + 1][j], values[j] - dp[i][j - 1]); } } return dp[0][n - 1] >= 0; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return false ; } int var_5 = var_1 . length ; int [ ] [ ] var_6 = new int [ var_5 ] [ var_5 ] ; for ( int var_7 = 0 ; var_7 < var_5 ; var_7 ++ ) { var_6 [ var_7 ] [ var_7 ] = var_1 [ var_7 ] ; } for ( int var_9 = 2 ; var_9 <= var_5 ; var_9 ++ ) { for ( int var_7 = 0 ; var_7 <= var_5 - var_9 ; var_7 ++ ) { int var_11 = var_9 + var_7 - 1 ; var_6 [ var_7 ] [ var_11 ] = Math . max ( var_1 [ var_7 ] - var_6 [ var_7 + 1 ] [ var_11 ] , var_1 [ var_11 ] - var_6 [ var_7 ] [ var_11 - 1 ] ) ; } } return var_6 [ 0 ] [ var_5 - 1 ] >= 0 ; } " 216,47. Permutations II_1.java,"private void dfs(List> rst, List list, Queue queue) { if (queue.isEmpty()) { rst.add(new ArrayList<>(list)); return; } int size = queue.size(); Integer last = null; while (size-- > 0) { int val = queue.poll(); if (last != null && last == val) { queue.offer(val); continue; } list.add(val); dfs(rst, list, queue); list.remove(list.size() - 1); queue.offer(val); last = val; } }","private void sample_funcname ( List < List < Integer >> rst , List list , Queue < Integer > queue ) { if ( queue . isEmpty ( ) ) { rst . add ( new ArrayList < > ( list ) ) ; return ; } int size = queue . size ( ) ; Integer last = null ; while ( size -- > 0 ) { int val = queue . poll ( ) ; if ( last != null && last == val ) { queue . offer ( val ) ; continue ; } list . add ( val ) ; dfs ( rst , list , queue ) ; list . remove ( list . size ( ) - 1 ) ; queue . offer ( val ) ; last = val ; } } " 217,46. Permutations_1.java,"private void dfs(List> rst, List list, Queue queue) { if (queue.isEmpty()) { rst.add(new ArrayList<>(list)); return; } int size = queue.size(); while (size-- > 0) { int val = queue.poll(); list.add(val); dfs(rst, list, queue); list.remove(list.size() - 1); queue.offer(val); } }","private void sample_funcname ( List < List < Integer >> rst , List < Integer > list , Queue < Integer > queue ) { if ( queue . isEmpty ( ) ) { rst . add ( new ArrayList < > ( list ) ) ; return ; } int size = queue . size ( ) ; while ( size -- > 0 ) { int val = queue . poll ( ) ; list . add ( val ) ; dfs ( rst , list , queue ) ; list . remove ( list . size ( ) - 1 ) ; queue . offer ( val ) ; } } " 218,14. Longest Common Prefix_1.java,"public String longestCommonPrefix(String[] strs) { if (strs == null || strs.length == 0) { return """"; } Arrays.sort(strs); String head = strs[0]; String tail = strs[strs.length - 1]; int size = head.length() < tail.length() ? head.length() : tail.length(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < size; i++) { if (head.charAt(i) != tail.charAt(i)) { break; } sb.append(head.charAt(i)); } return sb.toString(); }","public String var_0 ( String [ ] var_2 ) { if ( var_2 == null || var_2 . length == 0 ) { return """" ; } Arrays . sort ( var_2 ) ; String var_9 = var_2 [ 0 ] ; String var_11 = var_2 [ var_2 . length - 1 ] ; int var_12 = var_9 . length ( ) < var_11 . length ( ) ? var_9 . length ( ) : var_11 . length ( ) ; StringBuffer var_14 = new StringBuffer ( ) ; for ( int var_15 = 0 ; var_15 < var_12 ; var_15 ++ ) { if ( var_9 . charAt ( var_15 ) != var_11 . charAt ( var_15 ) ) { break ; } var_14 . append ( var_9 . charAt ( var_15 ) ) ; } return var_14 . toString ( ) ; } " 219,Jump Game II_2.java,"public int jump(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length; int[] dp = new int[n]; dp[0] = 0; for (int i = 1; i < n; i++) { dp[i] = Integer.MAX_VALUE; for (int j = 0; j < i; j++) { if (j + nums[j] >= i) dp[i] = Math.min(dp[i], dp[j] + 1); } } return dp[n - 1]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length ; int [ ] var_5 = new int [ var_4 ] ; var_5 [ 0 ] = 0 ; for ( int var_7 = 1 ; var_7 < var_4 ; var_7 ++ ) { var_5 [ var_7 ] = Integer . MAX_VALUE ; for ( int var_10 = 0 ; var_10 < var_7 ; var_10 ++ ) { if ( var_10 + var_0 [ var_10 ] >= var_7 ) var_5 [ var_7 ] = Math . min ( var_5 [ var_7 ] , var_5 [ var_10 ] + 1 ) ; } } return var_5 [ var_4 - 1 ] ; } " 220,1306. Jump Game III_1.java,"private void add(Queue queue, int[] arr, int start) { int left = start - arr[start], right = start + arr[start]; if (left >= 0) queue.offer(left); if (right < arr.length) queue.offer(right); }","private void var_0 ( Queue < Integer > var_3 , int [ ] var_4 , int var_5 ) { int var_6 = var_5 - var_4 [ var_5 ] , var_7 = var_5 + var_4 [ var_5 ] ; if ( var_6 >= 0 ) var_3 . offer ( var_6 ) ; if ( var_7 < var_4 . length ) var_3 . offer ( var_7 ) ; } " 221,Word Pattern_1.java,"public boolean wordPattern(String pattern, String str) { if (pattern == null || pattern.length() == 0 || str == null || str.length() == 0) { return false; } String[] strArr = str.split("" ""); if (pattern.length() != strArr.length) { return false; } HashMap map = new HashMap(); for (int i = 0; i < pattern.length(); i++) { char c = pattern.charAt(i); String s = strArr[i]; if (!map.containsKey(c)) { if (map.containsValue(s)) { return false; } map.put(c, s); } else if (!map.get(c).equals(s)) { return false; } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_2 . length ( ) == 0 || var_3 == null || var_3 . length ( ) == 0 ) { return false ; } String [ ] var_9 = var_3 . split ( "" "" ) ; if ( var_2 . length ( ) != var_9 . length ) { return false ; } HashMap < Character , String > var_12 = new HashMap < Character , String > ( ) ; for ( int var_13 = 0 ; var_13 < var_2 . length ( ) ; var_13 ++ ) { char var_15 = var_2 . charAt ( var_13 ) ; String var_16 = var_9 [ var_13 ] ; if ( ! var_12 . containsKey ( var_15 ) ) { if ( var_12 . containsValue ( var_16 ) ) { return false ; } var_12 . put ( var_15 , var_16 ) ; } else if ( ! var_12 . get ( var_15 ) . equals ( var_16 ) ) { return false ; } } return true ; } " 222,121. Best Time to Buy and Sell Stock_1.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length <= 1) return 0; int profit = 0, n = prices.length; int[] min = new int[n]; min[0] = prices[0]; for (int i = 1; i < n; i++) { min[i] = Math.min(min[i - 1], prices[i]); profit = Math.max(profit, prices[i] - min[i]); } return profit; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length <= 1 ) return 0 ; int var_5 = 0 , var_6 = var_0 . length ; int [ ] min = new int [ var_6 ] ; min [ 0 ] = var_0 [ 0 ] ; for ( int var_8 = 1 ; var_8 < var_6 ; var_8 ++ ) { min [ var_8 ] = Math . min ( min [ var_8 - 1 ] , var_0 [ var_8 ] ) ; var_5 = Math . max ( var_5 , var_0 [ var_8 ] - min [ var_8 ] ) ; } return var_5 ; } " 223,200. Number of Islands_4.java,"private boolean validate(char[][] grid, int x, int y) { return x < 0 || x >= grid.length || y < 0 || y >= grid[0].length || grid[x][y] == '0'; }","private boolean var_0 ( char [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 < 0 || var_2 >= var_1 . length || var_3 < 0 || var_3 >= var_1 [ 0 ] . length || var_1 [ var_2 ] [ var_3 ] == '0' ; } " 224,One Edit Distance_2.java,"public boolean isOneEditDistance(String s, String t) { if (s == null || t == null || s.equals(t) || Math.abs(s.length() - t.length()) > 1) { return false; } int size = s.length() > t.length() ? t.length() : s.length(); for (int i = 0; i < size; i++) { if (s.charAt(i) != t.charAt(i)) { if (s.substring(i + 1).equals(t.substring(i)) || s.substring(i).equals(t.substring(i + 1))) { return true; } return s.substring(i + 1).equals(t.substring(i + 1)); } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null || var_2 . equals ( var_3 ) || Math . abs ( var_2 . length ( ) - var_3 . length ( ) ) > 1 ) { return false ; } int var_10 = var_2 . length ( ) > var_3 . length ( ) ? var_3 . length ( ) : var_2 . length ( ) ; for ( int var_12 = 0 ; var_12 < var_10 ; var_12 ++ ) { if ( var_2 . charAt ( var_12 ) != var_3 . charAt ( var_12 ) ) { if ( var_2 . substring ( var_12 + 1 ) . equals ( var_3 . substring ( var_12 ) ) || var_2 . substring ( var_12 ) . equals ( var_3 . substring ( var_12 + 1 ) ) ) { return true ; } return var_2 . substring ( var_12 + 1 ) . equals ( var_3 . substring ( var_12 + 1 ) ) ; } } return true ; } " 225,40. Combination Sum II_2.java,"private boolean validate(int[] candidates, int target) { return candidates == null || candidates.length == 0 || target <= 0; }","private boolean var_0 ( int [ ] var_1 , int var_2 ) { return var_1 == null || var_1 . length == 0 || var_2 <= 0 ; } " 226,509. Fibonacci Number_2.java,"public int fibonacci(int n) { if (n <= 1) { return 0; } int[] fib = new int[n]; fib[0] = 0; fib[1] = 1; for (int i = 2; i < n; i++) { fib[i] = fib[i - 1] + fib[i - 2]; } return fib[n - 1]; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 1 ) { return 0 ; } int [ ] var_3 = new int [ var_0 ] ; var_3 [ 0 ] = 0 ; var_3 [ 1 ] = 1 ; for ( int var_5 = 2 ; var_5 < var_0 ; var_5 ++ ) { var_3 [ var_5 ] = var_3 [ var_5 - 1 ] + var_3 [ var_5 - 2 ] ; } return var_3 [ var_0 - 1 ] ; } " 227,55. Jump Game_3.java,"public boolean canJump(int[] nums) { if (nums == null || nums.length == 0) return true; int n = nums.length; boolean[] dp = new boolean[n]; dp[0] = true; for (int i = 1; i < n; i++) { dp[i] = false; for (int j = 0; j < i; j++) { if (dp[j] && j + nums[j] >= i) { dp[i] = true; break; } } } return dp[n - 1]; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) return true ; int var_5 = var_1 . length ; boolean [ ] var_7 = new boolean [ var_5 ] ; var_7 [ 0 ] = true ; for ( int var_9 = 1 ; var_9 < var_5 ; var_9 ++ ) { var_7 [ var_9 ] = false ; for ( int var_10 = 0 ; var_10 < var_9 ; var_10 ++ ) { if ( var_7 [ var_10 ] && var_10 + var_1 [ var_10 ] >= var_9 ) { var_7 [ var_9 ] = true ; break ; } } } return var_7 [ var_5 - 1 ] ; } " 228,Find Peak Element_3.java,"public int findPeakElement(int[] nums) { if (nums == null || nums.length <= 1) { return 0; } int n = nums.length; int start = 0; int end = nums.length - 1; int mid = 0; while (start <= end) { mid = start + (end - start) / 2; if ((mid - 1 < 0 || nums[mid] > nums[mid - 1]) && (mid + 1 >= n || nums[mid] > nums[mid + 1])) { return mid; } else if (mid - 1 >= 0 && nums[mid] < nums[mid - 1]) { end = mid - 1; } else { start = mid + 1; } } return mid; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length <= 1 ) { return 0 ; } int var_5 = var_0 . length ; int var_6 = 0 ; int var_7 = var_0 . length - 1 ; int var_8 = 0 ; while ( var_6 <= var_7 ) { var_8 = var_6 + ( var_7 - var_6 ) / 2 ; if ( ( var_8 - 1 < 0 || var_0 [ var_8 ] > var_0 [ var_8 - 1 ] ) && ( var_8 + 1 >= var_5 || var_0 [ var_8 ] > var_0 [ var_8 + 1 ] ) ) { return var_8 ; } else if ( var_8 - 1 >= 0 && var_0 [ var_8 ] < var_0 [ var_8 - 1 ] ) { var_7 = var_8 - 1 ; } else { var_6 = var_8 + 1 ; } } return var_8 ; } " 229,Minimum Subarray_1.java,"public int minSubArray(List nums) { if (nums == null || nums.size() == 0) return Integer.MAX_VALUE; int preMinSum = 0, min = Integer.MAX_VALUE; for (int num : nums) { preMinSum = Math.min(num, preMinSum + num); min = Math.min(min, preMinSum); } return min; }","public int sample_funcname ( List < Integer > var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) return Integer . MAX_VALUE ; int var_7 = 0 , min = Integer . MAX_VALUE ; for ( int var_9 : var_2 ) { var_7 = Math . min ( var_9 , var_7 + var_9 ) ; min = Math . min ( min , var_7 ) ; } return min ; } " 230,One Edit Distance_3.java,"public boolean isOneEditDistance(String s, String t) { if (s == null || t == null) { return false; } else if (Math.abs(s.length() - t.length()) > 1 || s.equals(t)) { return false; } int leng = s.length() > t.length() ? t.length() : s.length(); for (int i = 0; i < leng; i++) { String ss = s; String tt = t; if (s.charAt(i) != t.charAt(i)) { tt = t.substring(i + 1); ss = s.substring(i); if (tt.equals(ss)) { return true; } tt = t.substring(i); ss = s.substring(i + 1); if (tt.equals(ss)) { return true; } ss = s.substring(0, i) + s.substring(i + 1); tt = t.substring(0, i) + t.substring(i + 1); return ss.equals(tt); } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null ) { return false ; } else if ( Math . abs ( var_2 . length ( ) - var_3 . length ( ) ) > 1 || var_2 . equals ( var_3 ) ) { return false ; } int var_10 = var_2 . length ( ) > var_3 . length ( ) ? var_3 . length ( ) : var_2 . length ( ) ; for ( int var_12 = 0 ; var_12 < var_10 ; var_12 ++ ) { String var_13 = var_2 ; String var_14 = var_3 ; if ( var_2 . charAt ( var_12 ) != var_3 . charAt ( var_12 ) ) { var_14 = var_3 . substring ( var_12 + 1 ) ; var_13 = var_2 . substring ( var_12 ) ; if ( var_14 . equals ( var_13 ) ) { return true ; } var_14 = var_3 . substring ( var_12 ) ; var_13 = var_2 . substring ( var_12 + 1 ) ; if ( var_14 . equals ( var_13 ) ) { return true ; } var_13 = var_2 . substring ( 0 , var_12 ) + var_2 . substring ( var_12 + 1 ) ; var_14 = var_3 . substring ( 0 , var_12 ) + var_3 . substring ( var_12 + 1 ) ; return var_13 . equals ( var_14 ) ; } } return true ; } " 231,Maximum Average Subarray I_1.java,"public double findMaxAverage(int[] nums, int k) { if (nums == null || nums.length == 0) { return 0; } double sum = 0; for (int i = 0; i < k; i++) { sum += nums[i]; } double max = sum; for (int i = k; i < nums.length; i++) { max = Math.max(sum, max); sum = sum - nums[i - k] + nums[i]; } max = Math.max(sum, max); return max / k; }","public double sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } double var_5 = 0 ; for ( int var_6 = 0 ; var_6 < var_1 ; var_6 ++ ) { var_5 += var_0 [ var_6 ] ; } double max = var_5 ; for ( int var_6 = var_1 ; var_6 < var_0 . length ; var_6 ++ ) { max = Math . max ( var_5 , max ) ; var_5 = var_5 - var_0 [ var_6 - var_1 ] + var_0 [ var_6 ] ; } max = Math . max ( var_5 , max ) ; return max / var_1 ; } " 232,40. Combination Sum II_3.java,"private void dfs(List> result, List list, int[] candidates, int index, int target) { for (int i = index; i < candidates.length; i++) { if (i > index && candidates[i] == candidates[i - 1]) continue; int value = candidates[i]; list.add(value); if (target == value) result.add(new ArrayList<>(list)); else if (target - value > 0) dfs(result, list, candidates, i + 1, target - value); list.remove(list.size() - 1); } }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int [ ] candidates , int index , int target ) { for ( int i = index ; i < candidates . length ; i ++ ) { if ( i > index && candidates [ i ] == candidates [ i - 1 ] ) continue ; int value = candidates [ i ] ; list . add ( value ) ; if ( target == value ) result . add ( new ArrayList < > ( list ) ) ; else if ( target - value > 0 ) dfs ( result , list , candidates , i + 1 , target - value ) ; list . remove ( list . size ( ) - 1 ) ; } } " 233,55. Jump Game_2.java,"public boolean canJump(int[] nums) { if (nums == null || nums.length == 0) return true; int n = nums.length, lastPos = n - 1; for (int i = lastPos; i >= 0; i--) { if (i + nums[i] >= lastPos) lastPos = i; } return lastPos == 0; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) return true ; int var_5 = var_1 . length , var_7 = var_5 - 1 ; for ( int var_8 = var_7 ; var_8 >= 0 ; var_8 -- ) { if ( var_8 + var_1 [ var_8 ] >= var_7 ) var_7 = var_8 ; } return var_7 == 0 ; } " 234,Find Peak Element_2.java,"public int findPeakElement(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int start = 0; int end = n - 1; while (start + 1 < end) { int mid = (start + end) >> 1; if (nums[mid] > nums[mid - 1] && nums[mid] > nums[mid + 1]) { return mid; } else if (nums[mid] > nums[mid - 1]) { start = mid; } else { end = mid; } } return nums[start] > nums[end] ? start : end; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = 0 ; int var_7 = var_4 - 1 ; while ( var_5 + 1 < var_7 ) { int var_8 = ( var_5 + var_7 ) >> 1 ; if ( var_0 [ var_8 ] > var_0 [ var_8 - 1 ] && var_0 [ var_8 ] > var_0 [ var_8 + 1 ] ) { return var_8 ; } else if ( var_0 [ var_8 ] > var_0 [ var_8 - 1 ] ) { var_5 = var_8 ; } else { var_7 = var_8 ; } } return var_0 [ var_5 ] > var_0 [ var_7 ] ? var_5 : var_7 ; } " 235,509. Fibonacci Number_3.java,"public int fibonacci(int n) { if (n <= 1) { return 0; } if (n == 2) { return 1; } return fibonacci(n - 1) + fibonacci(n - 2); }","public int sample_funcname ( int n ) { if ( n <= 1 ) { return 0 ; } if ( n == 2 ) { return 1 ; } return fibonacci ( n - 1 ) + fibonacci ( n - 2 ) ; } " 236,Jump Game II_3.java,"public int jump(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int start = 0, end = 0, steps = 0; while (end < n - 1) { steps++; int farthest = 0; for (int i = start; i <= end; i++) { farthest = Math.max(farthest, i + nums[i]); if (farthest >= n - 1) { return steps; } } start = end + 1; end = farthest; } return 0; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = 0 , var_6 = 0 , var_7 = 0 ; while ( var_6 < var_4 - 1 ) { var_7 ++ ; int var_9 = 0 ; for ( int var_10 = var_5 ; var_10 <= var_6 ; var_10 ++ ) { var_9 = Math . max ( var_9 , var_10 + var_0 [ var_10 ] ) ; if ( var_9 >= var_4 - 1 ) { return var_7 ; } } var_5 = var_6 + 1 ; var_6 = var_9 ; } return 0 ; } " 237,Excel Sheet Column Number_1.java,"public int titleToNumber(String s) { if (s == null || s.length() == 0) { return 0; } int count = 0; for (char c : s.toCharArray()) { int digit = c - 'A' + 1; count = count * 26 + digit; } return count; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } int var_5 = 0 ; for ( char var_7 : var_1 . toCharArray ( ) ) { int var_10 = var_7 - 'A' + 1 ; var_5 = var_5 * 26 + var_10 ; } return var_5 ; } " 238,200. Number of Islands_5.java,"private boolean validate(char[][] grid, int x, int y) { return x >= 0 && x < grid.length && y >= 0 && y < grid[0].length && grid[x][y] == '1'; }","private boolean var_0 ( char [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 >= 0 && var_2 < var_1 . length && var_3 >= 0 && var_3 < var_1 [ 0 ] . length && var_1 [ var_2 ] [ var_3 ] == '1' ; } " 239,53. Maximum Subarray_1.java,"public int maxSubArray(int[] nums) { if (nums == null || nums.length == 0) return Integer.MIN_VALUE; int preMaxSum = 0, max = Integer.MIN_VALUE; for (int num : nums) { preMaxSum = Math.max(num, preMaxSum + num); max = Math.max(max, preMaxSum); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return Integer . MIN_VALUE ; int var_6 = 0 , max = Integer . MIN_VALUE ; for ( int var_8 : var_0 ) { var_6 = Math . max ( var_8 , var_6 + var_8 ) ; max = Math . max ( max , var_6 ) ; } return max ; } " 240,523. Continuous Subarray Sum_1.java,"public boolean checkSubarraySum(int[] nums, int k) { k = k == 0 ? Integer.MAX_VALUE : Math.abs(k); if (nums.length / 2 > k) return true; Set set = new HashSet<>(); int lastMod = 0; for (int num : nums) { int mod = (lastMod + num) % k; if (set.contains(mod)) return true; set.add(lastMod); lastMod = mod; } return false; }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { var_2 = var_2 == 0 ? Integer . MAX_VALUE : Math . abs ( var_2 ) ; if ( var_1 . length / 2 > var_2 ) return true ; Set < Integer > var_12 = new HashSet < > ( ) ; int var_13 = 0 ; for ( int var_14 : var_1 ) { int var_15 = ( var_13 + var_14 ) % var_2 ; if ( var_12 . contains ( var_15 ) ) return true ; var_12 . add ( var_13 ) ; var_13 = var_15 ; } return false ; } " 241,1060. Missing Element in Sorted Array_1.java,"public int missingElement(int[] nums, int k) { int start = 0, end = nums.length - 1; int count = nums[end] - nums[0] - end; if (count < k) { return nums[end] + k - count; } while (start + 1 < end) { int mid = start + (end - start) / 2; count = nums[mid] - nums[0] - mid; if (count >= k) end = mid; else start = mid; } count = nums[start] - nums[0] - start; return nums[start] + k - count; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = 0 , var_6 = var_0 . length - 1 ; int var_7 = var_0 [ var_6 ] - var_0 [ 0 ] - var_6 ; if ( var_7 < var_1 ) { return var_0 [ var_6 ] + var_1 - var_7 ; } while ( var_3 + 1 < var_6 ) { int var_9 = var_3 + ( var_6 - var_3 ) / 2 ; var_7 = var_0 [ var_9 ] - var_0 [ 0 ] - var_9 ; if ( var_7 >= var_1 ) var_6 = var_9 ; else var_3 = var_9 ; } var_7 = var_0 [ var_3 ] - var_0 [ 0 ] - var_3 ; return var_0 [ var_3 ] + var_1 - var_7 ; } " 242,315. Count of Smaller Numbers After Self_2.java,"private int[] findRange(int[] nums) { int diff = 0, min = Integer.MAX_VALUE, max = Integer.MIN_VALUE; for (int num : nums) { min = Math.min(min, num); max = Math.max(max, num); } if (min < 0) { diff = Math.abs(min); max += diff; min += diff; } return new int[]{min, max, diff}; }","private int [ ] sample_funcname ( int [ ] var_0 ) { int var_2 = 0 , min = Integer . MAX_VALUE , max = Integer . MIN_VALUE ; for ( int var_8 : var_0 ) { min = Math . min ( min , var_8 ) ; max = Math . max ( max , var_8 ) ; } if ( min < 0 ) { var_2 = Math . abs ( min ) ; max += var_2 ; min += var_2 ; } return new int [ ] { min , max , var_2 }; } " 243,Burst Balloons_1.java,"public int maxCoins(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int[] values = new int[n + 2]; values[0] = 1; values[n + 1] = 1; for (int i = 1; i <= n; i++) { values[i] = nums[i - 1]; } n = values.length; int[][] dp = new int[n][n]; for (int len = 3; len <= n; len++) { for (int i = 0; i <= n - len; i++) { int j = len + i - 1; for (int k = i + 1; k < j; k++) { dp[i][j] = Math.max(dp[i][j], dp[i][k] + dp[k][j] + values[i] * values[k] * values[j]); } } } return dp[0][n - 1]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int [ ] var_6 = new int [ var_4 + 2 ] ; var_6 [ 0 ] = 1 ; var_6 [ var_4 + 1 ] = 1 ; for ( int var_8 = 1 ; var_8 <= var_4 ; var_8 ++ ) { var_6 [ var_8 ] = var_0 [ var_8 - 1 ] ; } var_4 = var_6 . length ; int [ ] [ ] var_9 = new int [ var_4 ] [ var_4 ] ; for ( int var_11 = 3 ; var_11 <= var_4 ; var_11 ++ ) { for ( int var_8 = 0 ; var_8 <= var_4 - var_11 ; var_8 ++ ) { int var_12 = var_11 + var_8 - 1 ; for ( int var_13 = var_8 + 1 ; var_13 < var_12 ; var_13 ++ ) { var_9 [ var_8 ] [ var_12 ] = Math . max ( var_9 [ var_8 ] [ var_12 ] , var_9 [ var_8 ] [ var_13 ] + var_9 [ var_13 ] [ var_12 ] + var_6 [ var_8 ] * var_6 [ var_13 ] * var_6 [ var_12 ] ) ; } } } return var_9 [ 0 ] [ var_4 - 1 ] ; } " 244,1094. Car Pooling_2.java,"private PriorityQueue buildQueue(int[][] trips) { PriorityQueue queue = new PriorityQueue<>(Comparator.comparing(p -> p[0])); for (int[] trip : trips) { queue.offer(new int[]{trip[1], trip[0]}); queue.offer(new int[]{trip[2], -trip[0]}); } return queue; }","private PriorityQueue < int [ ] > var_0 ( int [ ] [ ] var_1 ) { PriorityQueue < int [ ] > var_7 = new PriorityQueue < > ( Comparator . comparing ( var_3 -> var_3 [ 0 ] ) ) ; for ( int [ ] var_8 : var_1 ) { var_7 . offer ( new int [ ] { var_8 [ 1 ] , var_8 [ 0 ] } ) ; var_7 . offer ( new int [ ] { var_8 [ 2 ] , - var_8 [ 0 ] } ) ; } return var_7 ; } " 245,Wiggle Sort_3.java,"public void swap(int[] nums, int x, int y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","public void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 246,[lint]. 3 Sum Closest_1.java,"public int threeSumClosest(int[] nums, int target) { if (nums == null || nums.length < 3) { return 0; } Arrays.sort(nums); long result = nums[0] + nums[1] + nums[2]; for (int i = 0; i < nums.length - 2; i++) { int start = i + 1; int end = nums.length - 1; while (start < end) { long sum = nums[start] + nums[end] + nums[i]; if (sum > target) { end--; } else { start++; } result = Math.abs(sum - target) < Math.abs(result - target) ? sum : result; } } return (int)result; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length < 3 ) { return 0 ; } Arrays . sort ( var_0 ) ; long var_10 = var_0 [ 0 ] + var_0 [ 1 ] + var_0 [ 2 ] ; for ( int var_11 = 0 ; var_11 < var_0 . length - 2 ; var_11 ++ ) { int var_12 = var_11 + 1 ; int var_13 = var_0 . length - 1 ; while ( var_12 < var_13 ) { long var_14 = var_0 [ var_12 ] + var_0 [ var_13 ] + var_0 [ var_11 ] ; if ( var_14 > var_1 ) { var_13 -- ; } else { var_12 ++ ; } var_10 = Math . abs ( var_14 - var_1 ) < Math . abs ( var_10 - var_1 ) ? var_14 : var_10 ; } } return ( int ) var_10 ; } " 247,Two Strings Are Anagrams_2.java,"public boolean isAnagram(String s, String t) { if (s == null || t == null || s.length() != t.length()) { return false; } if (s.equals(t)) { return true; } HashMap map = new HashMap(); for (int i = 0; i < s.length(); i++) { String ss = s.substring(i, i + 1); String tt = t.substring(i, i + 1); if (!map.containsKey(ss)) { map.put(ss, 0); } map.put(ss, map.get(ss) + 1); if (!map.containsKey(tt)) { map.put(tt, 0); } map.put(tt, map.get(tt) - 1); } for (Map.Entry entry : map.entrySet()) { if (entry.getValue() != 0) { return false; } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) != var_3 . length ( ) ) { return false ; } if ( var_2 . equals ( var_3 ) ) { return true ; } HashMap < String , Integer > var_9 = new HashMap < String , Integer > ( ) ; for ( int var_11 = 0 ; var_11 < var_2 . length ( ) ; var_11 ++ ) { String var_14 = var_2 . substring ( var_11 , var_11 + 1 ) ; String var_15 = var_3 . substring ( var_11 , var_11 + 1 ) ; if ( ! var_9 . containsKey ( var_14 ) ) { var_9 . put ( var_14 , 0 ) ; } var_9 . put ( var_14 , var_9 . get ( var_14 ) + 1 ) ; if ( ! var_9 . containsKey ( var_15 ) ) { var_9 . put ( var_15 , 0 ) ; } var_9 . put ( var_15 , var_9 . get ( var_15 ) - 1 ) ; } for ( Map . Entry < String , Integer > var_20 : var_9 . entrySet ( ) ) { if ( var_20 . getValue ( ) != 0 ) { return false ; } } return true ; } " 248,33. Search in Rotated Sorted Array_1.java,"public int search(int[] nums, int target) { if (nums == null || nums.length == 0) return -1; int start = 0, end = nums.length - 1; while (start + 1 < end) { int mid = start + (end - start) / 2; if (nums[mid] == target) return mid; if (nums[start] < nums[mid]) { if (nums[start] <= target && target <= nums[mid]) end = mid; else start = mid; } else { if (nums[mid] <= target && target <= nums[end]) start = mid; else end = mid; } } if (nums[start] == target) return start; if (nums[end] == target) return end; return -1; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) return - 1 ; int var_6 = 0 , var_7 = var_0 . length - 1 ; while ( var_6 + 1 < var_7 ) { int var_9 = var_6 + ( var_7 - var_6 ) / 2 ; if ( var_0 [ var_9 ] == var_1 ) return var_9 ; if ( var_0 [ var_6 ] < var_0 [ var_9 ] ) { if ( var_0 [ var_6 ] <= var_1 && var_1 <= var_0 [ var_9 ] ) var_7 = var_9 ; else var_6 = var_9 ; } else { if ( var_0 [ var_9 ] <= var_1 && var_1 <= var_0 [ var_7 ] ) var_6 = var_9 ; else var_7 = var_9 ; } } if ( var_0 [ var_6 ] == var_1 ) return var_6 ; if ( var_0 [ var_7 ] == var_1 ) return var_7 ; return - 1 ; } " 249,Backpack II_6.java,"public int backPackII(int m, int[] A, int V[]) { if (A == null || V == null || A.length != V.length) { return 0; } int n = A.length; int[][] dp = new int[2][m + 1]; dp[0][0] = 0; for (int j = 0; j <= m; j++) { dp[0][j] = 0; } int curr = 0, prev; for (int i = 1; i <= n; i++) { prev = curr; curr = 1 - prev; for (int j = 1; j <= m; j++) { dp[curr][j] = dp[prev][j]; if (j - A[i - 1] >= 0) { dp[curr][j] = Math.max(dp[curr][j], dp[prev][j - A[i - 1]] + V[i - 1]); } } } return dp[curr][m]; }","public int sample_funcname ( int var_0 , int [ ] var_1 , int var_2 [ ] ) { if ( var_1 == null || var_2 == null || var_1 . length != var_2 . length ) { return 0 ; } int var_6 = var_1 . length ; int [ ] [ ] var_9 = new int [ 2 ] [ var_0 + 1 ] ; var_9 [ 0 ] [ 0 ] = 0 ; for ( int var_10 = 0 ; var_10 <= var_0 ; var_10 ++ ) { var_9 [ 0 ] [ var_10 ] = 0 ; } int var_11 = 0 , var_12 ; for ( int var_13 = 1 ; var_13 <= var_6 ; var_13 ++ ) { var_12 = var_11 ; var_11 = 1 - var_12 ; for ( int var_10 = 1 ; var_10 <= var_0 ; var_10 ++ ) { var_9 [ var_11 ] [ var_10 ] = var_9 [ var_12 ] [ var_10 ] ; if ( var_10 - var_1 [ var_13 - 1 ] >= 0 ) { var_9 [ var_11 ] [ var_10 ] = Math . max ( var_9 [ var_11 ] [ var_10 ] , var_9 [ var_12 ] [ var_10 - var_1 [ var_13 - 1 ] ] + var_2 [ var_13 - 1 ] ) ; } } } return var_9 [ var_11 ] [ var_0 ] ; } " 250,215. Kth Largest Element in an Array_2.java,"private void swap(int[] nums, int x, int y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 251,Compare Version Numbers_2.java,"private int compareString(String str1, String str2) { if (str1.equals(str2)) { return 0; } while (str1 != null && str1.length() > 1 && str1.charAt(0) == '0') { str1 = str1.substring(1); } while (str2 != null && str2.length() > 1 && str2.charAt(0) == '0') { str2 = str2.substring(1); } if (str1.length() != str2.length()) { return str1.length() < str2.length() ? -1 : 1; } for (int i = 0; i < str1.length(); i++) { int digit1 = str1.charAt(i) - '0'; int digit2 = str2.charAt(i) - '0'; if (digit1 < digit2) { return -1; } else if (digit1 > digit2) { return 1; } } return 0; }","private int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 . equals ( var_2 ) ) { return 0 ; } while ( var_1 != null && var_1 . length ( ) > 1 && var_1 . charAt ( 0 ) == '0' ) { var_1 = var_1 . substring ( 1 ) ; } while ( var_2 != null && var_2 . length ( ) > 1 && var_2 . charAt ( 0 ) == '0' ) { var_2 = var_2 . substring ( 1 ) ; } if ( var_1 . length ( ) != var_2 . length ( ) ) { return var_1 . length ( ) < var_2 . length ( ) ? - 1 : 1 ; } for ( int var_11 = 0 ; var_11 < var_1 . length ( ) ; var_11 ++ ) { int var_12 = var_1 . charAt ( var_11 ) - '0' ; int var_13 = var_2 . charAt ( var_11 ) - '0' ; if ( var_12 < var_13 ) { return - 1 ; } else if ( var_12 > var_13 ) { return 1 ; } } return 0 ; } " 252,Backpack V_2.java,"public int backPackV(int[] nums, int target) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int[][] dp = new int[2][target + 1]; dp[0][0] = 1; for (int j = 1; j <= target; j++) { dp[0][j] = 0; } int curr = 0, prev = 1; for (int i = 1; i <= n; i++) { prev = curr; curr = 1 - curr; for (int j = 0; j <= target; j++) { dp[curr][j] = dp[prev][j]; if (j - nums[i - 1] >= 0) { dp[curr][j] += dp[prev][j - nums[i - 1]]; } } } return dp[curr][target]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = var_0 . length ; int [ ] [ ] var_8 = new int [ 2 ] [ var_1 + 1 ] ; var_8 [ 0 ] [ 0 ] = 1 ; for ( int var_9 = 1 ; var_9 <= var_1 ; var_9 ++ ) { var_8 [ 0 ] [ var_9 ] = 0 ; } int var_10 = 0 , var_11 = 1 ; for ( int var_12 = 1 ; var_12 <= var_5 ; var_12 ++ ) { var_11 = var_10 ; var_10 = 1 - var_10 ; for ( int var_9 = 0 ; var_9 <= var_1 ; var_9 ++ ) { var_8 [ var_10 ] [ var_9 ] = var_8 [ var_11 ] [ var_9 ] ; if ( var_9 - var_0 [ var_12 - 1 ] >= 0 ) { var_8 [ var_10 ] [ var_9 ] += var_8 [ var_11 ] [ var_9 - var_0 [ var_12 - 1 ] ] ; } } } return var_8 [ var_10 ] [ var_1 ] ; } " 253,1106. Parsing A Boolean Expression_3.java,"public boolean parseBoolExpr(String exp) { Stack stack = new Stack<>(); for (char c : exp.toCharArray()) { if (c == ')') { Set expItems = new HashSet<>(); while (stack.peek() != '(') expItems.add(stack.pop()); stack.pop(); char op = stack.pop(); if (op == '&') stack.push(expItems.contains('f') ? 'f' : 't'); else if (op == '|') stack.push(expItems.contains('t') ? 't' : 'f'); else if (op == '!') stack.push(expItems.contains('t') ? 'f' : 't'); } else if (c != ',') { stack.push(c); } } return stack.pop() == 't'; }","public boolean var_0 ( String var_2 ) { Stack < Character > var_5 = new Stack < > ( ) ; for ( char var_7 : var_2 . toCharArray ( ) ) { if ( var_7 == ')' ) { Set < Character > var_11 = new HashSet < > ( ) ; while ( var_5 . peek ( ) != '(' ) var_11 . add ( var_5 . pop ( ) ) ; var_5 . pop ( ) ; char var_16 = var_5 . pop ( ) ; if ( var_16 == '&' ) var_5 . push ( var_11 . contains ( 'f' ) ? 'f' : 't' ) ; else if ( var_16 == '|' ) var_5 . push ( var_11 . contains ( 't' ) ? 't' : 'f' ) ; else if ( var_16 == '!' ) var_5 . push ( var_11 . contains ( 't' ) ? 'f' : 't' ) ; } else if ( var_7 != ',' ) { var_5 . push ( var_7 ) ; } } return var_5 . pop ( ) == 't' ; } " 254,Remove Duplicate Letters_2.java,"String removeDuplicateLetters(String s) { if (s == null || s.length() <= 1) { return s; } char[] arr = s.toCharArray(); int[] count = new int[256]; boolean[] visited = new boolean[256]; for (char c : arr) { count[c]++; } Stack stack = new Stack<>(); stack.push('0'); for (char c : arr) { count[c]--; if (visited[c]) { continue; } while (c < stack.peek() && count[stack.peek()] > 0) { visited[stack.pop()] = false; } stack.push(c); visited[c] = true; } StringBuffer sb = new StringBuffer(); while (!stack.isEmpty()) { sb.insert(0, stack.pop()); } return sb.substring(1).toString(); }","String var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) <= 1 ) { return var_2 ; } char [ ] var_7 = var_2 . toCharArray ( ) ; int [ ] var_9 = new int [ 256 ] ; boolean [ ] var_11 = new boolean [ 256 ] ; for ( char var_12 : var_7 ) { var_9 [ var_12 ] ++ ; } Stack < Character > var_15 = new Stack < > ( ) ; var_15 . push ( '0' ) ; for ( char var_12 : var_7 ) { var_9 [ var_12 ] -- ; if ( var_11 [ var_12 ] ) { continue ; } while ( var_12 < var_15 . peek ( ) && var_9 [ var_15 . peek ( ) ] > 0 ) { var_11 [ var_15 . pop ( ) ] = false ; } var_15 . push ( var_12 ) ; var_11 [ var_12 ] = true ; } StringBuffer var_21 = new StringBuffer ( ) ; while ( ! var_15 . isEmpty ( ) ) { var_21 . insert ( 0 , var_15 . pop ( ) ) ; } return var_21 . substring ( 1 ) . toString ( ) ; } " 255,13. Roman to Integer_3.java,"private Map buildSpecialMap() { Map map = new HashMap<>(); map.put(""IV"", 4); map.put(""IX"", 9); map.put(""XL"", 40); map.put(""XC"", 90); map.put(""CD"", 400); map.put(""CM"", 900); return map; }","private Map < String , Integer > var_2 ( ) { Map < String , Integer > var_5 = new HashMap < > ( ) ; var_5 . put ( ""IV"" , 4 ) ; var_5 . put ( ""IX"" , 9 ) ; var_5 . put ( ""XL"" , 40 ) ; var_5 . put ( ""XC"" , 90 ) ; var_5 . put ( ""CD"" , 400 ) ; var_5 . put ( ""CM"" , 900 ) ; return var_5 ; } " 256,1033. Moving Stones Until Consecutive_1.java,"public int[] numMovesStones(int a, int b, int c) { int[] arr = new int[]{a, b, c}; Arrays.sort(arr); int max = arr[2] - arr[0] - 2; if (arr[2] - arr[0] == 2) return new int[]{0, max}; if (arr[1] - arr[0] <= 2 || arr[2] - arr[1] <= 2) return new int[]{1, max}; return new int[]{2, max}; }","public int [ ] sample_funcname ( int var_0 , int var_1 , int var_2 ) { int [ ] var_3 = new int [ ] { var_0 , var_1 , var_2 }; Arrays . sort ( var_3 ) ; int var_8 = var_3 [ 2 ] - var_3 [ 0 ] - 2 ; if ( var_3 [ 2 ] - var_3 [ 0 ] == 2 ) return new int [ ] { 0 , var_8 }; if ( var_3 [ 1 ] - var_3 [ 0 ] <= 2 || var_3 [ 2 ] - var_3 [ 1 ] <= 2 ) return new int [ ] { 1 , var_8 }; return new int [ ] { 2 , var_8 }; } " 257,Convert Expression to Polish Notation_1.java,"public int getWeight(int base, String s) { if (s.equals(""+"") || s.equals(""-"")) { return base + 1; } if (s.equals(""*"") || s.equals(""/"")) { return base + 2; } return Integer.MAX_VALUE; }","public int sample_funcname ( int var_0 , String var_2 ) { if ( var_2 . equals ( ""+"" ) || var_2 . equals ( ""-"" ) ) { return var_0 + 1 ; } if ( var_2 . equals ( ""*"" ) || var_2 . equals ( ""/"" ) ) { return var_0 + 2 ; } return Integer . MAX_VALUE ; } " 258,Minimum Size Subarray Sum_1.java,"public int minSubArrayLen(int s, int[] nums) { if (nums == null || nums.length == 0) { return 0; } int start, end, sum; start = end = sum = 0; int min = Integer.MAX_VALUE; while (end < nums.length) { while (sum < s && end < nums.length) { sum += nums[end]; end++; } while (sum >= s && start >= 0) { min = Math.min(min, end - start); sum -= nums[start]; start++; } } return min == Integer.MAX_VALUE ? 0 : min; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return 0 ; } int var_5 , var_6 , var_7 ; var_5 = var_6 = var_7 = 0 ; int min = Integer . MAX_VALUE ; while ( var_6 < var_1 . length ) { while ( var_7 < var_0 && var_6 < var_1 . length ) { var_7 += var_1 [ var_6 ] ; var_6 ++ ; } while ( var_7 >= var_0 && var_5 >= 0 ) { min = Math . min ( min , var_6 - var_5 ) ; var_7 -= var_1 [ var_5 ] ; var_5 ++ ; } } return min == Integer . MAX_VALUE ? 0 : min ; } " 259,717. 1-bit and 2-bit Characters_1.java,"public boolean isOneBitCharacter(int[] bits) { if (bits == null || bits.length == 0) { return false; } int index = 0; while (index < bits.length - 1) { index += bits[index] % 2 == 1 ? 2 : 1; } return index == bits.length - 1; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return false ; } int var_5 = 0 ; while ( var_5 < var_1 . length - 1 ) { var_5 += var_1 [ var_5 ] % 2 == 1 ? 2 : 1 ; } return var_5 == var_1 . length - 1 ; } " 260,Interleaving Positive and Negative Numbers_1.java,"public void rerange(int[] A) { if (A == null || A.length <= 1) { return; } Arrays.sort(A); int start = 0; int end = A.length - 1; if (A.length % 2 != 0) { if (A[(start + end) / 2] >= 0) { end--; } else { start++; } } while (start < end) { int temp = A[start]; A[start] = A[end]; A[end] = temp; start += 2; end -= 2; } }","public void var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length <= 1 ) { return ; } Arrays . sort ( var_1 ) ; int var_8 = 0 ; int var_9 = var_1 . length - 1 ; if ( var_1 . length % 2 != 0 ) { if ( var_1 [ ( var_8 + var_9 ) / 2 ] >= 0 ) { var_9 -- ; } else { var_8 ++ ; } } while ( var_8 < var_9 ) { int var_11 = var_1 [ var_8 ] ; var_1 [ var_8 ] = var_1 [ var_9 ] ; var_1 [ var_9 ] = var_11 ; var_8 += 2 ; var_9 -= 2 ; } } " 261,Maximum Subarray II_5.java,"public int maxTwoSubArrays(ArrayList nums) { if (nums == null || nums.size() == 0) { return 0; } int[] frontSum = new int[nums.size()]; int[] endSum = new int[nums.size()]; int maxSum = 0; frontSum[0] = nums.get(0); for (int i = 1; i < frontSum.length; i++) { if (frontSum[i - 1] < 0) { frontSum[i] = nums.get(i); } else { frontSum[i] = frontSum[i - 1] + nums.get(i); } } maxSum = frontSum[0]; for (int i = 1; i < frontSum.length; i++) { if (frontSum[i] < maxSum) { frontSum[i] = maxSum; } else { maxSum = frontSum[i]; } } endSum[endSum.length - 1] = nums.get(nums.size() - 1); for (int i = endSum.length - 2; i >= 0; i--) { if (endSum[i + 1] < 0) { endSum[i] = nums.get(i); } else { endSum[i] = endSum[i + 1] + nums.get(i); } } maxSum = endSum[endSum.length - 1]; for (int i = endSum.length - 2; i >= 0; i--) { if (endSum[i] < maxSum) { endSum[i] = maxSum; } else { maxSum = endSum[i]; } } maxSum = Integer.MIN_VALUE; for (int i = 0; i < nums.size() - 1; i++) { maxSum = Math.max(maxSum, frontSum[i] + endSum[i + 1]); } return maxSum; }","public int sample_funcname ( ArrayList < Integer > var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return 0 ; } int [ ] var_6 = new int [ var_2 . size ( ) ] ; int [ ] var_7 = new int [ var_2 . size ( ) ] ; int var_8 = 0 ; var_6 [ 0 ] = var_2 . get ( 0 ) ; for ( int var_11 = 1 ; var_11 < var_6 . length ; var_11 ++ ) { if ( var_6 [ var_11 - 1 ] < 0 ) { var_6 [ var_11 ] = var_2 . get ( var_11 ) ; } else { var_6 [ var_11 ] = var_6 [ var_11 - 1 ] + var_2 . get ( var_11 ) ; } } var_8 = var_6 [ 0 ] ; for ( int var_11 = 1 ; var_11 < var_6 . length ; var_11 ++ ) { if ( var_6 [ var_11 ] < var_8 ) { var_6 [ var_11 ] = var_8 ; } else { var_8 = var_6 [ var_11 ] ; } } var_7 [ var_7 . length - 1 ] = var_2 . get ( var_2 . size ( ) - 1 ) ; for ( int var_11 = var_7 . length - 2 ; var_11 >= 0 ; var_11 -- ) { if ( var_7 [ var_11 + 1 ] < 0 ) { var_7 [ var_11 ] = var_2 . get ( var_11 ) ; } else { var_7 [ var_11 ] = var_7 [ var_11 + 1 ] + var_2 . get ( var_11 ) ; } } var_8 = var_7 [ var_7 . length - 1 ] ; for ( int var_11 = var_7 . length - 2 ; var_11 >= 0 ; var_11 -- ) { if ( var_7 [ var_11 ] < var_8 ) { var_7 [ var_11 ] = var_8 ; } else { var_8 = var_7 [ var_11 ] ; } } var_8 = Integer . MIN_VALUE ; for ( int var_11 = 0 ; var_11 < var_2 . size ( ) - 1 ; var_11 ++ ) { var_8 = Math . max ( var_8 , var_6 [ var_11 ] + var_7 [ var_11 + 1 ] ) ; } return var_8 ; } " 262,1203. Sort Items by Groups Respecting Dependencies_3.java,"private Map> buildItemGraph(List items, List> beforeItems) { Map> graph = new HashMap<>(); for (int i : items) { for (int item : beforeItems.get(i)) { graph.putIfAbsent(item, new ArrayList<>()); graph.get(item).add(i); } } return graph; }","private Map < Integer , List < Integer >> var_2 ( List < Integer > var_3 , List < List < Integer >> var_4 ) { Map < Integer , List < Integer >> var_7 = new HashMap < > ( ) ; for ( int var_8 : var_3 ) { for ( int var_10 : var_4 . get ( var_8 ) ) { var_7 . putIfAbsent ( var_10 , new ArrayList < > ( ) ) ; var_7 . get ( var_10 ) . add ( var_8 ) ; } } return var_7 ; } " 263,256. Paint House_2.java,"public int minCost(int[][] costs) { if (costs == null || costs.length == 0) return 0; int n = costs.length, m = costs[0].length; int[][] dp = new int[n + 1][m]; for (int i = 1; i <= n; i++) { for (int j = 0; j < m; j++) { dp[i][j] = Integer.MAX_VALUE; for (int k = 0; k < m; k++) { if (j == k) continue; dp[i][j] = Math.min(dp[i][j], dp[i - 1][k] + costs[i - 1][j]); } } } int min = Integer.MAX_VALUE; for (int j = 0; j < m; j++) min = Math.min(min, dp[n][j]); return min; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_7 = new int [ var_4 + 1 ] [ var_5 ] ; for ( int var_8 = 1 ; var_8 <= var_4 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 < var_5 ; var_9 ++ ) { var_7 [ var_8 ] [ var_9 ] = Integer . MAX_VALUE ; for ( int var_12 = 0 ; var_12 < var_5 ; var_12 ++ ) { if ( var_9 == var_12 ) continue ; var_7 [ var_8 ] [ var_9 ] = Math . min ( var_7 [ var_8 ] [ var_9 ] , var_7 [ var_8 - 1 ] [ var_12 ] + var_0 [ var_8 - 1 ] [ var_9 ] ) ; } } } int min = Integer . MAX_VALUE ; for ( int var_9 = 0 ; var_9 < var_5 ; var_9 ++ ) min = Math . min ( min , var_7 [ var_4 ] [ var_9 ] ) ; return min ; } " 264,4Sum_2.java,"public ArrayList> fourSum(int[] numbers, int target) { ArrayList> rst = new ArrayList>(); if(numbers == null || numbers.length < 4) { return rst; } Arrays.sort(numbers); for (int i = 0; i < numbers.length - 3; i++) { if (i != 0 && numbers[i] == numbers[i - 1]) { continue; } for (int j = i + 1; j < numbers.length - 2; j++) { if (j != i + 1 && numbers[j] == numbers[j - 1]) { continue; } int third = j + 1; int fourth = numbers.length - 1; while (third < fourth) { int sum = numbers[i] + numbers[j] + numbers[third] + numbers[fourth]; if (sum < target) { third++; } else if (sum > target) { fourth--; } else { ArrayList list = new ArrayList(); list.add(numbers[i]); list.add(numbers[j]); list.add(numbers[third]); list.add(numbers[fourth]); rst.add(list); third++; fourth--; while (third < fourth && numbers[third] == numbers[third - 1]) { third++; } while (third < fourth && numbers[fourth] == numbers[fourth + 1]){ fourth--; } } } } } return rst; }","public ArrayList < ArrayList < Integer >> var_2 ( int [ ] var_3 , int var_4 ) { ArrayList < ArrayList < Integer >> var_5 = new ArrayList < ArrayList < Integer >> ( ) ; if ( var_3 == null || var_3 . length < 4 ) { return var_5 ; } Arrays . sort ( var_3 ) ; for ( int var_12 = 0 ; var_12 < var_3 . length - 3 ; var_12 ++ ) { if ( var_12 != 0 && var_3 [ var_12 ] == var_3 [ var_12 - 1 ] ) { continue ; } for ( int var_15 = var_12 + 1 ; var_15 < var_3 . length - 2 ; var_15 ++ ) { if ( var_15 != var_12 + 1 && var_3 [ var_15 ] == var_3 [ var_15 - 1 ] ) { continue ; } int var_17 = var_15 + 1 ; int var_18 = var_3 . length - 1 ; while ( var_17 < var_18 ) { int var_19 = var_3 [ var_12 ] + var_3 [ var_15 ] + var_3 [ var_17 ] + var_3 [ var_18 ] ; if ( var_19 < var_4 ) { var_17 ++ ; } else if ( var_19 > var_4 ) { var_18 -- ; } else { ArrayList < Integer > var_20 = new ArrayList < Integer > ( ) ; var_20 . add ( var_3 [ var_12 ] ) ; var_20 . add ( var_3 [ var_15 ] ) ; var_20 . add ( var_3 [ var_17 ] ) ; var_20 . add ( var_3 [ var_18 ] ) ; var_5 . add ( var_20 ) ; var_17 ++ ; var_18 -- ; while ( var_17 < var_18 && var_3 [ var_17 ] == var_3 [ var_17 - 1 ] ) { var_17 ++ ; } while ( var_17 < var_18 && var_3 [ var_18 ] == var_3 [ var_18 + 1 ] ) { var_18 -- ; } } } } } return var_5 ; } " 265,68. Text Justification_2.java,"private String generateSpace(int n) { if (n <= 0) return """"; StringBuffer sb = new StringBuffer(); for (int i = 0; i < n; i++) sb.append("" ""); return sb.toString(); }","private String var_0 ( int var_1 ) { if ( var_1 <= 0 ) return """" ; StringBuffer var_5 = new StringBuffer ( ) ; for ( int var_6 = 0 ; var_6 < var_1 ; var_6 ++ ) var_5 . append ( "" "" ) ; return var_5 . toString ( ) ; } " 266,Ones and Zeroes_2.java,"public int findMaxForm(String[] strs, int m, int n) { if (strs == null || strs.length == 0 || (m == 0 && n == 0)) { return 0; } int len = strs.length; int[][][] dp = new int[m + 1][n + 1][2]; int curr = 1; int prev = 0; int[] ones = new int[len]; int[] zeros = new int[len]; for (int k = 0; k < len; k++) { char[] ss = strs[k].toCharArray(); for (char c : ss) { ones[k] += c == '1' ? 1 : 0; zeros[k] += c == '0' ? 1 : 0; } } for (int k = 0; k <= len; k++) { prev = curr; curr = 1 - prev; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (k == 0 || (i == 0 && j == 0)) { dp[i][j][curr] = 0; continue; } dp[i][j][curr] = dp[i][j][prev]; int countZero = zeros[k - 1]; int countOne = ones[k - 1]; if (i >= countZero && j >= countOne) { dp[i][j][curr] = Math.max(dp[i][j][curr], dp[i - countZero][j - countOne][prev] + 1); } } } } return dp[m][n][curr]; }","public int sample_funcname ( String [ ] var_1 , int var_2 , int var_3 ) { if ( var_1 == null || var_1 . length == 0 || ( var_2 == 0 && var_3 == 0 ) ) { return 0 ; } int var_7 = var_1 . length ; int [ ] [ ] [ ] var_10 = new int [ var_2 + 1 ] [ var_3 + 1 ] [ 2 ] ; int var_11 = 1 ; int var_12 = 0 ; int [ ] var_13 = new int [ var_7 ] ; int [ ] var_14 = new int [ var_7 ] ; for ( int var_15 = 0 ; var_15 < var_7 ; var_15 ++ ) { char [ ] var_17 = var_1 [ var_15 ] . toCharArray ( ) ; for ( char var_18 : var_17 ) { var_13 [ var_15 ] += var_18 == '1' ? 1 : 0 ; var_14 [ var_15 ] += var_18 == '0' ? 1 : 0 ; } } for ( int var_15 = 0 ; var_15 <= var_7 ; var_15 ++ ) { var_12 = var_11 ; var_11 = 1 - var_12 ; for ( int var_21 = 0 ; var_21 <= var_2 ; var_21 ++ ) { for ( int var_22 = 0 ; var_22 <= var_3 ; var_22 ++ ) { if ( var_15 == 0 || ( var_21 == 0 && var_22 == 0 ) ) { var_10 [ var_21 ] [ var_22 ] [ var_11 ] = 0 ; continue ; } var_10 [ var_21 ] [ var_22 ] [ var_11 ] = var_10 [ var_21 ] [ var_22 ] [ var_12 ] ; int var_23 = var_14 [ var_15 - 1 ] ; int var_24 = var_13 [ var_15 - 1 ] ; if ( var_21 >= var_23 && var_22 >= var_24 ) { var_10 [ var_21 ] [ var_22 ] [ var_11 ] = Math . max ( var_10 [ var_21 ] [ var_22 ] [ var_11 ] , var_10 [ var_21 - var_23 ] [ var_22 - var_24 ] [ var_12 ] + 1 ) ; } } } } return var_10 [ var_2 ] [ var_3 ] [ var_11 ] ; } " 267,Best Time to Buy and Sell Stock IV_4.java,"public int maxProfit(int k, int[] prices) { if (prices == null || prices.length < 2 || k <= 0) { return 0; } if (k >= prices.length) { int profit = 0; for (int i = 1; i < prices.length; i++) { if (prices[i] > prices[i - 1]) { profit += prices[i] - prices[i - 1]; } } return profit; } int[][] local = new int[prices.length][k + 1]; int[][] global = new int[prices.length][k + 1]; for (int i = 1; i < prices.length; i++) { int diff = prices[i] - prices[i - 1]; for (int j = 1; j <= k; j++) { local[i][j] = Math.max(global[i-1][j-1] + diff, local[i - 1][j] + diff); global[i][j] = Math.max(global[i-1][j], local[i][j]); } } return global[prices.length - 1][k]; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length < 2 || var_0 <= 0 ) { return 0 ; } if ( var_0 >= var_1 . length ) { int var_6 = 0 ; for ( int var_8 = 1 ; var_8 < var_1 . length ; var_8 ++ ) { if ( var_1 [ var_8 ] > var_1 [ var_8 - 1 ] ) { var_6 += var_1 [ var_8 ] - var_1 [ var_8 - 1 ] ; } } return var_6 ; } int [ ] [ ] var_9 = new int [ var_1 . length ] [ var_0 + 1 ] ; int [ ] [ ] var_10 = new int [ var_1 . length ] [ var_0 + 1 ] ; for ( int var_8 = 1 ; var_8 < var_1 . length ; var_8 ++ ) { int var_11 = var_1 [ var_8 ] - var_1 [ var_8 - 1 ] ; for ( int var_12 = 1 ; var_12 <= var_0 ; var_12 ++ ) { var_9 [ var_8 ] [ var_12 ] = Math . max ( var_10 [ var_8 - 1 ] [ var_12 - 1 ] + var_11 , var_9 [ var_8 - 1 ] [ var_12 ] + var_11 ) ; var_10 [ var_8 ] [ var_12 ] = Math . max ( var_10 [ var_8 - 1 ] [ var_12 ] , var_9 [ var_8 ] [ var_12 ] ) ; } } return var_10 [ var_1 . length - 1 ] [ var_0 ] ; } " 268,387. First Unique Character in a String_1.java,"public int firstUniqChar(String s) { int[] freq = new int[256]; for (char c : s.toCharArray()) freq[c - 'a']++; for (int i = 0; i < s.length(); i++) { if (freq[s.charAt(i) - 'a'] == 1) return i; } return -1; }","public int sample_funcname ( String var_1 ) { int [ ] var_3 = new int [ 256 ] ; for ( char var_5 : var_1 . toCharArray ( ) ) var_3 [ var_5 - 'a' ] ++ ; for ( int var_8 = 0 ; var_8 < var_1 . length ( ) ; var_8 ++ ) { if ( var_3 [ var_1 . charAt ( var_8 ) - 'a' ] == 1 ) return var_8 ; } return - 1 ; } " 269,78. Subsets_3.java,"public List> subsets(int[] nums) { List> result = new ArrayList<>(); if (nums == null || nums.length == 0) { return result; } int n = nums.length; long maxRange = (long) Math.pow(2, n) - 1; for (int i = 0; i <= maxRange; i++) { List list = new ArrayList<>(); int index = 0; int num = i; while (num != 0) { if ((num & 1) == 1) { list.add(nums[index]); } num = num >> 1; index++; } result.add(list); } return result; }","public List < List < Integer >> var_2 ( int [ ] var_3 ) { List < List < Integer >> var_5 = new ArrayList < > ( ) ; if ( var_3 == null || var_3 . length == 0 ) { return var_5 ; } int var_9 = var_3 . length ; long var_14 = ( long ) Math . pow ( 2 , var_9 ) - 1 ; for ( int var_15 = 0 ; var_15 <= var_14 ; var_15 ++ ) { List < Integer > var_16 = new ArrayList < > ( ) ; int var_17 = 0 ; int var_18 = var_15 ; while ( var_18 != 0 ) { if ( ( var_18 & 1 ) == 1 ) { var_16 . add ( var_3 [ var_17 ] ) ; } var_18 = var_18 >> 1 ; var_17 ++ ; } var_5 . add ( var_16 ) ; } return var_5 ; } " 270,720. Longest Word in Dictionary_2.java,"private ArrayList matchWords(ArrayList wordList) { int maxWordLength = Integer.MIN_VALUE; ArrayList result = new ArrayList<>(); for (int i = wordList.size() - 1; i >= 0; i--) { String word = wordList.get(i); while(word.length() != 0) { if (wordList.contains(word)) { if (word.length() == 1) { if (wordList.get(i).length() < maxWordLength) { return result; } else { result.add(wordList.get(i)); maxWordLength = wordList.get(i).length(); } } word = word.substring(0, word.length() - 1); } else { break; } } } return result; }","private ArrayList < String > var_1 ( ArrayList < String > var_3 ) { int var_6 = Integer . MIN_VALUE ; ArrayList < String > var_7 = new ArrayList < > ( ) ; for ( int var_10 = var_3 . size ( ) - 1 ; var_10 >= 0 ; var_10 -- ) { String var_13 = var_3 . get ( var_10 ) ; while ( var_13 . length ( ) != 0 ) { if ( var_3 . contains ( var_13 ) ) { if ( var_13 . length ( ) == 1 ) { if ( var_3 . get ( var_10 ) . length ( ) < var_6 ) { return var_7 ; } else { var_7 . add ( var_3 . get ( var_10 ) ) ; var_6 = var_3 . get ( var_10 ) . length ( ) ; } } var_13 = var_13 . substring ( 0 , var_13 . length ( ) - 1 ) ; } else { break ; } } } return var_7 ; } " 271,Copy Books_4.java,"private int validate(int[] pages, int totalTimePerPerson, int k) { int temp = 0; for (int i = 0; i < pages.length; i++) { temp += pages[i]; if (temp == totalTimePerPerson) { temp = 0; k--; } else if (temp < totalTimePerPerson) { if (i + 1 >= pages.length || temp + pages[i + 1] > totalTimePerPerson) { temp = 0; k--; } } else { return -1; } } return k; }","private int sample_funcname ( int [ ] var_0 , int var_1 , int var_2 ) { int var_4 = 0 ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { var_4 += var_0 [ var_5 ] ; if ( var_4 == var_1 ) { var_4 = 0 ; var_2 -- ; } else if ( var_4 < var_1 ) { if ( var_5 + 1 >= var_0 . length || var_4 + var_0 [ var_5 + 1 ] > var_1 ) { var_4 = 0 ; var_2 -- ; } } else { return - 1 ; } } return var_2 ; } " 272,House Robber II_3.java,"public int rob(int[] nums) { if (nums == null || nums.length == 0) { return 0; } else if (nums.length == 1) { return nums[0]; } int n = nums.length; int[][] dp = new int[n][2]; dp[0][0] = 0; dp[1][0] = nums[1]; dp[0][1] = nums[0]; dp[1][1] = dp[0][1]; for (int i = 2; i < n; i++) { if (i == n - 1) { dp[i][0] = Math.max(dp[i - 1][0], dp[i -2][0] + nums[i]); dp[i][1] = dp[i - 1][1]; } else { dp[i][0] = Math.max(dp[i - 1][0], dp[i -2][0] + nums[i]); dp[i][1] = Math.max(dp[i - 1][1], dp[i -2][1] + nums[i]); } } return Math.max(dp[n - 1][0], dp[n - 1][1]); }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } else if ( var_0 . length == 1 ) { return var_0 [ 0 ] ; } int var_5 = var_0 . length ; int [ ] [ ] var_7 = new int [ var_5 ] [ 2 ] ; var_7 [ 0 ] [ 0 ] = 0 ; var_7 [ 1 ] [ 0 ] = var_0 [ 1 ] ; var_7 [ 0 ] [ 1 ] = var_0 [ 0 ] ; var_7 [ 1 ] [ 1 ] = var_7 [ 0 ] [ 1 ] ; for ( int var_8 = 2 ; var_8 < var_5 ; var_8 ++ ) { if ( var_8 == var_5 - 1 ) { var_7 [ var_8 ] [ 0 ] = Math . max ( var_7 [ var_8 - 1 ] [ 0 ] , var_7 [ var_8 - 2 ] [ 0 ] + var_0 [ var_8 ] ) ; var_7 [ var_8 ] [ 1 ] = var_7 [ var_8 - 1 ] [ 1 ] ; } else { var_7 [ var_8 ] [ 0 ] = Math . max ( var_7 [ var_8 - 1 ] [ 0 ] , var_7 [ var_8 - 2 ] [ 0 ] + var_0 [ var_8 ] ) ; var_7 [ var_8 ] [ 1 ] = Math . max ( var_7 [ var_8 - 1 ] [ 1 ] , var_7 [ var_8 - 2 ] [ 1 ] + var_0 [ var_8 ] ) ; } } return Math . max ( var_7 [ var_5 - 1 ] [ 0 ] , var_7 [ var_5 - 1 ] [ 1 ] ) ; } " 273,299. Bulls and Cows_2.java,"public String getHint(String secret, String guess) { if (secret == null || guess == null || secret.length() == 0 || guess.length() == 0) { return ""0A0B""; } char[] secretArr = secret.toCharArray(); char[] guessArr = guess.toCharArray(); Map secretMap = new HashMap<>(); Map guessMap = new HashMap<>(); int bulls = 0; for (int i = 0; i < secretArr.length; i++) { char a = secretArr[i], b = guessArr[i]; if (a == b) { bulls++; } else { secretMap.putIfAbsent(a, 0); secretMap.put(a, secretMap.get(a) + 1); guessMap.putIfAbsent(b, 0); guessMap.put(b, guessMap.get(b) + 1); } } int cows = 0; for (Map.Entry entry : secretMap.entrySet()) { char key = entry.getKey(); if (guessMap.containsKey(key)) { cows += Math.min(entry.getValue(), guessMap.get(key)); } } return String.format(""%sA%sB"", bulls, cows); }","public String var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) == 0 || var_3 . length ( ) == 0 ) { return ""0A0B"" ; } char [ ] var_9 = var_2 . toCharArray ( ) ; char [ ] var_10 = var_3 . toCharArray ( ) ; Map < Character , Integer > var_15 = new HashMap < > ( ) ; Map < Character , Integer > var_16 = new HashMap < > ( ) ; int var_17 = 0 ; for ( int var_18 = 0 ; var_18 < var_9 . length ; var_18 ++ ) { char var_19 = var_9 [ var_18 ] , var_20 = var_10 [ var_18 ] ; if ( var_19 == var_20 ) { var_17 ++ ; } else { var_15 . putIfAbsent ( var_19 , 0 ) ; var_15 . put ( var_19 , var_15 . get ( var_19 ) + 1 ) ; var_16 . putIfAbsent ( var_20 , 0 ) ; var_16 . put ( var_20 , var_16 . get ( var_20 ) + 1 ) ; } } int var_25 = 0 ; for ( Map . Entry < Character , Integer > var_27 : var_15 . entrySet ( ) ) { char var_29 = var_27 . getKey ( ) ; if ( var_16 . containsKey ( var_29 ) ) { var_25 += Math . min ( var_27 . getValue ( ) , var_16 . get ( var_29 ) ) ; } } return String . format ( ""%sA%sB"" , var_17 , var_25 ) ; } " 274,261. Graph Valid Tree_1.java,"private Map> buildGraph(int n, int[][] edges) { Map> graph = new HashMap<>(); for (int i = 0; i < n; i++) graph.putIfAbsent(i, new HashSet<>()); for (int[] edge: edges) { graph.get(edge[0]).add(edge[1]); graph.get(edge[1]).add(edge[0]); } return graph; }","private Map < Integer , Set < Integer >> var_2 ( int var_3 , int [ ] [ ] var_4 ) { Map < Integer , Set < Integer >> var_7 = new HashMap < > ( ) ; for ( int var_9 = 0 ; var_9 < var_3 ; var_9 ++ ) var_7 . putIfAbsent ( var_9 , new HashSet < > ( ) ) ; for ( int [ ] var_12 : var_4 ) { var_7 . get ( var_12 [ 0 ] ) . add ( var_12 [ 1 ] ) ; var_7 . get ( var_12 [ 1 ] ) . add ( var_12 [ 0 ] ) ; } return var_7 ; } " 275,118. Pascal's Triangle_1.java,"public List> generate(int numRows) { List> result = new ArrayList<>(); if (numRows == 0) return result; if (numRows >= 1) result.add(Arrays.asList(1)); if (numRows >= 2) result.add(Arrays.asList(1, 1)); for (int row = 2; row < numRows; row++) { List list = new ArrayList<>(Arrays.asList(1, 1)); List lastRow = result.get(row - 1); int end = row - 1; for (int i = 1; i <= end; i++) { list.add(i, lastRow.get(i) + lastRow.get(i - 1)); } result.add(list); } return result; }","public List < List < Integer >> var_2 ( int var_3 ) { List < List < Integer >> var_5 = new ArrayList < > ( ) ; if ( var_3 == 0 ) return var_5 ; if ( var_3 >= 1 ) var_5 . add ( Arrays . asList ( 1 ) ) ; if ( var_3 >= 2 ) var_5 . add ( Arrays . asList ( 1 , 1 ) ) ; for ( int var_12 = 2 ; var_12 < var_3 ; var_12 ++ ) { List < Integer > var_13 = new ArrayList < > ( Arrays . asList ( 1 , 1 ) ) ; List < Integer > var_15 = var_5 . get ( var_12 - 1 ) ; int var_16 = var_12 - 1 ; for ( int var_17 = 1 ; var_17 <= var_16 ; var_17 ++ ) { var_13 . add ( var_17 , var_15 . get ( var_17 ) + var_15 . get ( var_17 - 1 ) ) ; } var_5 . add ( var_13 ) ; } return var_5 ; } " 276,[lint]. HashHeap_1.java,"int parent(int id) { if (id == 0) { return -1; } return (id - 1) / 2; }","int sample_funcname ( int var_0 ) { if ( var_0 == 0 ) { return - 1 ; } return ( var_0 - 1 ) / 2 ; } " 277,122. Best Time to Buy and Sell Stock II_6.java,"private int dfs(int[] prices, int index, boolean sellStatus) { if (index == prices.length - 1) { return sellStatus ? prices[index] : 0; } int profit = 0; for (int i = index; i < prices.length; i++) { profit = Math.max(profit, dfs(prices, i + 1, sellStatus)); int levelDelta = sellStatus ? prices[i] : - prices[i]; profit = Math.max(profit, dfs(prices, i + 1, !sellStatus) + levelDelta); } return profit; }","private int sample_funcname ( int [ ] prices , int index , boolean sellStatus ) { if ( index == prices . length - 1 ) { return sellStatus ? prices [ index ] : 0 ; } int profit = 0 ; for ( int i = index ; i < prices . length ; i ++ ) { profit = Math . max ( profit , dfs ( prices , i + 1 , sellStatus ) ) ; int levelDelta = sellStatus ? prices [ i ] : - prices [ i ] ; profit = Math . max ( profit , dfs ( prices , i + 1 , ! sellStatus ) + levelDelta ) ; } return profit ; } " 278,340. Longest Substring with At Most K Distinct Characters_3.java,"public int lengthOfLongestSubstringKDistinct(String s, int k) { if (s == null || s.length() == 0) return 0; int n = s.length(); Map lastOccurMap = new LinkedHashMap<>(k + 1); int left = 0, right = 0, max = 0; while (right < n) { char c = s.charAt(right); if (lastOccurMap.containsKey(c)) lastOccurMap.remove(c); lastOccurMap.put(c, right++); if (lastOccurMap.size() > k) { Map.Entry leftMost = lastOccurMap.entrySet().iterator().next(); lastOccurMap.remove(leftMost.getKey()); left = leftMost.getValue() + 1; } max = Math.max(max, right - left); } return max; }","public int sample_funcname ( String var_1 , int var_2 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) return 0 ; int var_6 = var_1 . length ( ) ; Map < Character , Integer > var_12 = new LinkedHashMap < > ( var_2 + 1 ) ; int var_13 = 0 , var_14 = 0 , max = 0 ; while ( var_14 < var_6 ) { char var_17 = var_1 . charAt ( var_14 ) ; if ( var_12 . containsKey ( var_17 ) ) var_12 . remove ( var_17 ) ; var_12 . put ( var_17 , var_14 ++ ) ; if ( var_12 . size ( ) > var_2 ) { Map . Entry < Character , Integer > var_26 = var_12 . entrySet ( ) . iterator ( ) . next ( ) ; var_12 . remove ( var_26 . getKey ( ) ) ; var_13 = var_26 . getValue ( ) + 1 ; } max = Math . max ( max , var_14 - var_13 ) ; } return max ; } " 279,Flip Game II_1.java,"private void setSign(boolean[] sign, int i, boolean value) { sign[i] = value; sign[i + 1] = value; }","private void var_0 ( boolean [ ] var_2 , int var_3 , boolean var_4 ) { var_2 [ var_3 ] = var_4 ; var_2 [ var_3 + 1 ] = var_4 ; } " 280,41. First Missing Positive_2.java,"public int firstMissingPositive(int[] A) { if (A == null || A.length == 0) { return 1; } Arrays.sort(A); int count = -1; for (int i = 0; i < A.length; i++) { if (A[i] > 0) { if (count < 0) { count = A[i]; if (count != 1) { return 1; } } else if (A[i] == A[i - 1]) { count--; } else if(A[i] != count) { return count; } count++; } } if (count < 0) { return 1; } return count; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 1 ; } Arrays . sort ( var_0 ) ; int var_7 = - 1 ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { if ( var_0 [ var_8 ] > 0 ) { if ( var_7 < 0 ) { var_7 = var_0 [ var_8 ] ; if ( var_7 != 1 ) { return 1 ; } } else if ( var_0 [ var_8 ] == var_0 [ var_8 - 1 ] ) { var_7 -- ; } else if ( var_0 [ var_8 ] != var_7 ) { return var_7 ; } var_7 ++ ; } } if ( var_7 < 0 ) { return 1 ; } return var_7 ; } " 281,Nim Game_4.java,"public boolean canWinNim(int n) { if (n <= 3) { return true; } boolean[] dp = new boolean[3]; dp[0] = dp[1] = dp[2] = true; for (int i = 3; i < n; i++) { dp[i % 3] = !dp[(i - 1) % 3] || !dp[(i - 2) % 3] || !dp[(i - 3) % 3]; } return dp[(n - 1) % 3]; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 3 ) { return true ; } boolean [ ] var_4 = new boolean [ 3 ] ; var_4 [ 0 ] = var_4 [ 1 ] = var_4 [ 2 ] = true ; for ( int var_8 = 3 ; var_8 < var_1 ; var_8 ++ ) { var_4 [ var_8 % 3 ] = ! var_4 [ ( var_8 - 1 ) % 3 ] || ! var_4 [ ( var_8 - 2 ) % 3 ] || ! var_4 [ ( var_8 - 3 ) % 3 ] ; } return var_4 [ ( var_1 - 1 ) % 3 ] ; } " 282,Triangle Count_1.java,"public int triangleNumber(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int count = 0; Arrays.sort(nums); for (int i = 2; i < nums.length; i++) { int start = 0; int end = i - 1; while (start < end) { if (nums[start] + nums[end] > nums[i]) { count += end - start; end--; } else { start++; } } } return count; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = 0 ; Arrays . sort ( var_0 ) ; for ( int var_8 = 2 ; var_8 < var_0 . length ; var_8 ++ ) { int var_9 = 0 ; int var_11 = var_8 - 1 ; while ( var_9 < var_11 ) { if ( var_0 [ var_9 ] + var_0 [ var_11 ] > var_0 [ var_8 ] ) { var_4 += var_11 - var_9 ; var_11 -- ; } else { var_9 ++ ; } } } return var_4 ; } " 283,674. Longest Continuous Increasing Subsequence_4.java,"public int findLengthOfLCIS(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length; int[] dp = new int[2]; dp[0] = 1; int max = 1; for (int i = 1; i < n; i++) { dp[i%2] = 1; if (nums[i] > nums[i - 1]) dp[i%2] = Math.max(dp[i%2], dp[(i - 1)%2] + 1); max = Math.max(max, dp[i%2]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length ; int [ ] var_6 = new int [ 2 ] ; var_6 [ 0 ] = 1 ; int max = 1 ; for ( int var_9 = 1 ; var_9 < var_4 ; var_9 ++ ) { var_6 [ var_9 % 2 ] = 1 ; if ( var_0 [ var_9 ] > var_0 [ var_9 - 1 ] ) var_6 [ var_9 % 2 ] = Math . max ( var_6 [ var_9 % 2 ] , var_6 [ ( var_9 - 1 ) % 2 ] + 1 ) ; max = Math . max ( max , var_6 [ var_9 % 2 ] ) ; } return max ; } " 284,42. Trapping Rain Water_2.java,"public int trap(int[] height) { if (height == null || height.length == 0) return 0; int n = height.length, left = 0, right = n - 1; int maxLeft = height[0], maxRight = height[n - 1]; int total = 0; while (left < right) { if (maxLeft < maxRight) { left++; if (maxLeft > height[left]) total += maxLeft - height[left]; else maxLeft = height[left]; } else { right--; if (maxRight > height[right]) total += maxRight - height[right]; else maxRight = height[right]; } } return total; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = 0 , var_7 = var_4 - 1 ; int var_8 = var_0 [ 0 ] , var_9 = var_0 [ var_4 - 1 ] ; int var_10 = 0 ; while ( var_5 < var_7 ) { if ( var_8 < var_9 ) { var_5 ++ ; if ( var_8 > var_0 [ var_5 ] ) var_10 += var_8 - var_0 [ var_5 ] ; else var_8 = var_0 [ var_5 ] ; } else { var_7 -- ; if ( var_9 > var_0 [ var_7 ] ) var_10 += var_9 - var_0 [ var_7 ] ; else var_9 = var_0 [ var_7 ] ; } } return var_10 ; } " 285,Number of Longest Increasing Subsequence_1.java,"public int findNumberOfLIS(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length, maxLen = 0, maxFreq = 0; int[] len = new int[n]; int[] count = new int[n]; for (int i = 0; i < n; i++) { len[i] = 1; count[i] = 1; for (int j = 0; j < i; j++) { if (nums[j] < nums[i]) { if (len[i] == len[j] + 1) { count[i] += count[j]; } else if (len[i] < len[j] + 1) { len[i] = len[j] + 1; count[i] = count[j]; } } } if (maxLen == len[i]) { maxFreq += count[i]; } else if (maxLen < len[i]) { maxLen = len[i]; maxFreq = count[i]; } } return maxFreq; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = 0 , var_6 = 0 ; int [ ] var_7 = new int [ var_4 ] ; int [ ] var_8 = new int [ var_4 ] ; for ( int var_9 = 0 ; var_9 < var_4 ; var_9 ++ ) { var_7 [ var_9 ] = 1 ; var_8 [ var_9 ] = 1 ; for ( int var_11 = 0 ; var_11 < var_9 ; var_11 ++ ) { if ( var_0 [ var_11 ] < var_0 [ var_9 ] ) { if ( var_7 [ var_9 ] == var_7 [ var_11 ] + 1 ) { var_8 [ var_9 ] += var_8 [ var_11 ] ; } else if ( var_7 [ var_9 ] < var_7 [ var_11 ] + 1 ) { var_7 [ var_9 ] = var_7 [ var_11 ] + 1 ; var_8 [ var_9 ] = var_8 [ var_11 ] ; } } } if ( var_5 == var_7 [ var_9 ] ) { var_6 += var_8 [ var_9 ] ; } else if ( var_5 < var_7 [ var_9 ] ) { var_5 = var_7 [ var_9 ] ; var_6 = var_8 [ var_9 ] ; } } return var_6 ; } " 286,Best Time to Buy and Sell Stock with Transaction Fee_1.java,"public int maxProfit(int[] prices, int fee) { if (prices == null || prices.length <= 1) return 0; int n = prices.length; int[][] dp = new int[n + 1][2]; dp[0][0] = dp[0][1] = 0; dp[1][1] = 0; dp[1][0] = - prices[0]; for (int i = 2; i <= n; i++) { dp[i][0] = Math.max(dp[i-1][0], dp[i - 1][1] - prices[i - 1]); dp[i][1] = Math.max(dp[i-1][1], dp[i - 1][0] + prices[i - 1] - fee); } return dp[n][1]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length <= 1 ) return 0 ; int var_6 = var_0 . length ; int [ ] [ ] var_8 = new int [ var_6 + 1 ] [ 2 ] ; var_8 [ 0 ] [ 0 ] = var_8 [ 0 ] [ 1 ] = 0 ; var_8 [ 1 ] [ 1 ] = 0 ; var_8 [ 1 ] [ 0 ] = - var_0 [ 0 ] ; for ( int var_9 = 2 ; var_9 <= var_6 ; var_9 ++ ) { var_8 [ var_9 ] [ 0 ] = Math . max ( var_8 [ var_9 - 1 ] [ 0 ] , var_8 [ var_9 - 1 ] [ 1 ] - var_0 [ var_9 - 1 ] ) ; var_8 [ var_9 ] [ 1 ] = Math . max ( var_8 [ var_9 - 1 ] [ 1 ] , var_8 [ var_9 - 1 ] [ 0 ] + var_0 [ var_9 - 1 ] - var_1 ) ; } return var_8 [ var_6 ] [ 1 ] ; } " 287,1213. Intersection of Three Sorted Arrays_2.java,"public List arraysIntersection(int[] arr1, int[] arr2, int[] arr3) { List rst = new LinkedList<>(); int i = arr1.length - 1, j = arr2.length - 1, k = arr3.length - 1; while (i >= 0 && j >= 0 && k >= 0) { if (arr1[i] == arr2[j] && arr2[j] == arr3[k]) { if (rst.isEmpty() || arr1[i] != rst.get(rst.size() - 1)) rst.add(0, arr1[i]); i--; j--; k--; } else if (arr2[j] < arr3[k]) k--; else if (arr1[i] < arr2[j]) j--; else i--; } return rst; }","public List < Integer > var_1 ( int [ ] var_2 , int [ ] var_3 , int [ ] var_4 ) { List < Integer > var_7 = new LinkedList < > ( ) ; int var_10 = var_2 . length - 1 , var_11 = var_3 . length - 1 , var_12 = var_4 . length - 1 ; while ( var_10 >= 0 && var_11 >= 0 && var_12 >= 0 ) { if ( var_2 [ var_10 ] == var_3 [ var_11 ] && var_3 [ var_11 ] == var_4 [ var_12 ] ) { if ( var_7 . isEmpty ( ) || var_2 [ var_10 ] != var_7 . get ( var_7 . size ( ) - 1 ) ) var_7 . add ( 0 , var_2 [ var_10 ] ) ; var_10 -- ; var_11 -- ; var_12 -- ; } else if ( var_3 [ var_11 ] < var_4 [ var_12 ] ) var_12 -- ; else if ( var_2 [ var_10 ] < var_3 [ var_11 ] ) var_11 -- ; else var_10 -- ; } return var_7 ; } " 288,Convert Integer A to Integer B_1.java,"public static int bitSwapRequired(int a, int b) { int count = 0; for (int i = 0; i < 32; i++) { count += (a ^ b) >> i & 1; } return count; }","public static int sample_funcname ( int var_0 , int var_1 ) { int var_3 = 0 ; for ( int var_4 = 0 ; var_4 < 32 ; var_4 ++ ) { var_3 += ( var_0 ^ var_1 ) >> var_4 & 1 ; } return var_3 ; } " 289,Count 1 in Binary_1.java,"public int countOnes(int num) { int count = 0; for (int i = 1; i <= 32; i++) { count += num >> i & 1; } return count; }","public int sample_funcname ( int var_0 ) { int var_2 = 0 ; for ( int var_4 = 1 ; var_4 <= 32 ; var_4 ++ ) { var_2 += var_0 >> var_4 & 1 ; } return var_2 ; } " 290,463. Island Perimeter_1.java,"private boolean validate(int[][] grid, int x, int y) { return x >= 0 && y >= 0 && x < grid.length && y < grid[0].length && grid[x][y] == 1; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 >= 0 && var_3 >= 0 && var_2 < var_1 . length && var_3 < var_1 [ 0 ] . length && var_1 [ var_2 ] [ var_3 ] == 1 ; } " 291,43. Multiply Strings_3.java,"private char toChar(int num) { return (char)(num + '0'); }","private char sample_funcname ( int var_0 ) { return ( char ) ( var_0 + '0' ) ; } " 292,136. Single Number_1.java,"public int singleNumber(int[] nums) { if (nums == null || nums.length == 0) return 0; int result = 0; for (int i : nums) { result = result ^ i; } return result; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = 0 ; for ( int var_5 : var_0 ) { var_4 = var_4 ^ var_5 ; } return var_4 ; } " 293,Letter Combinations of a Phone Number_2.java,"public void helper(ArrayList rst, ArrayList list, ArrayList map, String digits, int level){ if (level == digits.length()) { StringBuffer sb = new StringBuffer(); for (String s : list) { sb.append(s); } rst.add(sb.toString()); return; } int num = Integer.parseInt(digits.substring(level, level + 1)); String[] strs = map.get(num); for (int i = 0; i < strs.length; i++) { list.add(strs[i]); helper(rst, list, map, digits, level + 1); list.remove(list.size() - 1); } }","public void sample_funcname ( ArrayList < String > rst , ArrayList < String > list , ArrayList < String [ ] > map , String digits , int level ) { if ( level == digits . length ( ) ) { StringBuffer sb = new StringBuffer ( ) ; for ( String s : list ) { sb . append ( s ) ; } rst . add ( sb . toString ( ) ) ; return ; } int num = Integer . parseInt ( digits . substring ( level , level + 1 ) ) ; String [ ] strs = map . get ( num ) ; for ( int i = 0 ; i < strs . length ; i ++ ) { list . add ( strs [ i ] ) ; helper ( rst , list , map , digits , level + 1 ) ; list . remove ( list . size ( ) - 1 ) ; } } " 294,O(1) Check Power of 2_1.java,"public boolean checkPowerOf2(int n) { if (n <= 0) { return false; } return (n & (n - 1)) == 0; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 0 ) { return false ; } return ( var_1 & ( var_1 - 1 ) ) == 0 ; } " 295,Longest Common Subsequence_1.java,"public int longestCommonSubsequence(String A, String B) { if (A == null || B == null || A.length() == 0 || B.length() == 0) { return 0; } int m = A.length(); int n = B.length(); int[][] dp = new int[m + 1][n + 1]; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0 || j == 0) { dp[i][j] = 0; continue; } dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]); if (A.charAt(i - 1) == B.charAt(j - 1)) { dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - 1] + 1); } } } return dp[m][n]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) == 0 || var_2 . length ( ) == 0 ) { return 0 ; } int var_6 = var_1 . length ( ) ; int var_7 = var_2 . length ( ) ; int [ ] [ ] var_9 = new int [ var_6 + 1 ] [ var_7 + 1 ] ; for ( int var_10 = 0 ; var_10 <= var_6 ; var_10 ++ ) { for ( int var_11 = 0 ; var_11 <= var_7 ; var_11 ++ ) { if ( var_10 == 0 || var_11 == 0 ) { var_9 [ var_10 ] [ var_11 ] = 0 ; continue ; } var_9 [ var_10 ] [ var_11 ] = Math . max ( var_9 [ var_10 - 1 ] [ var_11 ] , var_9 [ var_10 ] [ var_11 - 1 ] ) ; if ( var_1 . charAt ( var_10 - 1 ) == var_2 . charAt ( var_11 - 1 ) ) { var_9 [ var_10 ] [ var_11 ] = Math . max ( var_9 [ var_10 ] [ var_11 ] , var_9 [ var_10 - 1 ] [ var_11 - 1 ] + 1 ) ; } } } return var_9 [ var_6 ] [ var_7 ] ; } " 296,Longest Increasing Path in a Matrix_1.java,"private boolean validateCoordinate(int[][] matrix, int x, int y, int nx, int ny) { return nx >= 0 && nx < matrix.length && ny >= 0 && ny < matrix[0].length && matrix[x][y] < matrix[nx][ny]; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 , int var_4 , int var_5 ) { return var_4 >= 0 && var_4 < var_1 . length && var_5 >= 0 && var_5 < var_1 [ 0 ] . length && var_1 [ var_2 ] [ var_3 ] < var_1 [ var_4 ] [ var_5 ] ; } " 297,921. Minimum Add to Make Parentheses Valid_2.java,"public int minAddToMakeValid(String s) { if (s == null || s.length() == 0) { return 0; } int count = 0, openCount = 0; for (char c : s.toCharArray()) { if (c == '(') openCount++; else if (openCount == 0) count++; else openCount--; } return count + openCount; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } int var_5 = 0 , var_6 = 0 ; for ( char var_8 : var_1 . toCharArray ( ) ) { if ( var_8 == '(' ) var_6 ++ ; else if ( var_6 == 0 ) var_5 ++ ; else var_6 -- ; } return var_5 + var_6 ; } " 298,The Maze II_1.java,"private String getKey(int x, int y){ return x + ""@"" + y; }","private String var_0 ( int var_1 , int var_2 ) { return var_1 + ""@"" + var_2 ; } " 299,239. Sliding Window Maximum_4.java,"private void outQueue(Deque deque, int num) { if (deque.peekFirst() == num) deque.pollFirst(); }","private void var_0 ( Deque < Integer > var_3 , int var_4 ) { if ( var_3 . peekFirst ( ) == var_4 ) var_3 . pollFirst ( ) ; } " 300,[lint]. Anagrams_1.java,"public List anagrams(String[] strs) { List rst = new ArrayList<>(); if (strs == null || strs == null) return rst; Map> map = new HashMap<>(); for (String word : strs){ int[] arr = new int[26]; for (char c : word.toCharArray()) arr[c - 'a']++; String key = Arrays.toString(arr); map.putIfAbsent(key, new ArrayList<>()); map.get(key).add(word); } for (List list : map.values()) { if (list.size() >= 2) rst.addAll(list); } return rst; }","public List < String > var_1 ( String [ ] var_2 ) { List < String > var_5 = new ArrayList < > ( ) ; if ( var_2 == null || var_2 == null ) return var_5 ; Map < String , List < String >> var_9 = new HashMap < > ( ) ; for ( String var_10 : var_2 ) { int [ ] var_12 = new int [ 26 ] ; for ( char var_14 : var_10 . toCharArray ( ) ) var_12 [ var_14 - 'a' ] ++ ; String var_18 = Arrays . toString ( var_12 ) ; var_9 . putIfAbsent ( var_18 , new ArrayList < > ( ) ) ; var_9 . get ( var_18 ) . add ( var_10 ) ; } for ( List < String > var_23 : var_9 . values ( ) ) { if ( var_23 . size ( ) >= 2 ) var_5 . addAll ( var_23 ) ; } return var_5 ; } " 301,Find Minimum in Rotated Sorted Array_1.java,"public int findMin(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int start = 0; int end = n - 1; while (start + 1 < end) { int mid = (start + end) >> 1; if (mid - 1 >= 0 && mid + 1 < n && nums[mid - 1] > nums[mid] && nums[mid] < nums[mid + 1]) { return nums[mid]; } else if (nums[mid] > nums[end]) { start = mid; } else { end = mid; } } return nums[start] < nums[end] ? nums[start] : nums[end]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = 0 ; int var_7 = var_4 - 1 ; while ( var_5 + 1 < var_7 ) { int var_8 = ( var_5 + var_7 ) >> 1 ; if ( var_8 - 1 >= 0 && var_8 + 1 < var_4 && var_0 [ var_8 - 1 ] > var_0 [ var_8 ] && var_0 [ var_8 ] < var_0 [ var_8 + 1 ] ) { return var_0 [ var_8 ] ; } else if ( var_0 [ var_8 ] > var_0 [ var_7 ] ) { var_5 = var_8 ; } else { var_7 = var_8 ; } } return var_0 [ var_5 ] < var_0 [ var_7 ] ? var_0 [ var_5 ] : var_0 [ var_7 ] ; } " 302,Orderly Queue_1.java,"public String orderlyQueue(String S, int K) { if (K > 1) { char[] arr = S.toCharArray(); Arrays.sort(arr); return new String(arr); } String res = S; for (int i = 1; i < S.length(); i++) { String tmp = S.substring(i) + S.substring(0, i); if (res.compareTo(tmp) > 0) res = tmp; } return res; }","public String var_0 ( String var_2 , int var_3 ) { if ( var_3 > 1 ) { char [ ] var_6 = var_2 . toCharArray ( ) ; Arrays . sort ( var_6 ) ; return new String ( var_6 ) ; } String var_9 = var_2 ; for ( int var_10 = 1 ; var_10 < var_2 . length ( ) ; var_10 ++ ) { String var_14 = var_2 . substring ( var_10 ) + var_2 . substring ( 0 , var_10 ) ; if ( var_9 . compareTo ( var_14 ) > 0 ) var_9 = var_14 ; } return var_9 ; } " 303,274.H-Index_2.java,"public int hIndex(int[] citations) { if (citations == null || citations.length == 0) { return 0; } int n = citations.length; Arrays.sort(citations); int i = 0; while (i < n && citations[i] < n - i) { i++; } return n - i; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; Arrays . sort ( var_0 ) ; int var_7 = 0 ; while ( var_7 < var_4 && var_0 [ var_7 ] < var_4 - var_7 ) { var_7 ++ ; } return var_4 - var_7 ; } " 304,Walls and Gates_2.java,"private boolean validate(int[][] rooms) { return rooms == null || rooms.length == 0 || rooms[0] == null || rooms[0].length == 0; }","private boolean var_0 ( int [ ] [ ] var_1 ) { return var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 ; } " 305,Word Ladder_3.java,"public int compare(String s1, String s2) { int count = 0; for (int i = 0; i < s1.length(); i++) { count += s1.charAt(i) != s2.charAt(i) ? 1 : 0; if (count > 1) { return count; } } return count; }","public int sample_funcname ( String var_1 , String var_2 ) { int var_4 = 0 ; for ( int var_5 = 0 ; var_5 < var_1 . length ( ) ; var_5 ++ ) { var_4 += var_1 . charAt ( var_5 ) != var_2 . charAt ( var_5 ) ? 1 : 0 ; if ( var_4 > 1 ) { return var_4 ; } } return var_4 ; } " 306,Ugly Number II_1.java,"public int nthUglyNumber(int n) { if (n <= 1) return n; int[] dp = new int[n]; dp[0] = 1; int index2 = 0, index3 = 0, index5 = 0; int factor2 = 2, factor3 = 3, factor5 = 5; for (int i = 1; i < n; i++){ int min = Math.min(Math.min(factor2, factor3), factor5); dp[i] = min; if (factor2 == min) factor2 = dp[++index2] * 2; if (factor3 == min) factor3 = dp[++index3] * 3; if (factor5 == min) factor5 = dp[++index5] * 5; } return dp[n-1]; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 1 ) return var_0 ; int [ ] var_2 = new int [ var_0 ] ; var_2 [ 0 ] = 1 ; int var_4 = 0 , var_5 = 0 , var_6 = 0 ; int var_8 = 2 , var_10 = 3 , var_12 = 5 ; for ( int var_13 = 1 ; var_13 < var_0 ; var_13 ++ ) { int min = Math . min ( Math . min ( var_8 , var_10 ) , var_12 ) ; var_2 [ var_13 ] = min ; if ( var_8 == min ) var_8 = var_2 [ ++ var_4 ] * 2 ; if ( var_10 == min ) var_10 = var_2 [ ++ var_5 ] * 3 ; if ( var_12 == min ) var_12 = var_2 [ ++ var_6 ] * 5 ; } return var_2 [ var_0 - 1 ] ; } " 307,Search for a Range_2.java,"public ArrayList searchRange(ArrayList A, int target) { int start = 0; int end = A.size() - 1; int mid; ArrayList bound = new ArrayList(); bound.add(-1); bound.add(-1); if ( A.size() == 0) { return bound; } while (start + 1 < end) { mid = start + (end - start) / 2; if (A.get(mid) < target) { start = mid; } else if (A.get(mid) > target) { end = mid; } else { end = mid; } } if (A.get(start) == target) { bound.set(0, start); } else if (A.get(end) == target) { bound.set(0, end); } else { return bound; } start = 0; end = A.size() - 1; while (start + 1 < end) { mid = start + (end - start) / 2; if (A.get(mid) < target) { start = mid; } else if (A.get(mid) > target) { end = mid; } else { start = mid; } } if (A.get(end) == target) { bound.set(1, end); } else if (A.get(start) == target) { bound.set(1, start); } else { return bound; } return bound; }","public ArrayList < Integer > var_1 ( ArrayList < Integer > var_3 , int var_4 ) { int var_6 = 0 ; int var_9 = var_3 . size ( ) - 1 ; int var_10 ; ArrayList < Integer > var_11 = new ArrayList < Integer > ( ) ; var_11 . add ( - 1 ) ; var_11 . add ( - 1 ) ; if ( var_3 . size ( ) == 0 ) { return var_11 ; } while ( var_6 + 1 < var_9 ) { var_10 = var_6 + ( var_9 - var_6 ) / 2 ; if ( var_3 . get ( var_10 ) < var_4 ) { var_6 = var_10 ; } else if ( var_3 . get ( var_10 ) > var_4 ) { var_9 = var_10 ; } else { var_9 = var_10 ; } } if ( var_3 . get ( var_6 ) == var_4 ) { var_11 . set ( 0 , var_6 ) ; } else if ( var_3 . get ( var_9 ) == var_4 ) { var_11 . set ( 0 , var_9 ) ; } else { return var_11 ; } var_6 = 0 ; var_9 = var_3 . size ( ) - 1 ; while ( var_6 + 1 < var_9 ) { var_10 = var_6 + ( var_9 - var_6 ) / 2 ; if ( var_3 . get ( var_10 ) < var_4 ) { var_6 = var_10 ; } else if ( var_3 . get ( var_10 ) > var_4 ) { var_9 = var_10 ; } else { var_6 = var_10 ; } } if ( var_3 . get ( var_9 ) == var_4 ) { var_11 . set ( 1 , var_9 ) ; } else if ( var_3 . get ( var_6 ) == var_4 ) { var_11 . set ( 1 , var_6 ) ; } else { return var_11 ; } return var_11 ; } " 308,Backpack III_3.java,"public int backPackIII(int[] A, int[] V, int m) { if (A == null || A.length == 0 || V == null || V.length == 0 || m <= 0) { return 0; } int n = A.length; int[] dp = new int[m + 1]; dp[0] = 0; for (int i = 1; i <= n; i++) { for (int j = A[i - 1]; j <= m && j >= A[i - 1]; j++) { dp[j] = Math.max(dp[j], dp[j - A[i - 1]] + V[i - 1]); } } return dp[m]; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 , int var_2 ) { if ( var_0 == null || var_0 . length == 0 || var_1 == null || var_1 . length == 0 || var_2 <= 0 ) { return 0 ; } int var_6 = var_0 . length ; int [ ] var_8 = new int [ var_2 + 1 ] ; var_8 [ 0 ] = 0 ; for ( int var_9 = 1 ; var_9 <= var_6 ; var_9 ++ ) { for ( int var_10 = var_0 [ var_9 - 1 ] ; var_10 <= var_2 && var_10 >= var_0 [ var_9 - 1 ] ; var_10 ++ ) { var_8 [ var_10 ] = Math . max ( var_8 [ var_10 ] , var_8 [ var_10 - var_0 [ var_9 - 1 ] ] + var_1 [ var_9 - 1 ] ) ; } } return var_8 [ var_2 ] ; } " 309,448. Find All Numbers Disappeared in an Array_1.java,"private void swap(int[] nums, int a, int b) { int temp = nums[a]; nums[a] = nums[b]; nums[b] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 310,151. Reverse Words in a String_4.java,"private void reverse(char[] arr, int i, int j) { while (i < j) { char temp = arr[i]; arr[i++] = arr[j]; arr[j--] = temp; } }","private void var_0 ( char [ ] var_1 , int var_2 , int var_3 ) { while ( var_2 < var_3 ) { char var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ++ ] = var_1 [ var_3 ] ; var_1 [ var_3 -- ] = var_4 ; } } " 311,Sum of Two Integers_1.java,"public int getSum(int a, int b) { int sum = a ^ b; int nextCarry = (a & b) << 1; while (nextCarry != 0) { int currentCarry = sum & nextCarry; sum = sum ^ nextCarry; nextCarry = currentCarry << 1; } return sum; }","public int sample_funcname ( int var_0 , int var_1 ) { int var_2 = var_0 ^ var_1 ; int var_4 = ( var_0 & var_1 ) << 1 ; while ( var_4 != 0 ) { int var_6 = var_2 & var_4 ; var_2 = var_2 ^ var_4 ; var_4 = var_6 << 1 ; } return var_2 ; } " 312,204. Count Primes_1.java,"public int countPrimes(int n) { if (n <= 1) { return 0; } boolean[] primes = new boolean[n]; for (int i = 2; i < primes.length; i++) { primes[i] = true; } for (int i = 2; i * i < n; i++) { if (!primes[i]) { continue; } for (int j = i * i; j < n; j += i) { primes[j] = false; } } int count = 0; for (int i = 2; i < primes.length; i++) { count += primes[i] ? 1 : 0; } return count; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 1 ) { return 0 ; } boolean [ ] var_4 = new boolean [ var_0 ] ; for ( int var_6 = 2 ; var_6 < var_4 . length ; var_6 ++ ) { var_4 [ var_6 ] = true ; } for ( int var_6 = 2 ; var_6 * var_6 < var_0 ; var_6 ++ ) { if ( ! var_4 [ var_6 ] ) { continue ; } for ( int var_8 = var_6 * var_6 ; var_8 < var_0 ; var_8 += var_6 ) { var_4 [ var_8 ] = false ; } } int var_9 = 0 ; for ( int var_6 = 2 ; var_6 < var_4 . length ; var_6 ++ ) { var_9 += var_4 [ var_6 ] ? 1 : 0 ; } return var_9 ; } " 313,Decode String_3.java,"public String expressionExpand(String s) { if (s == null || s.length() == 0) { return """"; } StringBuffer sb = new StringBuffer(); String substring = """"; int number = 0; int paren = 0; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '[') { if (paren > 0) { substring += c; } paren++; } else if (c == ']') { paren--; if (paren == 0) { String innerString = expressionExpand(substring); for (int num = 0; num < number; num++) { sb.append(innerString); } number = 0; substring = """"; } else { substring += c; } } else if (Character.isDigit(c)) { if (paren == 0) { number = number * 10 + (c - '0'); } else { substring += c; } } else { if (paren == 0) { sb.append(String.valueOf(c)); } else { substring += c; } } } return sb.toString(); }","public String sample_funcname ( String s ) { if ( s == null || s . length ( ) == 0 ) { return """" ; } StringBuffer sb = new StringBuffer ( ) ; String substring = """" ; int number = 0 ; int paren = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c == '[' ) { if ( paren > 0 ) { substring += c ; } paren ++ ; } else if ( c == ']' ) { paren -- ; if ( paren == 0 ) { String innerString = expressionExpand ( substring ) ; for ( int num = 0 ; num < number ; num ++ ) { sb . append ( innerString ) ; } number = 0 ; substring = """" ; } else { substring += c ; } } else if ( Character . isDigit ( c ) ) { if ( paren == 0 ) { number = number * 10 + ( c - '0' ) ; } else { substring += c ; } } else { if ( paren == 0 ) { sb . append ( String . valueOf ( c ) ) ; } else { substring += c ; } } } return sb . toString ( ) ; } " 314,Expression Tree Build_1.java,"public int getWeight(int base, String s) { if (s.equals(""+"") || s.equals(""-"")) { return base + 1; } if (s.equals(""*"") || s.equals(""/"")) { return base + 2; } return Integer.MAX_VALUE; }","public int sample_funcname ( int var_0 , String var_2 ) { if ( var_2 . equals ( ""+"" ) || var_2 . equals ( ""-"" ) ) { return var_0 + 1 ; } if ( var_2 . equals ( ""*"" ) || var_2 . equals ( ""/"" ) ) { return var_0 + 2 ; } return Integer . MAX_VALUE ; } " 315,844. Backspace String Compare_2.java,"private String build(String s) { Stack stack = new Stack<>(); for (char c : s.toCharArray()) { if (c != '#') stack.push(c); else if (!stack.isEmpty()) stack.pop(); } StringBuffer sb = new StringBuffer(); while (!stack.isEmpty()) sb.insert(0, stack.pop()); return sb.toString(); }","private String var_0 ( String var_2 ) { Stack < Character > var_5 = new Stack < > ( ) ; for ( char var_7 : var_2 . toCharArray ( ) ) { if ( var_7 != '#' ) var_5 . push ( var_7 ) ; else if ( ! var_5 . isEmpty ( ) ) var_5 . pop ( ) ; } StringBuffer var_13 = new StringBuffer ( ) ; while ( ! var_5 . isEmpty ( ) ) var_13 . insert ( 0 , var_5 . pop ( ) ) ; return var_13 . toString ( ) ; } " 316,Interleaving String_3.java,"public boolean isInterleave(String s1, String s2, String s3) { if (s3 == null || (s1 == null && s2 == null) || s1.length() + s2.length() != s3.length()) { return false; } boolean[][] DP = new boolean[s1.length() + 1][s2.length() + 1]; DP[0][0] = true; for (int i = 1; i <= s1.length(); i++) { if (s3.charAt(i - 1) == s1.charAt(i - 1) && DP[i - 1][0]) { DP[i][0] = true; } } for (int j = 1; j <= s2.length(); j++) { if (s3.charAt(j - 1) == s2.charAt(j - 1) && DP[0][j - 1]) { DP[0][j] = true; } } for (int i = 1; i <= s1.length(); i++) { for (int j = 1; j <= s2.length(); j++) { if ((s3.charAt(i + j - 1) == s1.charAt(i - 1) && DP[i - 1][j]) || (s3.charAt(i + j - 1) == s2.charAt(j - 1) && DP[i][j - 1])) { DP[i][j] = true; } } } return DP[s1.length()][s2.length()]; }","public boolean var_0 ( String var_2 , String var_3 , String var_4 ) { if ( var_4 == null || ( var_2 == null && var_3 == null ) || var_2 . length ( ) + var_3 . length ( ) != var_4 . length ( ) ) { return false ; } boolean [ ] [ ] var_9 = new boolean [ var_2 . length ( ) + 1 ] [ var_3 . length ( ) + 1 ] ; var_9 [ 0 ] [ 0 ] = true ; for ( int var_10 = 1 ; var_10 <= var_2 . length ( ) ; var_10 ++ ) { if ( var_4 . charAt ( var_10 - 1 ) == var_2 . charAt ( var_10 - 1 ) && var_9 [ var_10 - 1 ] [ 0 ] ) { var_9 [ var_10 ] [ 0 ] = true ; } } for ( int var_13 = 1 ; var_13 <= var_3 . length ( ) ; var_13 ++ ) { if ( var_4 . charAt ( var_13 - 1 ) == var_3 . charAt ( var_13 - 1 ) && var_9 [ 0 ] [ var_13 - 1 ] ) { var_9 [ 0 ] [ var_13 ] = true ; } } for ( int var_10 = 1 ; var_10 <= var_2 . length ( ) ; var_10 ++ ) { for ( int var_13 = 1 ; var_13 <= var_3 . length ( ) ; var_13 ++ ) { if ( ( var_4 . charAt ( var_10 + var_13 - 1 ) == var_2 . charAt ( var_10 - 1 ) && var_9 [ var_10 - 1 ] [ var_13 ] ) || ( var_4 . charAt ( var_10 + var_13 - 1 ) == var_3 . charAt ( var_13 - 1 ) && var_9 [ var_10 ] [ var_13 - 1 ] ) ) { var_9 [ var_10 ] [ var_13 ] = true ; } } } return var_9 [ var_2 . length ( ) ] [ var_3 . length ( ) ] ; } " 317,Combination Sum III_1.java,"private void dfs(List> result, List list, int index, int k, int n) { for (int i = index; i <= 9; i++) { list.add(i); if (n == i && list.size() == k) { result.add(new ArrayList<>(list)); } else if (n > i){ dfs(result, list, i + 1, k, n - i); } list.remove(list.size() - 1); } }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int index , int k , int n ) { for ( int i = index ; i <= 9 ; i ++ ) { list . add ( i ) ; if ( n == i && list . size ( ) == k ) { result . add ( new ArrayList < > ( list ) ) ; } else if ( n > i ) { dfs ( result , list , i + 1 , k , n - i ) ; } list . remove ( list . size ( ) - 1 ) ; } } " 318,65. Valid Number_1.java,"public boolean isNumber(String s) { if (s == null) return false; s = s.trim(); if (s.length() == 0) return false; int i = 0; char[] ss = s.toCharArray(); if (ss[i] == '+' || ss[i] == '-') i++; boolean isNum = false, isDot = false, isExp = false; for (; i < s.length(); i++) { char c = ss[i]; if (Character.isDigit(c)) isNum = true; else if (c == '.') { if (isDot || isExp) return false; isDot = true; } else if (c == 'e') { if (isExp || !isNum) return false; isExp = true; isNum = false; } else if (c == '+' || c == '-') { if (i >= 1 && s.charAt(i - 1) != 'e') return false; } else return false; } return isNum; }","public boolean var_0 ( String var_2 ) { if ( var_2 == null ) return false ; var_2 = var_2 . trim ( ) ; if ( var_2 . length ( ) == 0 ) return false ; int var_7 = 0 ; char [ ] var_9 = var_2 . toCharArray ( ) ; if ( var_9 [ var_7 ] == '+' || var_9 [ var_7 ] == '-' ) var_7 ++ ; boolean var_20 = false , var_17 = false , var_18 = false ; for ( ; var_7 < var_2 . length ( ) ; var_7 ++ ) { char var_13 = var_9 [ var_7 ] ; if ( Character . isDigit ( var_13 ) ) var_20 = true ; else if ( var_13 == '.' ) { if ( var_17 || var_18 ) return false ; var_17 = true ; } else if ( var_13 == 'e' ) { if ( var_18 || ! var_20 ) return false ; var_18 = true ; var_20 = false ; } else if ( var_13 == '+' || var_13 == '-' ) { if ( var_7 >= 1 && var_2 . charAt ( var_7 - 1 ) != 'e' ) return false ; } else return false ; } return var_20 ; } " 319,1007. Minimum Domino Rotations For Equal Row_3.java,"private int count(int[] A, Integer candidate) { int count = 0; for (int num : A) count += (candidate == num) ? 1 : 0; return count; }","private int sample_funcname ( int [ ] var_0 , Integer var_2 ) { int var_4 = 0 ; for ( int var_5 : var_0 ) var_4 += ( var_2 == var_5 ) ? 1 : 0 ; return var_4 ; } " 320,Perfect Squares_2.java,"public int numSquares(int n) { if (n <= 1) { return 1; } int[] dp = new int[n + 1]; dp[0] = 0; for (int i = 1; i <= n; i++) { dp[i] = Integer.MAX_VALUE; for (int j = 1; j <= i && j * j <= i; j++) { dp[i] = Math.min(dp[i], dp[i - j * j] + 1); } } return dp[n]; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 1 ) { return 1 ; } int [ ] var_2 = new int [ var_0 + 1 ] ; var_2 [ 0 ] = 0 ; for ( int var_4 = 1 ; var_4 <= var_0 ; var_4 ++ ) { var_2 [ var_4 ] = Integer . MAX_VALUE ; for ( int var_7 = 1 ; var_7 <= var_4 && var_7 * var_7 <= var_4 ; var_7 ++ ) { var_2 [ var_4 ] = Math . min ( var_2 [ var_4 ] , var_2 [ var_4 - var_7 * var_7 ] + 1 ) ; } } return var_2 [ var_0 ] ; } " 321,52. N-Queens II_2.java,"private boolean validateBoard(List list, int newColNum) { int newRowNum = list.size(); for (int rowNum = 0; rowNum < list.size(); rowNum++) { int colNum = list.get(rowNum); if (colNum == newColNum || Math.abs(newColNum - colNum) == Math.abs(newRowNum - rowNum)) { return false; } } return true; }","private boolean var_0 ( List < Integer > var_3 , int var_4 ) { int var_6 = var_3 . size ( ) ; for ( int var_8 = 0 ; var_8 < var_3 . size ( ) ; var_8 ++ ) { int var_10 = var_3 . get ( var_8 ) ; if ( var_10 == var_4 || Math . abs ( var_4 - var_10 ) == Math . abs ( var_6 - var_8 ) ) { return false ; } } return true ; } " 322,88. Merge Sorted Array_1.java,"public void merge(int[] A, int m, int[] B, int n) { int index = m + n - 1; while (m > 0 && n > 0) { if (A[m - 1] > B[n - 1]) { A[index--] = A[--m]; } else { A[index--] = B[--n]; } } while (n > 0) { A[index--] = B[--n]; } }","public void var_0 ( int [ ] var_1 , int var_2 , int [ ] var_3 , int var_4 ) { int var_6 = var_2 + var_4 - 1 ; while ( var_2 > 0 && var_4 > 0 ) { if ( var_1 [ var_2 - 1 ] > var_3 [ var_4 - 1 ] ) { var_1 [ var_6 -- ] = var_1 [ -- var_2 ] ; } else { var_1 [ var_6 -- ] = var_3 [ -- var_4 ] ; } } while ( var_4 > 0 ) { var_1 [ var_6 -- ] = var_3 [ -- var_4 ] ; } } " 323,Coins in a Line II_1.java,"public boolean firstWillWin(int[] values) { if (values == null || values.length == 0) { return false; } if (values.length <= 2) { return true; } int n = values.length; int[] dp = new int[n + 1]; int[] sum = new int[n + 1]; dp[n] = 0; dp[n - 1] = values[n - 1]; dp[n - 2] = values[n - 1] + values[n - 2]; sum[n] = 0; sum[n - 1] = values[n - 1]; for (int i = n - 2; i >= 0; i--) { sum[i] = sum[i + 1] + values[i]; dp[i] = Math.max(sum[i] - dp[i + 1], sum[i] - dp[i + 2]); } return sum[0] - dp[0] < dp[0]; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return false ; } if ( var_1 . length <= 2 ) { return true ; } int var_6 = var_1 . length ; int [ ] var_8 = new int [ var_6 + 1 ] ; int [ ] var_9 = new int [ var_6 + 1 ] ; var_8 [ var_6 ] = 0 ; var_8 [ var_6 - 1 ] = var_1 [ var_6 - 1 ] ; var_8 [ var_6 - 2 ] = var_1 [ var_6 - 1 ] + var_1 [ var_6 - 2 ] ; var_9 [ var_6 ] = 0 ; var_9 [ var_6 - 1 ] = var_1 [ var_6 - 1 ] ; for ( int var_10 = var_6 - 2 ; var_10 >= 0 ; var_10 -- ) { var_9 [ var_10 ] = var_9 [ var_10 + 1 ] + var_1 [ var_10 ] ; var_8 [ var_10 ] = Math . max ( var_9 [ var_10 ] - var_8 [ var_10 + 1 ] , var_9 [ var_10 ] - var_8 [ var_10 + 2 ] ) ; } return var_9 [ 0 ] - var_8 [ 0 ] < var_8 [ 0 ] ; } " 324,[tool]. MergeSort_2.java,"private void printArray(int[] nums, String str) { System.out.print(str); if (nums == null || nums.length == 0) { System.out.println(); return; } for (int num : nums) { System.out.print(num + "", ""); } System.out.println(); }","private void var_0 ( int [ ] var_1 , String var_3 ) { System . out . print ( var_3 ) ; if ( var_1 == null || var_1 . length == 0 ) { System . out . println ( ) ; return ; } for ( int var_11 : var_1 ) { System . out . print ( var_11 + "", "" ) ; } System . out . println ( ) ; } " 325,Backpack_5.java,"public int backPack(int m, int[] A) { if (A == null || A.length == 0 || m <= 0) { return 0; } boolean[][] dp = new boolean[A.length + 1][m + 1]; dp[0][0] = true; for (int i = 1; i <= A.length; i++) { for (int j = 0; j <= m; j++) { if (j - A[i - 1] >= 0) { dp[i][j] = dp[i - 1][j] || dp[i - 1][j - A[i - 1]]; } else { dp[i][j] = dp[i - 1][j]; } } } for (int j = m; j >= 0; j--) { if (dp[A.length][j]) { return j; } } return 0; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 || var_0 <= 0 ) { return 0 ; } boolean [ ] [ ] var_7 = new boolean [ var_1 . length + 1 ] [ var_0 + 1 ] ; var_7 [ 0 ] [ 0 ] = true ; for ( int var_8 = 1 ; var_8 <= var_1 . length ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 <= var_0 ; var_9 ++ ) { if ( var_9 - var_1 [ var_8 - 1 ] >= 0 ) { var_7 [ var_8 ] [ var_9 ] = var_7 [ var_8 - 1 ] [ var_9 ] || var_7 [ var_8 - 1 ] [ var_9 - var_1 [ var_8 - 1 ] ] ; } else { var_7 [ var_8 ] [ var_9 ] = var_7 [ var_8 - 1 ] [ var_9 ] ; } } } for ( int var_9 = var_0 ; var_9 >= 0 ; var_9 -- ) { if ( var_7 [ var_1 . length ] [ var_9 ] ) { return var_9 ; } } return 0 ; } " 326,Number of Connected Components in an Undirected Graph_1.java,"private Map> buildGraph(int n, int[][] edges) { Map> graph = new HashMap<>(); for (int i = 0; i < n; i++) { if (!graph.containsKey(i)) { graph.put(i, new ArrayList<>()); } } for (int[] edge: edges) { graph.get(edge[0]).add(edge[1]); graph.get(edge[1]).add(edge[0]); } return graph; }","private Map < Integer , List < Integer >> var_2 ( int var_3 , int [ ] [ ] var_4 ) { Map < Integer , List < Integer >> var_7 = new HashMap < > ( ) ; for ( int var_9 = 0 ; var_9 < var_3 ; var_9 ++ ) { if ( ! var_7 . containsKey ( var_9 ) ) { var_7 . put ( var_9 , new ArrayList < > ( ) ) ; } } for ( int [ ] var_13 : var_4 ) { var_7 . get ( var_13 [ 0 ] ) . add ( var_13 [ 1 ] ) ; var_7 . get ( var_13 [ 1 ] ) . add ( var_13 [ 0 ] ) ; } return var_7 ; } " 327,1053. Previous Permutation With One Swap_1.java,"private void swap(int[] arr, int x, int y) { int temp = arr[x]; arr[x] = arr[y]; arr[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 328,Triangles_2.java,"public int minimumTotal(List> triangle) { if (triangle == null || triangle.size() == 0) { return 0; } int n = triangle.size(); int[][] dp = new int[2][n]; for (int j = 0; j < n; j++) { dp[(n - 1) % 2][j] = triangle.get(n - 1).get(j); } for (int i = n - 2; i >= 0; i--) { for (int j = 0; j <= i; j++) { dp[i % 2][j] = Math.min(dp[(i + 1)%2][j], dp[(i + 1)%2][j + 1]) + triangle.get(i).get(j); } } return dp[0][0]; }","public int sample_funcname ( List < List < Integer >> var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return 0 ; } int var_6 = var_2 . size ( ) ; int [ ] [ ] var_8 = new int [ 2 ] [ var_6 ] ; for ( int var_9 = 0 ; var_9 < var_6 ; var_9 ++ ) { var_8 [ ( var_6 - 1 ) % 2 ] [ var_9 ] = var_2 . get ( var_6 - 1 ) . get ( var_9 ) ; } for ( int var_12 = var_6 - 2 ; var_12 >= 0 ; var_12 -- ) { for ( int var_9 = 0 ; var_9 <= var_12 ; var_9 ++ ) { var_8 [ var_12 % 2 ] [ var_9 ] = Math . min ( var_8 [ ( var_12 + 1 ) % 2 ] [ var_9 ] , var_8 [ ( var_12 + 1 ) % 2 ] [ var_9 + 1 ] ) + var_2 . get ( var_12 ) . get ( var_9 ) ; } } return var_8 [ 0 ] [ 0 ] ; } " 329,QuickSort_1.java,"private void swap(int[] nums, int x, int y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 330,796. Rotate String_1.java,"public boolean rotateString(String A, String B) { if (A == null || B == null || A.length() != B.length()) { return false; } if (A.equals(B)) { return true; } StringBuffer sb = new StringBuffer(A); for (char c : A.toCharArray()) { sb.deleteCharAt(0); sb.append(c); if (sb.toString().equals(B)) { return true; } } return false; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) != var_3 . length ( ) ) { return false ; } if ( var_2 . equals ( var_3 ) ) { return true ; } StringBuffer var_8 = new StringBuffer ( var_2 ) ; for ( char var_10 : var_2 . toCharArray ( ) ) { var_8 . deleteCharAt ( 0 ) ; var_8 . append ( var_10 ) ; if ( var_8 . toString ( ) . equals ( var_3 ) ) { return true ; } } return false ; } " 331,367. Valid Perfect Square_1.java,"public boolean isPerfectSquare(int num) { long start = 0, end = num; while (start <= end) { long mid = start + (end - start) / 2; long sqrt = mid * mid; if (sqrt == num) return true; else if (sqrt < num) start = mid + 1; else end = mid - 1; } return false; }","public boolean var_0 ( int var_1 ) { long var_3 = 0 , var_4 = var_1 ; while ( var_3 <= var_4 ) { long var_6 = var_3 + ( var_4 - var_3 ) / 2 ; long var_7 = var_6 * var_6 ; if ( var_7 == var_1 ) return true ; else if ( var_7 < var_1 ) var_3 = var_6 + 1 ; else var_4 = var_6 - 1 ; } return false ; } " 332,Longest Valid Parentheses_1.java,"private int addPriorLength(int priorIndex, int[] dp) { return (priorIndex - 1 >= 0) ? dp[priorIndex - 1] : 0; }","private int sample_funcname ( int var_0 , int [ ] var_1 ) { return ( var_0 - 1 >= 0 ) ? var_1 [ var_0 - 1 ] : 0 ; } " 333,Count and Say_1.java,"public String countAndSay(int n) { if (n <= 1) { return n + """"; } String curr = ""1""; for (int i = 2; i <= n; i++) { int count = 1; char c = curr.charAt(0); int size = curr.length(); StringBuffer sb = new StringBuffer(); for (int j = 1; j < size; j++) { if (curr.charAt(j) == curr.charAt(j - 1)) { count++; } else { sb.append(count + String.valueOf(c)); c = curr.charAt(j); count = 1; } } sb.append(count + String.valueOf(c)); curr = sb.toString(); } return curr; }","public String var_0 ( int var_1 ) { if ( var_1 <= 1 ) { return var_1 + """" ; } String var_6 = ""1"" ; for ( int var_8 = 2 ; var_8 <= var_1 ; var_8 ++ ) { int var_9 = 1 ; char var_12 = var_6 . charAt ( 0 ) ; int var_14 = var_6 . length ( ) ; StringBuffer var_16 = new StringBuffer ( ) ; for ( int var_17 = 1 ; var_17 < var_14 ; var_17 ++ ) { if ( var_6 . charAt ( var_17 ) == var_6 . charAt ( var_17 - 1 ) ) { var_9 ++ ; } else { var_16 . append ( var_9 + String . valueOf ( var_12 ) ) ; var_12 = var_6 . charAt ( var_17 ) ; var_9 = 1 ; } } var_16 . append ( var_9 + String . valueOf ( var_12 ) ) ; var_6 = var_16 . toString ( ) ; } return var_6 ; } " 334,265. Paint House II_1.java,"public int minCostII(int[][] costs) { if (costs == null || costs.length == 0) return 0; if (costs.length == 1 && costs[0].length == 1) return costs[0][0]; int n = costs.length, k = costs[0].length; int[][] dp = new int[n + 1][k]; for (int i = 1; i <= n; i++) { for (int j = 0; j < k; j++) { dp[i][j] = Integer.MAX_VALUE; for (int m = 0; m < k; m++) { if (j == m) continue; dp[i][j] = Math.min(dp[i][j], dp[i - 1][m] + costs[i - 1][j]); } } } int min = Integer.MAX_VALUE; for (int j = 0; j < k; j++) min = Math.min(min, dp[n][j]); return min; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; if ( var_0 . length == 1 && var_0 [ 0 ] . length == 1 ) return var_0 [ 0 ] [ 0 ] ; int var_5 = var_0 . length , var_6 = var_0 [ 0 ] . length ; int [ ] [ ] var_7 = new int [ var_5 + 1 ] [ var_6 ] ; for ( int var_8 = 1 ; var_8 <= var_5 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 < var_6 ; var_9 ++ ) { var_7 [ var_8 ] [ var_9 ] = Integer . MAX_VALUE ; for ( int var_12 = 0 ; var_12 < var_6 ; var_12 ++ ) { if ( var_9 == var_12 ) continue ; var_7 [ var_8 ] [ var_9 ] = Math . min ( var_7 [ var_8 ] [ var_9 ] , var_7 [ var_8 - 1 ] [ var_12 ] + var_0 [ var_8 - 1 ] [ var_9 ] ) ; } } } int min = Integer . MAX_VALUE ; for ( int var_9 = 0 ; var_9 < var_6 ; var_9 ++ ) min = Math . min ( min , var_7 [ var_5 ] [ var_9 ] ) ; return min ; } " 335,64. Minimum Path Sum_5.java,"public int minPathSum(int[][] grid) { if (grid == null || grid.length == 0 || grid[0] == null || grid[0].length == 0) { return 0; } int m = grid.length, n = grid[0].length; int[][] dp = new int[m][n]; dp[0][0] = grid[0][0]; for (int i = 1; i < m; i++) dp[i][0] = dp[i - 1][0] + grid[i][0]; for (int j = 1; j < n; j++) dp[0][j] = dp[0][j - 1] + grid[0][j]; for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - 1]) + grid[i][j]; } } return dp[m - 1][n - 1]; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return 0 ; } int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_6 = new int [ var_4 ] [ var_5 ] ; var_6 [ 0 ] [ 0 ] = var_0 [ 0 ] [ 0 ] ; for ( int var_8 = 1 ; var_8 < var_4 ; var_8 ++ ) var_6 [ var_8 ] [ 0 ] = var_6 [ var_8 - 1 ] [ 0 ] + var_0 [ var_8 ] [ 0 ] ; for ( int var_9 = 1 ; var_9 < var_5 ; var_9 ++ ) var_6 [ 0 ] [ var_9 ] = var_6 [ 0 ] [ var_9 - 1 ] + var_0 [ 0 ] [ var_9 ] ; for ( int var_8 = 1 ; var_8 < var_4 ; var_8 ++ ) { for ( int var_9 = 1 ; var_9 < var_5 ; var_9 ++ ) { var_6 [ var_8 ] [ var_9 ] = Math . min ( var_6 [ var_8 - 1 ] [ var_9 ] , var_6 [ var_8 ] [ var_9 - 1 ] ) + var_0 [ var_8 ] [ var_9 ] ; } } return var_6 [ var_4 - 1 ] [ var_5 - 1 ] ; } " 336,771. Jewels and Stones_1.java,"public int numJewelsInStones(String J, String S) { if (J == null || J.length() == 0 || S == null || S.length() == 0) { return 0; } int m = J.length(); Set set = new HashSet<>(); int count = 0; for (char c : J.toCharArray()) { set.add(c); } for (char c : S.toCharArray()) { count += set.contains(c) ? 1 : 0; } return count; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_1 . length ( ) == 0 || var_2 == null || var_2 . length ( ) == 0 ) { return 0 ; } int var_6 = var_1 . length ( ) ; Set < Character > var_10 = new HashSet < > ( ) ; int var_11 = 0 ; for ( char var_13 : var_1 . toCharArray ( ) ) { var_10 . add ( var_13 ) ; } for ( char var_13 : var_2 . toCharArray ( ) ) { var_11 += var_10 . contains ( var_13 ) ? 1 : 0 ; } return var_11 ; } " 337,674. Longest Continuous Increasing Subsequence_3.java,"public int findLengthOfLCIS(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length; int[] dp = new int[n]; dp[0] = 1; int max = 1; for (int i = 1; i < n; i++) { dp[i] = 1; if (nums[i] > nums[i - 1]) dp[i] = Math.max(dp[i], dp[i - 1] + 1); max = Math.max(max, dp[i]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length ; int [ ] var_5 = new int [ var_4 ] ; var_5 [ 0 ] = 1 ; int max = 1 ; for ( int var_8 = 1 ; var_8 < var_4 ; var_8 ++ ) { var_5 [ var_8 ] = 1 ; if ( var_0 [ var_8 ] > var_0 [ var_8 - 1 ] ) var_5 [ var_8 ] = Math . max ( var_5 [ var_8 ] , var_5 [ var_8 - 1 ] + 1 ) ; max = Math . max ( max , var_5 [ var_8 ] ) ; } return max ; } " 338,438. Find All Anagrams in a String_2.java,"private boolean compare(int[] window, int[] countP) { for (int i = 0; i < 26; i++) { if (window[i] != countP[i]) return false; } return true; }","private boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { for ( int var_4 = 0 ; var_4 < 26 ; var_4 ++ ) { if ( var_1 [ var_4 ] != var_2 [ var_4 ] ) return false ; } return true ; } " 339,Nim Game_3.java,"public boolean canWinNim(int n ) { if (n <= 3) { return true; } boolean[] dp = new boolean[4]; dp[0] = true; dp[1] = dp[2] = dp[3] = true; for (int i = 4; i <= n; i++) { dp[i % 4] = !(dp[(i - 1) % 4] && dp[(i - 2) % 4] && dp[(i - 3) % 4]); } return dp[n % 4]; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 3 ) { return true ; } boolean [ ] var_5 = new boolean [ 4 ] ; var_5 [ 0 ] = true ; var_5 [ 1 ] = var_5 [ 2 ] = var_5 [ 3 ] = true ; for ( int var_8 = 4 ; var_8 <= var_1 ; var_8 ++ ) { var_5 [ var_8 % 4 ] = ! ( var_5 [ ( var_8 - 1 ) % 4 ] && var_5 [ ( var_8 - 2 ) % 4 ] && var_5 [ ( var_8 - 3 ) % 4 ] ) ; } return var_5 [ var_1 % 4 ] ; } " 340,Single Number II_1.java,"public int singleNumber(int[] A) { if (A == null || A.length == 0) { return -1; } int[] bits = new int[32]; int rst = 0; for (int i = 0; i < 32; i++) { for (int j = 0; j < A.length; j++){ bits[i] += A[j] >> i & 1; bits[i] %= 3; } rst |= bits[i] << i; } return rst; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int [ ] var_6 = new int [ 32 ] ; int var_7 = 0 ; for ( int var_8 = 0 ; var_8 < 32 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 < var_0 . length ; var_9 ++ ) { var_6 [ var_8 ] += var_0 [ var_9 ] >> var_8 & 1 ; var_6 [ var_8 ] %= 3 ; } var_7 |= var_6 [ var_8 ] << var_8 ; } return var_7 ; } " 341,Path Sum IV_1.java,"private int dfs(Map map, int key, int sum) { sum += map.get(key); int level = key / 10; int position = key % 10; int leftChildKey = (level + 1) * 10 + position * 2 - 1; int rightChildKey = leftChildKey + 1; if (!map.containsKey(leftChildKey) && !map.containsKey(rightChildKey)) return sum; int result = 0; if (map.containsKey(leftChildKey)) result += dfs(map, leftChildKey, sum); if (map.containsKey(rightChildKey)) result += dfs(map, rightChildKey, sum); return result; }","private int sample_funcname ( Map < Integer , Integer > map , int key , int sum ) { sum += map . get ( key ) ; int level = key / 10 ; int position = key % 10 ; int leftChildKey = ( level + 1 ) * 10 + position * 2 - 1 ; int rightChildKey = leftChildKey + 1 ; if ( ! map . containsKey ( leftChildKey ) && ! map . containsKey ( rightChildKey ) ) return sum ; int result = 0 ; if ( map . containsKey ( leftChildKey ) ) result += dfs ( map , leftChildKey , sum ) ; if ( map . containsKey ( rightChildKey ) ) result += dfs ( map , rightChildKey , sum ) ; return result ; } " 342,[lint]. Heapify_1.java,"private void swap(int[] nums, int x, int y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 343,893. Groups of Special-Equivalent Strings_1.java,"public int numSpecialEquivGroups(String[] A) { if (A == null || A.length == 0) { return 0; } HashSet set = new HashSet<>(); for (String s : A) { int[] odd = new int[256]; int[] even = new int[256]; for (int i = 0; i < s.length(); i++) { int c = s.charAt(i); if (i % 2 == 0) { even[c]++; } else { odd[c]++; } } String signature = Arrays.toString(odd) + Arrays.toString(even); set.add(signature); } return set.size(); }","public int sample_funcname ( String [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return 0 ; } HashSet < String > var_6 = new HashSet < > ( ) ; for ( String var_7 : var_1 ) { int [ ] var_9 = new int [ 256 ] ; int [ ] var_10 = new int [ 256 ] ; for ( int var_11 = 0 ; var_11 < var_7 . length ( ) ; var_11 ++ ) { int var_13 = var_7 . charAt ( var_11 ) ; if ( var_11 % 2 == 0 ) { var_10 [ var_13 ] ++ ; } else { var_9 [ var_13 ] ++ ; } } String var_17 = Arrays . toString ( var_9 ) + Arrays . toString ( var_10 ) ; var_6 . add ( var_17 ) ; } return var_6 . size ( ) ; } " 344,122. Best Time to Buy and Sell Stock II_1.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length == 0) { return 0; } int profit = 0; for (int i = 1; i < prices.length; i++) { if (prices[i] > prices[i - 1]) { profit += prices[i] - prices[i - 1]; } } return profit; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = 0 ; for ( int var_6 = 1 ; var_6 < var_0 . length ; var_6 ++ ) { if ( var_0 [ var_6 ] > var_0 [ var_6 - 1 ] ) { var_4 += var_0 [ var_6 ] - var_0 [ var_6 - 1 ] ; } } return var_4 ; } " 345,Bus Routes_1.java,"public int numBusesToDestination(int[][] routes, int S, int T) { Set visited = new HashSet<>(); Map> stopMap = new HashMap<>(); Queue queue = new LinkedList<>(); for (int i = 0; i < routes.length; i++) { for (int stop : routes[i]) { stopMap.putIfAbsent(stop, new HashSet<>()); stopMap.get(stop).add(i); } } queue.offer(S); int count = 0; while (!queue.isEmpty()) { int size = queue.size(); for (int i = 0; i < size; i++) { int stop = queue.poll(); if (stop == T) return count; for (int bus : stopMap.get(stop)) { if (!visited.contains(bus)) { visited.add(bus); for (int nextStop : routes[bus]) { queue.offer(nextStop); } } } } count++; } return -1; }","public int sample_funcname ( int [ ] [ ] var_0 , int var_1 , int var_2 ) { Set < Integer > var_6 = new HashSet < > ( ) ; Map < Integer , Set < Integer >> var_9 = new HashMap < > ( ) ; Queue < Integer > var_12 = new LinkedList < > ( ) ; for ( int var_14 = 0 ; var_14 < var_0 . length ; var_14 ++ ) { for ( int var_16 : var_0 [ var_14 ] ) { var_9 . putIfAbsent ( var_16 , new HashSet < > ( ) ) ; var_9 . get ( var_16 ) . add ( var_14 ) ; } } var_12 . offer ( var_1 ) ; int var_21 = 0 ; while ( ! var_12 . isEmpty ( ) ) { int size = var_12 . size ( ) ; for ( int var_14 = 0 ; var_14 < size ; var_14 ++ ) { int var_16 = var_12 . poll ( ) ; if ( var_16 == var_2 ) return var_21 ; for ( int var_25 : var_9 . get ( var_16 ) ) { if ( ! var_6 . contains ( var_25 ) ) { var_6 . add ( var_25 ) ; for ( int var_27 : var_0 [ var_25 ] ) { var_12 . offer ( var_27 ) ; } } } } var_21 ++ ; } return - 1 ; } " 346,Contiguous Array_2.java,"public int findMaxLength(int[] nums) { if (nums == null || nums.length == 0) return 0; Map map = new HashMap<>(); map.put(0, -1); int preSum = 0, max = 0; for (int i = 0; i < nums.length; i++) { preSum += nums[i]; int k = preSum - i - 1; if (map.containsKey(preSum - k)) { max = Math.max(max, i - map.get(preSum - k)); } if (!map.containsKey(preSum)) { map.put(preSum, i); } } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; Map < Integer , Integer > var_7 = new HashMap < > ( ) ; var_7 . put ( 0 , - 1 ) ; int var_10 = 0 , max = 0 ; for ( int var_12 = 0 ; var_12 < var_0 . length ; var_12 ++ ) { var_10 += var_0 [ var_12 ] ; int var_13 = var_10 - var_12 - 1 ; if ( var_7 . containsKey ( var_10 - var_13 ) ) { max = Math . max ( max , var_12 - var_7 . get ( var_10 - var_13 ) ) ; } if ( ! var_7 . containsKey ( var_10 ) ) { var_7 . put ( var_10 , var_12 ) ; } } return max ; } " 347,Swap Bits_1.java,"public int swapOddEvenBits(int x) { return ((x & 0xaaaaaaaa) >>> 1) + ((x & 0x55555555) << 1); }","public int sample_funcname ( int var_0 ) { return ( ( var_0 & 0xaaaaaaaa ) >>> 1 ) + ( ( var_0 & 0x55555555 ) << 1 ) ; } " 348,Plus One_1.java,"public int[] plusOne(int[] digits) { if(digits.length==0) return digits; digits[digits.length-1] += 1; for(int i = digits.length-1; i>0; i--){ if(digits[i] == 10){ digits[i]=0; digits[i-1]+=1; } else return digits; } if(digits[0]==10){ int[] output = new int[digits.length+1]; output[0] = 1; return output; } else return digits; }","public int [ ] sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return var_0 ; var_0 [ var_0 . length - 1 ] += 1 ; for ( int var_4 = var_0 . length - 1 ; var_4 > 0 ; var_4 -- ) { if ( var_0 [ var_4 ] == 10 ) { var_0 [ var_4 ] = 0 ; var_0 [ var_4 - 1 ] += 1 ; } else return var_0 ; } if ( var_0 [ 0 ] == 10 ) { int [ ] var_6 = new int [ var_0 . length + 1 ] ; var_6 [ 0 ] = 1 ; return var_6 ; } else return var_0 ; } " 349,Frog Jump_1.java,"private void move(Map> dp, int stone, int step) { if (step > 0 && dp.containsKey(stone + step)) { dp.get(stone + step).add(step); } }","private void var_0 ( Map < Integer , Set < Integer >> var_4 , int var_5 , int var_6 ) { if ( var_6 > 0 && var_4 . containsKey ( var_5 + var_6 ) ) { var_4 . get ( var_5 + var_6 ) . add ( var_6 ) ; } } " 350,254. Factor Combinations_1.java,"public void dfs(List> rst, List list, int num, Integer lastFactor) { if (lastFactor != null) { list.add(num); rst.add(new ArrayList<>(list)); list.remove(list.size() - 1); } int high = (int) Math.sqrt(num); int low = lastFactor == null ? 2 : Math.max(2, lastFactor); while (low <= high) { if (num % low == 0) { list.add(low); dfs(rst, list, num / low, low); list.remove(list.size() - 1); } low++; } }","public void sample_funcname ( List < List < Integer >> rst , List < Integer > list , int num , Integer lastFactor ) { if ( lastFactor != null ) { list . add ( num ) ; rst . add ( new ArrayList < > ( list ) ) ; list . remove ( list . size ( ) - 1 ) ; } int high = ( int ) Math . sqrt ( num ) ; int low = lastFactor == null ? 2 : Math . max ( 2 , lastFactor ) ; while ( low <= high ) { if ( num % low == 0 ) { list . add ( low ) ; dfs ( rst , list , num / low , low ) ; list . remove ( list . size ( ) - 1 ) ; } low ++ ; } } " 351,Longest Substring Without Repeating Characters_2.java,"public int lengthOfLongestSubstring(String s) { if (s == null || s.length() == 0) { return 0; } HashMap map = new HashMap<>(); char[] arr = s.toCharArray(); int rst = Integer.MIN_VALUE; for (int i = 0; i < arr.length; i++) { char c = arr[i]; if (map.containsKey(c)) { i = map.get(c); map = new HashMap<>(); } else { map.put(c, i); } rst = Math.max(rst, map.size()); } return rst == Integer.MIN_VALUE ? 0 : rst; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } HashMap < Character , Integer > var_8 = new HashMap < > ( ) ; char [ ] var_10 = var_1 . toCharArray ( ) ; int var_12 = Integer . MIN_VALUE ; for ( int var_13 = 0 ; var_13 < var_10 . length ; var_13 ++ ) { char var_14 = var_10 [ var_13 ] ; if ( var_8 . containsKey ( var_14 ) ) { var_13 = var_8 . get ( var_14 ) ; var_8 = new HashMap < > ( ) ; } else { var_8 . put ( var_14 , var_13 ) ; } var_12 = Math . max ( var_12 , var_8 . size ( ) ) ; } return var_12 == Integer . MIN_VALUE ? 0 : var_12 ; } " 352,293. Flip Game_1.java,"public List generatePossibleNextMoves(String s) { List rst = new ArrayList<>(); if (s == null || s.length() < 2) { return rst; } StringBuffer sb = new StringBuffer(s); for (int i = 0; i < s.length() - 1; i++) { String str = s.substring(i, i + 2); if (str.equals(""++"")) { sb.replace(i, i + 2, ""--""); rst.add(sb.toString()); sb.replace(i, i + 2, ""++""); } } return rst; }","public List < String > var_1 ( String var_2 ) { List < String > var_5 = new ArrayList < > ( ) ; if ( var_2 == null || var_2 . length ( ) < 2 ) { return var_5 ; } StringBuffer var_10 = new StringBuffer ( var_2 ) ; for ( int var_12 = 0 ; var_12 < var_2 . length ( ) - 1 ; var_12 ++ ) { String var_15 = var_2 . substring ( var_12 , var_12 + 2 ) ; if ( var_15 . equals ( ""++"" ) ) { var_10 . replace ( var_12 , var_12 + 2 , ""--"" ) ; var_5 . add ( var_10 . toString ( ) ) ; var_10 . replace ( var_12 , var_12 + 2 , ""++"" ) ; } } return var_5 ; } " 353,Binary Representation_2.java,"public String parseDecimal(String n) { if (n.length() == 0 || n.equals(""0"")) { return """"; } double num = Double.parseDouble(""0."" + n); HashSet set = new HashSet<>(); StringBuffer sb = new StringBuffer(); while (num > 0) { if (sb.length() > 32 || set.contains(num)) { return ""ERROR""; } set.add(num); if (num * 2 >= 1) { sb.append(""1""); num = num * 2 - 1; } else { sb.append(""0""); num = num * 2; } } return sb.toString(); }","public String var_0 ( String var_2 ) { if ( var_2 . length ( ) == 0 || var_2 . equals ( ""0"" ) ) { return """" ; } double var_11 = Double . parseDouble ( ""0."" + var_2 ) ; HashSet < Double > var_13 = new HashSet < > ( ) ; StringBuffer var_15 = new StringBuffer ( ) ; while ( var_11 > 0 ) { if ( var_15 . length ( ) > 32 || var_13 . contains ( var_11 ) ) { return ""ERROR"" ; } var_13 . add ( var_11 ) ; if ( var_11 * 2 >= 1 ) { var_15 . append ( ""1"" ) ; var_11 = var_11 * 2 - 1 ; } else { var_15 . append ( ""0"" ) ; var_11 = var_11 * 2 ; } } return var_15 . toString ( ) ; } " 354,36. Valid Sudoku_1.java,"private boolean helper(char c, Set set) { if (!set.contains(c)) set.add(c); else if (c != '.') return false; return true; }","private boolean var_0 ( char var_1 , Set < Character > var_4 ) { if ( ! var_4 . contains ( var_1 ) ) var_4 . add ( var_1 ) ; else if ( var_1 != '.' ) return false ; return true ; } " 355,78. Subsets_4.java,"private List buildResult(List indexRow, int[] nums) { List list = new ArrayList<>(); for (int index : indexRow) list.add(nums[index]); return list; }","private List < Integer > var_1 ( List < Integer > var_3 , int [ ] var_4 ) { List < Integer > var_6 = new ArrayList < > ( ) ; for ( int var_7 : var_3 ) var_6 . add ( var_4 [ var_7 ] ) ; return var_6 ; } " 356,Copy Books_3.java,"public int copyBooks(int[] pages, int K) { if (pages == null || pages.length == 0) { return 0; } int n = pages.length; if (K > n) { K = n; } int[][] dp = new int[2][n + 1]; dp[0][0] = 0; for (int i = 1; i <= n; i++) { dp[0][i] = Integer.MAX_VALUE; } for (int k = 1; k <= K; k++) { for (int i = 1; i <= n; i++) { int sum = 0; dp[k % 2][i] = Integer.MAX_VALUE; for (int j = i; j >= 0; j--) { dp[k % 2][i] = Math.min(dp[k % 2][i], Math.max(dp[(k - 1) % 2][j], sum)); if (j > 0) { sum += pages[j - 1]; } } } } return dp[K % 2][n]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = var_0 . length ; if ( var_1 > var_5 ) { var_1 = var_5 ; } int [ ] [ ] var_8 = new int [ 2 ] [ var_5 + 1 ] ; var_8 [ 0 ] [ 0 ] = 0 ; for ( int var_9 = 1 ; var_9 <= var_5 ; var_9 ++ ) { var_8 [ 0 ] [ var_9 ] = Integer . MAX_VALUE ; } for ( int var_12 = 1 ; var_12 <= var_1 ; var_12 ++ ) { for ( int var_9 = 1 ; var_9 <= var_5 ; var_9 ++ ) { int var_13 = 0 ; var_8 [ var_12 % 2 ] [ var_9 ] = Integer . MAX_VALUE ; for ( int var_14 = var_9 ; var_14 >= 0 ; var_14 -- ) { var_8 [ var_12 % 2 ] [ var_9 ] = Math . min ( var_8 [ var_12 % 2 ] [ var_9 ] , Math . max ( var_8 [ ( var_12 - 1 ) % 2 ] [ var_14 ] , var_13 ) ) ; if ( var_14 > 0 ) { var_13 += var_0 [ var_14 - 1 ] ; } } } } return var_8 [ var_1 % 2 ] [ var_5 ] ; } " 357,House Robber II_4.java,"public int rob(int[] nums) { if (nums == null || nums.length == 0) { return 0; } else if (nums.length == 1) { return nums[0]; } int n = nums.length; int[][] dp = new int[2][2]; dp[0][0] = 0; dp[1][0] = nums[1]; dp[0][1] = nums[0]; dp[1][1] = dp[0][1]; for (int i = 2; i < n; i++) { if (i == n - 1) { dp[i % 2][0] = Math.max(dp[(i - 1) % 2][0], dp[(i - 2) % 2][0] + nums[i]); dp[i % 2][1] = dp[(i - 1) % 2][1]; } else { dp[i % 2][0] = Math.max(dp[(i - 1) % 2][0], dp[(i - 2) % 2][0] + nums[i]); dp[i % 2][1] = Math.max(dp[(i - 1) % 2][1], dp[(i - 2) % 2][1] + nums[i]); } } return Math.max(dp[(n - 1) % 2][0], dp[(n - 1) % 2][1]); }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } else if ( var_0 . length == 1 ) { return var_0 [ 0 ] ; } int var_5 = var_0 . length ; int [ ] [ ] var_7 = new int [ 2 ] [ 2 ] ; var_7 [ 0 ] [ 0 ] = 0 ; var_7 [ 1 ] [ 0 ] = var_0 [ 1 ] ; var_7 [ 0 ] [ 1 ] = var_0 [ 0 ] ; var_7 [ 1 ] [ 1 ] = var_7 [ 0 ] [ 1 ] ; for ( int var_8 = 2 ; var_8 < var_5 ; var_8 ++ ) { if ( var_8 == var_5 - 1 ) { var_7 [ var_8 % 2 ] [ 0 ] = Math . max ( var_7 [ ( var_8 - 1 ) % 2 ] [ 0 ] , var_7 [ ( var_8 - 2 ) % 2 ] [ 0 ] + var_0 [ var_8 ] ) ; var_7 [ var_8 % 2 ] [ 1 ] = var_7 [ ( var_8 - 1 ) % 2 ] [ 1 ] ; } else { var_7 [ var_8 % 2 ] [ 0 ] = Math . max ( var_7 [ ( var_8 - 1 ) % 2 ] [ 0 ] , var_7 [ ( var_8 - 2 ) % 2 ] [ 0 ] + var_0 [ var_8 ] ) ; var_7 [ var_8 % 2 ] [ 1 ] = Math . max ( var_7 [ ( var_8 - 1 ) % 2 ] [ 1 ] , var_7 [ ( var_8 - 2 ) % 2 ] [ 1 ] + var_0 [ var_8 ] ) ; } } return Math . max ( var_7 [ ( var_5 - 1 ) % 2 ] [ 0 ] , var_7 [ ( var_5 - 1 ) % 2 ] [ 1 ] ) ; } " 358,Best Time to Buy and Sell Stock IV_3.java,"public int maxProfit(int k, int[] prices) { if (prices == null || prices.length == 0 || k <= 0) { return 0; } int profit = 0; int n = prices.length; int statusLength = 2 * k + 1; if (k >= n/2) { for (int i = 1; i < n; i++) { if (prices[i] > prices[i - 1]) { profit += prices[i] - prices[i - 1]; } } return profit; } int[][] dp = new int[2][statusLength]; int prev, curr = 0; dp[0][0] = 0; for (int i = 1; i < n; i++) { prev = curr; curr = 1 - prev; for (int j = 1; j < statusLength; j++) { if (j % 2 == 0) { dp[curr][j] = Math.max(dp[prev][j], dp[prev][j - 1] + prices[i] - prices[i - 1]); profit = Math.max(profit, dp[curr][j]); } else { dp[curr][j] = Math.max(dp[prev][j] + prices[i] - prices[i - 1], dp[prev][j - 1]); } } } return profit; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 || var_0 <= 0 ) { return 0 ; } int var_5 = 0 ; int var_6 = var_1 . length ; int var_9 = 2 * var_0 + 1 ; if ( var_0 >= var_6 / 2 ) { for ( int var_10 = 1 ; var_10 < var_6 ; var_10 ++ ) { if ( var_1 [ var_10 ] > var_1 [ var_10 - 1 ] ) { var_5 += var_1 [ var_10 ] - var_1 [ var_10 - 1 ] ; } } return var_5 ; } int [ ] [ ] var_11 = new int [ 2 ] [ var_9 ] ; int var_12 , var_13 = 0 ; var_11 [ 0 ] [ 0 ] = 0 ; for ( int var_10 = 1 ; var_10 < var_6 ; var_10 ++ ) { var_12 = var_13 ; var_13 = 1 - var_12 ; for ( int var_14 = 1 ; var_14 < var_9 ; var_14 ++ ) { if ( var_14 % 2 == 0 ) { var_11 [ var_13 ] [ var_14 ] = Math . max ( var_11 [ var_12 ] [ var_14 ] , var_11 [ var_12 ] [ var_14 - 1 ] + var_1 [ var_10 ] - var_1 [ var_10 - 1 ] ) ; var_5 = Math . max ( var_5 , var_11 [ var_13 ] [ var_14 ] ) ; } else { var_11 [ var_13 ] [ var_14 ] = Math . max ( var_11 [ var_12 ] [ var_14 ] + var_1 [ var_10 ] - var_1 [ var_10 - 1 ] , var_11 [ var_12 ] [ var_14 - 1 ] ) ; } } } return var_5 ; } " 359,383. Ransom Note_1.java,"public boolean canConstruct(String ransomNote, String magazine) { if (ransomNote == null) return true; if (magazine == null || magazine.length() < ransomNote.length()) return false; int[] count = new int[256]; for (char c : magazine.toCharArray()) { count[c]++; } for (char c : ransomNote.toCharArray()) { count[c]--; if (count[c] < 0) { return false; } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null ) return true ; if ( var_3 == null || var_3 . length ( ) < var_2 . length ( ) ) return false ; int [ ] var_7 = new int [ 256 ] ; for ( char var_9 : var_3 . toCharArray ( ) ) { var_7 [ var_9 ] ++ ; } for ( char var_9 : var_2 . toCharArray ( ) ) { var_7 [ var_9 ] -- ; if ( var_7 [ var_9 ] < 0 ) { return false ; } } return true ; } " 360,Maximum Subarray II_2.java,"public int maxTwoSubArrays(List nums) { if (nums == null || nums.size() == 0) { return 0; } int n = nums.size(); int[] dpLeft = new int[2]; int[] dpRight = new int[2]; dpLeft[0] = 0; dpRight[n % 2] = 0; int[] maxLeft = new int[n + 1]; int[] maxRight = new int[n + 1]; maxLeft[0] = Integer.MIN_VALUE; maxRight[n] = Integer.MIN_VALUE; for (int i = 1; i <= n; i++) { dpLeft[i % 2] = Math.max(dpLeft[(i - 1) % 2] + nums.get(i - 1), nums.get(i - 1)); maxLeft[i] = Math.max(maxLeft[i - 1], dpLeft[i % 2]); } for (int j = n - 1; j >= 0; j--) { dpRight[j % 2] = Math.max(dpRight[(j + 1) % 2] + nums.get(j), nums.get(j)); maxRight[j] = Math.max(maxRight[j + 1], dpRight[j % 2]); } int max = Integer.MIN_VALUE; for (int i = 1; i < n; i++) { max = Math.max(max, maxLeft[i] + maxRight[i]); } return max; }","public int sample_funcname ( List < Integer > var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return 0 ; } int var_6 = var_2 . size ( ) ; int [ ] var_8 = new int [ 2 ] ; int [ ] var_9 = new int [ 2 ] ; var_8 [ 0 ] = 0 ; var_9 [ var_6 % 2 ] = 0 ; int [ ] var_11 = new int [ var_6 + 1 ] ; int [ ] var_12 = new int [ var_6 + 1 ] ; var_11 [ 0 ] = Integer . MIN_VALUE ; var_12 [ var_6 ] = Integer . MIN_VALUE ; for ( int var_14 = 1 ; var_14 <= var_6 ; var_14 ++ ) { var_8 [ var_14 % 2 ] = Math . max ( var_8 [ ( var_14 - 1 ) % 2 ] + var_2 . get ( var_14 - 1 ) , var_2 . get ( var_14 - 1 ) ) ; var_11 [ var_14 ] = Math . max ( var_11 [ var_14 - 1 ] , var_8 [ var_14 % 2 ] ) ; } for ( int var_18 = var_6 - 1 ; var_18 >= 0 ; var_18 -- ) { var_9 [ var_18 % 2 ] = Math . max ( var_9 [ ( var_18 + 1 ) % 2 ] + var_2 . get ( var_18 ) , var_2 . get ( var_18 ) ) ; var_12 [ var_18 ] = Math . max ( var_12 [ var_18 + 1 ] , var_9 [ var_18 % 2 ] ) ; } int max = Integer . MIN_VALUE ; for ( int var_14 = 1 ; var_14 < var_6 ; var_14 ++ ) { max = Math . max ( max , var_11 [ var_14 ] + var_12 [ var_14 ] ) ; } return max ; } " 361,198. House Robber_1.java,"public int rob(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length; long[] dp = new long[n + 1]; dp[0] = 0; dp[1] = nums[0]; for (int i = 2; i <= n; i++) { dp[i] = Math.max(dp[i - 1], dp[i - 2] + nums[i - 1]); } return (int) dp[n]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length ; long [ ] var_6 = new long [ var_4 + 1 ] ; var_6 [ 0 ] = 0 ; var_6 [ 1 ] = var_0 [ 0 ] ; for ( int var_8 = 2 ; var_8 <= var_4 ; var_8 ++ ) { var_6 [ var_8 ] = Math . max ( var_6 [ var_8 - 1 ] , var_6 [ var_8 - 2 ] + var_0 [ var_8 - 1 ] ) ; } return ( int ) var_6 [ var_4 ] ; } " 362,1203. Sort Items by Groups Respecting Dependencies_4.java,"private Map> buildGroupGraph(int n, int[] group, List> beforeItems) { Map> graph = new HashMap<>(); for (int i = 0; i < n; i++) { int groupId = group[i]; for (int item : beforeItems.get(i)) { if (groupId == group[item]) continue; graph.putIfAbsent(group[item], new ArrayList<>()); graph.get(group[item]).add(groupId); } } return graph; }","private Map < Integer , List < Integer >> var_2 ( int var_3 , int [ ] var_4 , List < List < Integer >> var_5 ) { Map < Integer , List < Integer >> var_8 = new HashMap < > ( ) ; for ( int var_10 = 0 ; var_10 < var_3 ; var_10 ++ ) { int var_11 = var_4 [ var_10 ] ; for ( int var_13 : var_5 . get ( var_10 ) ) { if ( var_11 == var_4 [ var_13 ] ) continue ; var_8 . putIfAbsent ( var_4 [ var_13 ] , new ArrayList < > ( ) ) ; var_8 . get ( var_4 [ var_13 ] ) . add ( var_11 ) ; } } return var_8 ; } " 363,415. Add Strings_1.java,"public String addStrings(String num1, String num2) { StringBuffer sb = new StringBuffer(); int carry = 0; int i = num1.length() - 1, j = num2.length() - 1; for (; i >= 0 || j >= 0 || carry == 1; i--, j--) { int x = i < 0 ? 0 : (num1.charAt(i) - '0'); int y = j < 0 ? 0 : (num2.charAt(j) - '0'); int sum = x + y + carry; sb.append(sum % 10); carry = sum / 10; } return sb.reverse().toString(); }","public String var_0 ( String var_2 , String var_3 ) { StringBuffer var_5 = new StringBuffer ( ) ; int var_7 = 0 ; int var_10 = var_2 . length ( ) - 1 , var_11 = var_3 . length ( ) - 1 ; for ( ; var_10 >= 0 || var_11 >= 0 || var_7 == 1 ; var_10 -- , var_11 -- ) { int var_14 = var_10 < 0 ? 0 : ( var_2 . charAt ( var_10 ) - '0' ) ; int var_15 = var_11 < 0 ? 0 : ( var_3 . charAt ( var_11 ) - '0' ) ; int var_16 = var_14 + var_15 + var_7 ; var_5 . append ( var_16 % 10 ) ; var_7 = var_16 / 10 ; } return var_5 . reverse ( ) . toString ( ) ; } " 364,The Smallest Difference_1.java,"public int smallestDifference(int[] A, int[] B) { if (A == null || A.length == 0 || B == null || B.length == 0) { return 0; } if (A.length > B.length) { int[] temp = A; A = B; B = temp; } Arrays.sort(A); Arrays.sort(B); int diff = Integer.MAX_VALUE; for (int i = 0; i < A.length; i++) { int start = 0; int end = B.length - 1; int mid; if (B[start] >= A[A.length - 1]) { return B[start] - A[A.length - 1]; } if (A[start] >= B[B.length - 1]) { return A[start] - B[B.length - 1]; } while (start + 1 < end) { mid = start + (end - start)/2; if (B[mid] == A[i]) { return 0; } else if (mid - 1 >= 0 && B[mid - 1] < A[i] && A[i] < B[mid]) { diff = Math.min(diff, Math.min(A[i] - B[mid - 1], B[mid] - A[i])); break; } else if (mid + 1 < B.length - 1 && B[mid] < A[i] && A[i] < B[mid + 1]) { diff = Math.min(diff, Math.min(A[i] - B[mid], B[mid + 1] - A[i])); break; } else if (B[mid] > A[i]) { end = mid; } else { start = mid; } } if (start + 1 >= end) { int min = Math.min(Math.abs(A[i] - B[start]), Math.abs(A[i] - B[end])); diff = Math.min(diff, min); } } return diff; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { if ( var_0 == null || var_0 . length == 0 || var_1 == null || var_1 . length == 0 ) { return 0 ; } if ( var_0 . length > var_1 . length ) { int [ ] var_5 = var_0 ; var_0 = var_1 ; var_1 = var_5 ; } Arrays . sort ( var_0 ) ; Arrays . sort ( var_1 ) ; int var_10 = Integer . MAX_VALUE ; for ( int var_11 = 0 ; var_11 < var_0 . length ; var_11 ++ ) { int var_12 = 0 ; int var_14 = var_1 . length - 1 ; int var_15 ; if ( var_1 [ var_12 ] >= var_0 [ var_0 . length - 1 ] ) { return var_1 [ var_12 ] - var_0 [ var_0 . length - 1 ] ; } if ( var_0 [ var_12 ] >= var_1 [ var_1 . length - 1 ] ) { return var_0 [ var_12 ] - var_1 [ var_1 . length - 1 ] ; } while ( var_12 + 1 < var_14 ) { var_15 = var_12 + ( var_14 - var_12 ) / 2 ; if ( var_1 [ var_15 ] == var_0 [ var_11 ] ) { return 0 ; } else if ( var_15 - 1 >= 0 && var_1 [ var_15 - 1 ] < var_0 [ var_11 ] && var_0 [ var_11 ] < var_1 [ var_15 ] ) { var_10 = Math . min ( var_10 , Math . min ( var_0 [ var_11 ] - var_1 [ var_15 - 1 ] , var_1 [ var_15 ] - var_0 [ var_11 ] ) ) ; break ; } else if ( var_15 + 1 < var_1 . length - 1 && var_1 [ var_15 ] < var_0 [ var_11 ] && var_0 [ var_11 ] < var_1 [ var_15 + 1 ] ) { var_10 = Math . min ( var_10 , Math . min ( var_0 [ var_11 ] - var_1 [ var_15 ] , var_1 [ var_15 + 1 ] - var_0 [ var_11 ] ) ) ; break ; } else if ( var_1 [ var_15 ] > var_0 [ var_11 ] ) { var_14 = var_15 ; } else { var_12 = var_15 ; } } if ( var_12 + 1 >= var_14 ) { int min = Math . min ( Math . abs ( var_0 [ var_11 ] - var_1 [ var_12 ] ) , Math . abs ( var_0 [ var_11 ] - var_1 [ var_14 ] ) ) ; var_10 = Math . min ( var_10 , min ) ; } } return var_10 ; } " 365,221. Maximal Square_3.java,"public int maximalSquare(char[][] matrix) { if (matrix == null || matrix.length == 0 || matrix[0] == null || matrix[0].length == 0) { return 0; } int m = matrix.length; int n = matrix[0].length; int[][] dp = new int[2][n]; int maxLen = 0; int curr = 0; int prev = 0; for (int i = 0; i < m; i++) { curr = prev; prev = 1 - curr; for (int j = 0; j < n; j++) { if (i == 0 || j == 0) { dp[curr][j] = matrix[i][j] == '1' ? 1 : 0; maxLen = Math.max(dp[curr][j], maxLen); continue; } if (matrix[i][j] == '1') { dp[curr][j] = Math.min(Math.min(dp[prev][j], dp[curr][j - 1]), dp[prev][j - 1]) + 1; } else { dp[curr][j] = 0; } maxLen = Math.max(dp[curr][j], maxLen); } } return maxLen * maxLen; }","public int sample_funcname ( char [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_7 = new int [ 2 ] [ var_5 ] ; int var_8 = 0 ; int var_9 = 0 ; int var_10 = 0 ; for ( int var_11 = 0 ; var_11 < var_4 ; var_11 ++ ) { var_9 = var_10 ; var_10 = 1 - var_9 ; for ( int var_13 = 0 ; var_13 < var_5 ; var_13 ++ ) { if ( var_11 == 0 || var_13 == 0 ) { var_7 [ var_9 ] [ var_13 ] = var_0 [ var_11 ] [ var_13 ] == '1' ? 1 : 0 ; var_8 = Math . max ( var_7 [ var_9 ] [ var_13 ] , var_8 ) ; continue ; } if ( var_0 [ var_11 ] [ var_13 ] == '1' ) { var_7 [ var_9 ] [ var_13 ] = Math . min ( Math . min ( var_7 [ var_10 ] [ var_13 ] , var_7 [ var_9 ] [ var_13 - 1 ] ) , var_7 [ var_10 ] [ var_13 - 1 ] ) + 1 ; } else { var_7 [ var_9 ] [ var_13 ] = 0 ; } var_8 = Math . max ( var_7 [ var_9 ] [ var_13 ] , var_8 ) ; } } return var_8 * var_8 ; } " 366,13. Roman to Integer_4.java,"private Map buildMap() { Map map = new HashMap<>(); map.put('I', 1); map.put('V', 5); map.put('X', 10); map.put('L', 50); map.put('C', 100); map.put('D', 500); map.put('M', 1000); return map; }","private Map < Character , Integer > var_2 ( ) { Map < Character , Integer > var_5 = new HashMap < > ( ) ; var_5 . put ( 'I' , 1 ) ; var_5 . put ( 'V' , 5 ) ; var_5 . put ( 'X' , 10 ) ; var_5 . put ( 'L' , 50 ) ; var_5 . put ( 'C' , 100 ) ; var_5 . put ( 'D' , 500 ) ; var_5 . put ( 'M' , 1000 ) ; return var_5 ; } " 367,51. N-Queens_1.java,"private boolean validate(int[] columns, int row, int col) { for (int newRow = 0; newRow < row; newRow++) { int newCol = columns[newRow]; if (col == newCol || (Math.abs(row - newRow) == Math.abs(col - newCol))) { return false; } } return true; }","private boolean var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { for ( int var_5 = 0 ; var_5 < var_2 ; var_5 ++ ) { int var_6 = var_1 [ var_5 ] ; if ( var_3 == var_6 || ( Math . abs ( var_2 - var_5 ) == Math . abs ( var_3 - var_6 ) ) ) { return false ; } } return true ; } " 368,1216. Valid Palindrome III_1.java,"private int findLpsLength(String s) { int n = s.length(); int[][] dp = new int[n][n]; for (int i = n - 1; i >= 0; i--){ dp[i][i] = 1; for (int j = i + 1; j < n; j++) { if (s.charAt(i) == s.charAt(j)) dp[i][j] = dp[i + 1][j - 1] + 2; else dp[i][j] = Math.max(dp[i + 1][j], dp[i][j - 1]); } } return dp[0][n - 1]; }","private int sample_funcname ( String var_1 ) { int var_3 = var_1 . length ( ) ; int [ ] [ ] var_4 = new int [ var_3 ] [ var_3 ] ; for ( int var_6 = var_3 - 1 ; var_6 >= 0 ; var_6 -- ) { var_4 [ var_6 ] [ var_6 ] = 1 ; for ( int var_8 = var_6 + 1 ; var_8 < var_3 ; var_8 ++ ) { if ( var_1 . charAt ( var_6 ) == var_1 . charAt ( var_8 ) ) var_4 [ var_6 ] [ var_8 ] = var_4 [ var_6 + 1 ] [ var_8 - 1 ] + 2 ; else var_4 [ var_6 ] [ var_8 ] = Math . max ( var_4 [ var_6 + 1 ] [ var_8 ] , var_4 [ var_6 ] [ var_8 - 1 ] ) ; } } return var_4 [ 0 ] [ var_3 - 1 ] ; } " 369,Evaluate Reverse Polish Notation_1.java,"private boolean isOperator(String s) { if (s.length() != 1) return false; char c = s.charAt(0); return c == '+' || c == '-' || c == '/' || c == '*'; }","private boolean var_0 ( String var_2 ) { if ( var_2 . length ( ) != 1 ) return false ; char var_7 = var_2 . charAt ( 0 ) ; return var_7 == '+' || var_7 == '-' || var_7 == '/' || var_7 == '*' ; } " 370,39. Combination Sum_1.java,"private void dfs(List> result, List list, int[] candidates, int index, int target) { if (target == 0) { result.add(new ArrayList<>(list)); return; } for (int i = index; i < candidates.length; i++) { int value = candidates[i]; list.add(value); if (target - value >= 0) dfs(result, list, candidates, i, target - value); list.remove(list.size() - 1); } }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int [ ] candidates , int index , int target ) { if ( target == 0 ) { result . add ( new ArrayList < > ( list ) ) ; return ; } for ( int i = index ; i < candidates . length ; i ++ ) { int value = candidates [ i ] ; list . add ( value ) ; if ( target - value >= 0 ) dfs ( result , list , candidates , i , target - value ) ; list . remove ( list . size ( ) - 1 ) ; } } " 371,Backpack II_1.java,"public int backPackII(int m, int[] A, int V[]) { if (A == null || V == null || A.length != V.length) { return 0; } int n = A.length; int[][] dp = new int[n + 1][m + 1]; for (int i = 1; i <= n; i++) { for (int j = 0; j <= m; j++) { dp[i][j] = dp[i - 1][j]; if (j - A[i - 1] >= 0) { dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - A[i - 1]] + V[i - 1]); } } } return dp[n][m]; }","public int sample_funcname ( int var_0 , int [ ] var_1 , int var_2 [ ] ) { if ( var_1 == null || var_2 == null || var_1 . length != var_2 . length ) { return 0 ; } int var_6 = var_1 . length ; int [ ] [ ] var_8 = new int [ var_6 + 1 ] [ var_0 + 1 ] ; for ( int var_9 = 1 ; var_9 <= var_6 ; var_9 ++ ) { for ( int var_10 = 0 ; var_10 <= var_0 ; var_10 ++ ) { var_8 [ var_9 ] [ var_10 ] = var_8 [ var_9 - 1 ] [ var_10 ] ; if ( var_10 - var_1 [ var_9 - 1 ] >= 0 ) { var_8 [ var_9 ] [ var_10 ] = Math . max ( var_8 [ var_9 ] [ var_10 ] , var_8 [ var_9 - 1 ] [ var_10 - var_1 [ var_9 - 1 ] ] + var_2 [ var_9 - 1 ] ) ; } } } return var_8 [ var_6 ] [ var_0 ] ; } " 372,347. Top K Frequent Elements_1.java,"private Map buildFreqMap(int[] nums) { Map map = new HashMap<>(); for (int num : nums) map.put(num, map.getOrDefault(num, 0) + 1); return map; }","private Map < Integer , Integer > var_1 ( int [ ] var_2 ) { Map < Integer , Integer > var_5 = new HashMap < > ( ) ; for ( int var_6 : var_2 ) var_5 . put ( var_6 , var_5 . getOrDefault ( var_6 , 0 ) + 1 ) ; return var_5 ; } " 373,Missing Number_3.java,"public int missingNumber(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int result = nums.length; for (int i = 0; i < nums.length; i++) { result = result ^ nums[i] ^ i; } return result; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { var_4 = var_4 ^ var_0 [ var_5 ] ^ var_5 ; } return var_4 ; } " 374,152. Maximum Product Subarray_1.java,"public int maxProduct(int[] nums) { int n = nums.length; int[] maxProduct = new int[n], minProduct = new int[n]; maxProduct[0] = nums[0]; minProduct[0] = nums[0]; int max = nums[0]; for (int i = 1; i < n; i++) { int num = nums[i]; if (num > 0) { maxProduct[i] = Math.max(num, maxProduct[i - 1] * num); minProduct[i] = Math.min(num, minProduct[i - 1] * num); } else { maxProduct[i] = Math.max(num, minProduct[i - 1] * num); minProduct[i] = Math.min(num, maxProduct[i - 1] * num); } max = Math.max(max, maxProduct[i]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; int [ ] var_3 = new int [ var_2 ] , var_4 = new int [ var_2 ] ; var_3 [ 0 ] = var_0 [ 0 ] ; var_4 [ 0 ] = var_0 [ 0 ] ; int max = var_0 [ 0 ] ; for ( int var_8 = 1 ; var_8 < var_2 ; var_8 ++ ) { int var_9 = var_0 [ var_8 ] ; if ( var_9 > 0 ) { var_3 [ var_8 ] = Math . max ( var_9 , var_3 [ var_8 - 1 ] * var_9 ) ; var_4 [ var_8 ] = Math . min ( var_9 , var_4 [ var_8 - 1 ] * var_9 ) ; } else { var_3 [ var_8 ] = Math . max ( var_9 , var_4 [ var_8 - 1 ] * var_9 ) ; var_4 [ var_8 ] = Math . min ( var_9 , var_3 [ var_8 - 1 ] * var_9 ) ; } max = Math . max ( max , var_3 [ var_8 ] ) ; } return max ; } " 375,53. Maximum Subarray_6.java,"public int maxSubArray(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length, max = Integer.MIN_VALUE; int[] dp = new int[2]; dp[0] = 0; for (int i = 1; i <= n; i++) { dp[i % 2] = nums[i - 1] + (dp[(i - 1) % 2] >= 0 ? dp[(i - 1) % 2] : 0); max = Math.max(max, dp[i % 2]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length , max = Integer . MIN_VALUE ; int [ ] var_9 = new int [ 2 ] ; var_9 [ 0 ] = 0 ; for ( int var_11 = 1 ; var_11 <= var_4 ; var_11 ++ ) { var_9 [ var_11 % 2 ] = var_0 [ var_11 - 1 ] + ( var_9 [ ( var_11 - 1 ) % 2 ] >= 0 ? var_9 [ ( var_11 - 1 ) % 2 ] : 0 ) ; max = Math . max ( max , var_9 [ var_11 % 2 ] ) ; } return max ; } " 376,Longest Consecutive Sequence_2.java,"public int longestConsecutive(int[] num) { if (num == null || num.length == 0) { return 0; } int maxL = 1; HashMap history = new HashMap(); for (int i : num) { history.put(i, false); } for (int i : num) { if (history.get(i)) { continue; } int temp = i; int total = 1; while (history.containsKey(temp + 1)) { total++; temp++; history.put(temp, true); } temp = i; while (history.containsKey(temp - 1)) { total++; temp--; history.put(temp, true); } maxL = Math.max(maxL, total); } return maxL; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = 1 ; HashMap < Integer , Boolean > var_9 = new HashMap < Integer , Boolean > ( ) ; for ( int var_10 : var_0 ) { var_9 . put ( var_10 , false ) ; } for ( int var_10 : var_0 ) { if ( var_9 . get ( var_10 ) ) { continue ; } int var_13 = var_10 ; int var_14 = 1 ; while ( var_9 . containsKey ( var_13 + 1 ) ) { var_14 ++ ; var_13 ++ ; var_9 . put ( var_13 , true ) ; } var_13 = var_10 ; while ( var_9 . containsKey ( var_13 - 1 ) ) { var_14 ++ ; var_13 -- ; var_9 . put ( var_13 , true ) ; } var_5 = Math . max ( var_5 , var_14 ) ; } return var_5 ; } " 377,1. Two Sum_2.java,"public int[] twoSum(int[] numbers, int target) { if (numbers == null || numbers.length == 0) { return null; } int[] original = new int[numbers.length]; for (int i = 0; i < numbers.length; i++) { original[i] = numbers[i]; } Arrays.sort(numbers); int start = 0; int end = numbers.length - 1; int num1 = -1; int num2 = -1; while (start != end) { int sum = numbers[start] + numbers[end]; if (sum == target) { num1 = numbers[start]; num2 = numbers[end]; break; }else if (sum < target) { start++; } else { end--; } } int[] rst = new int[2]; rst[0] = -1; rst[1] = -1; for (int i = 0; i < original.length; i++) { if (original[i] == num1 || original[i] == num2) { if (rst[0] == -1) { rst[0] = i + 1; } else { rst[1] = i + 1; break; } } } return rst; }","public int [ ] sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return null ; } int [ ] var_5 = new int [ var_0 . length ] ; for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { var_5 [ var_6 ] = var_0 [ var_6 ] ; } Arrays . sort ( var_0 ) ; int var_9 = 0 ; int var_11 = var_0 . length - 1 ; int var_12 = - 1 ; int var_13 = - 1 ; while ( var_9 != var_11 ) { int var_14 = var_0 [ var_9 ] + var_0 [ var_11 ] ; if ( var_14 == var_1 ) { var_12 = var_0 [ var_9 ] ; var_13 = var_0 [ var_11 ] ; break ; } else if ( var_14 < var_1 ) { var_9 ++ ; } else { var_11 -- ; } } int [ ] var_16 = new int [ 2 ] ; var_16 [ 0 ] = - 1 ; var_16 [ 1 ] = - 1 ; for ( int var_6 = 0 ; var_6 < var_5 . length ; var_6 ++ ) { if ( var_5 [ var_6 ] == var_12 || var_5 [ var_6 ] == var_13 ) { if ( var_16 [ 0 ] == - 1 ) { var_16 [ 0 ] = var_6 + 1 ; } else { var_16 [ 1 ] = var_6 + 1 ; break ; } } } return var_16 ; } " 378,Paint Fence_2.java,"public int numWays(int n, int k) { if (n <= 1 || k <= 0) { return n * k; } int[] dp = new int[3]; dp[0] = 0; dp[1] = k; dp[2] = k + k * (k - 1); for (int i = 3; i <= n; i++) { dp[i % 3] = (k - 1) * (dp[(i - 1) % 3] + dp[(i - 2) % 3]); } return dp[n % 3]; }","public int sample_funcname ( int var_0 , int var_1 ) { if ( var_0 <= 1 || var_1 <= 0 ) { return var_0 * var_1 ; } int [ ] var_5 = new int [ 3 ] ; var_5 [ 0 ] = 0 ; var_5 [ 1 ] = var_1 ; var_5 [ 2 ] = var_1 + var_1 * ( var_1 - 1 ) ; for ( int var_7 = 3 ; var_7 <= var_0 ; var_7 ++ ) { var_5 [ var_7 % 3 ] = ( var_1 - 1 ) * ( var_5 [ ( var_7 - 1 ) % 3 ] + var_5 [ ( var_7 - 2 ) % 3 ] ) ; } return var_5 [ var_0 % 3 ] ; } " 379,K Empty Slots_1.java,"public int kEmptySlots(int[] flowers, int k) { if (flowers == null || flowers.length == 0 || k < 0) { return - 1; } TreeSet treeSet = new TreeSet<>(); for (int i = 0; i < flowers.length; i++) { int num = flowers[i]; treeSet.add(num); Integer lower = treeSet.lower(num); Integer higher = treeSet.higher(num); if (higher != null && higher - num == k + 1 ) { return i + 1; } if (lower != null && num - lower == k + 1) { return i + 1; } } return -1; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 || var_1 < 0 ) { return - 1 ; } TreeSet < Integer > var_8 = new TreeSet < > ( ) ; for ( int var_9 = 0 ; var_9 < var_0 . length ; var_9 ++ ) { int var_10 = var_0 [ var_9 ] ; var_8 . add ( var_10 ) ; Integer lower = var_8 . lower ( var_10 ) ; Integer higher = var_8 . higher ( var_10 ) ; if ( higher != null && higher - var_10 == var_1 + 1 ) { return var_9 + 1 ; } if ( lower != null && var_10 - lower == var_1 + 1 ) { return var_9 + 1 ; } } return - 1 ; } " 380,Jump Game II_4.java,"public int jump(int[] nums) { if (nums == null || nums.length <= 1) { return 0; } int index = 0; int step = 0; int range = 0; int maxRange = 0; while (index < nums.length) { if (range >= nums.length - 1) { break; } while (index <= range) { maxRange = Math.max(maxRange, index + nums[index]); index++; } range = maxRange; step++; } return step; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length <= 1 ) { return 0 ; } int var_5 = 0 ; int var_6 = 0 ; int var_7 = 0 ; int var_8 = 0 ; while ( var_5 < var_0 . length ) { if ( var_7 >= var_0 . length - 1 ) { break ; } while ( var_5 <= var_7 ) { var_8 = Math . max ( var_8 , var_5 + var_0 [ var_5 ] ) ; var_5 ++ ; } var_7 = var_8 ; var_6 ++ ; } return var_6 ; } " 381,259. 3Sum Smaller_2.java,"public int threeSumSmaller(int[] nums, int target) { if (nums == null || nums.length <= 2) { return 0; } Arrays.sort(nums); int rst = 0; for (int i = 0; i < nums.length - 2; i++) { int j = i + 1; int k = nums.length - 1; while (j < k) { if (nums[i] + nums[j] + nums[k] >= target) { k--; } else { rst += (k - j); j++; } } } return rst; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length <= 2 ) { return 0 ; } Arrays . sort ( var_0 ) ; int var_8 = 0 ; for ( int var_9 = 0 ; var_9 < var_0 . length - 2 ; var_9 ++ ) { int var_11 = var_9 + 1 ; int var_12 = var_0 . length - 1 ; while ( var_11 < var_12 ) { if ( var_0 [ var_9 ] + var_0 [ var_11 ] + var_0 [ var_12 ] >= var_1 ) { var_12 -- ; } else { var_8 += ( var_12 - var_11 ) ; var_11 ++ ; } } } return var_8 ; } " 382,91. Decode Ways_2.java,"private boolean check(String s, int i) { int twoDigit = (s.charAt(i - 1) - '0') * 10 + (s.charAt(i) - '0'); return twoDigit <= 26 && twoDigit >= 10; }","private boolean var_0 ( String var_2 , int var_3 ) { int var_8 = ( var_2 . charAt ( var_3 - 1 ) - '0' ) * 10 + ( var_2 . charAt ( var_3 ) - '0' ) ; return var_8 <= 26 && var_8 >= 10 ; } " 383,200. Number of Islands_2.java,"private int countIsland(char[][] grid) { int m = grid.length, n = grid[0].length; int count = 0; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { count += grid[i][j] == '1' ? 1 : 0; } } return count; }","private int sample_funcname ( char [ ] [ ] var_0 ) { int var_2 = var_0 . length , var_4 = var_0 [ 0 ] . length ; int var_5 = 0 ; for ( int var_6 = 0 ; var_6 < var_2 ; var_6 ++ ) { for ( int var_7 = 0 ; var_7 < var_4 ; var_7 ++ ) { var_5 += var_0 [ var_6 ] [ var_7 ] == '1' ? 1 : 0 ; } } return var_5 ; } " 384,40. Combination Sum II_4.java,"private boolean validate(int[] candidates, int target) { return candidates == null || candidates.length == 0 || target <= 0; }","private boolean var_0 ( int [ ] var_1 , int var_2 ) { return var_1 == null || var_1 . length == 0 || var_2 <= 0 ; } " 385,621. Task Scheduler_1.java,"public int leastInterval(char[] tasks, int n) { if (tasks == null) return 0; PriorityQueue pq = new PriorityQueue<>(26, Collections.reverseOrder()); int[] counts = new int[26]; for (char c : tasks) counts[c - 'A']++; for (int i = 0; i < counts.length; i++) { if (counts[i] > 0) pq.offer(counts[i]); } int count = 0; while (!pq.isEmpty()) { int k = n + 1; List list = new ArrayList<>(); while (k > 0 && !pq.isEmpty()) { Integer taskCount = pq.poll(); if (taskCount-- > 1) list.add(taskCount); count++; k--; } pq.addAll(list); if (pq.isEmpty()) break; count += k; } return count; }","public int sample_funcname ( char [ ] var_0 , int var_1 ) { if ( var_0 == null ) return 0 ; PriorityQueue < Integer > var_9 = new PriorityQueue < > ( 26 , Collections . reverseOrder ( ) ) ; int [ ] var_10 = new int [ 26 ] ; for ( char var_11 : var_0 ) var_10 [ var_11 - 'A' ] ++ ; for ( int var_13 = 0 ; var_13 < var_10 . length ; var_13 ++ ) { if ( var_10 [ var_13 ] > 0 ) var_9 . offer ( var_10 [ var_13 ] ) ; } int var_16 = 0 ; while ( ! var_9 . isEmpty ( ) ) { int var_19 = var_1 + 1 ; List < Integer > var_22 = new ArrayList < > ( ) ; while ( var_19 > 0 && ! var_9 . isEmpty ( ) ) { Integer var_24 = var_9 . poll ( ) ; if ( var_24 -- > 1 ) var_22 . add ( var_24 ) ; var_16 ++ ; var_19 -- ; } var_9 . addAll ( var_22 ) ; if ( var_9 . isEmpty ( ) ) break ; var_16 += var_19 ; } return var_16 ; } " 386,64. Minimum Path Sum_2.java,"public int minPathSum(int[][] grid) { if (grid == null || grid.length == 0 || grid[0] == null || grid[0].length == 0) { return 0; } int m = grid.length; int n = grid[0].length; int[][] dp = new int[2][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (i == 0 && j == 0) { dp[i % 2][j] = grid[i][j]; continue; } int fromUp = i == 0 ? Integer.MAX_VALUE : dp[(i - 1) % 2][j]; int fromLeft = j == 0 ? Integer.MAX_VALUE : dp[i % 2][j - 1]; dp[i % 2][j] = Math.min(fromUp, fromLeft) + grid[i][j]; } } return dp[(m - 1) % 2][n - 1]; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_7 = new int [ 2 ] [ var_5 ] ; for ( int var_8 = 0 ; var_8 < var_4 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 < var_5 ; var_9 ++ ) { if ( var_8 == 0 && var_9 == 0 ) { var_7 [ var_8 % 2 ] [ var_9 ] = var_0 [ var_8 ] [ var_9 ] ; continue ; } int var_13 = var_8 == 0 ? Integer . MAX_VALUE : var_7 [ ( var_8 - 1 ) % 2 ] [ var_9 ] ; int var_14 = var_9 == 0 ? Integer . MAX_VALUE : var_7 [ var_8 % 2 ] [ var_9 - 1 ] ; var_7 [ var_8 % 2 ] [ var_9 ] = Math . min ( var_13 , var_14 ) + var_0 [ var_8 ] [ var_9 ] ; } } return var_7 [ ( var_4 - 1 ) % 2 ] [ var_5 - 1 ] ; } " 387,350. Intersection of Two Arrays II_2.java,"private int[] convertToArray(List list) { int[] rst = new int[list.size()]; for (int i = 0; i < list.size(); i++) { rst[i] = list.get(i); } return rst; }","private int [ ] sample_funcname ( List < Integer > var_2 ) { int [ ] var_4 = new int [ var_2 . size ( ) ] ; for ( int var_6 = 0 ; var_6 < var_2 . size ( ) ; var_6 ++ ) { var_4 [ var_6 ] = var_2 . get ( var_6 ) ; } return var_4 ; } " 388,Submatrix Sum_1.java,"private boolean validateInput(int[][] nums) { if (nums == null || nums.length == 0 || nums[0] == null || nums[0].length == 0) { return true; } return false; }","private boolean var_0 ( int [ ] [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 ) { return true ; } return false ; } " 389,361. Bomb Enemy_1.java,"public int maxKilledEnemies(char[][] grid) { if (grid == null || grid.length == 0 || grid[0].length == 0) { return 0; } int m = grid.length; int n = grid[0].length; int[][] up = new int[m][n]; int[][] down = new int[m][n]; int[][] left = new int[m][n]; int[][] right = new int[m][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (grid[i][j] != 'W') { up[i][j] = grid[i][j] == 'E' ? 1 : 0; up[i][j] += i - 1 >= 0 ? up[i - 1][j] : 0; } } } for (int i = m - 1; i >= 0; i--) { for (int j = 0; j < n; j++) { if (grid[i][j] != 'W') { down[i][j] = grid[i][j] == 'E' ? 1 : 0; down[i][j] += i + 1 < m ? down[i + 1][j] : 0; } } } for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (grid[i][j] != 'W') { left[i][j] = grid[i][j] == 'E' ? 1 : 0; left[i][j] += j - 1 >= 0 ? left[i][j - 1] : 0; } } } for (int i = 0; i < m; i++) { for (int j = n - 1; j >= 0; j--) { if (grid[i][j] != 'W') { right[i][j] = grid[i][j] == 'E' ? 1 : 0; right[i][j] += j + 1 < n ? right[i][j + 1] : 0; } } } int max = 0; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (grid[i][j] == '0') { max = Math.max(max, up[i][j] + down[i][j] + left[i][j] + right[i][j]); } } } return max; }","public int sample_funcname ( char [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_6 = new int [ var_4 ] [ var_5 ] ; int [ ] [ ] var_7 = new int [ var_4 ] [ var_5 ] ; int [ ] [ ] var_8 = new int [ var_4 ] [ var_5 ] ; int [ ] [ ] var_9 = new int [ var_4 ] [ var_5 ] ; for ( int var_10 = 0 ; var_10 < var_4 ; var_10 ++ ) { for ( int var_11 = 0 ; var_11 < var_5 ; var_11 ++ ) { if ( var_0 [ var_10 ] [ var_11 ] != 'W' ) { var_6 [ var_10 ] [ var_11 ] = var_0 [ var_10 ] [ var_11 ] == 'E' ? 1 : 0 ; var_6 [ var_10 ] [ var_11 ] += var_10 - 1 >= 0 ? var_6 [ var_10 - 1 ] [ var_11 ] : 0 ; } } } for ( int var_10 = var_4 - 1 ; var_10 >= 0 ; var_10 -- ) { for ( int var_11 = 0 ; var_11 < var_5 ; var_11 ++ ) { if ( var_0 [ var_10 ] [ var_11 ] != 'W' ) { var_7 [ var_10 ] [ var_11 ] = var_0 [ var_10 ] [ var_11 ] == 'E' ? 1 : 0 ; var_7 [ var_10 ] [ var_11 ] += var_10 + 1 < var_4 ? var_7 [ var_10 + 1 ] [ var_11 ] : 0 ; } } } for ( int var_10 = 0 ; var_10 < var_4 ; var_10 ++ ) { for ( int var_11 = 0 ; var_11 < var_5 ; var_11 ++ ) { if ( var_0 [ var_10 ] [ var_11 ] != 'W' ) { var_8 [ var_10 ] [ var_11 ] = var_0 [ var_10 ] [ var_11 ] == 'E' ? 1 : 0 ; var_8 [ var_10 ] [ var_11 ] += var_11 - 1 >= 0 ? var_8 [ var_10 ] [ var_11 - 1 ] : 0 ; } } } for ( int var_10 = 0 ; var_10 < var_4 ; var_10 ++ ) { for ( int var_11 = var_5 - 1 ; var_11 >= 0 ; var_11 -- ) { if ( var_0 [ var_10 ] [ var_11 ] != 'W' ) { var_9 [ var_10 ] [ var_11 ] = var_0 [ var_10 ] [ var_11 ] == 'E' ? 1 : 0 ; var_9 [ var_10 ] [ var_11 ] += var_11 + 1 < var_5 ? var_9 [ var_10 ] [ var_11 + 1 ] : 0 ; } } } int max = 0 ; for ( int var_10 = 0 ; var_10 < var_4 ; var_10 ++ ) { for ( int var_11 = 0 ; var_11 < var_5 ; var_11 ++ ) { if ( var_0 [ var_10 ] [ var_11 ] == '0' ) { max = Math . max ( max , var_6 [ var_10 ] [ var_11 ] + var_7 [ var_10 ] [ var_11 ] + var_8 [ var_10 ] [ var_11 ] + var_9 [ var_10 ] [ var_11 ] ) ; } } } return max ; } " 390,Longest Common Substring_1.java,"public int longestCommonSubstring(String A, String B) { if (A == null || B == null || A.length() == 0 || B.length() == 0) { return 0; } int m = A.length(); int n = B.length(); int[][] dp = new int[m + 1][n + 1]; int max = 0; for (int i = 0; i <= m; i++) { for(int j = 0; j <= n; j++) { if (i == 0 || j == 0) { dp[i][j] = 0; continue; } if (A.charAt(i - 1) == B.charAt(j - 1)) { dp[i][j] = dp[i - 1][j - 1] + 1; } else { dp[i][j] = 0; } max = Math.max(max, dp[i][j]); } } return max; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) == 0 || var_2 . length ( ) == 0 ) { return 0 ; } int var_6 = var_1 . length ( ) ; int var_7 = var_2 . length ( ) ; int [ ] [ ] var_9 = new int [ var_6 + 1 ] [ var_7 + 1 ] ; int max = 0 ; for ( int var_11 = 0 ; var_11 <= var_6 ; var_11 ++ ) { for ( int var_12 = 0 ; var_12 <= var_7 ; var_12 ++ ) { if ( var_11 == 0 || var_12 == 0 ) { var_9 [ var_11 ] [ var_12 ] = 0 ; continue ; } if ( var_1 . charAt ( var_11 - 1 ) == var_2 . charAt ( var_12 - 1 ) ) { var_9 [ var_11 ] [ var_12 ] = var_9 [ var_11 - 1 ] [ var_12 - 1 ] + 1 ; } else { var_9 [ var_11 ] [ var_12 ] = 0 ; } max = Math . max ( max , var_9 [ var_11 ] [ var_12 ] ) ; } } return max ; } " 391,Backpack_2.java,"public int backPack(int m, int[] A) { if (A == null || A.length < 0) { return 0; } int n = A.length; int[][] dp = new int[2][m + 1]; for (int i = 1; i <= n; i++) { for (int j = 0; j <= m; j++) { dp[i % 2][j] = dp[(i - 1) % 2][j]; if (j - A[i - 1] >= 0) { dp[i % 2][j] = Math.max(dp[i % 2][j], dp[(i - 1) % 2][j - A[i - 1]] + A[i - 1]); } } } return dp[n % 2][m]; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length < 0 ) { return 0 ; } int var_5 = var_1 . length ; int [ ] [ ] var_8 = new int [ 2 ] [ var_0 + 1 ] ; for ( int var_9 = 1 ; var_9 <= var_5 ; var_9 ++ ) { for ( int var_10 = 0 ; var_10 <= var_0 ; var_10 ++ ) { var_8 [ var_9 % 2 ] [ var_10 ] = var_8 [ ( var_9 - 1 ) % 2 ] [ var_10 ] ; if ( var_10 - var_1 [ var_9 - 1 ] >= 0 ) { var_8 [ var_9 % 2 ] [ var_10 ] = Math . max ( var_8 [ var_9 % 2 ] [ var_10 ] , var_8 [ ( var_9 - 1 ) % 2 ] [ var_10 - var_1 [ var_9 - 1 ] ] + var_1 [ var_9 - 1 ] ) ; } } } return var_8 [ var_5 % 2 ] [ var_0 ] ; } " 392,71. Simplify Path_1.java,"public String simplifyPath(String path) { Stack stack = new Stack<>(); String[] parts = path.split(""/""); for (String s : parts) { if (s.isEmpty() || s.equals(""."")) continue; if (s.equals("".."")) { if (!stack.isEmpty()) stack.pop(); continue; } stack.push(s); } StringBuffer sb = new StringBuffer(); while (!stack.isEmpty()) sb.insert(0, ""/"" + stack.pop()); if (sb.length() == 0) sb.append(""/""); return sb.toString(); }","public String var_0 ( String var_2 ) { Stack < String > var_4 = new Stack < > ( ) ; String [ ] var_7 = var_2 . split ( ""/"" ) ; for ( String var_8 : var_7 ) { if ( var_8 . isEmpty ( ) || var_8 . equals ( ""."" ) ) continue ; if ( var_8 . equals ( "".."" ) ) { if ( ! var_4 . isEmpty ( ) ) var_4 . pop ( ) ; continue ; } var_4 . push ( var_8 ) ; } StringBuffer var_16 = new StringBuffer ( ) ; while ( ! var_4 . isEmpty ( ) ) var_16 . insert ( 0 , ""/"" + var_4 . pop ( ) ) ; if ( var_16 . length ( ) == 0 ) var_16 . append ( ""/"" ) ; return var_16 . toString ( ) ; } " 393,Stone Game_1.java,"public int stoneGame(int[] A) { if (A == null || A.length == 0) { return 0; } int n = A.length; int[][] f = new int[n][n]; for (int i = 0; i < n; i++) { f[i][i] = 0; } int[][] sum = new int[n][n]; sum[0][0] = A[0]; for (int i = 0; i < n; i++) { sum[i][i] = A[i]; for (int j = i + 1; j < n; j++) { sum[i][j] = sum[i][j - 1] + A[j]; } } for (int delta = 1; delta < n; delta++) { for (int start = 0; start < n - delta; start++) { int end = start + delta; f[start][end] = Integer.MAX_VALUE; for (int k = start; k < end; k++) { f[start][end] = Math.min(f[start][end], f[start][k] + f[k + 1][end] + sum[start][end]); } } } return f[0][n - 1]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int [ ] [ ] var_5 = new int [ var_4 ] [ var_4 ] ; for ( int var_6 = 0 ; var_6 < var_4 ; var_6 ++ ) { var_5 [ var_6 ] [ var_6 ] = 0 ; } int [ ] [ ] var_7 = new int [ var_4 ] [ var_4 ] ; var_7 [ 0 ] [ 0 ] = var_0 [ 0 ] ; for ( int var_6 = 0 ; var_6 < var_4 ; var_6 ++ ) { var_7 [ var_6 ] [ var_6 ] = var_0 [ var_6 ] ; for ( int var_9 = var_6 + 1 ; var_9 < var_4 ; var_9 ++ ) { var_7 [ var_6 ] [ var_9 ] = var_7 [ var_6 ] [ var_9 - 1 ] + var_0 [ var_9 ] ; } } for ( int var_10 = 1 ; var_10 < var_4 ; var_10 ++ ) { for ( int var_11 = 0 ; var_11 < var_4 - var_10 ; var_11 ++ ) { int var_12 = var_11 + var_10 ; var_5 [ var_11 ] [ var_12 ] = Integer . MAX_VALUE ; for ( int var_15 = var_11 ; var_15 < var_12 ; var_15 ++ ) { var_5 [ var_11 ] [ var_12 ] = Math . min ( var_5 [ var_11 ] [ var_12 ] , var_5 [ var_11 ] [ var_15 ] + var_5 [ var_15 + 1 ] [ var_12 ] + var_7 [ var_11 ] [ var_12 ] ) ; } } } return var_5 [ 0 ] [ var_4 - 1 ] ; } " 394,Find Minimum in Rotated Sorted Array II_1.java,"public int findMin(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int start = 0; int end = n - 1; while (start + 1 < end) { int mid = (start + end) >> 1; if (nums[mid] == nums[end]) { end--; } else if (nums[mid] > nums[end]) { start = mid; } else { end = mid; } } return nums[start] < nums[end] ? nums[start] : nums[end]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = 0 ; int var_7 = var_4 - 1 ; while ( var_5 + 1 < var_7 ) { int var_8 = ( var_5 + var_7 ) >> 1 ; if ( var_0 [ var_8 ] == var_0 [ var_7 ] ) { var_7 -- ; } else if ( var_0 [ var_8 ] > var_0 [ var_7 ] ) { var_5 = var_8 ; } else { var_7 = var_8 ; } } return var_0 [ var_5 ] < var_0 [ var_7 ] ? var_0 [ var_5 ] : var_0 [ var_7 ] ; } " 395,20. Valid Parentheses_1.java,"private boolean validate(char a, char b) { if (a == '(') return b == ')'; if (a == '{') return b == '}'; if (a == '[') return b == ']'; return false; }","private boolean var_0 ( char var_1 , char var_2 ) { if ( var_1 == '(' ) return var_2 == ')' ; if ( var_1 == '{' ) return var_2 == '}' ; if ( var_1 == '[' ) return var_2 == ']' ; return false ; } " 396,Expression Add Operators_1.java,"private void backtrack(List list) { list.remove(list.size() - 1); list.remove(list.size() - 1); }","private void var_0 ( List < String > var_3 ) { var_3 . remove ( var_3 . size ( ) - 1 ) ; var_3 . remove ( var_3 . size ( ) - 1 ) ; } " 397,252. Meeting Rooms_1.java,"public boolean canAttendMeetings(int[][] intervals) { if (intervals == null) return true; Arrays.sort(intervals, Comparator.comparing(i -> i[0])); for (int i = 0; i < intervals.length - 1; i++) { if (intervals[i][1] > intervals[i + 1][0]) return false; } return true; }","public boolean var_0 ( int [ ] [ ] var_1 ) { if ( var_1 == null ) return true ; Arrays . sort ( var_1 , Comparator . comparing ( var_7 -> var_7 [ 0 ] ) ) ; for ( int var_7 = 0 ; var_7 < var_1 . length - 1 ; var_7 ++ ) { if ( var_1 [ var_7 ] [ 1 ] > var_1 [ var_7 + 1 ] [ 0 ] ) return false ; } return true ; } " 398,Gray Code_2.java,"public List grayCode(int n) { List rst = new ArrayList(); if (n < 0) { return rst; } char[] bits = new char[n]; for (int i = 0; i < bits.length; i++) { bits[i] = '0'; } String str = new String(bits); if (n == 0) { str = ""0""; } rst.add(Integer.parseInt(str, 2)); int step = n - 1; boolean LR = true; int steps = (int)Math.pow(2, n) - 1; for (int i = 0; i < steps; i++) { bits[step] = bits[step] == '0' ? '1' : '0'; str = new String(bits); rst.add(Integer.parseInt(str, 2)); if (LR) { step--; } else { step++; } if (step == (n - 1) || step == 0) { LR = !LR; } } return rst; }","public List < Integer > var_1 ( int var_2 ) { List < Integer > var_5 = new ArrayList < Integer > ( ) ; if ( var_2 < 0 ) { return var_5 ; } char [ ] var_7 = new char [ var_2 ] ; for ( int var_8 = 0 ; var_8 < var_7 . length ; var_8 ++ ) { var_7 [ var_8 ] = '0' ; } String var_12 = new String ( var_7 ) ; if ( var_2 == 0 ) { var_12 = ""0"" ; } var_5 . add ( Integer . parseInt ( var_12 , 2 ) ) ; int var_18 = var_2 - 1 ; boolean var_24 = true ; int var_22 = ( int ) Math . pow ( 2 , var_2 ) - 1 ; for ( int var_8 = 0 ; var_8 < var_22 ; var_8 ++ ) { var_7 [ var_18 ] = var_7 [ var_18 ] == '0' ? '1' : '0' ; var_12 = new String ( var_7 ) ; var_5 . add ( Integer . parseInt ( var_12 , 2 ) ) ; if ( var_24 ) { var_18 -- ; } else { var_18 ++ ; } if ( var_18 == ( var_2 - 1 ) || var_18 == 0 ) { var_24 = ! var_24 ; } } return var_5 ; } " 399,Sliding Puzzle_3.java,"private String boardToString(int[] nums) { StringBuffer sb = new StringBuffer(); for (int num : nums) { sb.append(num + ""#""); } return sb.toString(); }","private String var_0 ( int [ ] var_1 ) { StringBuffer var_3 = new StringBuffer ( ) ; for ( int var_4 : var_1 ) { var_3 . append ( var_4 + ""#"" ) ; } return var_3 . toString ( ) ; } " 400,Interleaving String_4.java,"public boolean isInterleave(String s1, String s2, String s3) { if (s3 == null || (s1 == null && s2 == null) || s1.length() + s2.length() != s3.length()) { return false; } int i = 0; int j = 0; String base = """"; for (int k = 0; k < s1.length()*s2.length() - 1; k++) { if (i < s1.length() || j < s2.length()) { if (i < s1.length() && s3.indexOf(base + s1.charAt(i)) == 0) { base += s1.charAt(i); i++; } else if (j < s2.length() && s3.indexOf(base + s2.charAt(j)) == 0) { base += s2.charAt(j); j++; } else { return false; } } } return true; }","public boolean var_0 ( String var_2 , String var_3 , String var_4 ) { if ( var_4 == null || ( var_2 == null && var_3 == null ) || var_2 . length ( ) + var_3 . length ( ) != var_4 . length ( ) ) { return false ; } int var_8 = 0 ; int var_9 = 0 ; String var_11 = """" ; for ( int var_12 = 0 ; var_12 < var_2 . length ( ) * var_3 . length ( ) - 1 ; var_12 ++ ) { if ( var_8 < var_2 . length ( ) || var_9 < var_3 . length ( ) ) { if ( var_8 < var_2 . length ( ) && var_4 . indexOf ( var_11 + var_2 . charAt ( var_8 ) ) == 0 ) { var_11 += var_2 . charAt ( var_8 ) ; var_8 ++ ; } else if ( var_9 < var_3 . length ( ) && var_4 . indexOf ( var_11 + var_3 . charAt ( var_9 ) ) == 0 ) { var_11 += var_3 . charAt ( var_9 ) ; var_9 ++ ; } else { return false ; } } } return true ; } " 401,76. Minimum Window Substring_3.java,"private boolean valid(int[] source, int[] target) { for (int i = 0; i < 256; i++) { if (source[i] < target[i]) return false; } return true; }","private boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { for ( int var_4 = 0 ; var_4 < 256 ; var_4 ++ ) { if ( var_1 [ var_4 ] < var_2 [ var_4 ] ) return false ; } return true ; } " 402,Kth Largest Element in an Array_2.java,"private void swap(int[] nums, int x, int y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 403,151. Reverse Words in a String_3.java,"private String output(char[] arr) { StringBuffer sb = new StringBuffer(); int count = 0; for (char c : arr) { count += c == ' ' ? 1 : 0; if (count != 0 & c != ' ') count = 0; if (count <= 1) sb.append(c); } return sb.toString().trim(); }","private String var_0 ( char [ ] var_1 ) { StringBuffer var_3 = new StringBuffer ( ) ; int var_5 = 0 ; for ( char var_6 : var_1 ) { var_5 += var_6 == ' ' ? 1 : 0 ; if ( var_5 != 0 & var_6 != ' ' ) var_5 = 0 ; if ( var_5 <= 1 ) var_3 . append ( var_6 ) ; } return var_3 . toString ( ) . trim ( ) ; } " 404,875. Koko Eating Bananas_1.java,"private int calc(int[] piles, double k) { int count = 0; for (int i : piles) { count += Math.ceil(i / k); } return count; }","private int sample_funcname ( int [ ] var_0 , double var_1 ) { int var_3 = 0 ; for ( int var_4 : var_0 ) { var_3 += Math . ceil ( var_4 / var_1 ) ; } return var_3 ; } " 405,Bricks Falling When Hit_3.java,"private boolean validate(int[][] grid, int x, int y) { return x >= 0 && x < grid.length && y >= 0 && y < grid[0].length && grid[x][y] == 1; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 >= 0 && var_2 < var_1 . length && var_3 >= 0 && var_3 < var_1 [ 0 ] . length && var_1 [ var_2 ] [ var_3 ] == 1 ; } " 406,Backpack III_4.java,"public int backPackIII(int[] A, int[] V, int m) { if (A == null || V == null || A.length != V.length) { return 0; } int n = A.length; int[][] dp = new int[n + 1][m + 1]; for (int j = 0; j <= m; j++) { dp[0][j] = -1; } dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= m; j++) { for (int k = 0; k * A[i - 1] <= m; k++) { if (j - k * A[i - 1] >= 0 && dp[i - 1][j - k * A[i - 1]] != -1) { dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - k * A[i - 1]] + k * V[i - 1]); } } } } int rst = 0; for (int j = 0; j <= m; j++) { rst = Math.max(rst, dp[n][j]); } return rst; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 , int var_2 ) { if ( var_0 == null || var_1 == null || var_0 . length != var_1 . length ) { return 0 ; } int var_6 = var_0 . length ; int [ ] [ ] var_8 = new int [ var_6 + 1 ] [ var_2 + 1 ] ; for ( int var_9 = 0 ; var_9 <= var_2 ; var_9 ++ ) { var_8 [ 0 ] [ var_9 ] = - 1 ; } var_8 [ 0 ] [ 0 ] = 0 ; for ( int var_10 = 1 ; var_10 <= var_6 ; var_10 ++ ) { for ( int var_9 = 0 ; var_9 <= var_2 ; var_9 ++ ) { for ( int var_11 = 0 ; var_11 * var_0 [ var_10 - 1 ] <= var_2 ; var_11 ++ ) { if ( var_9 - var_11 * var_0 [ var_10 - 1 ] >= 0 && var_8 [ var_10 - 1 ] [ var_9 - var_11 * var_0 [ var_10 - 1 ] ] != - 1 ) { var_8 [ var_10 ] [ var_9 ] = Math . max ( var_8 [ var_10 ] [ var_9 ] , var_8 [ var_10 - 1 ] [ var_9 - var_11 * var_0 [ var_10 - 1 ] ] + var_11 * var_1 [ var_10 - 1 ] ) ; } } } } int var_14 = 0 ; for ( int var_9 = 0 ; var_9 <= var_2 ; var_9 ++ ) { var_14 = Math . max ( var_14 , var_8 [ var_6 ] [ var_9 ] ) ; } return var_14 ; } " 407,K Edit Distance_1.java,"private boolean validate(String word, String target, int k) { if (word.equals(target)) { return true; } if (Math.abs(word.length() - target.length()) > k) { return false; } int m = word.length(); int n = target.length(); int[][] dp = new int[2][n + 1]; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0) { dp[i % 2][j] = j; continue; } if (j == 0) { dp[i % 2][j] = i; continue; } dp[i % 2][j] = Math.min(dp[(i - 1) % 2][j - 1], Math.min(dp[i % 2][j - 1], dp[(i - 1) % 2][j])) + 1; if (word.charAt(i - 1) == target.charAt(j - 1)) { dp[i % 2][j] = Math.min(dp[i % 2][j], dp[(i - 1) % 2][j - 1]); } } } return dp[m % 2][n] <= k; }","private boolean var_0 ( String var_2 , String var_3 , int var_4 ) { if ( var_2 . equals ( var_3 ) ) { return true ; } if ( Math . abs ( var_2 . length ( ) - var_3 . length ( ) ) > var_4 ) { return false ; } int var_9 = var_2 . length ( ) ; int var_10 = var_3 . length ( ) ; int [ ] [ ] var_13 = new int [ 2 ] [ var_10 + 1 ] ; for ( int var_15 = 0 ; var_15 <= var_9 ; var_15 ++ ) { for ( int var_16 = 0 ; var_16 <= var_10 ; var_16 ++ ) { if ( var_15 == 0 ) { var_13 [ var_15 % 2 ] [ var_16 ] = var_16 ; continue ; } if ( var_16 == 0 ) { var_13 [ var_15 % 2 ] [ var_16 ] = var_15 ; continue ; } var_13 [ var_15 % 2 ] [ var_16 ] = Math . min ( var_13 [ ( var_15 - 1 ) % 2 ] [ var_16 - 1 ] , Math . min ( var_13 [ var_15 % 2 ] [ var_16 - 1 ] , var_13 [ ( var_15 - 1 ) % 2 ] [ var_16 ] ) ) + 1 ; if ( var_2 . charAt ( var_15 - 1 ) == var_3 . charAt ( var_16 - 1 ) ) { var_13 [ var_15 % 2 ] [ var_16 ] = Math . min ( var_13 [ var_15 % 2 ] [ var_16 ] , var_13 [ ( var_15 - 1 ) % 2 ] [ var_16 - 1 ] ) ; } } } return var_13 [ var_9 % 2 ] [ var_10 ] <= var_4 ; } " 408,105. Construct Binary Tree from Preorder and Inorder Traversal_1.java,"private Map buildMap(int[] inorder) { Map map = new HashMap<>(); for (int i = 0; i < inorder.length; i++) map.put(inorder[i], i); return map; }","private Map < Integer , Integer > var_1 ( int [ ] var_2 ) { Map < Integer , Integer > var_5 = new HashMap < > ( ) ; for ( int var_7 = 0 ; var_7 < var_2 . length ; var_7 ++ ) var_5 . put ( var_2 [ var_7 ] , var_7 ) ; return var_5 ; } " 409,Encode and Decode Strings_1.java,"public String encode(List strs) { if (strs.size() == 0) { return """"; } StringBuffer sb = new StringBuffer(); for (int i = 0; i < strs.size(); i++) { sb.append(strs.get(i).length() + ""#"" + strs.get(i)); } return sb.toString(); }","public String var_0 ( List < String > var_3 ) { if ( var_3 . size ( ) == 0 ) { return """" ; } StringBuffer var_8 = new StringBuffer ( ) ; for ( int var_9 = 0 ; var_9 < var_3 . size ( ) ; var_9 ++ ) { var_8 . append ( var_3 . get ( var_9 ) . length ( ) + ""#"" + var_3 . get ( var_9 ) ) ; } return var_8 . toString ( ) ; } " 410,Unique Binary Search Tree_2.java,"public int numTrees(int n) { if (n <= 1) { return 1; } int[] count = new int[n + 1]; count[0] = 1; count[1] = 1; for (int i = 2; i < n + 1; i++) { for (int j = 0; j < i; j++) { count[i] += count[j] * count[i - j - 1]; } } return count[n]; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 1 ) { return 1 ; } int [ ] var_2 = new int [ var_0 + 1 ] ; var_2 [ 0 ] = 1 ; var_2 [ 1 ] = 1 ; for ( int var_5 = 2 ; var_5 < var_0 + 1 ; var_5 ++ ) { for ( int var_6 = 0 ; var_6 < var_5 ; var_6 ++ ) { var_2 [ var_5 ] += var_2 [ var_6 ] * var_2 [ var_5 - var_6 - 1 ] ; } } return var_2 [ var_0 ] ; } " 411,[lint]. Unique Characters_1.java,"public boolean isUnique(String str) { if (str == null || str.length() == 0) return true; char[] arr = str.toCharArray(); Arrays.sort(arr); for (int i = 1; i < arr.length; i++) { if (arr[i] == arr[i - 1]) return false; } return true; }","public boolean var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) return true ; char [ ] var_7 = var_2 . toCharArray ( ) ; Arrays . sort ( var_7 ) ; for ( int var_11 = 1 ; var_11 < var_7 . length ; var_11 ++ ) { if ( var_7 [ var_11 ] == var_7 [ var_11 - 1 ] ) return false ; } return true ; } " 412,Walls and Gates_5.java,"private boolean validateCoordinate(int[][] rooms, int x, int y) { return x < 0 || x >= rooms.length || y < 0 || y >= rooms[0].length || rooms[x][y] == -1 || rooms[x][y] == 0; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 < 0 || var_2 >= var_1 . length || var_3 < 0 || var_3 >= var_1 [ 0 ] . length || var_1 [ var_2 ] [ var_3 ] == - 1 || var_1 [ var_2 ] [ var_3 ] == 0 ; } " 413,724. Find Pivot Index_1.java,"public int pivotIndex(int[] nums) { if (nums == null || nums.length == 0) return -1; int n = nums.length; for (int i = 1; i < n; i++) nums[i] += nums[i - 1]; if (nums[n-1] - nums[0] == 0) return 0; for (int i = 1; i < n; i++) { if (nums[i - 1] == nums[n - 1] - nums[i]) return i; } return -1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return - 1 ; int var_5 = var_0 . length ; for ( int var_6 = 1 ; var_6 < var_5 ; var_6 ++ ) var_0 [ var_6 ] += var_0 [ var_6 - 1 ] ; if ( var_0 [ var_5 - 1 ] - var_0 [ 0 ] == 0 ) return 0 ; for ( int var_6 = 1 ; var_6 < var_5 ; var_6 ++ ) { if ( var_0 [ var_6 - 1 ] == var_0 [ var_5 - 1 ] - var_0 [ var_6 ] ) return var_6 ; } return - 1 ; } " 414,Basic Calculator_1.java,"private int getWeight(int base, char c) { if (c == '(') return base + 10; if (c == ')') return base - 10; if (c == '+' || c == '-') return base + 1; if (c == '*' || c == '/') return base + 2; return Integer.MAX_VALUE; }","private int sample_funcname ( int var_0 , char var_1 ) { if ( var_1 == '(' ) return var_0 + 10 ; if ( var_1 == ')' ) return var_0 - 10 ; if ( var_1 == '+' || var_1 == '-' ) return var_0 + 1 ; if ( var_1 == '*' || var_1 == '/' ) return var_0 + 2 ; return Integer . MAX_VALUE ; } " 415,727. Minimum Window Subsequence_1.java,"private int backtrack(char[] ss, char[] tt, int index) { for (int i = tt.length - 1; i >= 0; i--) { while(ss[index--] != tt[i]); } return index + 1; }","private int sample_funcname ( char [ ] var_0 , char [ ] var_1 , int var_2 ) { for ( int var_5 = var_1 . length - 1 ; var_5 >= 0 ; var_5 -- ) { while ( var_0 [ var_2 -- ] != var_1 [ var_5 ] ) ; } return var_2 + 1 ; } " 416,139. Word Break_2.java,"private boolean dfs(Set dict, Set set, String s) { if (dict.contains(s)) return true; StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); sb.append(c); if (dict.contains(sb.toString())) { String sub = s.substring(i + 1); if (set.contains(sub)) continue; if (dfs(dict, set, sub)) return true; set.add(sub); } } return false; }","private boolean sample_funcname ( Set < String > dict , Set < String > set , String s ) { if ( dict . contains ( s ) ) return true ; StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; sb . append ( c ) ; if ( dict . contains ( sb . toString ( ) ) ) { String sub = s . substring ( i + 1 ) ; if ( set . contains ( sub ) ) continue ; if ( dfs ( dict , set , sub ) ) return true ; set . add ( sub ) ; } } return false ; } " 417,57. Insert Interval_3.java,"private int[][] convert(List list) { int[][] rst = new int[list.size()][2]; for (int i = 0; i < list.size(); i++) { rst[i][0] = list.get(i)[0]; rst[i][1] = list.get(i)[1]; } return rst; }","private int [ ] [ ] sample_funcname ( List < int [ ] > var_1 ) { int [ ] [ ] var_4 = new int [ var_1 . size ( ) ] [ 2 ] ; for ( int var_6 = 0 ; var_6 < var_1 . size ( ) ; var_6 ++ ) { var_4 [ var_6 ] [ 0 ] = var_1 . get ( var_6 ) [ 0 ] ; var_4 [ var_6 ] [ 1 ] = var_1 . get ( var_6 ) [ 1 ] ; } return var_4 ; } " 418,Add Digits_1.java,"public int addDigits(int num) { if (num < 10) { return num; } while (num > 9) { int temp = 0; while (num != 0) { temp += num % 10; num = num / 10; } num = temp; } return num; }","public int sample_funcname ( int var_0 ) { if ( var_0 < 10 ) { return var_0 ; } while ( var_0 > 9 ) { int var_4 = 0 ; while ( var_0 != 0 ) { var_4 += var_0 % 10 ; var_0 = var_0 / 10 ; } var_0 = var_4 ; } return var_0 ; } " 419,896. Monotonic Array_1.java,"private boolean validate(int a, int b, boolean incline) { if (incline) return a <= b; return a >= b; }","private boolean var_0 ( int var_1 , int var_2 , boolean var_4 ) { if ( var_4 ) return var_1 <= var_2 ; return var_1 >= var_2 ; } " 420,739. Daily Temperatures_2.java,"public int[] dailyTemperatures(int[] T) { int n = T.length; int[] rst = new int[n]; Integer[] tempIndex = new Integer[101]; for (int i = n - 1; i >= 0; i--) { int num = T[i], warmerIndex = Integer.MAX_VALUE;; for (int t = num + 1; t <= 100; t++) { if (tempIndex[t] != null && tempIndex[t] < warmerIndex) warmerIndex = tempIndex[t]; } if (warmerIndex < Integer.MAX_VALUE) rst[i] = warmerIndex - i; tempIndex[num] = i; } return rst; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; int [ ] var_3 = new int [ var_2 ] ; Integer [ ] var_6 = new Integer [ 101 ] ; for ( int var_8 = var_2 - 1 ; var_8 >= 0 ; var_8 -- ) { int var_10 = var_0 [ var_8 ] , var_12 = Integer . MAX_VALUE ; ; for ( int var_13 = var_10 + 1 ; var_13 <= 100 ; var_13 ++ ) { if ( var_6 [ var_13 ] != null && var_6 [ var_13 ] < var_12 ) var_12 = var_6 [ var_13 ] ; } if ( var_12 < Integer . MAX_VALUE ) var_3 [ var_8 ] = var_12 - var_8 ; var_6 [ var_10 ] = var_8 ; } return var_3 ; } " 421,1021. Remove Outermost Parentheses_1.java,"private boolean isPair(char a, char b) { return a == '(' && b ==')'; }","private boolean var_0 ( char var_1 , char var_2 ) { return var_1 == '(' && var_2 == ')' ; } " 422,Contains Duplicate III_1.java,"public boolean containsNearbyAlmostDuplicate(int[] nums, int k, int t) { if (nums == null || nums.length == 0 || k <= 0 || t < 0) { return false; } TreeSet treeSet = new TreeSet<>(); for (int i = 0; i < nums.length; i++) { Long target = treeSet.ceiling((long)nums[i] - t); if (target != null && target <= (long)nums[i] + t) { return true; } if (i >= k) { treeSet.remove((long)nums[i - k]); } treeSet.add((long)nums[i]); } return false; }","public boolean var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { if ( var_1 == null || var_1 . length == 0 || var_2 <= 0 || var_3 < 0 ) { return false ; } TreeSet < Long > var_9 = new TreeSet < > ( ) ; for ( int var_10 = 0 ; var_10 < var_1 . length ; var_10 ++ ) { Long var_12 = var_9 . ceiling ( ( long ) var_1 [ var_10 ] - var_3 ) ; if ( var_12 != null && var_12 <= ( long ) var_1 [ var_10 ] + var_3 ) { return true ; } if ( var_10 >= var_2 ) { var_9 . remove ( ( long ) var_1 [ var_10 - var_2 ] ) ; } var_9 . add ( ( long ) var_1 [ var_10 ] ) ; } return false ; } " 423,239. Sliding Window Maximum_3.java,"private void inQueue(Deque deque, int num) { while (!deque.isEmpty() && deque.peekLast() < num) { deque.pollLast(); } deque.offerLast(num); }","private void var_0 ( Deque < Integer > var_3 , int var_4 ) { while ( ! var_3 . isEmpty ( ) && var_3 . peekLast ( ) < var_4 ) { var_3 . pollLast ( ) ; } var_3 . offerLast ( var_4 ) ; } " 424,Search Insert Position_1.java,"public int searchInsert(int[] A, int target) { if (A == null || A.length == 0) { return 0; } int start = 0; int end = A.length - 1; int mid = start + (end - start)/2; while (start + 1 < end) { mid = start + (end - start)/2; if (A[mid] == target) { return mid; } else if (A[mid] > target) { end = mid; } else { start = mid; } } if (A[start] >= target) { return start; } else if (A[start] < target && target <= A[end]) { return end; } else { return end + 1; } }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = 0 ; int var_7 = var_0 . length - 1 ; int var_9 = var_5 + ( var_7 - var_5 ) / 2 ; while ( var_5 + 1 < var_7 ) { var_9 = var_5 + ( var_7 - var_5 ) / 2 ; if ( var_0 [ var_9 ] == var_1 ) { return var_9 ; } else if ( var_0 [ var_9 ] > var_1 ) { var_7 = var_9 ; } else { var_5 = var_9 ; } } if ( var_0 [ var_5 ] >= var_1 ) { return var_5 ; } else if ( var_0 [ var_5 ] < var_1 && var_1 <= var_0 [ var_7 ] ) { return var_7 ; } else { return var_7 + 1 ; } } " 425,788. Rotated Digits_1.java,"private int[] freq(int num) { int[] count = new int[10]; while (num != 0) { count[num%10]++; num /= 10; } return count; }","private int [ ] sample_funcname ( int var_0 ) { int [ ] var_2 = new int [ 10 ] ; while ( var_0 != 0 ) { var_2 [ var_0 % 10 ] ++ ; var_0 /= 10 ; } return var_2 ; } " 426,Reverse Words in a String II_2.java,"public void reverseWords(char[] s) { if (s == null || s.length == 0) { return; } int len = s.length; for (int i = 0; i < len / 2; i++) { char temp = s[i]; s[i] = s[len - 1 - i]; s[len - 1 - i] = temp; } int start = 0; int mid = 0; int end = 0; for (int i = 0; i < len; i++) { if (s[i] == ' ') { mid = start + (end - start) / 2; for (int j = start; j <= mid; j++) { char temp = s[j]; s[j] = s[end - (j - start)]; s[end - (j - start)] = temp; } start = i + 1; } else { end = i; } } mid = start + (end - start) / 2; for (int j = start; j <= mid; j++) { char temp = s[j]; s[j] = s[end - (j - start)]; s[end - (j - start)] = temp; } }","public void var_0 ( char [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return ; } int var_5 = var_1 . length ; for ( int var_6 = 0 ; var_6 < var_5 / 2 ; var_6 ++ ) { char var_8 = var_1 [ var_6 ] ; var_1 [ var_6 ] = var_1 [ var_5 - 1 - var_6 ] ; var_1 [ var_5 - 1 - var_6 ] = var_8 ; } int var_10 = 0 ; int var_11 = 0 ; int var_12 = 0 ; for ( int var_6 = 0 ; var_6 < var_5 ; var_6 ++ ) { if ( var_1 [ var_6 ] == ' ' ) { var_11 = var_10 + ( var_12 - var_10 ) / 2 ; for ( int var_14 = var_10 ; var_14 <= var_11 ; var_14 ++ ) { char var_8 = var_1 [ var_14 ] ; var_1 [ var_14 ] = var_1 [ var_12 - ( var_14 - var_10 ) ] ; var_1 [ var_12 - ( var_14 - var_10 ) ] = var_8 ; } var_10 = var_6 + 1 ; } else { var_12 = var_6 ; } } var_11 = var_10 + ( var_12 - var_10 ) / 2 ; for ( int var_14 = var_10 ; var_14 <= var_11 ; var_14 ++ ) { char var_8 = var_1 [ var_14 ] ; var_1 [ var_14 ] = var_1 [ var_12 - ( var_14 - var_10 ) ] ; var_1 [ var_12 - ( var_14 - var_10 ) ] = var_8 ; } } " 427,Largest Number_1.java,"public String largestNumber(int[] num) { if (num == null || num.length == 0) { return """"; } String[] strs = new String[num.length]; for (int i = 0; i < num.length; i++) { strs[i] = num[i] + """"; } Arrays.sort(strs, new Comparator() { public int compare(String s1, String s2) { return (s2 + s1).compareTo(s1 + s2); } }); StringBuffer sb = new StringBuffer(); for (int i = 0; i < num.length; i++) { sb.append(strs[i]); } String rst = sb.toString(); if (rst.charAt(0) == '0') { return ""0""; } return rst; }","public String var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return """" ; } String [ ] var_7 = new String [ var_1 . length ] ; for ( int var_8 = 0 ; var_8 < var_1 . length ; var_8 ++ ) { var_7 [ var_8 ] = var_1 [ var_8 ] + """" ; } Arrays . sort ( var_7 , new Comparator < String > ( ) { public int compare ( String var_13 , String var_14 ) { return ( var_14 + var_13 ) . compareTo ( var_13 + var_14 ) ; } } ) ; StringBuffer var_17 = new StringBuffer ( ) ; for ( int var_8 = 0 ; var_8 < var_1 . length ; var_8 ++ ) { var_17 . append ( var_7 [ var_8 ] ) ; } String var_20 = var_17 . toString ( ) ; if ( var_20 . charAt ( 0 ) == '0' ) { return ""0"" ; } return var_20 ; } " 428,Majority Number III_1.java,"public int majorityNumber(ArrayList nums, int k) { if (nums == null || nums.size() == 0) { return -1; } HashMap map = new HashMap(); for (Integer num : nums) { if (map.containsKey(num)) { map.put(num, map.get(num) + 1); } else { if (map.size() == k) { Iterator> iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = iter.next(); if (entry.getValue() - 1 == 0) { iter.remove(); } else { map.put(entry.getKey(), entry.getValue() - 1); } } } else { map.put(num, 1); } } } int result = 0; int max = 0; for (Map.Entry entry : map.entrySet()) { if (entry.getValue() > max) { max = entry.getValue(); result = entry.getKey(); } } return result; }","public int sample_funcname ( ArrayList < Integer > var_2 , int var_3 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return - 1 ; } HashMap < Integer , Integer > var_9 = new HashMap < Integer , Integer > ( ) ; for ( Integer var_10 : var_2 ) { if ( var_9 . containsKey ( var_10 ) ) { var_9 . put ( var_10 , var_9 . get ( var_10 ) + 1 ) ; } else { if ( var_9 . size ( ) == var_3 ) { Iterator < Map . Entry < Integer , Integer >> var_19 = var_9 . entrySet ( ) . iterator ( ) ; while ( var_19 . hasNext ( ) ) { Map . Entry < Integer , Integer > var_22 = var_19 . next ( ) ; if ( var_22 . getValue ( ) - 1 == 0 ) { var_19 . remove ( ) ; } else { var_9 . put ( var_22 . getKey ( ) , var_22 . getValue ( ) - 1 ) ; } } } else { var_9 . put ( var_10 , 1 ) ; } } } int var_26 = 0 ; int var_27 = 0 ; for ( Map . Entry < Integer , Integer > var_22 : var_9 . entrySet ( ) ) { if ( var_22 . getValue ( ) > var_27 ) { var_27 = var_22 . getValue ( ) ; var_26 = var_22 . getKey ( ) ; } } return var_26 ; } " 429,Number Of Corner Rectangles_1.java,"private boolean validate(int[][] grid) { return grid == null || grid.length == 0 || grid[0] == null || grid[0].length == 0; }","private boolean var_0 ( int [ ] [ ] var_1 ) { return var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 ; } " 430,Subarray Sum Closest_1.java,"public int compare(int[] a, int[] b) { return Integer.compare(a[0], b[0]); }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { return Integer . compare ( var_0 [ 0 ] , var_1 [ 0 ] ) ; } " 431,Distinct Subsequences_1.java,"public int numDistinct(String s, String t) { if (s == null || t == null || t.length() > s.length()) { return 0; } else if (s.equals(t)) { return 1; } int m = s.length(); int n = t.length(); int[][] dp = new int[m + 1][n + 1]; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (j == 0) { dp[i][j] = 1; continue; } if (i == 0) { dp[i][j] = 0; continue; } dp[i][j] = dp[i - 1][j]; if (s.charAt(i - 1) == t.charAt(j - 1)) { dp[i][j] += dp[i - 1][j - 1]; } } } return dp[m][n]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_2 . length ( ) > var_1 . length ( ) ) { return 0 ; } else if ( var_1 . equals ( var_2 ) ) { return 1 ; } int var_8 = var_1 . length ( ) ; int var_9 = var_2 . length ( ) ; int [ ] [ ] var_10 = new int [ var_8 + 1 ] [ var_9 + 1 ] ; for ( int var_11 = 0 ; var_11 <= var_8 ; var_11 ++ ) { for ( int var_12 = 0 ; var_12 <= var_9 ; var_12 ++ ) { if ( var_12 == 0 ) { var_10 [ var_11 ] [ var_12 ] = 1 ; continue ; } if ( var_11 == 0 ) { var_10 [ var_11 ] [ var_12 ] = 0 ; continue ; } var_10 [ var_11 ] [ var_12 ] = var_10 [ var_11 - 1 ] [ var_12 ] ; if ( var_1 . charAt ( var_11 - 1 ) == var_2 . charAt ( var_12 - 1 ) ) { var_10 [ var_11 ] [ var_12 ] += var_10 [ var_11 - 1 ] [ var_12 - 1 ] ; } } } return var_10 [ var_8 ] [ var_9 ] ; } " 432,140. Word Break II_1.java,"private String output(List list) { StringBuffer sb = new StringBuffer(); for (String s : list) sb.append(s).append("" ""); return sb.toString().trim(); }","private String var_0 ( List < String > var_3 ) { StringBuffer var_5 = new StringBuffer ( ) ; for ( String var_6 : var_3 ) var_5 . append ( var_6 ) . append ( "" "" ) ; return var_5 . toString ( ) . trim ( ) ; } " 433,689. Maximum Sum of 3 Non-Overlapping Subarrays_1.java,"private int[] calcLeft(int[] nums, int[] presum, int k) { int n = nums.length; int[] left = new int[n]; for (int i = k, total = presum[k] - presum[0]; i < n; i++) { int sum = presum[i + 1] - presum[i + 1 - k]; if (sum > total) { left[i] = i + 1 - k; total = sum; } else left[i] = left[i - 1]; } return left; }","private int [ ] sample_funcname ( int [ ] var_0 , int [ ] var_1 , int var_2 ) { int var_4 = var_0 . length ; int [ ] var_5 = new int [ var_4 ] ; for ( int var_6 = var_2 , var_8 = var_1 [ var_2 ] - var_1 [ 0 ] ; var_6 < var_4 ; var_6 ++ ) { int var_10 = var_1 [ var_6 + 1 ] - var_1 [ var_6 + 1 - var_2 ] ; if ( var_10 > var_8 ) { var_5 [ var_6 ] = var_6 + 1 - var_2 ; var_8 = var_10 ; } else var_5 [ var_6 ] = var_5 [ var_6 - 1 ] ; } return var_5 ; } " 434,Counting Bits_2.java,"public int[] countBits(int num) { if (num < 0) { return null; } int[] dp = new int[num + 1]; dp[0] = 0; for (int i = 1; i <= num; i++) { int prevNum = i >> 1; dp[i] = dp[prevNum] + (i & 1); } return dp; }","public int [ ] sample_funcname ( int var_0 ) { if ( var_0 < 0 ) { return null ; } int [ ] var_4 = new int [ var_0 + 1 ] ; var_4 [ 0 ] = 0 ; for ( int var_5 = 1 ; var_5 <= var_0 ; var_5 ++ ) { int var_6 = var_5 >> 1 ; var_4 [ var_5 ] = var_4 [ var_6 ] + ( var_5 & 1 ) ; } return var_4 ; } " 435,301. Remove Invalid Parentheses_1.java,"private void dfs(List rst, String s, int i, int j, char open, char close) { for (int count = 0; i < s.length(); i++) { count += s.charAt(i) == open ? 1 : 0; count -= s.charAt(i) == close ? 1 : 0; if (count < 0) { int init = j; for (; j <= i; j++) { if (s.charAt(j) == close && (j == init || s.charAt(j) != s.charAt(j - 1))) { dfs(rst, s.substring(0, j) + s.substring(j + 1), i, j, open, close); } } return; } } String reversed = new StringBuffer(s).reverse().toString(); if (open == '(') { dfs(rst, reversed, 0, 0, close, open); } else { rst.add(reversed); } }","private void sample_funcname ( List < String > rst , String s , int i , int j , char open , char close ) { for ( int count = 0 ; i < s . length ( ) ; i ++ ) { count += s . charAt ( i ) == open ? 1 : 0 ; count -= s . charAt ( i ) == close ? 1 : 0 ; if ( count < 0 ) { int init = j ; for ( ; j <= i ; j ++ ) { if ( s . charAt ( j ) == close && ( j == init || s . charAt ( j ) != s . charAt ( j - 1 ) ) ) { dfs ( rst , s . substring ( 0 , j ) + s . substring ( j + 1 ) , i , j , open , close ) ; } } return ; } } String reversed = new StringBuffer ( s ) . reverse ( ) . toString ( ) ; if ( open == '(' ) { dfs ( rst , reversed , 0 , 0 , close , open ) ; } else { rst . add ( reversed ) ; } } " 436,43. Multiply Strings_4.java,"private int toInt(String s, int x) { return s.charAt(x) - '0'; }","private int sample_funcname ( String var_1 , int var_2 ) { return var_1 . charAt ( var_2 ) - '0' ; } " 437,Coins in a Line_1.java,"public boolean firstWillWin(int n) { if (n <= 0) { return false; } boolean[] dp = new boolean[n + 1]; dp[0] = false; dp[1] = true; for (int i = 2; i <= n; i++) { dp[i] = !dp[i - 2] || !dp[i - 1]; } return dp[n]; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 0 ) { return false ; } boolean [ ] var_5 = new boolean [ var_1 + 1 ] ; var_5 [ 0 ] = false ; var_5 [ 1 ] = true ; for ( int var_7 = 2 ; var_7 <= var_1 ; var_7 ++ ) { var_5 [ var_7 ] = ! var_5 [ var_7 - 2 ] || ! var_5 [ var_7 - 1 ] ; } return var_5 [ var_1 ] ; } " 438,785. Is Graph Bipartite_2.java,"public boolean isBipartite(int[][] graph) { int n = graph.length; Boolean[] states = new Boolean[n]; for (int i = 0; i < n; i++) { if (states[i] != null) continue; Queue queue = new LinkedList(); queue.offer(i); states[i] = true; while (!queue.isEmpty()) { int curr = queue.poll(); for (int next : graph[curr]) { if (states[next] != null) { if (states[next] == states[curr]) return false; continue; } states[next] = !states[curr]; queue.offer(next); } } } return true; }","public boolean var_0 ( int [ ] [ ] var_1 ) { int var_3 = var_1 . length ; Boolean [ ] var_5 = new Boolean [ var_3 ] ; for ( int var_7 = 0 ; var_7 < var_3 ; var_7 ++ ) { if ( var_5 [ var_7 ] != null ) continue ; Queue < Integer > var_12 = new LinkedList < Integer > ( ) ; var_12 . offer ( var_7 ) ; var_5 [ var_7 ] = true ; while ( ! var_12 . isEmpty ( ) ) { int var_16 = var_12 . poll ( ) ; for ( int var_17 : var_1 [ var_16 ] ) { if ( var_5 [ var_17 ] != null ) { if ( var_5 [ var_17 ] == var_5 [ var_16 ] ) return false ; continue ; } var_5 [ var_17 ] = ! var_5 [ var_16 ] ; var_12 . offer ( var_17 ) ; } } } return true ; } " 439,Trapping Rain Water II_3.java,"public int trapRainWater(int[][] heightMap) { if (heightMap == null || heightMap.length == 0 || heightMap[0] == null || heightMap[0].length == 0) { return 0; } int m = heightMap.length; int n = heightMap[0].length; int[][] maxLeft = new int[m][n]; int[][] maxRight = new int[m][n]; int[][] maxUp = new int[m][n]; int[][] maxDown = new int[m][n]; for (int i = 0; i < m; i++) { maxLeft[i][0] = heightMap[i][0]; maxRight[i][n - 1] = heightMap[i][n - 1]; } for (int j = 0; j < n; j++) { maxUp[0][j] = heightMap[0][j]; maxDown[m - 1][j] = heightMap[m - 1][j]; } for (int i = 0; i < m; i++) { for (int j = 1; j < n; j++) { maxLeft[i][j] = Math.max(maxLeft[i][j - 1], heightMap[i][j]); maxRight[i][n - j - 1] = Math.max(maxRight[i][n - j], heightMap[i][n - j - 1]); } } for (int j = 0; j < n; j++) { for (int i = 1; i < m; i++) { maxUp[i][j] = Math.max(maxUp[i - 1][j], heightMap[i][j]); maxDown[m - i - 1][j] = Math.max(maxDown[m - i][j], heightMap[m - i - 1][j]); } } int total = 0; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { int lowestHeight = Math.min(Math.min(maxLeft[i][j], maxRight[i][j]), Math.min(maxUp[i][j], maxDown[i][j])); total += lowestHeight > heightMap[i][j] ? lowestHeight - heightMap[i][j] : 0; } } return total; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_6 = new int [ var_4 ] [ var_5 ] ; int [ ] [ ] var_7 = new int [ var_4 ] [ var_5 ] ; int [ ] [ ] var_8 = new int [ var_4 ] [ var_5 ] ; int [ ] [ ] var_9 = new int [ var_4 ] [ var_5 ] ; for ( int var_10 = 0 ; var_10 < var_4 ; var_10 ++ ) { var_6 [ var_10 ] [ 0 ] = var_0 [ var_10 ] [ 0 ] ; var_7 [ var_10 ] [ var_5 - 1 ] = var_0 [ var_10 ] [ var_5 - 1 ] ; } for ( int var_12 = 0 ; var_12 < var_5 ; var_12 ++ ) { var_8 [ 0 ] [ var_12 ] = var_0 [ 0 ] [ var_12 ] ; var_9 [ var_4 - 1 ] [ var_12 ] = var_0 [ var_4 - 1 ] [ var_12 ] ; } for ( int var_10 = 0 ; var_10 < var_4 ; var_10 ++ ) { for ( int var_12 = 1 ; var_12 < var_5 ; var_12 ++ ) { var_6 [ var_10 ] [ var_12 ] = Math . max ( var_6 [ var_10 ] [ var_12 - 1 ] , var_0 [ var_10 ] [ var_12 ] ) ; var_7 [ var_10 ] [ var_5 - var_12 - 1 ] = Math . max ( var_7 [ var_10 ] [ var_5 - var_12 ] , var_0 [ var_10 ] [ var_5 - var_12 - 1 ] ) ; } } for ( int var_12 = 0 ; var_12 < var_5 ; var_12 ++ ) { for ( int var_10 = 1 ; var_10 < var_4 ; var_10 ++ ) { var_8 [ var_10 ] [ var_12 ] = Math . max ( var_8 [ var_10 - 1 ] [ var_12 ] , var_0 [ var_10 ] [ var_12 ] ) ; var_9 [ var_4 - var_10 - 1 ] [ var_12 ] = Math . max ( var_9 [ var_4 - var_10 ] [ var_12 ] , var_0 [ var_4 - var_10 - 1 ] [ var_12 ] ) ; } } int var_15 = 0 ; for ( int var_10 = 0 ; var_10 < var_4 ; var_10 ++ ) { for ( int var_12 = 0 ; var_12 < var_5 ; var_12 ++ ) { int var_17 = Math . min ( Math . min ( var_6 [ var_10 ] [ var_12 ] , var_7 [ var_10 ] [ var_12 ] ) , Math . min ( var_8 [ var_10 ] [ var_12 ] , var_9 [ var_10 ] [ var_12 ] ) ) ; var_15 += var_17 > var_0 [ var_10 ] [ var_12 ] ? var_17 - var_0 [ var_10 ] [ var_12 ] : 0 ; } } return var_15 ; } " 440,Permutation Index_1.java,"public long permutationIndex(int[] A) { if (A == null || A.length == 0) { return 0; } HashMap map = new HashMap(); int n = A.length; long rst = 0; for (int i = 0; i < n; i++) { int count = 0; for (int j = i + 1; j < n; j++) { if (A[j] < A[i]) { count++; } } map.put(A[i], count); } for (int i = 0; i < n; i++) { long fact = 1; for (int j = (n - i - 1); j >= 1; j--) { fact *= j; } rst += map.get(A[i]) * fact; } return rst + 1; }","public long sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } HashMap < Integer , Integer > var_6 = new HashMap < Integer , Integer > ( ) ; int var_7 = var_0 . length ; long var_8 = 0 ; for ( int var_9 = 0 ; var_9 < var_7 ; var_9 ++ ) { int var_10 = 0 ; for ( int var_12 = var_9 + 1 ; var_12 < var_7 ; var_12 ++ ) { if ( var_0 [ var_12 ] < var_0 [ var_9 ] ) { var_10 ++ ; } } var_6 . put ( var_0 [ var_9 ] , var_10 ) ; } for ( int var_9 = 0 ; var_9 < var_7 ; var_9 ++ ) { long var_14 = 1 ; for ( int var_12 = ( var_7 - var_9 - 1 ) ; var_12 >= 1 ; var_12 -- ) { var_14 *= var_12 ; } var_8 += var_6 . get ( var_0 [ var_9 ] ) * var_14 ; } return var_8 + 1 ; } " 441,1108. Defanging an IP Address_1.java,"public String defangIPaddr(String address) { StringBuffer sb = new StringBuffer(); for (char c : address.toCharArray()) { if (c == '.') { sb.append(""[.]""); } else { sb.append(c); } } return sb.toString(); }","public String var_0 ( String var_2 ) { StringBuffer var_4 = new StringBuffer ( ) ; for ( char var_6 : var_2 . toCharArray ( ) ) { if ( var_6 == '.' ) { var_4 . append ( ""[.]"" ) ; } else { var_4 . append ( var_6 ) ; } } return var_4 . toString ( ) ; } " 442,Trapping Rain Water II_2.java,"private boolean isInvalid(int[][] heightMap) { return heightMap == null || heightMap.length == 0 || heightMap[0] == null || heightMap[0].length == 0; }","private boolean var_0 ( int [ ] [ ] var_1 ) { return var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 ; } " 443,63. Unique Paths II_1.java,"public int uniquePathsWithObstacles(int[][] obstacleGrid) { if (obstacleGrid == null || obstacleGrid.length == 0) return 0; int m = obstacleGrid.length, n = obstacleGrid[0].length; int[][] dp = new int[m][n]; for (int i = 0, j = 0; j < n; j++) { if (obstacleGrid[i][j] == 1) break; dp[i][j] = 1; } for (int i = 0, j = 0; i < m; i++) { if (obstacleGrid[i][j] == 1) break; dp[i][j] = 1; } for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { if (obstacleGrid[i][j] == 1) continue; dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; } } return dp[m - 1][n - 1]; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_6 = new int [ var_4 ] [ var_5 ] ; for ( int var_7 = 0 , var_8 = 0 ; var_8 < var_5 ; var_8 ++ ) { if ( var_0 [ var_7 ] [ var_8 ] == 1 ) break ; var_6 [ var_7 ] [ var_8 ] = 1 ; } for ( int var_7 = 0 , var_8 = 0 ; var_7 < var_4 ; var_7 ++ ) { if ( var_0 [ var_7 ] [ var_8 ] == 1 ) break ; var_6 [ var_7 ] [ var_8 ] = 1 ; } for ( int var_7 = 1 ; var_7 < var_4 ; var_7 ++ ) { for ( int var_8 = 1 ; var_8 < var_5 ; var_8 ++ ) { if ( var_0 [ var_7 ] [ var_8 ] == 1 ) continue ; var_6 [ var_7 ] [ var_8 ] = var_6 [ var_7 - 1 ] [ var_8 ] + var_6 [ var_7 ] [ var_8 - 1 ] ; } } return var_6 [ var_4 - 1 ] [ var_5 - 1 ] ; } " 444,322. Coin Change_1.java,"public int coinChange(int[] coins, int amount) { int[] dp = new int[amount + 1]; dp[0] = 0; for (int i = 1; i <= amount; i++) { dp[i] = Integer.MAX_VALUE; for (int coin : coins) { if (coin > i || dp[i - coin] == Integer.MAX_VALUE) continue; dp[i] = Math.min(dp[i], dp[i - coin] + 1); } } return dp[amount] == Integer.MAX_VALUE ? -1 : dp[amount]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { int [ ] var_3 = new int [ var_1 + 1 ] ; var_3 [ 0 ] = 0 ; for ( int var_5 = 1 ; var_5 <= var_1 ; var_5 ++ ) { var_3 [ var_5 ] = Integer . MAX_VALUE ; for ( int var_8 : var_0 ) { if ( var_8 > var_5 || var_3 [ var_5 - var_8 ] == Integer . MAX_VALUE ) continue ; var_3 [ var_5 ] = Math . min ( var_3 [ var_5 ] , var_3 [ var_5 - var_8 ] + 1 ) ; } } return var_3 [ var_1 ] == Integer . MAX_VALUE ? - 1 : var_3 [ var_1 ] ; } " 445,Word Ladder II_2.java,"public ArrayList expand(String str, Set dict) { ArrayList list = new ArrayList(); for (int i = 0; i < str.length(); i++) { for (int j = 0; j < 26; j++) { if (str.charAt(i) != (char)('a' + j)) { String newStr = str.substring(0, i) + (char)('a' + j) + str.substring(i + 1); if (dict.contains(newStr)) { list.add(newStr); } } } } return list; }","public ArrayList < String > var_1 ( String var_2 , Set < String > var_4 ) { ArrayList < String > var_6 = new ArrayList < String > ( ) ; for ( int var_8 = 0 ; var_8 < var_2 . length ( ) ; var_8 ++ ) { for ( int var_10 = 0 ; var_10 < 26 ; var_10 ++ ) { if ( var_2 . charAt ( var_8 ) != ( char ) ( 'a' + var_10 ) ) { String var_16 = var_2 . substring ( 0 , var_8 ) + ( char ) ( 'a' + var_10 ) + var_2 . substring ( var_8 + 1 ) ; if ( var_4 . contains ( var_16 ) ) { var_6 . add ( var_16 ) ; } } } } return var_6 ; } " 446,245. Shortest Word Distance III_2.java,"public int shortestWordDistance(String[] words, String word1, String word2) { Map> map = new HashMap<>(); for (int i = 0; i < words.length; i++) { map.putIfAbsent(words[i], new ArrayList<>()); map.get(words[i]).add(i); } List list1 = map.get(word1), list2 = map.get(word2); int min = Integer.MAX_VALUE; int i = 0, j = 0, m = list1.size(), n = list2.size(); while (i < m && j < n) { int p1 = list1.get(i), p2 = list2.get(j); if (p1 == p2) { if (i + 1 < m) i++; else if (j + 1 <= n) j++; continue; } min = Math.min(min, Math.abs(p1 - p2)); if (p1 < p2) i++; else j++; } return min; }","public int sample_funcname ( String [ ] var_1 , String var_2 , String var_3 ) { Map < String , List < Integer >> var_8 = new HashMap < > ( ) ; for ( int var_10 = 0 ; var_10 < var_1 . length ; var_10 ++ ) { var_8 . putIfAbsent ( var_1 [ var_10 ] , new ArrayList < > ( ) ) ; var_8 . get ( var_1 [ var_10 ] ) . add ( var_10 ) ; } List < Integer > var_16 = var_8 . get ( var_2 ) , var_17 = var_8 . get ( var_3 ) ; int min = Integer . MAX_VALUE ; int var_10 = 0 , var_20 = 0 , var_22 = var_16 . size ( ) , var_23 = var_17 . size ( ) ; while ( var_10 < var_22 && var_20 < var_23 ) { int var_24 = var_16 . get ( var_10 ) , var_25 = var_17 . get ( var_20 ) ; if ( var_24 == var_25 ) { if ( var_10 + 1 < var_22 ) var_10 ++ ; else if ( var_20 + 1 <= var_23 ) var_20 ++ ; continue ; } min = Math . min ( min , Math . abs ( var_24 - var_25 ) ) ; if ( var_24 < var_25 ) var_10 ++ ; else var_20 ++ ; } return min ; } " 447,43. Multiply Strings_5.java,"public String multiply(String num1, String num2) { if (num1 == null || num2 == null) { return """"; } else if (num1.length() == 0 || num2.length() == 0) { return num1.length() == 0 ? num2 : num1; } else if (num1.equals(""0"") || num2.equals(""0"")) { return ""0""; } num1 = new StringBuffer(num1).reverse().toString(); num2 = new StringBuffer(num2).reverse().toString(); int[] product = new int[num1.length() + num2.length()]; for (int i = 0; i < num1.length(); i++) { int a = num1.charAt(i) - '0'; for (int j = 0; j < num2.length(); j++) { int b = num2.charAt(j) - '0'; product[i + j] += a * b; } } StringBuffer sb = new StringBuffer(); for (int i = 0; i < product.length; i++) { int number = product[i] % 10; int carrier = product[i] / 10; sb.append(number); if (i < product.length - 1) { product[i + 1] += carrier; } } sb.reverse(); while (sb.length() > 0 && sb.charAt(0) == '0') { sb.deleteCharAt(0); } return sb.toString(); }","public String var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null ) { return """" ; } else if ( var_2 . length ( ) == 0 || var_3 . length ( ) == 0 ) { return var_2 . length ( ) == 0 ? var_3 : var_2 ; } else if ( var_2 . equals ( ""0"" ) || var_3 . equals ( ""0"" ) ) { return ""0"" ; } var_2 = new StringBuffer ( var_2 ) . reverse ( ) . toString ( ) ; var_3 = new StringBuffer ( var_3 ) . reverse ( ) . toString ( ) ; int [ ] var_13 = new int [ var_2 . length ( ) + var_3 . length ( ) ] ; for ( int var_14 = 0 ; var_14 < var_2 . length ( ) ; var_14 ++ ) { int var_17 = var_2 . charAt ( var_14 ) - '0' ; for ( int var_18 = 0 ; var_18 < var_3 . length ( ) ; var_18 ++ ) { int var_19 = var_3 . charAt ( var_18 ) - '0' ; var_13 [ var_14 + var_18 ] += var_17 * var_19 ; } } StringBuffer var_20 = new StringBuffer ( ) ; for ( int var_14 = 0 ; var_14 < var_13 . length ; var_14 ++ ) { int var_22 = var_13 [ var_14 ] % 10 ; int var_23 = var_13 [ var_14 ] / 10 ; var_20 . append ( var_22 ) ; if ( var_14 < var_13 . length - 1 ) { var_13 [ var_14 + 1 ] += var_23 ; } } var_20 . reverse ( ) ; while ( var_20 . length ( ) > 0 && var_20 . charAt ( 0 ) == '0' ) { var_20 . deleteCharAt ( 0 ) ; } return var_20 . toString ( ) ; } " 448,373. Find K Pairs with Smallest Sums_2.java,"private PriorityQueue> initQueue(int k) { return new PriorityQueue<>(k, new Comparator>() { public int compare(List a, List b) { return b.get(0) + b.get(1) - a.get(0) - a.get(1); } }); }","private PriorityQueue < List < Integer >> var_2 ( int var_3 ) { return new PriorityQueue < > ( var_3 , new Comparator < List < Integer >> ( ) { public int compare ( List < Integer > var_7 , List < Integer > var_8 ) { return var_8 . get ( 0 ) + var_8 . get ( 1 ) - var_7 . get ( 0 ) - var_7 . get ( 1 ) ; } } ) ; } " 449,34. Find First and Last Position of Element in Sorted Array_2.java,"private int binarySearch(int[] nums, int target, boolean isLeft) { int n = nums.length, start = 0, end = n - 1; while (start + 1 < end) { int mid = start + (end - start) / 2, val = nums[mid]; if (val == target) { if (isLeft && mid - 1 >= 0 && nums[mid - 1] == target) end = mid; else if (!isLeft && mid + 1 <= n - 1 && nums[mid + 1] == target) start = mid; else return mid; } else if (val < target) start = mid; else end = mid; } if (nums[start] == target && nums[end] == target) return isLeft ? start : end; if (nums[start] == target) return start; if (nums[end] == target) return end; return -1; }","private int sample_funcname ( int [ ] var_0 , int var_1 , boolean var_3 ) { int var_5 = var_0 . length , var_7 = 0 , var_9 = var_5 - 1 ; while ( var_7 + 1 < var_9 ) { int var_11 = var_7 + ( var_9 - var_7 ) / 2 , var_12 = var_0 [ var_11 ] ; if ( var_12 == var_1 ) { if ( var_3 && var_11 - 1 >= 0 && var_0 [ var_11 - 1 ] == var_1 ) var_9 = var_11 ; else if ( ! var_3 && var_11 + 1 <= var_5 - 1 && var_0 [ var_11 + 1 ] == var_1 ) var_7 = var_11 ; else return var_11 ; } else if ( var_12 < var_1 ) var_7 = var_11 ; else var_9 = var_11 ; } if ( var_0 [ var_7 ] == var_1 && var_0 [ var_9 ] == var_1 ) return var_3 ? var_7 : var_9 ; if ( var_0 [ var_7 ] == var_1 ) return var_7 ; if ( var_0 [ var_9 ] == var_1 ) return var_9 ; return - 1 ; } " 450,49. Group Anagrams_1.java,"private String getKey(String s) { int[] count = new int[26]; for (char c : s.toCharArray()) count[c - 'a']++; StringBuilder sb = new StringBuilder(); for (int i = 0; i < 26; i++) sb.append(count[i]); return sb.toString(); }","private String var_0 ( String var_2 ) { int [ ] var_4 = new int [ 26 ] ; for ( char var_6 : var_2 . toCharArray ( ) ) var_4 [ var_6 - 'a' ] ++ ; StringBuilder var_9 = new StringBuilder ( ) ; for ( int var_11 = 0 ; var_11 < 26 ; var_11 ++ ) var_9 . append ( var_4 [ var_11 ] ) ; return var_9 . toString ( ) ; } " 451,516. Longest Palindromic Subsequence_2.java,"public int longestPalindromeSubseq(String s) { char[] ss = s.toCharArray(); int n = s.length(); int[][] dp = new int[n][n]; for (int i = 0; i < n; i++) dp[i][i] = 1; for (int i = 0; i < n - 1; i++) dp[i][i + 1] = ss[i] == ss[i + 1] ? 2 : 1; for (int len = 3; len <= n; len++) { for (int i = 0; i <= n - len; i++) { int j = len + i - 1; dp[i][j] = Math.max(dp[i + 1][j], dp[i][j - 1]); if (ss[i] == ss[j]) dp[i][j] = Math.max(dp[i][j], dp[i + 1][j - 1] + 2); } } return dp[0][n - 1]; }","public int sample_funcname ( String var_1 ) { char [ ] var_3 = var_1 . toCharArray ( ) ; int var_5 = var_1 . length ( ) ; int [ ] [ ] var_6 = new int [ var_5 ] [ var_5 ] ; for ( int var_8 = 0 ; var_8 < var_5 ; var_8 ++ ) var_6 [ var_8 ] [ var_8 ] = 1 ; for ( int var_8 = 0 ; var_8 < var_5 - 1 ; var_8 ++ ) var_6 [ var_8 ] [ var_8 + 1 ] = var_3 [ var_8 ] == var_3 [ var_8 + 1 ] ? 2 : 1 ; for ( int var_12 = 3 ; var_12 <= var_5 ; var_12 ++ ) { for ( int var_8 = 0 ; var_8 <= var_5 - var_12 ; var_8 ++ ) { int var_13 = var_12 + var_8 - 1 ; var_6 [ var_8 ] [ var_13 ] = Math . max ( var_6 [ var_8 + 1 ] [ var_13 ] , var_6 [ var_8 ] [ var_13 - 1 ] ) ; if ( var_3 [ var_8 ] == var_3 [ var_13 ] ) var_6 [ var_8 ] [ var_13 ] = Math . max ( var_6 [ var_8 ] [ var_13 ] , var_6 [ var_8 + 1 ] [ var_13 - 1 ] + 2 ) ; } } return var_6 [ 0 ] [ var_5 - 1 ] ; } " 452,239. Sliding Window Maximum_2.java,"private void outQueue(Deque deque, int num) { if (deque.peekFirst() == num) deque.pollFirst(); }","private void var_0 ( Deque < Integer > var_3 , int var_4 ) { if ( var_3 . peekFirst ( ) == var_4 ) var_3 . pollFirst ( ) ; } " 453,414. Third Maximum Number_1.java,"public int thirdMax(int[] nums) { PriorityQueue pq = new PriorityQueue<>(); for (int num : nums) { if (!pq.contains(num)) { pq.offer(num); if (pq.size() > 3) pq.poll(); } } if (pq.size() < 3) { while (pq.size() > 1) pq.poll(); } return pq.peek(); }","public int sample_funcname ( int [ ] var_0 ) { PriorityQueue < Integer > var_3 = new PriorityQueue < > ( ) ; for ( int var_4 : var_0 ) { if ( ! var_3 . contains ( var_4 ) ) { var_3 . offer ( var_4 ) ; if ( var_3 . size ( ) > 3 ) var_3 . poll ( ) ; } } if ( var_3 . size ( ) < 3 ) { while ( var_3 . size ( ) > 1 ) var_3 . poll ( ) ; } return var_3 . peek ( ) ; } " 454,Total Occurrence of Target_1.java,"public int totalOccurrence(int[] A, int target) { if (A == null || A.length == 0) { return 0; } int start = 0; int end = A.length - 1; int mid = start + (end - start)/2; int first = 0; int last = 0; while (start + 1 < end){ mid = start + (end - start)/2; if (A[mid] == target) { if (mid - 1 >= 0 && A[mid - 1] == target) { end = mid; } else { break; } } else if (A[mid] < target) { start = mid; } else { end = mid; } } if (A[start] == target) { first = start; } else if (A[mid] == target){ first = mid; } else if (A[end] == target){ first = end; } else { return 0; } if (mid + 1 < A.length && A[mid + 1] != target) { return 1; } start = first; last = start + 1; end = A.length - 1; while (start + 1 < end){ mid = start + (end - start)/2; if (A[mid] == target) { if (mid + 1 < A.length && A[mid + 1] == target) { start = mid; } else { break; } } else if (A[mid] < target) { start = mid; } else { end = mid; } } if (A[end] == target) { last = end; } else if (A[mid] == target){ last = mid; } else if (A[start] == target) { last = start; } return last - first + 1; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = 0 ; int var_7 = var_0 . length - 1 ; int var_9 = var_5 + ( var_7 - var_5 ) / 2 ; int var_10 = 0 ; int var_11 = 0 ; while ( var_5 + 1 < var_7 ) { var_9 = var_5 + ( var_7 - var_5 ) / 2 ; if ( var_0 [ var_9 ] == var_1 ) { if ( var_9 - 1 >= 0 && var_0 [ var_9 - 1 ] == var_1 ) { var_7 = var_9 ; } else { break ; } } else if ( var_0 [ var_9 ] < var_1 ) { var_5 = var_9 ; } else { var_7 = var_9 ; } } if ( var_0 [ var_5 ] == var_1 ) { var_10 = var_5 ; } else if ( var_0 [ var_9 ] == var_1 ) { var_10 = var_9 ; } else if ( var_0 [ var_7 ] == var_1 ) { var_10 = var_7 ; } else { return 0 ; } if ( var_9 + 1 < var_0 . length && var_0 [ var_9 + 1 ] != var_1 ) { return 1 ; } var_5 = var_10 ; var_11 = var_5 + 1 ; var_7 = var_0 . length - 1 ; while ( var_5 + 1 < var_7 ) { var_9 = var_5 + ( var_7 - var_5 ) / 2 ; if ( var_0 [ var_9 ] == var_1 ) { if ( var_9 + 1 < var_0 . length && var_0 [ var_9 + 1 ] == var_1 ) { var_5 = var_9 ; } else { break ; } } else if ( var_0 [ var_9 ] < var_1 ) { var_5 = var_9 ; } else { var_7 = var_9 ; } } if ( var_0 [ var_7 ] == var_1 ) { var_11 = var_7 ; } else if ( var_0 [ var_9 ] == var_1 ) { var_11 = var_9 ; } else if ( var_0 [ var_5 ] == var_1 ) { var_11 = var_5 ; } return var_11 - var_10 + 1 ; } " 455,Binary Gap_1.java,"public int binaryGap(int N) { if (N <= 0) return 0; int max = 0, start = -1, end = 0; while (N > 0) { if ((N & 1) == 1) { if (start == -1) start = end; else { max = Math.max(max, end - start); start = end; } } end++; N = N >> 1; } return max; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 0 ) return 0 ; int max = 0 , var_4 = - 1 , var_5 = 0 ; while ( var_0 > 0 ) { if ( ( var_0 & 1 ) == 1 ) { if ( var_4 == - 1 ) var_4 = var_5 ; else { max = Math . max ( max , var_5 - var_4 ) ; var_4 = var_5 ; } } var_5 ++ ; var_0 = var_0 >> 1 ; } return max ; } " 456,Space Replacement_1.java,"public int replaceBlank(char[] string, int length) { if (string == null || string.length == 0) { return 0; } int count = 0; for (char c : string) { if (c == ' ') { count += 2; } } int lastIndex = length + count - 1; for (int i = length - 1; i >= 0; i--) { if (string[i] == ' ') { string[lastIndex--] = '0'; string[lastIndex--] = '2'; string[lastIndex--] = '%'; } else { string[lastIndex--] = string[i]; } } return length + count; }","public int sample_funcname ( char [ ] var_0 , int length ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = 0 ; for ( char var_5 : var_0 ) { if ( var_5 == ' ' ) { var_4 += 2 ; } } int var_9 = length + var_4 - 1 ; for ( int var_10 = length - 1 ; var_10 >= 0 ; var_10 -- ) { if ( var_0 [ var_10 ] == ' ' ) { var_0 [ var_9 -- ] = '0' ; var_0 [ var_9 -- ] = '2' ; var_0 [ var_9 -- ] = '%' ; } else { var_0 [ var_9 -- ] = var_0 [ var_10 ] ; } } return length + var_4 ; } " 457,274.H-Index_4.java,"public int hIndex(int[] citations) { if (citations == null || citations.length == 0) { return 0; } int n = citations.length; Arrays.sort(citations); for (int i = 0; i < n; i++) { int h = n - i; if (citations[i] >= h) { return h; } } return 0; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; Arrays . sort ( var_0 ) ; for ( int var_7 = 0 ; var_7 < var_4 ; var_7 ++ ) { int var_8 = var_4 - var_7 ; if ( var_0 [ var_7 ] >= var_8 ) { return var_8 ; } } return 0 ; } " 458,8. String to Integer (atoi)_1.java,"private boolean isDigit(char c) { return c >= '0' && c <= '9'; }","private boolean var_0 ( char var_1 ) { return var_1 >= '0' && var_1 <= '9' ; } " 459,Best Time to Buy and Sell Stock III_1.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length == 0) { return 0; } int profit = 0; int n = prices.length; int[][] dp = new int[n][5]; dp[0][0] = 0; for (int i = 1; i < n; i++) { for (int j = 1; j < 5; j++) { int dailyDiff = prices[i] - prices[i - 1]; if (j % 2 == 0) { dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - 1] + dailyDiff); profit = Math.max(profit, dp[i][j]); } else { dp[i][j] = Math.max(dp[i - 1][j] + dailyDiff, dp[i - 1][j - 1]); } } } return profit; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = 0 ; int var_5 = var_0 . length ; int [ ] [ ] var_7 = new int [ var_5 ] [ 5 ] ; var_7 [ 0 ] [ 0 ] = 0 ; for ( int var_9 = 1 ; var_9 < var_5 ; var_9 ++ ) { for ( int var_10 = 1 ; var_10 < 5 ; var_10 ++ ) { int var_11 = var_0 [ var_9 ] - var_0 [ var_9 - 1 ] ; if ( var_10 % 2 == 0 ) { var_7 [ var_9 ] [ var_10 ] = Math . max ( var_7 [ var_9 - 1 ] [ var_10 ] , var_7 [ var_9 - 1 ] [ var_10 - 1 ] + var_11 ) ; var_4 = Math . max ( var_4 , var_7 [ var_9 ] [ var_10 ] ) ; } else { var_7 [ var_9 ] [ var_10 ] = Math . max ( var_7 [ var_9 - 1 ] [ var_10 ] + var_11 , var_7 [ var_9 - 1 ] [ var_10 - 1 ] ) ; } } } return var_4 ; } " 460,Walls and Gates_4.java,"private boolean validate(int[][] rooms) { return rooms == null || rooms.length == 0 || rooms[0] == null || rooms[0].length == 0; }","private boolean var_0 ( int [ ] [ ] var_1 ) { return var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 ; } " 461,57. Insert Interval_2.java,"private int[][] convert(List list) { int[][] rst = new int[list.size()][2]; for (int i = 0; i < list.size(); i++) { rst[i][0] = list.get(i)[0]; rst[i][1] = list.get(i)[1]; } return rst; }","private int [ ] [ ] sample_funcname ( List < int [ ] > var_1 ) { int [ ] [ ] var_4 = new int [ var_1 . size ( ) ] [ 2 ] ; for ( int var_6 = 0 ; var_6 < var_1 . size ( ) ; var_6 ++ ) { var_4 [ var_6 ] [ 0 ] = var_1 . get ( var_6 ) [ 0 ] ; var_4 [ var_6 ] [ 1 ] = var_1 . get ( var_6 ) [ 1 ] ; } return var_4 ; } " 462,Palindrome Permutation II_1.java,"public void permutateUnique(List rst, String str, boolean[] visited, String s) { if (str.length() == s.length()) { rst.add(str); return; } for (int i = 0; i < s.length(); i++) { if (visited[i] || (i > 0 && !visited[i - 1] && s.charAt(i - 1) == s.charAt(i))) { continue; } visited[i] = true; permutateUnique(rst, str + s.charAt(i), visited, s); visited[i] = false; } }","public void sample_funcname ( List < String > rst , String str , boolean [ ] visited , String s ) { if ( str . length ( ) == s . length ( ) ) { rst . add ( str ) ; return ; } for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( visited [ i ] || ( i > 0 && ! visited [ i - 1 ] && s . charAt ( i - 1 ) == s . charAt ( i ) ) ) { continue ; } visited [ i ] = true ; permutateUnique ( rst , str + s . charAt ( i ) , visited , s ) ; visited [ i ] = false ; } } " 463,207. Course Schedule_1.java,"private boolean validateInput(int numCourses, int[][] prerequisites) { return numCourses == 0 || prerequisites == null || prerequisites.length == 0 || prerequisites[0] == null || prerequisites[0].length == 0; }","private boolean var_0 ( int var_1 , int [ ] [ ] var_2 ) { return var_1 == 0 || var_2 == null || var_2 . length == 0 || var_2 [ 0 ] == null || var_2 [ 0 ] . length == 0 ; } " 464,Reshape the Matrix_1.java,"public int[][] matrixReshape(int[][] nums, int r, int c) { int totalElements = nums.length * nums[0].length; if (totalElements != r * c || totalElements % r != 0) { return nums; } final int[][] result = new int[r][c]; int newR = 0; int newC = 0; for (int i = 0; i < nums.length; i++) { for (int j = 0; j < nums[i].length; j++) { result[newR][newC] = nums[i][j]; newC++; if (newC == c) { newC = 0; newR++; } } } return result; }","public int [ ] [ ] sample_funcname ( int [ ] [ ] var_0 , int var_1 , int var_2 ) { int var_5 = var_0 . length * var_0 [ 0 ] . length ; if ( var_5 != var_1 * var_2 || var_5 % var_1 != 0 ) { return var_0 ; } final int [ ] [ ] var_6 = new int [ var_1 ] [ var_2 ] ; int var_7 = 0 ; int var_8 = 0 ; for ( int var_9 = 0 ; var_9 < var_0 . length ; var_9 ++ ) { for ( int var_10 = 0 ; var_10 < var_0 [ var_9 ] . length ; var_10 ++ ) { var_6 [ var_7 ] [ var_8 ] = var_0 [ var_9 ] [ var_10 ] ; var_8 ++ ; if ( var_8 == var_2 ) { var_8 = 0 ; var_7 ++ ; } } } return var_6 ; } " 465,159. Longest Substring with At Most Two Distinct Characters_2.java,"public int lengthOfLongestSubstringTwoDistinct(String s) { if (s == null || s.length() == 0) return 0; int n = s.length(); Map lastOccurMap = new HashMap<>(); int left = 0, right = 0, max = 0; while (right < n) { if (lastOccurMap.size() <= 2) { lastOccurMap.put(s.charAt(right), right++); } if (lastOccurMap.size() > 2) { int leftMost = right; for (int index : lastOccurMap.values()) { leftMost = Math.min(leftMost, index); } lastOccurMap.remove(s.charAt(leftMost)); left = leftMost + 1; } max = Math.max(max, right - left); } return max; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) return 0 ; int var_5 = var_1 . length ( ) ; Map < Character , Integer > var_10 = new HashMap < > ( ) ; int var_11 = 0 , var_12 = 0 , max = 0 ; while ( var_12 < var_5 ) { if ( var_10 . size ( ) <= 2 ) { var_10 . put ( var_1 . charAt ( var_12 ) , var_12 ++ ) ; } if ( var_10 . size ( ) > 2 ) { int var_18 = var_12 ; for ( int var_20 : var_10 . values ( ) ) { var_18 = Math . min ( var_18 , var_20 ) ; } var_10 . remove ( var_1 . charAt ( var_18 ) ) ; var_11 = var_18 + 1 ; } max = Math . max ( max , var_12 - var_11 ) ; } return max ; } " 466,Permutation Sequence_1.java,"public String getPermutation(int n, int k) { if (n <= 0 || k <= 0) { return """"; } StringBuffer sb = new StringBuffer(); boolean[] visited = new boolean[n]; int factorio = 1; for (int i = 1; i < n; i++) { factorio *= i; } k = k - 1; for (int i = 0; i < n; i++) { int index = k / factorio; k = k % factorio; for (int j = 0; j < n; j++) { if (!visited[j]) { if (index == 0) { visited[j] = true; sb.append((char)('0' + j + 1)); break; } else { index--; } } } if (i < n - 1) { factorio = factorio / (n - i - 1); } } return sb.toString(); }","public String var_0 ( int var_1 , int var_2 ) { if ( var_1 <= 0 || var_2 <= 0 ) { return """" ; } StringBuffer var_6 = new StringBuffer ( ) ; boolean [ ] var_8 = new boolean [ var_1 ] ; int var_10 = 1 ; for ( int var_11 = 1 ; var_11 < var_1 ; var_11 ++ ) { var_10 *= var_11 ; } var_2 = var_2 - 1 ; for ( int var_11 = 0 ; var_11 < var_1 ; var_11 ++ ) { int var_12 = var_2 / var_10 ; var_2 = var_2 % var_10 ; for ( int var_13 = 0 ; var_13 < var_1 ; var_13 ++ ) { if ( ! var_8 [ var_13 ] ) { if ( var_12 == 0 ) { var_8 [ var_13 ] = true ; var_6 . append ( ( char ) ( '0' + var_13 + 1 ) ) ; break ; } else { var_12 -- ; } } } if ( var_11 < var_1 - 1 ) { var_10 = var_10 / ( var_1 - var_11 - 1 ) ; } } return var_6 . toString ( ) ; } " 467,Bricks Falling When Hit_2.java,"private int flip(int[][] grid, Set visited) { int count = 0; for (String s : visited) { String[] ss = s.split(""@""); int i = Integer.parseInt(ss[0]), j = Integer.parseInt(ss[1]); if (grid[i][j] > 0) { grid[i][j] = 0; count++; } } return count; }","private int sample_funcname ( int [ ] [ ] var_0 , Set < String > var_3 ) { int var_5 = 0 ; for ( String var_6 : var_3 ) { String [ ] var_9 = var_6 . split ( ""@"" ) ; int var_12 = Integer . parseInt ( var_9 [ 0 ] ) , var_14 = Integer . parseInt ( var_9 [ 1 ] ) ; if ( var_0 [ var_12 ] [ var_14 ] > 0 ) { var_0 [ var_12 ] [ var_14 ] = 0 ; var_5 ++ ; } } return var_5 ; } " 468,743. Network Delay Time_2.java,"private Map> buildGraph(int[][] times) { Map> graph = new HashMap<>(); for (int[] record : times) { graph.putIfAbsent(record[0], new ArrayList<>()); graph.get(record[0]).add(record); } return graph; }","private Map < Integer , List < int [ ] >> var_2 ( int [ ] [ ] var_3 ) { Map < Integer , List < int [ ] >> var_6 = new HashMap < > ( ) ; for ( int [ ] var_7 : var_3 ) { var_6 . putIfAbsent ( var_7 [ 0 ] , new ArrayList < > ( ) ) ; var_6 . get ( var_7 [ 0 ] ) . add ( var_7 ) ; } return var_6 ; } " 469,Backpack III_5.java,"public int backPackIII(int[] A, int[] V, int m) { if (A == null || V == null || A.length != V.length) { return 0; } int n = A.length; int[][] dp = new int[n + 1][m + 1]; for (int j = 0; j <= m; j++) { dp[0][j] = -1; } dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= m; j++) { dp[i][j] = dp[i - 1][j]; if (j - A[i - 1] >= 0) { dp[i][j] = Math.max(dp[i][j], dp[i][j - A[i - 1]] + V[i - 1]); } } } int rst = 0; for (int j = 0; j <= m; j++) { rst = Math.max(rst, dp[n][j]); } return rst; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 , int var_2 ) { if ( var_0 == null || var_1 == null || var_0 . length != var_1 . length ) { return 0 ; } int var_6 = var_0 . length ; int [ ] [ ] var_8 = new int [ var_6 + 1 ] [ var_2 + 1 ] ; for ( int var_9 = 0 ; var_9 <= var_2 ; var_9 ++ ) { var_8 [ 0 ] [ var_9 ] = - 1 ; } var_8 [ 0 ] [ 0 ] = 0 ; for ( int var_10 = 1 ; var_10 <= var_6 ; var_10 ++ ) { for ( int var_9 = 0 ; var_9 <= var_2 ; var_9 ++ ) { var_8 [ var_10 ] [ var_9 ] = var_8 [ var_10 - 1 ] [ var_9 ] ; if ( var_9 - var_0 [ var_10 - 1 ] >= 0 ) { var_8 [ var_10 ] [ var_9 ] = Math . max ( var_8 [ var_10 ] [ var_9 ] , var_8 [ var_10 ] [ var_9 - var_0 [ var_10 - 1 ] ] + var_1 [ var_10 - 1 ] ) ; } } } int var_13 = 0 ; for ( int var_9 = 0 ; var_9 <= var_2 ; var_9 ++ ) { var_13 = Math . max ( var_13 , var_8 [ var_6 ] [ var_9 ] ) ; } return var_13 ; } " 470,Cracking the Safe_1.java,"public String crackSafe(int n, int k) { Set set = new HashSet<>(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < n; i++) sb.append(""0""); set.add(sb.toString()); for (int i = 0; i < Math.pow(k, n); i++) { String tail = sb.substring(sb.length() - n + 1); for (int j = k - 1; j >= 0; j--) { String newStr = tail + j; if (!set.contains(newStr)) { set.add(newStr); sb.append(j); break; } } } return sb.toString(); }","public String var_0 ( int var_1 , int var_2 ) { Set < String > var_6 = new HashSet < > ( ) ; StringBuffer var_8 = new StringBuffer ( ) ; for ( int var_10 = 0 ; var_10 < var_1 ; var_10 ++ ) var_8 . append ( ""0"" ) ; var_6 . add ( var_8 . toString ( ) ) ; for ( int var_10 = 0 ; var_10 < Math . pow ( var_2 , var_1 ) ; var_10 ++ ) { String var_20 = var_8 . substring ( var_8 . length ( ) - var_1 + 1 ) ; for ( int var_21 = var_2 - 1 ; var_21 >= 0 ; var_21 -- ) { String var_22 = var_20 + var_21 ; if ( ! var_6 . contains ( var_22 ) ) { var_6 . add ( var_22 ) ; var_8 . append ( var_21 ) ; break ; } } } return var_8 . toString ( ) ; } " 471,Scramble String_2.java,"public boolean isScramble(String s1, String s2) { if (s1 == null || s2 == null || s1.length() != s2.length()) { return false; } int n = s1.length(); boolean[][][] dp = new boolean[n][n][n + 1]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { dp[i][j][1] = s1.charAt(i) == s2.charAt(j); } } for (int len = 2; len <= n; len++) { for (int i = 0; i <= n - len; i++) { for (int j = 0; j <= n - len; j++) { for (int w = 1; w < len; w++) { dp[i][j][len] |= (dp[i][j][w] && dp[i + w][j + w][len - w]); dp[i][j][len] |= (dp[i][j + len - w][w] && dp[i + w][j][len - w]); } } } } return dp[0][0][n]; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) != var_3 . length ( ) ) { return false ; } int var_6 = var_2 . length ( ) ; boolean [ ] [ ] [ ] var_9 = new boolean [ var_6 ] [ var_6 ] [ var_6 + 1 ] ; for ( int var_11 = 0 ; var_11 < var_6 ; var_11 ++ ) { for ( int var_12 = 0 ; var_12 < var_6 ; var_12 ++ ) { var_9 [ var_11 ] [ var_12 ] [ 1 ] = var_2 . charAt ( var_11 ) == var_3 . charAt ( var_12 ) ; } } for ( int var_15 = 2 ; var_15 <= var_6 ; var_15 ++ ) { for ( int var_11 = 0 ; var_11 <= var_6 - var_15 ; var_11 ++ ) { for ( int var_12 = 0 ; var_12 <= var_6 - var_15 ; var_12 ++ ) { for ( int var_16 = 1 ; var_16 < var_15 ; var_16 ++ ) { var_9 [ var_11 ] [ var_12 ] [ var_15 ] |= ( var_9 [ var_11 ] [ var_12 ] [ var_16 ] && var_9 [ var_11 + var_16 ] [ var_12 + var_16 ] [ var_15 - var_16 ] ) ; var_9 [ var_11 ] [ var_12 ] [ var_15 ] |= ( var_9 [ var_11 ] [ var_12 + var_15 - var_16 ] [ var_16 ] && var_9 [ var_11 + var_16 ] [ var_12 ] [ var_15 - var_16 ] ) ; } } } } return var_9 [ 0 ] [ 0 ] [ var_6 ] ; } " 472,76. Minimum Window Substring_2.java,"public String minWindow(String s, String t) { int end = 0, start = 0, head = 0, counter = t.length(); int minLength = Integer.MAX_VALUE, n = s.length(); String rst = """"; int[] map = new int[256]; for (char c : t.toCharArray()) map[c]++; while (end < n) { if (map[s.charAt(end++)]-- > 0) counter--; while (counter == 0) { int len = end - start; if (len < minLength) { minLength = len; head = start; } if (map[s.charAt(start++)]++ == 0) counter++; } } return minLength == Integer.MAX_VALUE ? """" : s.substring(head, head + minLength); }","public String var_0 ( String var_2 , String var_3 ) { int var_5 = 0 , var_6 = 0 , var_7 = 0 , var_9 = var_3 . length ( ) ; int var_12 = Integer . MAX_VALUE , var_13 = var_2 . length ( ) ; String var_15 = """" ; int [ ] var_17 = new int [ 256 ] ; for ( char var_19 : var_3 . toCharArray ( ) ) var_17 [ var_19 ] ++ ; while ( var_5 < var_13 ) { if ( var_17 [ var_2 . charAt ( var_5 ++ ) ] -- > 0 ) var_9 -- ; while ( var_9 == 0 ) { int var_21 = var_5 - var_6 ; if ( var_21 < var_12 ) { var_12 = var_21 ; var_7 = var_6 ; } if ( var_17 [ var_2 . charAt ( var_6 ++ ) ] ++ == 0 ) var_9 ++ ; } } return var_12 == Integer . MAX_VALUE ? """" : var_2 . substring ( var_7 , var_7 + var_12 ) ; } " 473,Kth Largest Element in an Array_3.java,"public void swap( ArrayListnums, int x, int y){ int temp = nums.get(x); nums.set(x, nums.get(y)); nums.set(y, temp); }","public void var_0 ( ArrayList < Integer > var_3 , int var_4 , int var_5 ) { int var_7 = var_3 . get ( var_4 ) ; var_3 . set ( var_4 , var_3 . get ( var_5 ) ) ; var_3 . set ( var_5 , var_7 ) ; } " 474,Sort Colors II_1.java,"private void swap(int[] nums, int x, int y){ int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 475,151. Reverse Words in a String_2.java,"private void reverse(String[] strs) { int i = 0, j = strs.length - 1; while (i < j) { String temp = strs[i]; strs[i++] = strs[j]; strs[j--] = temp; } }","private void var_0 ( String [ ] var_2 ) { int var_4 = 0 , var_7 = var_2 . length - 1 ; while ( var_4 < var_7 ) { String var_8 = var_2 [ var_4 ] ; var_2 [ var_4 ++ ] = var_2 [ var_7 ] ; var_2 [ var_7 -- ] = var_8 ; } } " 476,210. Course Schedule II_1.java,"public int[] findOrder(int numCourses, int[][] prerequisites) { if (numCourses == 0 || prerequisites == null) { return new int[numCourses]; } List[] inDegreeEdges = new ArrayList[numCourses]; int[] dependencyCount = new int[numCourses]; for (int i = 0; i < numCourses; i++) inDegreeEdges[i] = new ArrayList<>(); for (int[] prerequisite : prerequisites) { inDegreeEdges[prerequisite[1]].add(prerequisite[0]); dependencyCount[prerequisite[0]]++; } Queue queue = new LinkedList<>(); for (int i = 0; i < numCourses; i++) { if (dependencyCount[i] == 0) queue.add(i); } List sortedList = new ArrayList<>(); while (!queue.isEmpty()) { int leafNode = queue.poll(); sortedList.add(leafNode); List dependencies = inDegreeEdges[leafNode]; for (int node : dependencies) { if (--dependencyCount[node] == 0) queue.add(node); } } if (sortedList.size() != numCourses) { return new int[0]; } int[] rst = new int[sortedList.size()]; for (int i = 0; i < sortedList.size(); i++) { rst[i] = sortedList.get(i); } return rst; }","public int [ ] sample_funcname ( int var_0 , int [ ] [ ] var_1 ) { if ( var_0 == 0 || var_1 == null ) { return new int [ var_0 ] ; } List [ ] var_6 = new ArrayList [ var_0 ] ; int [ ] var_7 = new int [ var_0 ] ; for ( int var_8 = 0 ; var_8 < var_0 ; var_8 ++ ) var_6 [ var_8 ] = new ArrayList < > ( ) ; for ( int [ ] var_9 : var_1 ) { var_6 [ var_9 [ 1 ] ] . add ( var_9 [ 0 ] ) ; var_7 [ var_9 [ 0 ] ] ++ ; } Queue < Integer > var_15 = new LinkedList < > ( ) ; for ( int var_8 = 0 ; var_8 < var_0 ; var_8 ++ ) { if ( var_7 [ var_8 ] == 0 ) var_15 . add ( var_8 ) ; } List < Integer > var_16 = new ArrayList < > ( ) ; while ( ! var_15 . isEmpty ( ) ) { int var_19 = var_15 . poll ( ) ; var_16 . add ( var_19 ) ; List < Integer > var_20 = var_6 [ var_19 ] ; for ( int var_21 : var_20 ) { if ( -- var_7 [ var_21 ] == 0 ) var_15 . add ( var_21 ) ; } } if ( var_16 . size ( ) != var_0 ) { return new int [ 0 ] ; } int [ ] var_23 = new int [ var_16 . size ( ) ] ; for ( int var_8 = 0 ; var_8 < var_16 . size ( ) ; var_8 ++ ) { var_23 [ var_8 ] = var_16 . get ( var_8 ) ; } return var_23 ; } " 477,611. Valid Triangle Number_2.java,"public int triangleNumber(int[] nums) { Arrays.sort(nums); int n = nums.length, count = 0; for (int i = 0; i <= n - 3; i++) { if (nums[i] == 0) continue; int k = i + 2; for (int j = i + 1; j <= n - 2; j++) { while (k < n && nums[i] + nums[j] > nums[k]) k++; count += k - j - 1; } } return count; }","public int sample_funcname ( int [ ] var_0 ) { Arrays . sort ( var_0 ) ; int var_4 = var_0 . length , var_6 = 0 ; for ( int var_7 = 0 ; var_7 <= var_4 - 3 ; var_7 ++ ) { if ( var_0 [ var_7 ] == 0 ) continue ; int var_10 = var_7 + 2 ; for ( int var_12 = var_7 + 1 ; var_12 <= var_4 - 2 ; var_12 ++ ) { while ( var_10 < var_4 && var_0 [ var_7 ] + var_0 [ var_12 ] > var_0 [ var_10 ] ) var_10 ++ ; var_6 += var_10 - var_12 - 1 ; } } return var_6 ; } " 478,217. Contains Duplicate_2.java,"public boolean containsDuplicate(int[] nums) { if (nums == null || nums.length == 0) { return false; } Arrays.sort(nums); for (int i = 0; i < nums.length - 1; i++) { if (nums[i] == nums[i + 1]) { return true; } } return false; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return false ; } Arrays . sort ( var_1 ) ; for ( int var_7 = 0 ; var_7 < var_1 . length - 1 ; var_7 ++ ) { if ( var_1 [ var_7 ] == var_1 [ var_7 + 1 ] ) { return true ; } } return false ; } " 479,246. Strobogrammatic Number_2.java,"public boolean isStrobogrammatic(String num) { if (num == null || num.length() == 0) return true; if (num.length() == 1) return num.equals(""0"") || num.equals(""1"") || num.equals(""8""); List candidate = new ArrayList<>(Arrays.asList('0', '1', '8', '6', '9')); char[] charArray = num.toCharArray(); for (int i = 0; i < charArray.length; i++) { if (!candidate.contains(charArray[i])) return false; if (charArray[i] == '6') charArray[i] = '9'; else if (charArray[i] == '9') charArray[i] = '6'; } StringBuffer sb = new StringBuffer(String.valueOf(charArray)); String reversedNum = sb.reverse().toString(); return num.equals(reversedNum); }","public boolean var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) return true ; if ( var_2 . length ( ) == 1 ) return var_2 . equals ( ""0"" ) || var_2 . equals ( ""1"" ) || var_2 . equals ( ""8"" ) ; List < Character > var_21 = new ArrayList < > ( Arrays . asList ( '0' , '1' , '8' , '6' , '9' ) ) ; char [ ] var_23 = var_2 . toCharArray ( ) ; for ( int var_24 = 0 ; var_24 < var_23 . length ; var_24 ++ ) { if ( ! var_21 . contains ( var_23 [ var_24 ] ) ) return false ; if ( var_23 [ var_24 ] == '6' ) var_23 [ var_24 ] = '9' ; else if ( var_23 [ var_24 ] == '9' ) var_23 [ var_24 ] = '6' ; } StringBuffer var_28 = new StringBuffer ( String . valueOf ( var_23 ) ) ; String var_31 = var_28 . reverse ( ) . toString ( ) ; return var_2 . equals ( var_31 ) ; } " 480,Container With Most Water_1.java,"public int maxArea(int[] heights) { if (heights == null || heights.length == 0) { return 0; } int left = 0; int right = heights.length - 1; int maxWater = Integer.MIN_VALUE; while (left < right) { int lowWall = heights[left] < heights[right] ? heights[left] : heights[right]; maxWater = Math.max(maxWater, (right - left) * lowWall); if (heights[left] < heights[right]) { left++; } else { right--; } } return maxWater; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = 0 ; int var_6 = var_0 . length - 1 ; int var_9 = Integer . MIN_VALUE ; while ( var_4 < var_6 ) { int var_10 = var_0 [ var_4 ] < var_0 [ var_6 ] ? var_0 [ var_4 ] : var_0 [ var_6 ] ; var_9 = Math . max ( var_9 , ( var_6 - var_4 ) * var_10 ) ; if ( var_0 [ var_4 ] < var_0 [ var_6 ] ) { var_4 ++ ; } else { var_6 -- ; } } return var_9 ; } " 481,Max Area of Island_1.java,"private boolean validate(int[][] grid, int x, int y) { return x >= 0 && x < grid.length && y >= 0 && y < grid[0].length && grid[x][y] == 1; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 >= 0 && var_2 < var_1 . length && var_3 >= 0 && var_3 < var_1 [ 0 ] . length && var_1 [ var_2 ] [ var_3 ] == 1 ; } " 482,Sliding Puzzle_2.java,"private boolean evaluate(int[] nums) { for (int i = 0; i < nums.length; i++) { if (i + 1 != nums[i]) { if (i == 5 && nums[i] == 0) continue; return false; } } return true; }","private boolean var_0 ( int [ ] var_1 ) { for ( int var_3 = 0 ; var_3 < var_1 . length ; var_3 ++ ) { if ( var_3 + 1 != var_1 [ var_3 ] ) { if ( var_3 == 5 && var_1 [ var_3 ] == 0 ) continue ; return false ; } } return true ; } " 483,58. Length of Last Word_2.java,"public int lengthOfLastWord(String s) { if (s == null || s.length() == 0) { return 0; } String[] arr = s.split(""\\ ""); String lastWord = arr[arr.length - 1]; return lastWord.length(); }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } String [ ] var_7 = var_1 . split ( ""\\ "" ) ; String var_9 = var_7 [ var_7 . length - 1 ] ; return var_9 . length ( ) ; } " 484,686. Repeated String Match_1.java,"private boolean validate(String A, String B) { boolean[] checkA = new boolean[256]; boolean[] checkB = new boolean[256]; for (char c : A.toCharArray()) { checkA[c] = true; } for (char c : B.toCharArray()) { checkB[c] = true; } for (int i = 0; i < 256; i++) { if (checkB[i] && !checkA[i]) { return false; } } return true; }","private boolean var_0 ( String var_2 , String var_3 ) { boolean [ ] var_6 = new boolean [ 256 ] ; boolean [ ] var_7 = new boolean [ 256 ] ; for ( char var_9 : var_2 . toCharArray ( ) ) { var_6 [ var_9 ] = true ; } for ( char var_9 : var_3 . toCharArray ( ) ) { var_7 [ var_9 ] = true ; } for ( int var_11 = 0 ; var_11 < 256 ; var_11 ++ ) { if ( var_7 [ var_11 ] && ! var_6 [ var_11 ] ) { return false ; } } return true ; } " 485,Perfect Squares_4.java,"public int numSquares(int n) { if (n <= 0) { return 0; } int[] dp = new int[n + 1]; dp[0] = 0; for (int i = 1; i <= n; i++) { int maxSqrNum = (int)Math.floor(Math.sqrt(i)); int min = Integer.MAX_VALUE; for (int j = 1; j <= maxSqrNum; j++) { min = Math.min(min, dp[i - j * j] + 1); } dp[i] = min; } return dp[n]; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 0 ) { return 0 ; } int [ ] var_3 = new int [ var_0 + 1 ] ; var_3 [ 0 ] = 0 ; for ( int var_4 = 1 ; var_4 <= var_0 ; var_4 ++ ) { int var_8 = ( int ) Math . floor ( Math . sqrt ( var_4 ) ) ; int min = Integer . MAX_VALUE ; for ( int var_12 = 1 ; var_12 <= var_8 ; var_12 ++ ) { min = Math . min ( min , var_3 [ var_4 - var_12 * var_12 ] + 1 ) ; } var_3 [ var_4 ] = min ; } return var_3 [ var_0 ] ; } " 486,408. Valid Word Abbreviation_1.java,"private boolean isInt(char c) { return c >= '0' && c <= '9'; }","private boolean var_0 ( char var_1 ) { return var_1 >= '0' && var_1 <= '9' ; } " 487,Word Search II_2.java,"public boolean search(char[][] board, String word, int i, int j, int start) { if (start == word.length()) { return true; } if (i < 0 || i >= board.length || j < 0 || j >= board[0].length || board[i][j] != word.charAt(start)) { return false; } board[i][j] = '#'; boolean rst = search(board, word, i, j - 1, start + 1) || search(board, word, i, j + 1, start + 1) || search(board, word, i + 1, j, start + 1) || search(board, word, i - 1, j, start + 1); board[i][j] = word.charAt(start); return rst; }","public boolean sample_funcname ( char [ ] [ ] board , String word , int i , int j , int start ) { if ( start == word . length ( ) ) { return true ; } if ( i < 0 || i >= board . length || j < 0 || j >= board [ 0 ] . length || board [ i ] [ j ] != word . charAt ( start ) ) { return false ; } board [ i ] [ j ] = '#' ; boolean rst = search ( board , word , i , j - 1 , start + 1 ) || search ( board , word , i , j + 1 , start + 1 ) || search ( board , word , i + 1 , j , start + 1 ) || search ( board , word , i - 1 , j , start + 1 ) ; board [ i ] [ j ] = word . charAt ( start ) ; return rst ; } " 488,Backpack_3.java,"public int backPack(int m, int[] A) { if (A == null || A.length < 0) { return 0; } int n = A.length; boolean[][] dp = new boolean[n + 1][m + 1]; dp[0][0] = true; for (int j = 1; j <= m; j++) { dp[0][j] = false; } for (int i = 1; i <= n; i++) { for (int j = 0; j <= m; j++) { dp[i][j] = dp[i - 1][j]; if (j - A[i - 1] >= 0) { dp[i][j] |= dp[i - 1][j - A[i - 1]]; } } } for (int j = m; j >= 0; j--) { if (dp[n][j]) { return j; } } return 0; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length < 0 ) { return 0 ; } int var_5 = var_1 . length ; boolean [ ] [ ] var_8 = new boolean [ var_5 + 1 ] [ var_0 + 1 ] ; var_8 [ 0 ] [ 0 ] = true ; for ( int var_9 = 1 ; var_9 <= var_0 ; var_9 ++ ) { var_8 [ 0 ] [ var_9 ] = false ; } for ( int var_10 = 1 ; var_10 <= var_5 ; var_10 ++ ) { for ( int var_9 = 0 ; var_9 <= var_0 ; var_9 ++ ) { var_8 [ var_10 ] [ var_9 ] = var_8 [ var_10 - 1 ] [ var_9 ] ; if ( var_9 - var_1 [ var_10 - 1 ] >= 0 ) { var_8 [ var_10 ] [ var_9 ] |= var_8 [ var_10 - 1 ] [ var_9 - var_1 [ var_10 - 1 ] ] ; } } } for ( int var_9 = var_0 ; var_9 >= 0 ; var_9 -- ) { if ( var_8 [ var_5 ] [ var_9 ] ) { return var_9 ; } } return 0 ; } " 489,1041. Robot Bounded In Circle_1.java,"public boolean judgeCircle(String moves) { if (moves == null || moves.length() % 2 == 1) { return false; } int trackX = 0; int trackY = 0; for (int i = 0; i < moves.length(); i++) { if (moves.charAt(i) == 'U' || moves.charAt(i) == 'D') { trackY += moves.charAt(i) == 'U' ? 1 : -1; } if (moves.charAt(i) == 'L' || moves.charAt(i) == 'R') { trackX += moves.charAt(i) == 'L' ? 1 : -1; } } return trackX == 0 && trackY == 0; }","public boolean var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) % 2 == 1 ) { return false ; } int var_8 = 0 ; int var_9 = 0 ; for ( int var_10 = 0 ; var_10 < var_2 . length ( ) ; var_10 ++ ) { if ( var_2 . charAt ( var_10 ) == 'U' || var_2 . charAt ( var_10 ) == 'D' ) { var_9 += var_2 . charAt ( var_10 ) == 'U' ? 1 : - 1 ; } if ( var_2 . charAt ( var_10 ) == 'L' || var_2 . charAt ( var_10 ) == 'R' ) { var_8 += var_2 . charAt ( var_10 ) == 'L' ? 1 : - 1 ; } } return var_8 == 0 && var_9 == 0 ; } " 490,Largest Rectangle in Histogram_1.java,"public int largestRectangleArea(int[] heights) { if (heights == null || heights.length == 0) { return 0; } int n = heights.length; int max = 0; Stack stack = new Stack<>(); for (int i = 0; i <= n; i++) { int currHeight = i == n ? -1 : heights[i]; while (!stack.isEmpty() && currHeight <= heights[stack.peek()]) { int currPeekHeight = heights[stack.pop()]; int width = stack.isEmpty() ? i : i - stack.peek() - 1; max = Math.max(max, currPeekHeight * width); } stack.push(i); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int max = 0 ; Stack < Integer > var_8 = new Stack < > ( ) ; for ( int var_9 = 0 ; var_9 <= var_4 ; var_9 ++ ) { int var_11 = var_9 == var_4 ? - 1 : var_0 [ var_9 ] ; while ( ! var_8 . isEmpty ( ) && var_11 <= var_0 [ var_8 . peek ( ) ] ) { int var_15 = var_0 [ var_8 . pop ( ) ] ; int var_16 = var_8 . isEmpty ( ) ? var_9 : var_9 - var_8 . peek ( ) - 1 ; max = Math . max ( max , var_15 * var_16 ) ; } var_8 . push ( var_9 ) ; } return max ; } " 491,399. Evaluate Division_1.java,"private String getKey(String a, String b) { return String.format(""%s->%s"", a, b); }","private String var_0 ( String var_2 , String var_3 ) { return String . format ( ""%s->%s"" , var_2 , var_3 ) ; } " 492,64. Minimum Path Sum_3.java,"public int minPathSum(int[][] grid) { if (grid == null || grid.length == 0 || grid[0] == null || grid[0].length == 0) return 0; int m = grid.length, n = grid[0].length; int[][] dp = new int[m][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { dp[i][j] = grid[i][j]; if (i == 0 && j == 0) continue; if (i == 0 && j > 0) dp[i][j] += dp[i][j - 1]; else if (i > 0 && j == 0) dp[i][j] += dp[i - 1][j]; else dp[i][j] += Math.min(dp[i - 1][j], dp[i][j - 1]); } } return dp[m - 1][n - 1]; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_6 = new int [ var_4 ] [ var_5 ] ; for ( int var_7 = 0 ; var_7 < var_4 ; var_7 ++ ) { for ( int var_8 = 0 ; var_8 < var_5 ; var_8 ++ ) { var_6 [ var_7 ] [ var_8 ] = var_0 [ var_7 ] [ var_8 ] ; if ( var_7 == 0 && var_8 == 0 ) continue ; if ( var_7 == 0 && var_8 > 0 ) var_6 [ var_7 ] [ var_8 ] += var_6 [ var_7 ] [ var_8 - 1 ] ; else if ( var_7 > 0 && var_8 == 0 ) var_6 [ var_7 ] [ var_8 ] += var_6 [ var_7 - 1 ] [ var_8 ] ; else var_6 [ var_7 ] [ var_8 ] += Math . min ( var_6 [ var_7 - 1 ] [ var_8 ] , var_6 [ var_7 ] [ var_8 - 1 ] ) ; } } return var_6 [ var_4 - 1 ] [ var_5 - 1 ] ; } " 493,311. Sparse Matrix Multiplication_1.java,"private boolean validate(int[][] A, int[][] B) { if (A == null || B == null) return true; if (A[0].length != B.length) return true; return false; }","private boolean var_0 ( int [ ] [ ] var_1 , int [ ] [ ] var_2 ) { if ( var_1 == null || var_2 == null ) return true ; if ( var_1 [ 0 ] . length != var_2 . length ) return true ; return false ; } " 494,327. Count of Range Sum_1.java,"private int mergeSort(long[] preSum, int lower, int upper, int start, int end) { if (start + 1 >= end) return 0; int mid = (start + end) / 2, count = 0; count += mergeSort(preSum, lower, upper, start, mid); count += mergeSort(preSum, lower, upper, mid, end); int lo = mid, hi = mid; for (int i = start; i < mid; i++) { while (lo < end && preSum[lo] - preSum[i] < lower) lo++; while (hi < end && preSum[hi] - preSum[i] <= upper) hi++; count += hi - lo; } Arrays.sort(preSum, start, end); return count; }","private int sample_funcname ( long [ ] preSum , int lower , int upper , int start , int end ) { if ( start + 1 >= end ) return 0 ; int mid = ( start + end ) / 2 , count = 0 ; count += mergeSort ( preSum , lower , upper , start , mid ) ; count += mergeSort ( preSum , lower , upper , mid , end ) ; int lo = mid , hi = mid ; for ( int i = start ; i < mid ; i ++ ) { while ( lo < end && preSum [ lo ] - preSum [ i ] < lower ) lo ++ ; while ( hi < end && preSum [ hi ] - preSum [ i ] <= upper ) hi ++ ; count += hi - lo ; } Arrays . sort ( preSum , start , end ) ; return count ; } " 495,Find Peak Element_4.java,"public int findPeak(int[] A) { int start = 1; int end = A.length - 2; int mid; while (start + 1 < end) { mid = start + (end - start) / 2; if (A[mid] > A[mid - 1] && A[mid] > A[mid + 1]) { return mid; } else if (A[mid] > A[start] && A[mid] < A[mid + 1]) { start = mid; } else { end = mid; } } if (A[start] > A[start - 1] && A[start] > A[start + 1]) { return start; } else { return end; } }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 1 ; int var_5 = var_0 . length - 2 ; int var_6 ; while ( var_2 + 1 < var_5 ) { var_6 = var_2 + ( var_5 - var_2 ) / 2 ; if ( var_0 [ var_6 ] > var_0 [ var_6 - 1 ] && var_0 [ var_6 ] > var_0 [ var_6 + 1 ] ) { return var_6 ; } else if ( var_0 [ var_6 ] > var_0 [ var_2 ] && var_0 [ var_6 ] < var_0 [ var_6 + 1 ] ) { var_2 = var_6 ; } else { var_5 = var_6 ; } } if ( var_0 [ var_2 ] > var_0 [ var_2 - 1 ] && var_0 [ var_2 ] > var_0 [ var_2 + 1 ] ) { return var_2 ; } else { return var_5 ; } } " 496,567. Permutation in String_1.java,"private Integer[] countFreq(String s) { Integer[] freq = new Integer[256]; for (char c : s.toCharArray()) freq[c] = freq[c] == null ? 1 : freq[c] + 1; return freq; }","private Integer [ ] var_0 ( String var_2 ) { Integer [ ] var_5 = new Integer [ 256 ] ; for ( char var_7 : var_2 . toCharArray ( ) ) var_5 [ var_7 ] = var_5 [ var_7 ] == null ? 1 : var_5 [ var_7 ] + 1 ; return var_5 ; } " 497,Expression Evaluation_1.java,"public int getWeight(int base, String s) { if (s.equals(""+"") || s.equals(""-"")) { return base + 1; } if (s.equals(""*"") || s.equals(""/"")) { return base + 2; } return Integer.MAX_VALUE; }","public int sample_funcname ( int var_0 , String var_2 ) { if ( var_2 . equals ( ""+"" ) || var_2 . equals ( ""-"" ) ) { return var_0 + 1 ; } if ( var_2 . equals ( ""*"" ) || var_2 . equals ( ""/"" ) ) { return var_0 + 2 ; } return Integer . MAX_VALUE ; } " 498,10. Regular Expression Matching_1.java,"public boolean isMatch(String s, String p) { if (s == null || p == null) return false; int m = s.length(), n = p.length(); boolean[][] dp = new boolean[m + 1][n + 1]; char[] ss = s.toCharArray(); char[] pp = p.toCharArray(); for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0 && j == 0) { dp[i][j] = true; continue; } if (j == 0) { dp[i][j] = false; continue; } dp[i][j] = false; if (pp[j - 1] != '*') { if (i >= 1 && (ss[i - 1] == pp[j - 1] || pp[j - 1] == '.')) { dp[i][j] = dp[i - 1][j - 1]; } } else { if (j >= 2 ) { dp[i][j] |= dp[i][j - 2]; } if (j >= 2 && i >= 1 && (ss[i - 1] == pp[j - 2] || pp[j - 2] == '.')) { dp[i][j] |= dp[i - 1][j]; } } } } return dp[m][n]; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null ) return false ; int var_6 = var_2 . length ( ) , var_7 = var_3 . length ( ) ; boolean [ ] [ ] var_10 = new boolean [ var_6 + 1 ] [ var_7 + 1 ] ; char [ ] var_12 = var_2 . toCharArray ( ) ; char [ ] var_13 = var_3 . toCharArray ( ) ; for ( int var_15 = 0 ; var_15 <= var_6 ; var_15 ++ ) { for ( int var_16 = 0 ; var_16 <= var_7 ; var_16 ++ ) { if ( var_15 == 0 && var_16 == 0 ) { var_10 [ var_15 ] [ var_16 ] = true ; continue ; } if ( var_16 == 0 ) { var_10 [ var_15 ] [ var_16 ] = false ; continue ; } var_10 [ var_15 ] [ var_16 ] = false ; if ( var_13 [ var_16 - 1 ] != '*' ) { if ( var_15 >= 1 && ( var_12 [ var_15 - 1 ] == var_13 [ var_16 - 1 ] || var_13 [ var_16 - 1 ] == '.' ) ) { var_10 [ var_15 ] [ var_16 ] = var_10 [ var_15 - 1 ] [ var_16 - 1 ] ; } } else { if ( var_16 >= 2 ) { var_10 [ var_15 ] [ var_16 ] |= var_10 [ var_15 ] [ var_16 - 2 ] ; } if ( var_16 >= 2 && var_15 >= 1 && ( var_12 [ var_15 - 1 ] == var_13 [ var_16 - 2 ] || var_13 [ var_16 - 2 ] == '.' ) ) { var_10 [ var_15 ] [ var_16 ] |= var_10 [ var_15 - 1 ] [ var_16 ] ; } } } } return var_10 [ var_6 ] [ var_7 ] ; } " 499,91. Decode Ways_3.java,"private boolean check(String s, int i) { if (i + 1 >= s.length()) return false; int twoDigit = (s.charAt(i) - '0') * 10 + (s.charAt(i + 1) - '0'); return twoDigit <= 26 && twoDigit >= 10; }","private boolean var_0 ( String var_2 , int var_3 ) { if ( var_3 + 1 >= var_2 . length ( ) ) return false ; int var_9 = ( var_2 . charAt ( var_3 ) - '0' ) * 10 + ( var_2 . charAt ( var_3 + 1 ) - '0' ) ; return var_9 <= 26 && var_9 >= 10 ; } " 500,200. Number of Islands_3.java,"private int convertToIndex(int x, int y, int rowLength) { return x * rowLength + y; }","private int sample_funcname ( int var_0 , int var_1 , int var_2 ) { return var_0 * var_2 + var_1 ; } " 501,46. Permutations_6.java,"public List> permute(int[] nums) { List> rst = new ArrayList<>(); if (nums == null || nums.length == 0) return rst; List numList = new ArrayList<>(); for (int num : nums) numList.add(num); int n = nums.length; Queue> queue = new LinkedList<>(); queue.offer(new ArrayList<>()); while (!queue.isEmpty()) { List list = queue.poll(); if (list.size() == n) { rst.add(new ArrayList<>(list)); continue; } List candidates = new ArrayList<>(numList); candidates.removeAll(list); for (int num : candidates) { list.add(num); queue.offer(new ArrayList<>(list)); list.remove(list.size() - 1); } } return rst; }","public List < List < Integer >> var_2 ( int [ ] var_3 ) { List < List < Integer >> var_5 = new ArrayList < > ( ) ; if ( var_3 == null || var_3 . length == 0 ) return var_5 ; List < Integer > var_9 = new ArrayList < > ( ) ; for ( int var_10 : var_3 ) var_9 . add ( var_10 ) ; int var_12 = var_3 . length ; Queue < List < Integer >> var_15 = new LinkedList < > ( ) ; var_15 . offer ( new ArrayList < > ( ) ) ; while ( ! var_15 . isEmpty ( ) ) { List < Integer > var_19 = var_15 . poll ( ) ; if ( var_19 . size ( ) == var_12 ) { var_5 . add ( new ArrayList < > ( var_19 ) ) ; continue ; } List < Integer > var_21 = new ArrayList < > ( var_9 ) ; var_21 . removeAll ( var_19 ) ; for ( int var_10 : var_21 ) { var_19 . add ( var_10 ) ; var_15 . offer ( new ArrayList < > ( var_19 ) ) ; var_19 . remove ( var_19 . size ( ) - 1 ) ; } } return var_5 ; } " 502,53. Maximum Subarray_7.java,"private int findContinuousSum(int start, int left, int right, int offset, int[] nums) { int continuousSum = 0, max = 0; for (int i = start; i >= left && i <= right; i+=offset) { continuousSum += nums[i]; max = Math.max(max, continuousSum); } return max; }","private int sample_funcname ( int var_0 , int var_1 , int var_2 , int var_3 , int [ ] var_4 ) { int var_6 = 0 , max = 0 ; for ( int var_8 = var_0 ; var_8 >= var_1 && var_8 <= var_2 ; var_8 += var_3 ) { var_6 += var_4 [ var_8 ] ; max = Math . max ( max , var_6 ) ; } return max ; } " 503,Longest Consecutive Sequence_3.java,"public int longestConsecutive(int[] num) { if (num == null || num.length == 0) { return 0; } if (num.length == 1) { return 1; } int count = 1; int max = 1; Arrays.sort(num); for (int i = 1; i < num.length; i++) { if (num[i - 1] == num[i]) { continue; } else if (num[i - 1] + 1 == num[i]) { count++; max = Math.max(count, max); } else { count = 1; } } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } if ( var_0 . length == 1 ) { return 1 ; } int var_5 = 1 ; int max = 1 ; Arrays . sort ( var_0 ) ; for ( int var_9 = 1 ; var_9 < var_0 . length ; var_9 ++ ) { if ( var_0 [ var_9 - 1 ] == var_0 [ var_9 ] ) { continue ; } else if ( var_0 [ var_9 - 1 ] + 1 == var_0 [ var_9 ] ) { var_5 ++ ; max = Math . max ( var_5 , max ) ; } else { var_5 = 1 ; } } return max ; } " 504,767. Reorganize String_1.java,"public String reorganizeString(String S) { if (S == null || S.length() == 0) return """"; Map map = new HashMap<>(); for (char c : S.toCharArray()) { map.put(c, map.getOrDefault(c, 0) + 1); } PriorityQueue> pq = new PriorityQueue<>((a, b) -> (b.getValue() - a.getValue())); pq.addAll(map.entrySet()); StringBuilder sb = new StringBuilder(); Queue> buffer = new LinkedList<>(); while (!pq.isEmpty()) { Map.Entry entry = pq.poll(); sb.append(entry.getKey()); entry.setValue(entry.getValue() - 1); buffer.offer(entry); if (buffer.size() == 2) { Map.Entry temp = buffer.poll(); if (temp.getValue() > 0) pq.offer(temp); } } return sb.length() == S.length() ? sb.toString() : """"; }","public String var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) return """" ; Map < Character , Integer > var_11 = new HashMap < > ( ) ; for ( char var_13 : var_2 . toCharArray ( ) ) { var_11 . put ( var_13 , var_11 . getOrDefault ( var_13 , 0 ) + 1 ) ; } PriorityQueue < Map . Entry < Character , Integer >> var_22 = new PriorityQueue < > ( ( var_20 , var_19 ) -> ( var_19 . getValue ( ) - var_20 . getValue ( ) ) ) ; var_22 . addAll ( var_11 . entrySet ( ) ) ; StringBuilder var_26 = new StringBuilder ( ) ; Queue < Map . Entry < Character , Integer >> var_29 = new LinkedList < > ( ) ; while ( ! var_22 . isEmpty ( ) ) { Map . Entry < Character , Integer > var_32 = var_22 . poll ( ) ; var_26 . append ( var_32 . getKey ( ) ) ; var_32 . setValue ( var_32 . getValue ( ) - 1 ) ; var_29 . offer ( var_32 ) ; if ( var_29 . size ( ) == 2 ) { Map . Entry < Character , Integer > var_39 = var_29 . poll ( ) ; if ( var_39 . getValue ( ) > 0 ) var_22 . offer ( var_39 ) ; } } return var_26 . length ( ) == var_2 . length ( ) ? var_26 . toString ( ) : """" ; } " 505,349. Intersection of Two Arrays_2.java,"private boolean binarySearch(int[] nums, int target) { int start = 0; int end = nums.length - 1; while(start <= end) { int mid = (start + end) / 2; if (nums[mid] < target) { start = mid + 1; } else if (nums[mid] > target) { end = mid - 1; } else { return true; } } return false; }","private boolean var_0 ( int [ ] var_1 , int var_2 ) { int var_4 = 0 ; int var_7 = var_1 . length - 1 ; while ( var_4 <= var_7 ) { int var_9 = ( var_4 + var_7 ) / 2 ; if ( var_1 [ var_9 ] < var_2 ) { var_4 = var_9 + 1 ; } else if ( var_1 [ var_9 ] > var_2 ) { var_7 = var_9 - 1 ; } else { return true ; } } return false ; } " 506,680. Valid Palindrome II_2.java,"public boolean validate(String s, int start, int end, boolean state) { if (start > end) return false; while (start < end) { if (s.charAt(start++) == s.charAt(end--)) { continue; } else if (state) { return validate(s, start - 1, end, false) || validate(s, start, end + 1, false); } return false; } return true; }","public boolean sample_funcname ( String s , int start , int end , boolean state ) { if ( start > end ) return false ; while ( start < end ) { if ( s . charAt ( start ++ ) == s . charAt ( end -- ) ) { continue ; } else if ( state ) { return validate ( s , start - 1 , end , false ) || validate ( s , start , end + 1 , false ) ; } return false ; } return true ; } " 507,605. Can Place Flowers_1.java,"public boolean canPlaceFlowers(int[] flowerbed, int n) { if (flowerbed.length == 0 || n <= 0) return true; int m = flowerbed.length; for (int i = 0; i < m; i++) { if (flowerbed[i] == 1) continue; int lastVal = i == 0 ? 0 : flowerbed[i-1]; int nextval = i == m-1? 0: flowerbed[i+1]; if (lastVal == 0 && nextval == 0) { flowerbed[i] = 1; n--; } if (n <= 0) return true; } return false; }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { if ( var_1 . length == 0 || var_2 <= 0 ) return true ; int var_5 = var_1 . length ; for ( int var_6 = 0 ; var_6 < var_5 ; var_6 ++ ) { if ( var_1 [ var_6 ] == 1 ) continue ; int var_8 = var_6 == 0 ? 0 : var_1 [ var_6 - 1 ] ; int var_9 = var_6 == var_5 - 1 ? 0 : var_1 [ var_6 + 1 ] ; if ( var_8 == 0 && var_9 == 0 ) { var_1 [ var_6 ] = 1 ; var_2 -- ; } if ( var_2 <= 0 ) return true ; } return false ; } " 508,493. Reverse Pairs_1.java,"private int mergeSort(int[] nums, int start, int end) { if (start >= end) return 0; int mid = start + (end - start) / 2; int count = mergeSort(nums, start, mid) + mergeSort(nums, mid + 1, end); for (int i = start, j = mid + 1; i <= mid; i++) { while (j <= end && nums[i] / 2.0 > nums[j]) j++; count += j - (mid + 1); } Arrays.sort(nums, start, end + 1); return count; }","private int sample_funcname ( int [ ] nums , int start , int end ) { if ( start >= end ) return 0 ; int mid = start + ( end - start ) / 2 ; int count = mergeSort ( nums , start , mid ) + mergeSort ( nums , mid + 1 , end ) ; for ( int i = start , j = mid + 1 ; i <= mid ; i ++ ) { while ( j <= end && nums [ i ] / 2.0 > nums [ j ] ) j ++ ; count += j - ( mid + 1 ) ; } Arrays . sort ( nums , start , end + 1 ) ; return count ; } " 509,Missing Number_2.java,"private void swap(int[] nums, int x, int y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 510,Trailing Zeros_1.java,"public long trailingZeros(long n) { if ( n < 5) { return 0; } long count = 0; for (long i = 5; n / i != 0; i *= 5) { count += n / i; } return count; }","public long sample_funcname ( long var_0 ) { if ( var_0 < 5 ) { return 0 ; } long var_3 = 0 ; for ( long var_4 = 5 ; var_0 / var_4 != 0 ; var_4 *= 5 ) { var_3 += var_0 / var_4 ; } return var_3 ; } " 511,Russian Doll Envelopes_2.java,"public int maxEnvelopes(int[][] envelopes) { if (envelopes == null || envelopes.length == 0 || envelopes[0] == null || envelopes[0].length == 0) { return 0; } int n = 0, m = 0; for (int[] envelope : envelopes) { n = Math.max(n, envelope[0]); m = Math.max(m, envelope[1]); } int[][] dp = new int[n + 1][m + 1]; for (int[] envelope : envelopes) { dp[envelope[0]][envelope[1]] = 1; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { int temp = dp[i][j] == 1 ? dp[i - 1][j - 1] + dp[i][j] : Math.max(dp[i - 1][j], dp[i][j - 1]); dp[i][j] = Math.max(temp, dp[i][j]); } } return dp[n][m]; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return 0 ; } int var_4 = 0 , var_5 = 0 ; for ( int [ ] var_6 : var_0 ) { var_4 = Math . max ( var_4 , var_6 [ 0 ] ) ; var_5 = Math . max ( var_5 , var_6 [ 1 ] ) ; } int [ ] [ ] var_10 = new int [ var_4 + 1 ] [ var_5 + 1 ] ; for ( int [ ] var_6 : var_0 ) { var_10 [ var_6 [ 0 ] ] [ var_6 [ 1 ] ] = 1 ; } for ( int var_11 = 1 ; var_11 <= var_4 ; var_11 ++ ) { for ( int var_12 = 1 ; var_12 <= var_5 ; var_12 ++ ) { int var_13 = var_10 [ var_11 ] [ var_12 ] == 1 ? var_10 [ var_11 - 1 ] [ var_12 - 1 ] + var_10 [ var_11 ] [ var_12 ] : Math . max ( var_10 [ var_11 - 1 ] [ var_12 ] , var_10 [ var_11 ] [ var_12 - 1 ] ) ; var_10 [ var_11 ] [ var_12 ] = Math . max ( var_13 , var_10 [ var_11 ] [ var_12 ] ) ; } } return var_10 [ var_4 ] [ var_5 ] ; } " 512,977. Squares of a Sorted Array_1.java,"public int findPos(int[] A) { for (int i = 0; i < A.length; i++) { if (A[i] >= 0) return i - 1; } return 0; }","public int sample_funcname ( int [ ] var_0 ) { for ( int var_2 = 0 ; var_2 < var_0 . length ; var_2 ++ ) { if ( var_0 [ var_2 ] >= 0 ) return var_2 - 1 ; } return 0 ; } " 513,1153. String Transforms Into Another String_1.java,"public boolean canConvert(String str1, String str2) { if (str1.equals(str2)) return true; Map map = new HashMap<>(); for (int i = 0; i < str1.length(); i++) { char a = str1.charAt(i), b = str2.charAt(i); map.putIfAbsent(a, b); if (map.get(a) != b) return false; } return new HashSet<>(map.values()).size() < 26; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 . equals ( var_3 ) ) return true ; Map < Character , Character > var_8 = new HashMap < > ( ) ; for ( int var_10 = 0 ; var_10 < var_2 . length ( ) ; var_10 ++ ) { char var_13 = var_2 . charAt ( var_10 ) , var_14 = var_3 . charAt ( var_10 ) ; var_8 . putIfAbsent ( var_13 , var_14 ) ; if ( var_8 . get ( var_13 ) != var_14 ) return false ; } return new HashSet < > ( var_8 . values ( ) ) . size ( ) < 26 ; } " 514,Sort Colors_2.java,"private void swap(int[] nums, int x, int y){ int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 515,221. Maximal Square_2.java,"public int maximalSquare(char[][] matrix) { if (matrix == null || matrix.length == 0 || matrix[0] == null || matrix[0].length == 0) { return 0; } int m = matrix.length; int n = matrix[0].length; int[][] dp = new int[m][n]; int maxLen = 0; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { dp[i][j] = matrix[i][j] == '1' ? 1 : 0; maxLen = Math.max(dp[i][j], maxLen); } } for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { if (matrix[i][j] == '1') { dp[i][j] = Math.min(Math.min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1; maxLen = Math.max(dp[i][j], maxLen); } } } return maxLen * maxLen; }","public int sample_funcname ( char [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_6 = new int [ var_4 ] [ var_5 ] ; int var_7 = 0 ; for ( int var_8 = 0 ; var_8 < var_4 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 < var_5 ; var_9 ++ ) { var_6 [ var_8 ] [ var_9 ] = var_0 [ var_8 ] [ var_9 ] == '1' ? 1 : 0 ; var_7 = Math . max ( var_6 [ var_8 ] [ var_9 ] , var_7 ) ; } } for ( int var_8 = 1 ; var_8 < var_4 ; var_8 ++ ) { for ( int var_9 = 1 ; var_9 < var_5 ; var_9 ++ ) { if ( var_0 [ var_8 ] [ var_9 ] == '1' ) { var_6 [ var_8 ] [ var_9 ] = Math . min ( Math . min ( var_6 [ var_8 - 1 ] [ var_9 ] , var_6 [ var_8 ] [ var_9 - 1 ] ) , var_6 [ var_8 - 1 ] [ var_9 - 1 ] ) + 1 ; var_7 = Math . max ( var_6 [ var_8 ] [ var_9 ] , var_7 ) ; } } } return var_7 * var_7 ; } " 516,1267. Count Servers that Communicate_2.java,"private int dfs(int[][] grid, int i, int j, boolean[][] visited) { if (visited[i][j] || grid[i][j] == 0) return 0; visited[i][j] = true; int count = 1; for (int x = 0; x < grid.length; x++) { count += dfs(grid, x, j, visited); } for (int y = 0; y < grid[0].length; y++) { count += dfs(grid, i, y, visited); } return count; }","private int sample_funcname ( int [ ] [ ] grid , int i , int j , boolean [ ] [ ] visited ) { if ( visited [ i ] [ j ] || grid [ i ] [ j ] == 0 ) return 0 ; visited [ i ] [ j ] = true ; int count = 1 ; for ( int x = 0 ; x < grid . length ; x ++ ) { count += dfs ( grid , x , j , visited ) ; } for ( int y = 0 ; y < grid [ 0 ] . length ; y ++ ) { count += dfs ( grid , i , y , visited ) ; } return count ; } " 517,Maximum Subarray II_3.java,"public int maxTwoSubArrays(List nums) { if (nums == null || nums.size() == 0) { return 0; } int n = nums.size(); int[] dpLeft = new int[2]; int[] dpRight = new int[2]; dpLeft[0] = 0; dpRight[n % 2] = 0; int[] maxLeft = new int[n + 1];; int[] maxRight = new int[n + 1]; maxLeft[0] = Integer.MIN_VALUE; maxRight[n] = Integer.MIN_VALUE; for (int i = 1; i <= n; i++) { dpLeft[i % 2] = Math.max(dpLeft[(i - 1) % 2] + nums.get(i - 1), nums.get(i - 1)); maxLeft[i] = Math.max(maxLeft[i - 1], dpLeft[i % 2]); int j = n - i; dpRight[j % 2] = Math.max(dpRight[(j + 1) % 2] + nums.get(j), nums.get(j)); maxRight[j] = Math.max(maxRight[j + 1], dpRight[j % 2]); } int max = Integer.MIN_VALUE; for (int i = 1; i < n; i++) { max = Math.max(max, maxLeft[i] + maxRight[i]); } return max; }","public int sample_funcname ( List < Integer > var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return 0 ; } int var_6 = var_2 . size ( ) ; int [ ] var_8 = new int [ 2 ] ; int [ ] var_9 = new int [ 2 ] ; var_8 [ 0 ] = 0 ; var_9 [ var_6 % 2 ] = 0 ; int [ ] var_11 = new int [ var_6 + 1 ] ; ; int [ ] var_12 = new int [ var_6 + 1 ] ; var_11 [ 0 ] = Integer . MIN_VALUE ; var_12 [ var_6 ] = Integer . MIN_VALUE ; for ( int var_14 = 1 ; var_14 <= var_6 ; var_14 ++ ) { var_8 [ var_14 % 2 ] = Math . max ( var_8 [ ( var_14 - 1 ) % 2 ] + var_2 . get ( var_14 - 1 ) , var_2 . get ( var_14 - 1 ) ) ; var_11 [ var_14 ] = Math . max ( var_11 [ var_14 - 1 ] , var_8 [ var_14 % 2 ] ) ; int var_18 = var_6 - var_14 ; var_9 [ var_18 % 2 ] = Math . max ( var_9 [ ( var_18 + 1 ) % 2 ] + var_2 . get ( var_18 ) , var_2 . get ( var_18 ) ) ; var_12 [ var_18 ] = Math . max ( var_12 [ var_18 + 1 ] , var_9 [ var_18 % 2 ] ) ; } int max = Integer . MIN_VALUE ; for ( int var_14 = 1 ; var_14 < var_6 ; var_14 ++ ) { max = Math . max ( max , var_11 [ var_14 ] + var_12 [ var_14 ] ) ; } return max ; } " 518,[lint]. 2 Sum II_1.java,"public int twoSum2(int[] nums, int target) { if (nums == null || nums.length == 0) { return 0; } int count = 0; int left = 0; int right = nums.length - 1; Arrays.sort(nums); while (left < right) { if (nums[left] + nums[right] > target) { count += (right - left); right--; } else { left++; } } return count; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = 0 ; int var_6 = 0 ; int var_8 = var_0 . length - 1 ; Arrays . sort ( var_0 ) ; while ( var_6 < var_8 ) { if ( var_0 [ var_6 ] + var_0 [ var_8 ] > var_1 ) { var_5 += ( var_8 - var_6 ) ; var_8 -- ; } else { var_6 ++ ; } } return var_5 ; } " 519,Best Time to Buy and Sell Stock IV_2.java,"public int maxProfit(int k, int[] prices) { if (prices == null || prices.length == 0 || k <= 0) { return 0; } int profit = 0; int n = prices.length; int statusLength = 2 * k + 1; if (k >= n/2) { for (int i = 1; i < n; i++) { if (prices[i] > prices[i - 1]) { profit += prices[i] - prices[i - 1]; } } return profit; } int[][] dp = new int[2][statusLength]; dp[0][0] = 0; for (int i = 1; i < n; i++) { for (int j = 1; j < statusLength; j++) { if (j % 2 == 0) { dp[i % 2][j] = Math.max(dp[(i - 1) % 2][j], dp[(i - 1) % 2][j - 1] + prices[i] - prices[i - 1]); profit = Math.max(profit, dp[i % 2][j]); } else { dp[i % 2][j] = Math.max(dp[(i - 1) % 2][j] + prices[i] - prices[i - 1], dp[(i - 1) % 2][j - 1]); } } } return profit; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 || var_0 <= 0 ) { return 0 ; } int var_5 = 0 ; int var_6 = var_1 . length ; int var_9 = 2 * var_0 + 1 ; if ( var_0 >= var_6 / 2 ) { for ( int var_10 = 1 ; var_10 < var_6 ; var_10 ++ ) { if ( var_1 [ var_10 ] > var_1 [ var_10 - 1 ] ) { var_5 += var_1 [ var_10 ] - var_1 [ var_10 - 1 ] ; } } return var_5 ; } int [ ] [ ] var_11 = new int [ 2 ] [ var_9 ] ; var_11 [ 0 ] [ 0 ] = 0 ; for ( int var_10 = 1 ; var_10 < var_6 ; var_10 ++ ) { for ( int var_12 = 1 ; var_12 < var_9 ; var_12 ++ ) { if ( var_12 % 2 == 0 ) { var_11 [ var_10 % 2 ] [ var_12 ] = Math . max ( var_11 [ ( var_10 - 1 ) % 2 ] [ var_12 ] , var_11 [ ( var_10 - 1 ) % 2 ] [ var_12 - 1 ] + var_1 [ var_10 ] - var_1 [ var_10 - 1 ] ) ; var_5 = Math . max ( var_5 , var_11 [ var_10 % 2 ] [ var_12 ] ) ; } else { var_11 [ var_10 % 2 ] [ var_12 ] = Math . max ( var_11 [ ( var_10 - 1 ) % 2 ] [ var_12 ] + var_1 [ var_10 ] - var_1 [ var_10 - 1 ] , var_11 [ ( var_10 - 1 ) % 2 ] [ var_12 - 1 ] ) ; } } } return var_5 ; } " 520,Palindrome Pairs_1.java,"private boolean isPalindrome(String word) { if (word.length() == 1) { return true; } int start = 0; int end = word.length() - 1; while (start < end) { if (word.charAt(start) != word.charAt(end)) { return false; } start++; end--; } return true; }","private boolean var_0 ( String var_2 ) { if ( var_2 . length ( ) == 1 ) { return true ; } int var_6 = 0 ; int var_7 = var_2 . length ( ) - 1 ; while ( var_6 < var_7 ) { if ( var_2 . charAt ( var_6 ) != var_2 . charAt ( var_7 ) ) { return false ; } var_6 ++ ; var_7 -- ; } return true ; } " 521,72. Edit Distance_1.java,"public int minDistance(String word1, String word2) { if (word1 == null && word2 == null) return 0; if (word1 == null || word2 == null) return word1 == null ? word2.length() : word1.length(); int m = word1.length(), n = word2.length(); int[][] dp = new int[m + 1][n + 1]; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0) { dp[i][j] = j; continue; } if (j == 0) { dp[i][j] = i; continue; } if (word1.charAt(i - 1) == word2.charAt(j - 1)) { dp[i][j] = dp[i - 1][j - 1]; } else { dp[i][j] = Math.min(dp[i - 1][j - 1], Math.min(dp[i][j - 1], dp[i - 1][j])) + 1; } } } return dp[m][n]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null && var_2 == null ) return 0 ; if ( var_1 == null || var_2 == null ) return var_1 == null ? var_2 . length ( ) : var_1 . length ( ) ; int var_6 = var_1 . length ( ) , var_7 = var_2 . length ( ) ; int [ ] [ ] var_9 = new int [ var_6 + 1 ] [ var_7 + 1 ] ; for ( int var_10 = 0 ; var_10 <= var_6 ; var_10 ++ ) { for ( int var_11 = 0 ; var_11 <= var_7 ; var_11 ++ ) { if ( var_10 == 0 ) { var_9 [ var_10 ] [ var_11 ] = var_11 ; continue ; } if ( var_11 == 0 ) { var_9 [ var_10 ] [ var_11 ] = var_10 ; continue ; } if ( var_1 . charAt ( var_10 - 1 ) == var_2 . charAt ( var_11 - 1 ) ) { var_9 [ var_10 ] [ var_11 ] = var_9 [ var_10 - 1 ] [ var_11 - 1 ] ; } else { var_9 [ var_10 ] [ var_11 ] = Math . min ( var_9 [ var_10 - 1 ] [ var_11 - 1 ] , Math . min ( var_9 [ var_10 ] [ var_11 - 1 ] , var_9 [ var_10 - 1 ] [ var_11 ] ) ) + 1 ; } } } return var_9 [ var_6 ] [ var_7 ] ; } " 522,Search a 2D Matrix II_1.java,"public boolean searchMatrix(int[][] matrix, int target) { if (matrix == null || matrix.length == 0 || matrix[0].length == 0) { return false; } int row = matrix.length; int col = matrix[0].length; int x = row - 1; int y = 0; while (x >= 0 && y < col) { if (matrix[x][y] < target) { y++; } else if (matrix[x][y] > target) { x--; } else { return true; } } return false; }","public boolean var_0 ( int [ ] [ ] var_1 , int var_2 ) { if ( var_1 == null || var_1 . length == 0 || var_1 [ 0 ] . length == 0 ) { return false ; } int var_6 = var_1 . length ; int var_7 = var_1 [ 0 ] . length ; int var_9 = var_6 - 1 ; int var_10 = 0 ; while ( var_9 >= 0 && var_10 < var_7 ) { if ( var_1 [ var_9 ] [ var_10 ] < var_2 ) { var_10 ++ ; } else if ( var_1 [ var_9 ] [ var_10 ] > var_2 ) { var_9 -- ; } else { return true ; } } return false ; } " 523,Copy Books_2.java,"public int copyBooks(int[] pages, int K) { if (pages == null || pages.length == 0) { return 0; } int n = pages.length; if (K > n) { K = n; } int[][] dp = new int[K + 1][n + 1]; dp[0][0] = 0; for (int i = 1; i <= n; i++) { dp[0][i] = Integer.MAX_VALUE; } for (int k = 1; k <= K; k++) { for (int i = 1; i <= n; i++) { int sum = 0; dp[k][i] = Integer.MAX_VALUE; for (int j = i; j >= 0; j--) { dp[k][i] = Math.min(dp[k][i], Math.max(dp[k - 1][j], sum)); if (j > 0) { sum += pages[j - 1]; } } } } return dp[K][n]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = var_0 . length ; if ( var_1 > var_5 ) { var_1 = var_5 ; } int [ ] [ ] var_7 = new int [ var_1 + 1 ] [ var_5 + 1 ] ; var_7 [ 0 ] [ 0 ] = 0 ; for ( int var_8 = 1 ; var_8 <= var_5 ; var_8 ++ ) { var_7 [ 0 ] [ var_8 ] = Integer . MAX_VALUE ; } for ( int var_11 = 1 ; var_11 <= var_1 ; var_11 ++ ) { for ( int var_8 = 1 ; var_8 <= var_5 ; var_8 ++ ) { int var_12 = 0 ; var_7 [ var_11 ] [ var_8 ] = Integer . MAX_VALUE ; for ( int var_13 = var_8 ; var_13 >= 0 ; var_13 -- ) { var_7 [ var_11 ] [ var_8 ] = Math . min ( var_7 [ var_11 ] [ var_8 ] , Math . max ( var_7 [ var_11 - 1 ] [ var_13 ] , var_12 ) ) ; if ( var_13 > 0 ) { var_12 += var_0 [ var_13 - 1 ] ; } } } } return var_7 [ var_1 ] [ var_5 ] ; } " 524,House Robber II_5.java,"public int rob(int[] nums) { if (nums == null || nums.length == 0) { return 0; } else if (nums.length == 1) { return nums[0]; } else if (nums.length == 2) { return Math.max(nums[0], nums[1]); } int n = nums.length; int[] dp1 = new int[n]; dp1[0] = nums[0]; dp1[1] = Math.max(nums[0], nums[1]); for (int i = 2; i < n - 1; i++) { dp1[i] = Math.max(dp1[i - 1], dp1[i - 2] + nums[i]); } dp1[n - 1] = dp1[n - 2]; int[] dp2 = new int[n]; dp2[0] = 0; dp2[1] = nums[1]; for (int i = 2; i < n - 2; i++) { dp2[i] = Math.max(dp2[i - 1], dp2[i - 2] + nums[i]); } dp2[n - 1] = dp2[n - 3] + nums[n - 1]; return Math.max(dp2[n - 1], dp1[n - 1]); }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } else if ( var_0 . length == 1 ) { return var_0 [ 0 ] ; } else if ( var_0 . length == 2 ) { return Math . max ( var_0 [ 0 ] , var_0 [ 1 ] ) ; } int var_8 = var_0 . length ; int [ ] var_9 = new int [ var_8 ] ; var_9 [ 0 ] = var_0 [ 0 ] ; var_9 [ 1 ] = Math . max ( var_0 [ 0 ] , var_0 [ 1 ] ) ; for ( int var_10 = 2 ; var_10 < var_8 - 1 ; var_10 ++ ) { var_9 [ var_10 ] = Math . max ( var_9 [ var_10 - 1 ] , var_9 [ var_10 - 2 ] + var_0 [ var_10 ] ) ; } var_9 [ var_8 - 1 ] = var_9 [ var_8 - 2 ] ; int [ ] var_11 = new int [ var_8 ] ; var_11 [ 0 ] = 0 ; var_11 [ 1 ] = var_0 [ 1 ] ; for ( int var_10 = 2 ; var_10 < var_8 - 2 ; var_10 ++ ) { var_11 [ var_10 ] = Math . max ( var_11 [ var_10 - 1 ] , var_11 [ var_10 - 2 ] + var_0 [ var_10 ] ) ; } var_11 [ var_8 - 1 ] = var_11 [ var_8 - 3 ] + var_0 [ var_8 - 1 ] ; return Math . max ( var_11 [ var_8 - 1 ] , var_9 [ var_8 - 1 ] ) ; } " 525,Combinations_1.java,"private void dfs(List> result, List list, int index, int k, int n) { for (int i = index; i <= n; i++) { list.add(i); if (list.size() == k) { result.add(new ArrayList<>(list)); list.remove(list.size() - 1); continue; } dfs(result, list, i + 1, k, n); list.remove(list.size() - 1); } }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int index , int k , int n ) { for ( int i = index ; i <= n ; i ++ ) { list . add ( i ) ; if ( list . size ( ) == k ) { result . add ( new ArrayList < > ( list ) ) ; list . remove ( list . size ( ) - 1 ) ; continue ; } dfs ( result , list , i + 1 , k , n ) ; list . remove ( list . size ( ) - 1 ) ; } } " 526,843. Guess the Word_2.java,"private int countMatch(String a, String b) { int count = 0; for (int i = 0; i < 6; i++) { if (a.charAt(i) == b.charAt(i)) count++; } return count; }","private int sample_funcname ( String var_1 , String var_2 ) { int var_4 = 0 ; for ( int var_5 = 0 ; var_5 < 6 ; var_5 ++ ) { if ( var_1 . charAt ( var_5 ) == var_2 . charAt ( var_5 ) ) var_4 ++ ; } return var_4 ; } " 527,266. Palindrome Permutation_1.java,"public boolean canPermutePalindrome(String s) { if (s == null || s.length() == 0) return false; int[] chars = new int[256]; for (char c : s.toCharArray()) chars[c]++; int countOdd = 0; for (int i = 0; i < chars.length; i++) { countOdd += chars[i] % 2; if (countOdd > 1) return false; } return true; }","public boolean var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) return false ; int [ ] var_7 = new int [ 256 ] ; for ( char var_9 : var_2 . toCharArray ( ) ) var_7 [ var_9 ] ++ ; int var_10 = 0 ; for ( int var_11 = 0 ; var_11 < var_7 . length ; var_11 ++ ) { var_10 += var_7 [ var_11 ] % 2 ; if ( var_10 > 1 ) return false ; } return true ; } " 528,257. Binary Tree Paths_1.java,"private String convert(List path) { return String.join(""->"", path); }","private String var_0 ( List < String > var_3 ) { return String . join ( ""->"" , var_3 ) ; } " 529,1170. Compare Strings by Frequency of the Smallest Character_1.java,"private int count(String w) { int[] count = new int[26]; for (char c : w.toCharArray()) count[c - 'a']++; for (int num : count) { if (num != 0) return num; } return 0; }","private int sample_funcname ( String var_1 ) { int [ ] var_3 = new int [ 26 ] ; for ( char var_5 : var_1 . toCharArray ( ) ) var_3 [ var_5 - 'a' ] ++ ; for ( int var_7 : var_3 ) { if ( var_7 != 0 ) return var_7 ; } return 0 ; } " 530,Unique Word Abbreviation_1.java,"private String convertToAbbr(String word) { if (word == null || word.length() <= 2) { return word; } return word.charAt(0) + String.valueOf(word.length() - 2) + word.charAt(word.length() - 1); }","private String var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) <= 2 ) { return var_2 ; } return var_2 . charAt ( 0 ) + String . valueOf ( var_2 . length ( ) - 2 ) + var_2 . charAt ( var_2 . length ( ) - 1 ) ; } " 531,639. Decode Ways II_2.java,"private int countDouble(char a, char b) { if (a == '0' || (a >= '3' && a <= '9')) return 0; if (a == '1') return b == '*' ? 9 : 1; if (a == '2') { if (b == '*') return 6; if (b <= '6') return 1; return 0; } if (b >= '0' && b <= '6') return 2; if (b >= '7' && b <= '9') return 1; return 15; }","private int sample_funcname ( char var_0 , char var_1 ) { if ( var_0 == '0' || ( var_0 >= '3' && var_0 <= '9' ) ) return 0 ; if ( var_0 == '1' ) return var_1 == '*' ? 9 : 1 ; if ( var_0 == '2' ) { if ( var_1 == '*' ) return 6 ; if ( var_1 <= '6' ) return 1 ; return 0 ; } if ( var_1 >= '0' && var_1 <= '6' ) return 2 ; if ( var_1 >= '7' && var_1 <= '9' ) return 1 ; return 15 ; } " 532,Longest Substring Without Repeating Characters_3.java,"public int lengthOfLongestSubstring(String s) { if (s == null || s.length() == 0) { return 0; } HashMap map = new HashMap(); int head = 0; int max = 0; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (map.containsKey(c)) { if (map.get(c) + 1 > head) { head = map.get(c) + 1; } } map.put(c, i); String str = s.substring(head, i + 1); max = Math.max(max, str.length()); } return max; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } HashMap < Character , Integer > var_8 = new HashMap < Character , Integer > ( ) ; int var_9 = 0 ; int max = 0 ; for ( int var_11 = 0 ; var_11 < var_1 . length ( ) ; var_11 ++ ) { char var_13 = var_1 . charAt ( var_11 ) ; if ( var_8 . containsKey ( var_13 ) ) { if ( var_8 . get ( var_13 ) + 1 > var_9 ) { var_9 = var_8 . get ( var_13 ) + 1 ; } } var_8 . put ( var_13 , var_11 ) ; String var_19 = var_1 . substring ( var_9 , var_11 + 1 ) ; max = Math . max ( max , var_19 . length ( ) ) ; } return max ; } " 533,766. Toeplitz Matrix_1.java,"private boolean check(int x, int y, int[][] matrix) { int n = matrix.length, m = matrix[0].length; for (int i = x, j = y; i < n && j < m; i++, j++) { if (matrix[i][j] != matrix[x][y]) return false; } return true; }","private boolean var_0 ( int var_1 , int var_2 , int [ ] [ ] var_3 ) { int var_5 = var_3 . length , var_7 = var_3 [ 0 ] . length ; for ( int var_8 = var_1 , var_9 = var_2 ; var_8 < var_5 && var_9 < var_7 ; var_8 ++ , var_9 ++ ) { if ( var_3 [ var_8 ] [ var_9 ] != var_3 [ var_1 ] [ var_2 ] ) return false ; } return true ; } " 534,Fraction to Recurring Decimal_1.java,"public String fractionToDecimal(int numerator, int denominator) { long nume = Math.abs((long)numerator); long deno = Math.abs((long)denominator); String sign = (numerator < 0) ^ (denominator < 0) ? ""-"" : """"; if (deno == 0) { return """"; } else if (nume == 0) { return ""0""; } else if (nume % deno == 0) { return sign + nume/deno + """"; } HashMap map = new HashMap(); StringBuffer rst = new StringBuffer(sign + nume/deno + "".""); long end = nume%deno * 10; int i = 0; while (end != 0){ if (map.containsKey(end)) { rst.insert(rst.indexOf(""."") + map.get(end) + 1, ""(""); rst.append("")""); return rst.toString(); } rst.append(end/deno); map.put(end, i++); end = (end % deno) * 10; } return rst.toString(); }","public String var_0 ( int var_1 , int var_2 ) { long var_5 = Math . abs ( ( long ) var_1 ) ; long var_6 = Math . abs ( ( long ) var_2 ) ; String var_11 = ( var_1 < 0 ) ^ ( var_2 < 0 ) ? ""-"" : """" ; if ( var_6 == 0 ) { return """" ; } else if ( var_5 == 0 ) { return ""0"" ; } else if ( var_5 % var_6 == 0 ) { return var_11 + var_5 / var_6 + """" ; } HashMap < Long , Integer > var_16 = new HashMap < Long , Integer > ( ) ; StringBuffer var_19 = new StringBuffer ( var_11 + var_5 / var_6 + ""."" ) ; long var_21 = var_5 % var_6 * 10 ; int var_22 = 0 ; while ( var_21 != 0 ) { if ( var_16 . containsKey ( var_21 ) ) { var_19 . insert ( var_19 . indexOf ( ""."" ) + var_16 . get ( var_21 ) + 1 , ""("" ) ; var_19 . append ( "")"" ) ; return var_19 . toString ( ) ; } var_19 . append ( var_21 / var_6 ) ; var_16 . put ( var_21 , var_22 ++ ) ; var_21 = ( var_21 % var_6 ) * 10 ; } return var_19 . toString ( ) ; } " 535,438. Find All Anagrams in a String_3.java,"private boolean isAnagram(String a, String b) { int[] arr = new int[26]; for (int i = 0; i < a.length(); i++) { arr[a.charAt(i) - 'a']++; arr[b.charAt(i) - 'a']--; } for (int i = 0; i < 26; i++) { if (arr[i] != 0) { return false; } } return true; }","private boolean var_0 ( String var_2 , String var_3 ) { int [ ] var_5 = new int [ 26 ] ; for ( int var_7 = 0 ; var_7 < var_2 . length ( ) ; var_7 ++ ) { var_5 [ var_2 . charAt ( var_7 ) - 'a' ] ++ ; var_5 [ var_3 . charAt ( var_7 ) - 'a' ] -- ; } for ( int var_7 = 0 ; var_7 < 26 ; var_7 ++ ) { if ( var_5 [ var_7 ] != 0 ) { return false ; } } return true ; } " 536,Nim Game_2.java,"public boolean canWinNim(int n ) { if (n <= 3) { return true; } boolean[] dp = new boolean[n + 1]; dp[0] = true; dp[1] = dp[2] = dp[3] = true; for (int i = 4; i <= n; i++) { dp[i] = !(dp[i - 1] && dp[i - 2] && dp[i - 3]); } return dp[n]; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 3 ) { return true ; } boolean [ ] var_5 = new boolean [ var_1 + 1 ] ; var_5 [ 0 ] = true ; var_5 [ 1 ] = var_5 [ 2 ] = var_5 [ 3 ] = true ; for ( int var_8 = 4 ; var_8 <= var_1 ; var_8 ++ ) { var_5 [ var_8 ] = ! ( var_5 [ var_8 - 1 ] && var_5 [ var_8 - 2 ] && var_5 [ var_8 - 3 ] ) ; } return var_5 [ var_1 ] ; } " 537,665. Non-decreasing Array_1.java,"public boolean checkPossibility(int[] nums) { if (nums == null || nums.length < 0) { return false; } else if (nums.length <= 2) { return true; } int count = 0; for (int i = 0; i < nums.length - 1; i++) { if (nums[i] > nums[i + 1]) { if (i >= 1 && nums[i - 1] < nums[i + 1]) { nums[i] = nums[i + 1]; } else if (i >= 1 && nums[i - 1] > nums[i + 1]) { nums[i + 1] = nums[i]; } count++; } if (count >= 2) { return false; } } return true; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length < 0 ) { return false ; } else if ( var_1 . length <= 2 ) { return true ; } int var_6 = 0 ; for ( int var_7 = 0 ; var_7 < var_1 . length - 1 ; var_7 ++ ) { if ( var_1 [ var_7 ] > var_1 [ var_7 + 1 ] ) { if ( var_7 >= 1 && var_1 [ var_7 - 1 ] < var_1 [ var_7 + 1 ] ) { var_1 [ var_7 ] = var_1 [ var_7 + 1 ] ; } else if ( var_7 >= 1 && var_1 [ var_7 - 1 ] > var_1 [ var_7 + 1 ] ) { var_1 [ var_7 + 1 ] = var_1 [ var_7 ] ; } var_6 ++ ; } if ( var_6 >= 2 ) { return false ; } } return true ; } " 538,Word Search_2.java,"public boolean search(char[][] board, String word, int i, int j, int start) { if (start == word.length()) { return true; } if (i < 0 || i >= board.length || j < 0 || j >= board[0].length || board[i][j] != word.charAt(start)) { return false; } board[i][j] = '#'; boolean rst = search(board, word, i, j - 1, start + 1) || search(board, word, i, j + 1, start + 1) || search(board, word, i + 1, j, start + 1) || search(board, word, i - 1, j, start + 1); board[i][j] = word.charAt(start); return rst; }","public boolean sample_funcname ( char [ ] [ ] board , String word , int i , int j , int start ) { if ( start == word . length ( ) ) { return true ; } if ( i < 0 || i >= board . length || j < 0 || j >= board [ 0 ] . length || board [ i ] [ j ] != word . charAt ( start ) ) { return false ; } board [ i ] [ j ] = '#' ; boolean rst = search ( board , word , i , j - 1 , start + 1 ) || search ( board , word , i , j + 1 , start + 1 ) || search ( board , word , i + 1 , j , start + 1 ) || search ( board , word , i - 1 , j , start + 1 ) ; board [ i ] [ j ] = word . charAt ( start ) ; return rst ; } " 539,674. Longest Continuous Increasing Subsequence_2.java,"public int findLengthOfLCIS(int[] nums) { if (nums == null || nums.length == 0) return 0; int max = 1, size = 1; for (int i = 1; i < nums.length; i++) { if (nums[i] > nums[i - 1]) size++; else size = 1; max = Math.max(size, max); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int max = 1 , var_6 = 1 ; for ( int var_7 = 1 ; var_7 < var_0 . length ; var_7 ++ ) { if ( var_0 [ var_7 ] > var_0 [ var_7 - 1 ] ) var_6 ++ ; else var_6 = 1 ; max = Math . max ( var_6 , max ) ; } return max ; } " 540,Longest Increasing Subsequence_1.java,"public int lengthOfLIS(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int[] dp = new int[n]; int max = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { if (nums[i] > nums[j]) { dp[i] = Math.max(dp[i], dp[j] + 1); } } max = Math.max(dp[i], max); } return max + 1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int [ ] var_5 = new int [ var_4 ] ; int max = 0 ; for ( int var_7 = 0 ; var_7 < var_4 ; var_7 ++ ) { for ( int var_8 = 0 ; var_8 < var_7 ; var_8 ++ ) { if ( var_0 [ var_7 ] > var_0 [ var_8 ] ) { var_5 [ var_7 ] = Math . max ( var_5 [ var_7 ] , var_5 [ var_8 ] + 1 ) ; } } max = Math . max ( var_5 [ var_7 ] , max ) ; } return max + 1 ; } " 541,Subsets II_6.java,"public void dfs(List> rst, ArrayList list, int index, int[] nums) { if (!rst.contains(list)) { rst.add(new ArrayList(list)); } for (int i = index; i < nums.length; i++) { list.add(nums[i]); dfs(rst, list, i + 1, nums); list.remove(list.size() - 1); } }","public void sample_funcname ( List < List < Integer >> rst , ArrayList < Integer > list , int index , int [ ] nums ) { if ( ! rst . contains ( list ) ) { rst . add ( new ArrayList < Integer > ( list ) ) ; } for ( int i = index ; i < nums . length ; i ++ ) { list . add ( nums [ i ] ) ; dfs ( rst , list , i + 1 , nums ) ; list . remove ( list . size ( ) - 1 ) ; } } " 542,42. Trapping Rain Water_4.java,"public int trap(int[] height) { if (height == null || height.length == 0) return 0; final Stack stack = new Stack<>(); int total = 0; stack.push(0); for (int i = 1; i < height.length; i++) { int curr = height[i]; if (curr >= height[stack.peek()]) { int bottom = height[stack.pop()]; while (!stack.isEmpty() && curr >= height[stack.peek()]) { int leftBound = stack.pop(); total += (height[leftBound] - bottom) * (i - leftBound - 1); bottom = height[leftBound]; } if (!stack.isEmpty() && curr < height[stack.peek()]) { total += (curr - bottom) * (i - stack.peek() - 1); } } stack.push(i); } return total; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; final Stack < Integer > var_6 = new Stack < > ( ) ; int var_7 = 0 ; var_6 . push ( 0 ) ; for ( int var_10 = 1 ; var_10 < var_0 . length ; var_10 ++ ) { int var_11 = var_0 [ var_10 ] ; if ( var_11 >= var_0 [ var_6 . peek ( ) ] ) { int var_14 = var_0 [ var_6 . pop ( ) ] ; while ( ! var_6 . isEmpty ( ) && var_11 >= var_0 [ var_6 . peek ( ) ] ) { int var_16 = var_6 . pop ( ) ; var_7 += ( var_0 [ var_16 ] - var_14 ) * ( var_10 - var_16 - 1 ) ; var_14 = var_0 [ var_16 ] ; } if ( ! var_6 . isEmpty ( ) && var_11 < var_0 [ var_6 . peek ( ) ] ) { var_7 += ( var_11 - var_14 ) * ( var_10 - var_6 . peek ( ) - 1 ) ; } } var_6 . push ( var_10 ) ; } return var_7 ; } " 543,567. Permutation in String_2.java,"private Integer[] countFreq(String s) { Integer[] freq = new Integer[256]; for (char c : s.toCharArray()) freq[c] = freq[c] == null ? 1 : freq[c] + 1; return freq; }","private Integer [ ] var_0 ( String var_2 ) { Integer [ ] var_5 = new Integer [ 256 ] ; for ( char var_7 : var_2 . toCharArray ( ) ) var_5 [ var_7 ] = var_5 [ var_7 ] == null ? 1 : var_5 [ var_7 ] + 1 ; return var_5 ; } " 544,327. Count of Range Sum_2.java,"private long[] calcPreSum(int[] nums) { long[] preSum = new long[nums.length + 1]; for (int i = 1; i < preSum.length; i++) { preSum[i] = preSum[i - 1] + nums[i - 1]; } return preSum; }","private long [ ] sample_funcname ( int [ ] var_0 ) { long [ ] var_3 = new long [ var_0 . length + 1 ] ; for ( int var_4 = 1 ; var_4 < var_3 . length ; var_4 ++ ) { var_3 [ var_4 ] = var_3 [ var_4 - 1 ] + var_0 [ var_4 - 1 ] ; } return var_3 ; } " 545,1249. Minimum Remove to Make Valid Parentheses_1.java,"public String minRemoveToMakeValid(String s) { Set set = new HashSet<>(); Stack stack = new Stack<>(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '(') stack.push(i); if (c == ')') { if (!stack.isEmpty()) stack.pop(); else set.add(i); } } while (!stack.isEmpty()) set.add(stack.pop()); StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { if (!set.contains(i)) sb.append(s.charAt(i)); } return sb.toString(); }","public String var_0 ( String var_2 ) { Set < Integer > var_6 = new HashSet < > ( ) ; Stack < Integer > var_8 = new Stack < > ( ) ; for ( int var_10 = 0 ; var_10 < var_2 . length ( ) ; var_10 ++ ) { char var_13 = var_2 . charAt ( var_10 ) ; if ( var_13 == '(' ) var_8 . push ( var_10 ) ; if ( var_13 == ')' ) { if ( ! var_8 . isEmpty ( ) ) var_8 . pop ( ) ; else var_6 . add ( var_10 ) ; } } while ( ! var_8 . isEmpty ( ) ) var_6 . add ( var_8 . pop ( ) ) ; StringBuffer var_21 = new StringBuffer ( ) ; for ( int var_10 = 0 ; var_10 < var_2 . length ( ) ; var_10 ++ ) { if ( ! var_6 . contains ( var_10 ) ) var_21 . append ( var_2 . charAt ( var_10 ) ) ; } return var_21 . toString ( ) ; } " 546,Backspace String Compare_1.java,"private String type(String s) { Stack stack = new Stack<>(); for (char c : s.toCharArray()) { if (c == '#') { if (!stack.isEmpty()) stack.pop(); } else { stack.push(c); } } StringBuffer sb = new StringBuffer(); while (!stack.isEmpty()) { sb.append(stack.pop()); } return sb.toString(); }","private String var_0 ( String var_2 ) { Stack < Character > var_5 = new Stack < > ( ) ; for ( char var_7 : var_2 . toCharArray ( ) ) { if ( var_7 == '#' ) { if ( ! var_5 . isEmpty ( ) ) var_5 . pop ( ) ; } else { var_5 . push ( var_7 ) ; } } StringBuffer var_13 = new StringBuffer ( ) ; while ( ! var_5 . isEmpty ( ) ) { var_13 . append ( var_5 . pop ( ) ) ; } return var_13 . toString ( ) ; } " 547,636. Exclusive Time of Functions_1.java,"public int[] exclusiveTime(int n, List logs) { int[] rst = new int[n]; Stack stack = new Stack<>(); int timestamp = 0; for (String log : logs) { String[] parts = log.split("":""); int task = Integer.parseInt(parts[0]); boolean start = parts[1].equals(""start""); int time = Integer.parseInt(parts[2]); if (!stack.isEmpty()) rst[stack.peek()] += time - timestamp; timestamp = time; if (start) stack.push(task); else { int endTask = stack.pop(); rst[endTask] += 1; timestamp++; } } return rst; }","public int [ ] sample_funcname ( int var_0 , List < String > var_3 ) { int [ ] var_4 = new int [ var_0 ] ; Stack < Integer > var_7 = new Stack < > ( ) ; int var_9 = 0 ; for ( String var_10 : var_3 ) { String [ ] var_13 = var_10 . split ( "":"" ) ; int var_15 = Integer . parseInt ( var_13 [ 0 ] ) ; boolean var_20 = var_13 [ 1 ] . equals ( ""start"" ) ; int var_22 = Integer . parseInt ( var_13 [ 2 ] ) ; if ( ! var_7 . isEmpty ( ) ) var_4 [ var_7 . peek ( ) ] += var_22 - var_9 ; var_9 = var_22 ; if ( var_20 ) var_7 . push ( var_15 ) ; else { int var_27 = var_7 . pop ( ) ; var_4 [ var_27 ] += 1 ; var_9 ++ ; } } return var_4 ; } " 548,275. H-Index II_1.java,"public int hIndex(int[] citations) { if (citations == null || citations.length == 0) { return 0; } int n = citations.length; int start = 0, end = n - 1; while (start + 1 < end) { int mid = start + (end - start) / 2; int h = n - mid; if (citations[mid] < h) start = mid; else { if (mid - 1 >= 0 && citations[mid - 1] <= h) return h; end = mid; } } if (citations[start] >= n - start) return n - start; if (citations[end] >= n - end) return n - end; return 0; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = 0 , var_7 = var_4 - 1 ; while ( var_5 + 1 < var_7 ) { int var_9 = var_5 + ( var_7 - var_5 ) / 2 ; int var_10 = var_4 - var_9 ; if ( var_0 [ var_9 ] < var_10 ) var_5 = var_9 ; else { if ( var_9 - 1 >= 0 && var_0 [ var_9 - 1 ] <= var_10 ) return var_10 ; var_7 = var_9 ; } } if ( var_0 [ var_5 ] >= var_4 - var_5 ) return var_4 - var_5 ; if ( var_0 [ var_7 ] >= var_4 - var_7 ) return var_4 - var_7 ; return 0 ; } " 549,694. Number of Distinct Islands_1.java,"private boolean validateInput(int[][] grid, int x, int y) { return x < 0 || x >= grid.length || y < 0 || y >= grid[0].length || grid[x][y] == 0; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 < 0 || var_2 >= var_1 . length || var_3 < 0 || var_3 >= var_1 [ 0 ] . length || var_1 [ var_2 ] [ var_3 ] == 0 ; } " 550,767. Reorganize String_2.java,"private Map buildCountMap(String S) { Map map = new HashMap<>(); for (char c : S.toCharArray()) { int count = map.getOrDefault(c, 0) + 1; if (count > (S.length() + 1) / 2) return new HashMap<>(); map.put(c, count); } return map; }","private Map < Character , Integer > var_2 ( String var_4 ) { Map < Character , Integer > var_7 = new HashMap < > ( ) ; for ( char var_9 : var_4 . toCharArray ( ) ) { int var_13 = var_7 . getOrDefault ( var_9 , 0 ) + 1 ; if ( var_13 > ( var_4 . length ( ) + 1 ) / 2 ) return new HashMap < > ( ) ; var_7 . put ( var_9 , var_13 ) ; } return var_7 ; } " 551,Maximal Rectangle_1.java,"private int findLargestRectInHistogram(int[] height) { Stack stack = new Stack<>(); int m = height.length; int max = 0; for (int i = 0; i <= m; i++) { int currHeight = i == m ? -1 : height[i]; while (!stack.isEmpty() && currHeight <= height[stack.peek()]) { int peekHeight = height[stack.pop()]; int width = stack.isEmpty() ? i : i - stack.peek() - 1; max = Math.max(max, peekHeight * width); } stack.push(i); } return max; }","private int sample_funcname ( int [ ] var_0 ) { Stack < Integer > var_3 = new Stack < > ( ) ; int var_5 = var_0 . length ; int max = 0 ; for ( int var_8 = 0 ; var_8 <= var_5 ; var_8 ++ ) { int var_10 = var_8 == var_5 ? - 1 : var_0 [ var_8 ] ; while ( ! var_3 . isEmpty ( ) && var_10 <= var_0 [ var_3 . peek ( ) ] ) { int var_14 = var_0 [ var_3 . pop ( ) ] ; int var_15 = var_3 . isEmpty ( ) ? var_8 : var_8 - var_3 . peek ( ) - 1 ; max = Math . max ( max , var_14 * var_15 ) ; } var_3 . push ( var_8 ) ; } return max ; } " 552,Next Closest Time_1.java,"public String nextClosestTime(String time) { if (time == null || time.length() == 0) { return time; } Set nums = new HashSet<>(); for (int i = 0; i < time.length(); i++) { if (time.charAt(i) != ':') { nums.add(time.charAt(i) - '0'); } } Set hh = new HashSet<>(); for (int i : nums) { for (int j : nums) { int num = i * 10 + j; if (num >= 0 && num < 24) { hh.add(i + """" + j); } } } Set mm = new HashSet<>(); for (int i : nums) { for (int j : nums) { int num = i * 10 + j; if (num >= 0 && num < 60) { mm.add(i + """" + j); } } } String result = time; int timeValue = Integer.parseInt(time.substring(0, 2)) * 60 + Integer.parseInt(time.substring(3)); int diff = Integer.MAX_VALUE; for (String h : hh) { for (String m : mm) { String newTime = h + "":"" + m; int value = 0; if (newTime.compareTo(time) <= 0) { value = Integer.parseInt(h) * 60 + Integer.parseInt(m) + 1440; } else { value = Integer.parseInt(h) * 60 + Integer.parseInt(m); } if (value - timeValue < diff) { diff = value - timeValue; result = newTime; } } } return result; }","public String var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) { return var_2 ; } Set < Integer > var_9 = new HashSet < > ( ) ; for ( int var_10 = 0 ; var_10 < var_2 . length ( ) ; var_10 ++ ) { if ( var_2 . charAt ( var_10 ) != ':' ) { var_9 . add ( var_2 . charAt ( var_10 ) - '0' ) ; } } Set < String > var_15 = new HashSet < > ( ) ; for ( int var_10 : var_9 ) { for ( int var_16 : var_9 ) { int var_18 = var_10 * 10 + var_16 ; if ( var_18 >= 0 && var_18 < 24 ) { var_15 . add ( var_10 + """" + var_16 ) ; } } } Set < String > var_21 = new HashSet < > ( ) ; for ( int var_10 : var_9 ) { for ( int var_16 : var_9 ) { int var_18 = var_10 * 10 + var_16 ; if ( var_18 >= 0 && var_18 < 60 ) { var_21 . add ( var_10 + """" + var_16 ) ; } } } String var_23 = var_2 ; int var_28 = Integer . parseInt ( var_2 . substring ( 0 , 2 ) ) * 60 + Integer . parseInt ( var_2 . substring ( 3 ) ) ; int var_30 = Integer . MAX_VALUE ; for ( String var_31 : var_15 ) { for ( String var_32 : var_21 ) { String var_34 = var_31 + "":"" + var_32 ; int var_35 = 0 ; if ( var_34 . compareTo ( var_2 ) <= 0 ) { var_35 = Integer . parseInt ( var_31 ) * 60 + Integer . parseInt ( var_32 ) + 1440 ; } else { var_35 = Integer . parseInt ( var_31 ) * 60 + Integer . parseInt ( var_32 ) ; } if ( var_35 - var_28 < var_30 ) { var_30 = var_35 - var_28 ; var_23 = var_34 ; } } } return var_23 ; } " 553,53. Maximum Subarray_4.java,"public int maxSubArray(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length; int[] dp = new int[2]; dp[0] = 0; int max = Integer.MIN_VALUE; for (int i = 1; i <= n; i++) { dp[i % 2] = Math.max(dp[(i - 1) % 2] + nums[i - 1], nums[i - 1]); max = Math.max(max, dp[i % 2]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length ; int [ ] var_6 = new int [ 2 ] ; var_6 [ 0 ] = 0 ; int max = Integer . MIN_VALUE ; for ( int var_11 = 1 ; var_11 <= var_4 ; var_11 ++ ) { var_6 [ var_11 % 2 ] = Math . max ( var_6 [ ( var_11 - 1 ) % 2 ] + var_0 [ var_11 - 1 ] , var_0 [ var_11 - 1 ] ) ; max = Math . max ( max , var_6 [ var_11 % 2 ] ) ; } return max ; } " 554,152. Maximum Product Subarray_3.java,"public int maxProduct(int[] nums) { int n = nums.length; int[] maxProduct = new int[n], minProduct = new int[n]; maxProduct[0] = nums[0]; minProduct[0] = nums[0]; int max = nums[0]; for (int i = 1; i < n; i++) { int num = nums[i]; maxProduct[i] = Math.max(num, Math.max(maxProduct[i - 1] * num, minProduct[i - 1] * num)); minProduct[i] = Math.min(num, Math.min(minProduct[i - 1] * num, maxProduct[i - 1] * num)); max = Math.max(max, maxProduct[i]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; int [ ] var_3 = new int [ var_2 ] , var_4 = new int [ var_2 ] ; var_3 [ 0 ] = var_0 [ 0 ] ; var_4 [ 0 ] = var_0 [ 0 ] ; int max = var_0 [ 0 ] ; for ( int var_8 = 1 ; var_8 < var_2 ; var_8 ++ ) { int var_9 = var_0 [ var_8 ] ; var_3 [ var_8 ] = Math . max ( var_9 , Math . max ( var_3 [ var_8 - 1 ] * var_9 , var_4 [ var_8 - 1 ] * var_9 ) ) ; var_4 [ var_8 ] = Math . min ( var_9 , Math . min ( var_4 [ var_8 - 1 ] * var_9 , var_3 [ var_8 - 1 ] * var_9 ) ) ; max = Math . max ( max , var_3 [ var_8 ] ) ; } return max ; } " 555,46. Permutations_5.java,"private void populateQueue(Queue> queue, List list, int[] nums) { for (int num : nums) { if (list.contains(num)) continue; list.add(num); queue.offer(new ArrayList<>(list)); list.remove(list.size() - 1); } }","private void var_0 ( Queue < List < Integer >> var_4 , List < Integer > var_5 , int [ ] var_6 ) { for ( int var_7 : var_6 ) { if ( var_5 . contains ( var_7 ) ) continue ; var_5 . add ( var_7 ) ; var_4 . offer ( new ArrayList < > ( var_5 ) ) ; var_5 . remove ( var_5 . size ( ) - 1 ) ; } } " 556,Missing Number_1.java,"private void swap(int[] nums, int x, int y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 557,283. Move Zeroes_1.java,"public void moveZeroes(int[] nums) { if (nums == null) return; int index = 0, n = nums.length; for (int i = 0; i < n; i++) { if (nums[i] != 0) nums[index++] = nums[i]; } for (int i = index; i < n; i++) { nums[i] = 0; } }","public void var_0 ( int [ ] var_1 ) { if ( var_1 == null ) return ; int var_4 = 0 , var_6 = var_1 . length ; for ( int var_7 = 0 ; var_7 < var_6 ; var_7 ++ ) { if ( var_1 [ var_7 ] != 0 ) var_1 [ var_4 ++ ] = var_1 [ var_7 ] ; } for ( int var_7 = var_4 ; var_7 < var_6 ; var_7 ++ ) { var_1 [ var_7 ] = 0 ; } } " 558,680. Valid Palindrome II_1.java,"public boolean validate(String s, int start, int end, boolean state) { if (start > end) return false; while (start < end) { if (s.charAt(start) == s.charAt(end)) { start++; end--; continue; } else if (state) { return validate(s, start + 1, end, false) || validate(s, start, end - 1, false); } return false; } return true; }","public boolean sample_funcname ( String s , int start , int end , boolean state ) { if ( start > end ) return false ; while ( start < end ) { if ( s . charAt ( start ) == s . charAt ( end ) ) { start ++ ; end -- ; continue ; } else if ( state ) { return validate ( s , start + 1 , end , false ) || validate ( s , start , end - 1 , false ) ; } return false ; } return true ; } " 559,349. Intersection of Two Arrays_1.java,"public int[] intersection(int[] nums1, int[] nums2) { Set set = new HashSet<>(); for (int num : nums1) set.add(num); Set rst = new HashSet<>(); for (int num: nums2) { if (set.contains(num)) rst.add(num); } int i = 0; int[] result = new int[rst.size()]; for (int num : rst) result[i++] = num; return result; }","public int [ ] sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { Set < Integer > var_5 = new HashSet < > ( ) ; for ( int var_6 : var_0 ) var_5 . add ( var_6 ) ; Set < Integer > var_8 = new HashSet < > ( ) ; for ( int var_6 : var_1 ) { if ( var_5 . contains ( var_6 ) ) var_8 . add ( var_6 ) ; } int var_11 = 0 ; int [ ] var_13 = new int [ var_8 . size ( ) ] ; for ( int var_6 : var_8 ) var_13 [ var_11 ++ ] = var_6 ; return var_13 ; } " 560,Backpack II_3.java,"public int backPackII(int m, int[] A, int V[]) { if (A == null || V == null || A.length != V.length) { return 0; } int n = A.length; int[][] dp = new int[n + 1][m + 1]; for (int j = 0; j <= m; j++) { dp[0][j] = -1; } dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp[i][j] = dp[i - 1][j]; if (j - A[i - 1] >= 0 && dp[i - 1][j - A[i - 1]] != -1) { dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - A[i - 1]] + V[i - 1]); } } } int rst = 0; for (int j = 0; j <= m; j++) { if (dp[n][j] != -1) { rst = Math.max(rst, dp[n][j]); } } return rst; }","public int sample_funcname ( int var_0 , int [ ] var_1 , int var_2 [ ] ) { if ( var_1 == null || var_2 == null || var_1 . length != var_2 . length ) { return 0 ; } int var_6 = var_1 . length ; int [ ] [ ] var_8 = new int [ var_6 + 1 ] [ var_0 + 1 ] ; for ( int var_9 = 0 ; var_9 <= var_0 ; var_9 ++ ) { var_8 [ 0 ] [ var_9 ] = - 1 ; } var_8 [ 0 ] [ 0 ] = 0 ; for ( int var_10 = 1 ; var_10 <= var_6 ; var_10 ++ ) { for ( int var_9 = 1 ; var_9 <= var_0 ; var_9 ++ ) { var_8 [ var_10 ] [ var_9 ] = var_8 [ var_10 - 1 ] [ var_9 ] ; if ( var_9 - var_1 [ var_10 - 1 ] >= 0 && var_8 [ var_10 - 1 ] [ var_9 - var_1 [ var_10 - 1 ] ] != - 1 ) { var_8 [ var_10 ] [ var_9 ] = Math . max ( var_8 [ var_10 ] [ var_9 ] , var_8 [ var_10 - 1 ] [ var_9 - var_1 [ var_10 - 1 ] ] + var_2 [ var_10 - 1 ] ) ; } } } int var_13 = 0 ; for ( int var_9 = 0 ; var_9 <= var_0 ; var_9 ++ ) { if ( var_8 [ var_6 ] [ var_9 ] != - 1 ) { var_13 = Math . max ( var_13 , var_8 [ var_6 ] [ var_9 ] ) ; } } return var_13 ; } " 561,Brick Wall_1.java,"private boolean validate(List> wall) { return wall == null || wall.size() == 0 || wall.get(0) == null || wall.get(0).size() == 0; }","private boolean var_0 ( List < List < Integer >> var_3 ) { return var_3 == null || var_3 . size ( ) == 0 || var_3 . get ( 0 ) == null || var_3 . get ( 0 ) . size ( ) == 0 ; } " 562,39. Combination Sum_3.java,"private void dfs(List> result, List list, int[] candidates, int index, int target) { for (int i = index; i < candidates.length; i++) { int value = candidates[i]; list.add(value); if (target == value) result.add(new ArrayList<>(list)); else if (target - value > 0) dfs(result, list, candidates, i, target - value); list.remove(list.size() - 1); } }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int [ ] candidates , int index , int target ) { for ( int i = index ; i < candidates . length ; i ++ ) { int value = candidates [ i ] ; list . add ( value ) ; if ( target == value ) result . add ( new ArrayList < > ( list ) ) ; else if ( target - value > 0 ) dfs ( result , list , candidates , i , target - value ) ; list . remove ( list . size ( ) - 1 ) ; } } " 563,Russian Doll Envelopes_1.java,"public int maxEnvelopes(int[][] envelopes) { if (envelopes == null || envelopes.length == 0 || envelopes[0] == null || envelopes[0].length == 0) { return 0; } Arrays.sort(envelopes, new Comparator() { public int compare (int[] a, int[] b) { if (a[0] == b[0]) { return a[1] - b[1]; } else { return a[0] - b[0]; } } }); int n = envelopes.length; int[] dp = new int[n]; int max = 0; for (int i = 0; i < n; i++) { dp[i] = 1; for (int j = 0; j < i; j++) { if(envelopes[j][0] < envelopes[i][0] && envelopes[j][1] < envelopes[i][1]) { dp[i] = Math.max(dp[i], dp[j] + 1); } } max = Math.max(max, dp[i]); } return max; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return 0 ; } Arrays . sort ( var_0 , new Comparator < int [ ] > ( ) { public int compare ( int [ ] var_8 , int [ ] var_9 ) { if ( var_8 [ 0 ] == var_9 [ 0 ] ) { return var_8 [ 1 ] - var_9 [ 1 ] ; } else { return var_8 [ 0 ] - var_9 [ 0 ] ; } } } ) ; int var_11 = var_0 . length ; int [ ] var_12 = new int [ var_11 ] ; int max = 0 ; for ( int var_14 = 0 ; var_14 < var_11 ; var_14 ++ ) { var_12 [ var_14 ] = 1 ; for ( int var_15 = 0 ; var_15 < var_14 ; var_15 ++ ) { if ( var_0 [ var_15 ] [ 0 ] < var_0 [ var_14 ] [ 0 ] && var_0 [ var_15 ] [ 1 ] < var_0 [ var_14 ] [ 1 ] ) { var_12 [ var_14 ] = Math . max ( var_12 [ var_14 ] , var_12 [ var_15 ] + 1 ) ; } } max = Math . max ( max , var_12 [ var_14 ] ) ; } return max ; } " 564,221. Maximal Square_1.java,"public int maximalSquare(char[][] matrix) { if (matrix == null || matrix.length == 0 || matrix[0] == null || matrix[0].length == 0) return 0; int m = matrix.length, n = matrix[0].length; int[][] dp = new int[m + 1][n + 1]; int maxLen = 0; for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { if (matrix[i - 1][j - 1] == '0') continue; dp[i][j] = Math.min(Math.min(dp[i][j-1], dp[i-1][j]), dp[i-1][j-1]) + 1; maxLen = Math.max(maxLen, dp[i][j]); } } return maxLen * maxLen; }","public int sample_funcname ( char [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_7 = new int [ var_4 + 1 ] [ var_5 + 1 ] ; int var_8 = 0 ; for ( int var_9 = 1 ; var_9 <= var_4 ; var_9 ++ ) { for ( int var_10 = 1 ; var_10 <= var_5 ; var_10 ++ ) { if ( var_0 [ var_9 - 1 ] [ var_10 - 1 ] == '0' ) continue ; var_7 [ var_9 ] [ var_10 ] = Math . min ( Math . min ( var_7 [ var_9 ] [ var_10 - 1 ] , var_7 [ var_9 - 1 ] [ var_10 ] ) , var_7 [ var_9 - 1 ] [ var_10 - 1 ] ) + 1 ; var_8 = Math . max ( var_8 , var_7 [ var_9 ] [ var_10 ] ) ; } } return var_8 * var_8 ; } " 565,51. N-Queens_3.java,"private boolean validate(List list, int newColNum) { int newRowNum = list.size(); for (int rowNum = 0; rowNum < list.size(); rowNum++) { int colNum = list.get(rowNum); if (colNum == newColNum || Math.abs(rowNum - newRowNum) == Math.abs(colNum - newColNum)) { return false; } } return true; }","private boolean var_0 ( List < Integer > var_3 , int var_4 ) { int var_6 = var_3 . size ( ) ; for ( int var_8 = 0 ; var_8 < var_3 . size ( ) ; var_8 ++ ) { int var_10 = var_3 . get ( var_8 ) ; if ( var_10 == var_4 || Math . abs ( var_8 - var_6 ) == Math . abs ( var_10 - var_4 ) ) { return false ; } } return true ; } " 566,Palindromic Substrings_1.java,"private boolean[][] buildPalin(String s) { int n = s.length(); boolean[][] isPalin = new boolean[n][n]; for (int i = 0; i < n; i++) isPalin[i][i] = true; for (int j = 0; j < n; j++) { for (int i = 0; i <= j; i++) { isPalin[i][j] = s.charAt(i) == s.charAt(j) && (j - i <= 1 || isPalin[i + 1][j - 1]); } } return isPalin; }","private boolean [ ] [ ] var_0 ( String var_2 ) { int var_4 = var_2 . length ( ) ; boolean [ ] [ ] var_6 = new boolean [ var_4 ] [ var_4 ] ; for ( int var_8 = 0 ; var_8 < var_4 ; var_8 ++ ) var_6 [ var_8 ] [ var_8 ] = true ; for ( int var_9 = 0 ; var_9 < var_4 ; var_9 ++ ) { for ( int var_8 = 0 ; var_8 <= var_9 ; var_8 ++ ) { var_6 [ var_8 ] [ var_9 ] = var_2 . charAt ( var_8 ) == var_2 . charAt ( var_9 ) && ( var_9 - var_8 <= 1 || var_6 [ var_8 + 1 ] [ var_9 - 1 ] ) ; } } return var_6 ; } " 567,1004. Max Consecutive Ones III_1.java,"public int longestOnes(int[] A, int k) { int left = 0, right = 0, n = A.length; while (right < n) { if (A[right++] == 0) k--; if (k < 0) { if (A[left] == 0) k++; left++; } } return right - left; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = 0 , var_4 = 0 , var_6 = var_0 . length ; while ( var_4 < var_6 ) { if ( var_0 [ var_4 ++ ] == 0 ) var_1 -- ; if ( var_1 < 0 ) { if ( var_0 [ var_3 ] == 0 ) var_1 ++ ; var_3 ++ ; } } return var_4 - var_3 ; } " 568,Sort Colors_1.java,"private void swap(int[] nums, int x, int y){ int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 569,415. Add Strings_3.java,"private String convertToString(int[] result) { int n = result[result.length - 1] == 0 ? result.length - 1: result.length; StringBuffer sb = new StringBuffer(); for (int i = 0; i < n; i++) { char c = (char)('0' + result[n - i - 1]); sb.append(c); } return sb.toString(); }","private String var_0 ( int [ ] var_1 ) { int var_5 = var_1 [ var_1 . length - 1 ] == 0 ? var_1 . length - 1 : var_1 . length ; StringBuffer var_7 = new StringBuffer ( ) ; for ( int var_8 = 0 ; var_8 < var_5 ; var_8 ++ ) { char var_10 = ( char ) ( '0' + var_1 [ var_5 - var_8 - 1 ] ) ; var_7 . append ( var_10 ) ; } return var_7 . toString ( ) ; } " 570,[lint]. 2 Sum II_2.java,"public int binarySearch(int[] nums, int target, int start, int end) { int mid; int sum; while (start + 1 < end) { mid = start + (end - start) /2; if (mid - 1 >= 0 && nums[mid-1] <= target && target < nums[mid]) { return mid; } else if (mid + 1 < nums.length && nums[mid] <= target && target < nums[mid + 1]) { return mid + 1; } else if (target < nums[mid]) { end = mid; } else { start = mid; } } if (nums[start] > target) { return start; } return (nums[end] > target) ? end : nums.length; }","public int sample_funcname ( int [ ] var_0 , int var_1 , int var_2 , int var_3 ) { int var_4 ; int var_5 ; while ( var_2 + 1 < var_3 ) { var_4 = var_2 + ( var_3 - var_2 ) / 2 ; if ( var_4 - 1 >= 0 && var_0 [ var_4 - 1 ] <= var_1 && var_1 < var_0 [ var_4 ] ) { return var_4 ; } else if ( var_4 + 1 < var_0 . length && var_0 [ var_4 ] <= var_1 && var_1 < var_0 [ var_4 + 1 ] ) { return var_4 + 1 ; } else if ( var_1 < var_0 [ var_4 ] ) { var_3 = var_4 ; } else { var_2 = var_4 ; } } if ( var_0 [ var_2 ] > var_1 ) { return var_2 ; } return ( var_0 [ var_3 ] > var_1 ) ? var_3 : var_0 . length ; } " 571,198. House Robber_3.java,"public int rob(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length; int[][] dp = new int[n][2]; dp[0][1] = nums[0]; for (int i = 1; i < n; i++) { dp[i][0] = Math.max(dp[i - 1][1], dp[i - 1][0]); dp[i][1] = dp[i - 1][0] + nums[i]; } return Math.max(dp[n - 1][0], dp[n - 1][1]); }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length ; int [ ] [ ] var_6 = new int [ var_4 ] [ 2 ] ; var_6 [ 0 ] [ 1 ] = var_0 [ 0 ] ; for ( int var_8 = 1 ; var_8 < var_4 ; var_8 ++ ) { var_6 [ var_8 ] [ 0 ] = Math . max ( var_6 [ var_8 - 1 ] [ 1 ] , var_6 [ var_8 - 1 ] [ 0 ] ) ; var_6 [ var_8 ] [ 1 ] = var_6 [ var_8 - 1 ] [ 0 ] + var_0 [ var_8 ] ; } return Math . max ( var_6 [ var_4 - 1 ] [ 0 ] , var_6 [ var_4 - 1 ] [ 1 ] ) ; } " 572,1267. Count Servers that Communicate_1.java,"public int countServers(int[][] grid) { int total = 0; int m = grid.length, n = grid[0].length; int[] row = new int[m], col = new int[n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (grid[i][j] == 1) { total++; row[i]++; col[j]++; } } } for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (grid[i][j] == 1 && row[i] == 1 && col[j] == 1) { total--; } } } return total; }","public int sample_funcname ( int [ ] [ ] var_0 ) { int var_2 = 0 ; int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ; int [ ] var_6 = new int [ var_4 ] , var_7 = new int [ var_5 ] ; for ( int var_8 = 0 ; var_8 < var_4 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 < var_5 ; var_9 ++ ) { if ( var_0 [ var_8 ] [ var_9 ] == 1 ) { var_2 ++ ; var_6 [ var_8 ] ++ ; var_7 [ var_9 ] ++ ; } } } for ( int var_8 = 0 ; var_8 < var_4 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 < var_5 ; var_9 ++ ) { if ( var_0 [ var_8 ] [ var_9 ] == 1 && var_6 [ var_8 ] == 1 && var_7 [ var_9 ] == 1 ) { var_2 -- ; } } } return var_2 ; } " 573,Palindrome Pairs_2.java,"private boolean isPalindrome(String word) { if (word.length() == 1) { return true; } int start = 0; int end = word.length() - 1; while (start < end) { if (word.charAt(start) != word.charAt(end)) { return false; } start++; end--; } return true; }","private boolean var_0 ( String var_2 ) { if ( var_2 . length ( ) == 1 ) { return true ; } int var_6 = 0 ; int var_7 = var_2 . length ( ) - 1 ; while ( var_6 < var_7 ) { if ( var_2 . charAt ( var_6 ) != var_2 . charAt ( var_7 ) ) { return false ; } var_6 ++ ; var_7 -- ; } return true ; } " 574,557. Reverse Words in a String III_1.java,"public void reverse(char[] s, int start, int end) { while (start < end) { char temp = s[start]; s[start] = s[end]; s[end] = temp; start++; end--; } }","public void var_0 ( char [ ] var_1 , int var_2 , int var_3 ) { while ( var_2 < var_3 ) { char var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; var_2 ++ ; var_3 -- ; } } " 575,Best Time to Buy and Sell Stock IV_1.java,"public int maxProfit(int k, int[] prices) { if (prices == null || prices.length == 0 || k <= 0) { return 0; } int profit = 0; int n = prices.length; int statusLength = 2 * k + 1; if (k >= n/2) { for (int i = 1; i < n; i++) { if (prices[i] > prices[i - 1]) { profit += prices[i] - prices[i - 1]; } } return profit; } int[][] dp = new int[n][statusLength]; dp[0][0] = 0; for (int i = 1; i < n; i++) { for (int j = 1; j < statusLength; j++) { if (j % 2 == 0) { dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - 1] + prices[i] - prices[i - 1]); profit = Math.max(profit, dp[i][j]); } else { dp[i][j] = Math.max(dp[i - 1][j] + prices[i] - prices[i - 1], dp[i - 1][j - 1]); } } } return profit; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 || var_0 <= 0 ) { return 0 ; } int var_5 = 0 ; int var_6 = var_1 . length ; int var_9 = 2 * var_0 + 1 ; if ( var_0 >= var_6 / 2 ) { for ( int var_10 = 1 ; var_10 < var_6 ; var_10 ++ ) { if ( var_1 [ var_10 ] > var_1 [ var_10 - 1 ] ) { var_5 += var_1 [ var_10 ] - var_1 [ var_10 - 1 ] ; } } return var_5 ; } int [ ] [ ] var_11 = new int [ var_6 ] [ var_9 ] ; var_11 [ 0 ] [ 0 ] = 0 ; for ( int var_10 = 1 ; var_10 < var_6 ; var_10 ++ ) { for ( int var_12 = 1 ; var_12 < var_9 ; var_12 ++ ) { if ( var_12 % 2 == 0 ) { var_11 [ var_10 ] [ var_12 ] = Math . max ( var_11 [ var_10 - 1 ] [ var_12 ] , var_11 [ var_10 - 1 ] [ var_12 - 1 ] + var_1 [ var_10 ] - var_1 [ var_10 - 1 ] ) ; var_5 = Math . max ( var_5 , var_11 [ var_10 ] [ var_12 ] ) ; } else { var_11 [ var_10 ] [ var_12 ] = Math . max ( var_11 [ var_10 - 1 ] [ var_12 ] + var_1 [ var_10 ] - var_1 [ var_10 - 1 ] , var_11 [ var_10 - 1 ] [ var_12 - 1 ] ) ; } } } return var_5 ; } " 576,843. Guess the Word_1.java,"private int countMatch(String a, String b) { int count = 0; for (int i = 0; i < 6; i++) { if (a.charAt(i) == b.charAt(i)) count++; } return count; }","private int sample_funcname ( String var_1 , String var_2 ) { int var_4 = 0 ; for ( int var_5 = 0 ; var_5 < 6 ; var_5 ++ ) { if ( var_1 . charAt ( var_5 ) == var_2 . charAt ( var_5 ) ) var_4 ++ ; } return var_4 ; } " 577,Cosine Similarity_1.java,"public double cosineSimilarity(int[] A, int[] B) { if (A == null || B == null || A.length == 0 || B.length == 0 || A.length != B.length) { return 2; } double sumProduct = 0; double sumASq = 0; double sumBSq = 0; for (int i = 0; i < A.length; i++) { sumProduct += A[i]*B[i]; sumASq += A[i] * A[i]; sumBSq += B[i] * B[i]; } if (sumASq == 0 && sumBSq == 0) { return 2.0; } return sumProduct / (Math.sqrt(sumASq) * Math.sqrt(sumBSq)); }","public double sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { if ( var_0 == null || var_1 == null || var_0 . length == 0 || var_1 . length == 0 || var_0 . length != var_1 . length ) { return 2 ; } double var_6 = 0 ; double var_7 = 0 ; double var_8 = 0 ; for ( int var_9 = 0 ; var_9 < var_0 . length ; var_9 ++ ) { var_6 += var_0 [ var_9 ] * var_1 [ var_9 ] ; var_7 += var_0 [ var_9 ] * var_0 [ var_9 ] ; var_8 += var_1 [ var_9 ] * var_1 [ var_9 ] ; } if ( var_7 == 0 && var_8 == 0 ) { return 2.0 ; } return var_6 / ( Math . sqrt ( var_7 ) * Math . sqrt ( var_8 ) ) ; } " 578,Maximum XOR of Two Numbers in an Array_1.java,"public int findMaximumXOR(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int res = 0, mask = 0; for (int i = 31; i >= 0; i--) { mask = mask | (1 << i); final Set set = new HashSet<>(); for (int num : nums) { set.add(num & mask); } int temp = res | (1 << i); for (int prefix : set) { if (set.contains(temp ^ prefix)) { res = temp; break; } } } return res; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = 0 , var_5 = 0 ; for ( int var_7 = 31 ; var_7 >= 0 ; var_7 -- ) { var_5 = var_5 | ( 1 << var_7 ) ; final Set < Integer > var_12 = new HashSet < > ( ) ; for ( int var_13 : var_0 ) { var_12 . add ( var_13 & var_5 ) ; } int var_15 = var_4 | ( 1 << var_7 ) ; for ( int var_16 : var_12 ) { if ( var_12 . contains ( var_15 ^ var_16 ) ) { var_4 = var_15 ; break ; } } } return var_4 ; } " 579,Copy Books_1.java,"public int copyBooks(int[] pages, int K) { if (pages == null || pages.length == 0) { return 0; } int n = pages.length; if (K > n) { K = n; } int[][] dp = new int[n + 1][K + 1]; dp[0][0] = 0; for (int i = 1; i <= n; i++) { dp[i][0] = Integer.MAX_VALUE; } for (int i = 1; i <= n; i++) { for (int k = 1; k <= K; k++) { int sum = 0; dp[i][k] = Integer.MAX_VALUE; for (int j = i; j >= 0; j--) { dp[i][k] = Math.min(dp[i][k], Math.max(dp[j][k - 1], sum)); if (j > 0) { sum += pages[j - 1]; } } } } return dp[n][K]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = var_0 . length ; if ( var_1 > var_5 ) { var_1 = var_5 ; } int [ ] [ ] var_7 = new int [ var_5 + 1 ] [ var_1 + 1 ] ; var_7 [ 0 ] [ 0 ] = 0 ; for ( int var_8 = 1 ; var_8 <= var_5 ; var_8 ++ ) { var_7 [ var_8 ] [ 0 ] = Integer . MAX_VALUE ; } for ( int var_8 = 1 ; var_8 <= var_5 ; var_8 ++ ) { for ( int var_11 = 1 ; var_11 <= var_1 ; var_11 ++ ) { int var_12 = 0 ; var_7 [ var_8 ] [ var_11 ] = Integer . MAX_VALUE ; for ( int var_13 = var_8 ; var_13 >= 0 ; var_13 -- ) { var_7 [ var_8 ] [ var_11 ] = Math . min ( var_7 [ var_8 ] [ var_11 ] , Math . max ( var_7 [ var_13 ] [ var_11 - 1 ] , var_12 ) ) ; if ( var_13 > 0 ) { var_12 += var_0 [ var_13 - 1 ] ; } } } } return var_7 [ var_5 ] [ var_1 ] ; } " 580,Combinations_2.java,"public void helper(List> rst, List solution, int n, int k, int start) { if (solution.size() == k) { rst.add(new ArrayList(solution)); return; } for (int i = start; i <= n; i++) { solution.add(i); helper(rst, solution, n, k, i + 1); solution.remove(solution.size() - 1); } }","public void sample_funcname ( List < List < Integer >> rst , List < Integer > solution , int n , int k , int start ) { if ( solution . size ( ) == k ) { rst . add ( new ArrayList ( solution ) ) ; return ; } for ( int i = start ; i <= n ; i ++ ) { solution . add ( i ) ; helper ( rst , solution , n , k , i + 1 ) ; solution . remove ( solution . size ( ) - 1 ) ; } } " 581,Search a 2D Matrix II_2.java,"public boolean searchMatrix(int[][] matrix, int target) { if (matrix == null || matrix.length == 0 || matrix[0].length == 0) { return false; } int row = matrix.length; int col = matrix[0].length; int x = 0; int y = col - 1; while (x < row && y >= 0) { if (matrix[x][y] < target) { x++; } else if (matrix[x][y] > target) { y--; } else { return true; } } return false; }","public boolean var_0 ( int [ ] [ ] var_1 , int var_2 ) { if ( var_1 == null || var_1 . length == 0 || var_1 [ 0 ] . length == 0 ) { return false ; } int var_6 = var_1 . length ; int var_7 = var_1 [ 0 ] . length ; int var_8 = 0 ; int var_10 = var_7 - 1 ; while ( var_8 < var_6 && var_10 >= 0 ) { if ( var_1 [ var_8 ] [ var_10 ] < var_2 ) { var_8 ++ ; } else if ( var_1 [ var_8 ] [ var_10 ] > var_2 ) { var_10 -- ; } else { return true ; } } return false ; } " 582,72. Edit Distance_2.java,"public int minDistance(String word1, String word2) { if (word1 == null && word2 == null) return 0; if (word1 == null || word2 == null) return word1 == null ? word2.length() : word1.length(); int m = word1.length(); int n = word2.length(); int[][] dp = new int[2][n + 1]; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0) { dp[i%2][j] = j; continue; } if (j == 0) { dp[i%2][j] = i; continue; } if (word1.charAt(i - 1) == word2.charAt(j - 1)) { dp[i%2][j] = dp[(i - 1)%2][j - 1]; } else { dp[i%2][j] = Math.min(dp[(i - 1)%2][j - 1], Math.min(dp[i%2][j - 1], dp[(i - 1)%2][j])) + 1; } } } return dp[m%2][n]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null && var_2 == null ) return 0 ; if ( var_1 == null || var_2 == null ) return var_1 == null ? var_2 . length ( ) : var_1 . length ( ) ; int var_6 = var_1 . length ( ) ; int var_7 = var_2 . length ( ) ; int [ ] [ ] var_10 = new int [ 2 ] [ var_7 + 1 ] ; for ( int var_11 = 0 ; var_11 <= var_6 ; var_11 ++ ) { for ( int var_12 = 0 ; var_12 <= var_7 ; var_12 ++ ) { if ( var_11 == 0 ) { var_10 [ var_11 % 2 ] [ var_12 ] = var_12 ; continue ; } if ( var_12 == 0 ) { var_10 [ var_11 % 2 ] [ var_12 ] = var_11 ; continue ; } if ( var_1 . charAt ( var_11 - 1 ) == var_2 . charAt ( var_12 - 1 ) ) { var_10 [ var_11 % 2 ] [ var_12 ] = var_10 [ ( var_11 - 1 ) % 2 ] [ var_12 - 1 ] ; } else { var_10 [ var_11 % 2 ] [ var_12 ] = Math . min ( var_10 [ ( var_11 - 1 ) % 2 ] [ var_12 - 1 ] , Math . min ( var_10 [ var_11 % 2 ] [ var_12 - 1 ] , var_10 [ ( var_11 - 1 ) % 2 ] [ var_12 ] ) ) + 1 ; } } } return var_10 [ var_6 % 2 ] [ var_7 ] ; } " 583,1170. Compare Strings by Frequency of the Smallest Character_2.java,"private int calc(int[] wordCounts, int count) { int rst = 0; for (int i = wordCounts.length - 1; i >= 0; i--) { if (wordCounts[i] <= count) break; rst++; } return rst; }","private int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = 0 ; for ( int var_6 = var_0 . length - 1 ; var_6 >= 0 ; var_6 -- ) { if ( var_0 [ var_6 ] <= var_1 ) break ; var_3 ++ ; } return var_3 ; } " 584,218. The Skyline Problem_5.java,"int rson(int id) { return id * 2 + 2; }","int sample_funcname ( int var_0 ) { return var_0 * 2 + 2 ; } " 585,293. Flip Game_3.java,"public static void search(char target, char replace, char[] arr, List rst) { int p1 = 0; int p2 = 1; while (p2 <= arr.length - 1) { if (arr[p1] == target && arr[p2] == target) { arr[p1] = replace; arr[p2] = replace; rst.add(new String(arr)); arr[p1] = target; arr[p2] = target; } p1++; p2++; } }","public static void var_0 ( char var_1 , char var_2 , char [ ] var_3 , List < String > var_6 ) { int var_8 = 0 ; int var_10 = 1 ; while ( var_10 <= var_3 . length - 1 ) { if ( var_3 [ var_8 ] == var_1 && var_3 [ var_10 ] == var_1 ) { var_3 [ var_8 ] = var_2 ; var_3 [ var_10 ] = var_2 ; var_6 . add ( new String ( var_3 ) ) ; var_3 [ var_8 ] = var_1 ; var_3 [ var_10 ] = var_1 ; } var_8 ++ ; var_10 ++ ; } } " 586,852. Peak Index in a Mountain Array_1.java,"public int peakIndexInMountainArray(int[] A) { int start = 1, end = A.length - 2; int mid = start + (end - start)/2; while (start + 1 < end) { mid = start + (end - start)/2; if (A[mid-1] < A[mid] && A[mid] > A[mid+1]) return mid; else if (A[mid-1] < A[mid+1]) start = mid; else if (A[mid-1] > A[mid+1]) end = mid; } return A[start] < A[end] ? end : start; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 1 , var_5 = var_0 . length - 2 ; int var_6 = var_2 + ( var_5 - var_2 ) / 2 ; while ( var_2 + 1 < var_5 ) { var_6 = var_2 + ( var_5 - var_2 ) / 2 ; if ( var_0 [ var_6 - 1 ] < var_0 [ var_6 ] && var_0 [ var_6 ] > var_0 [ var_6 + 1 ] ) return var_6 ; else if ( var_0 [ var_6 - 1 ] < var_0 [ var_6 + 1 ] ) var_2 = var_6 ; else if ( var_0 [ var_6 - 1 ] > var_0 [ var_6 + 1 ] ) var_5 = var_6 ; } return var_0 [ var_2 ] < var_0 [ var_5 ] ? var_5 : var_2 ; } " 587,266. Palindrome Permutation_2.java,"public boolean canPermutePalindrome(String s) { if (s == null || s.length() == 0) { return true; } HashMap map = new HashMap(); for (int i = 0; i < s.length(); i++) { String str = s.charAt(i) + """"; if (!map.containsKey(str)) { map.put(str, 1); } else { map.put(str, map.get(str) + 1); } } int countOdd = 0; for (HashMap.Entry entry : map.entrySet()) { if (entry.getValue() % 2 == 1) { countOdd++; } if (countOdd > 1) { return false; } } return true; }","public boolean var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) { return true ; } HashMap < String , Integer > var_8 = new HashMap < String , Integer > ( ) ; for ( int var_9 = 0 ; var_9 < var_2 . length ( ) ; var_9 ++ ) { String var_12 = var_2 . charAt ( var_9 ) + """" ; if ( ! var_8 . containsKey ( var_12 ) ) { var_8 . put ( var_12 , 1 ) ; } else { var_8 . put ( var_12 , var_8 . get ( var_12 ) + 1 ) ; } } int var_17 = 0 ; for ( HashMap . Entry < String , Integer > var_19 : var_8 . entrySet ( ) ) { if ( var_19 . getValue ( ) % 2 == 1 ) { var_17 ++ ; } if ( var_17 > 1 ) { return false ; } } return true ; } " 588,639. Decode Ways II_1.java,"private int countSingle(char c) { if (c == '*') return 9; if (c == '0') return 0; return 1; }","private int sample_funcname ( char var_0 ) { if ( var_0 == '*' ) return 9 ; if ( var_0 == '0' ) return 0 ; return 1 ; } " 589,168. Excel Sheet Column Title_1.java,"public String convertToTitle(int n) { if (n <= 0) { return null; } StringBuilder sb = new StringBuilder(); while (n > 0) { int remain = n % 26; n = n / 26; if (remain == 0) { sb.append(""Z""); n--; } else { sb.append((char)('A' + remain - 1)); } } return sb.reverse().toString(); }","public String var_0 ( int var_1 ) { if ( var_1 <= 0 ) { return null ; } StringBuilder var_5 = new StringBuilder ( ) ; while ( var_1 > 0 ) { int var_7 = var_1 % 26 ; var_1 = var_1 / 26 ; if ( var_7 == 0 ) { var_5 . append ( ""Z"" ) ; var_1 -- ; } else { var_5 . append ( ( char ) ( 'A' + var_7 - 1 ) ) ; } } return var_5 . reverse ( ) . toString ( ) ; } " 590,Plus One_3.java,"public int[] plusOne(int[] digits) { if (digits == null || digits.length == 0) { return null; } String str = """"; for (int i = 0; i < digits.length; i++) { str += digits[i]; } long digit = Long.parseLong(str); digit += 1; str = digit + """"; int[] rst = new int[str.length()]; for (int i = 0; i < str.length(); i++) { rst[i] = Character.getNumericValue(str.charAt(i)); } return rst; }","public int [ ] sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return null ; } String var_6 = """" ; for ( int var_7 = 0 ; var_7 < var_0 . length ; var_7 ++ ) { var_6 += var_0 [ var_7 ] ; } long var_10 = Long . parseLong ( var_6 ) ; var_10 += 1 ; var_6 = var_10 + """" ; int [ ] var_12 = new int [ var_6 . length ( ) ] ; for ( int var_7 = 0 ; var_7 < var_6 . length ( ) ; var_7 ++ ) { var_12 [ var_7 ] = Character . getNumericValue ( var_6 . charAt ( var_7 ) ) ; } return var_12 ; } " 591,122. Best Time to Buy and Sell Stock II_3.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length == 0) return 0; int n = prices.length; int[][] dp = new int[n+1][2]; dp[0][0] = dp[0][1] = 0; dp[1][0] = - prices[0]; for (int i = 2; i <= n; i++) { dp[i][0] = Math.max(dp[i-1][0], dp[i-1][1] - prices[i-1]); dp[i][1] = Math.max(dp[i-1][1], dp[i-1][0] + prices[i-1]); } return dp[n][1]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length ; int [ ] [ ] var_7 = new int [ var_4 + 1 ] [ 2 ] ; var_7 [ 0 ] [ 0 ] = var_7 [ 0 ] [ 1 ] = 0 ; var_7 [ 1 ] [ 0 ] = - var_0 [ 0 ] ; for ( int var_8 = 2 ; var_8 <= var_4 ; var_8 ++ ) { var_7 [ var_8 ] [ 0 ] = Math . max ( var_7 [ var_8 - 1 ] [ 0 ] , var_7 [ var_8 - 1 ] [ 1 ] - var_0 [ var_8 - 1 ] ) ; var_7 [ var_8 ] [ 1 ] = Math . max ( var_7 [ var_8 - 1 ] [ 1 ] , var_7 [ var_8 - 1 ] [ 0 ] + var_0 [ var_8 - 1 ] ) ; } return var_7 [ var_4 ] [ 1 ] ; } " 592,Hamming Distance_1.java,"public int hammingDistance(int x, int y) { int xor = x ^ y; int count = 0; while (xor != 0) { count += xor & 1; xor = xor >> 1; } return count; }","public int sample_funcname ( int var_0 , int var_1 ) { int var_2 = var_0 ^ var_1 ; int var_4 = 0 ; while ( var_2 != 0 ) { var_4 += var_2 & 1 ; var_2 = var_2 >> 1 ; } return var_4 ; } " 593,Flip Game II_4.java,"public static boolean checkP1Win(String str, int x, boolean isP1) { String s = str.substring(0,x) + ""--"" + str.substring(x + 2); if (s.indexOf(""++"") == -1) { return isP1; } for (int i = s.indexOf(""++""); i >= 0 && i < s.length() - 1; i = s.indexOf(""++"")) { if (checkP1Win(s, i, !isP1)) { return true; } s = s.substring(0, i) + ""-"" + s.substring(i + 1); } return false; }","public static boolean sample_funcname ( String str , int x , boolean isP1 ) { String s = str . substring ( 0 , x ) + ""--"" + str . substring ( x + 2 ) ; if ( s . indexOf ( ""++"" ) == - 1 ) { return isP1 ; } for ( int i = s . indexOf ( ""++"" ) ; i >= 0 && i < s . length ( ) - 1 ; i = s . indexOf ( ""++"" ) ) { if ( checkP1Win ( s , i , ! isP1 ) ) { return true ; } s = s . substring ( 0 , i ) + ""-"" + s . substring ( i + 1 ) ; } return false ; } " 594,189. Rotate Array_1.java,"private void rotateByRange(int[] nums, int x, int y) { while (x >= 0 && x < y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; x++; y--; } }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { while ( var_2 >= 0 && var_2 < var_3 ) { int var_5 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_5 ; var_2 ++ ; var_3 -- ; } } " 595,297. Serialize and Deserialize Binary Tree_1.java,"private void truncateData(StringBuffer sb) { sb.delete(0, sb.indexOf("","") + 1); }","private void var_0 ( StringBuffer var_2 ) { var_2 . delete ( 0 , var_2 . indexOf ( "","" ) + 1 ) ; } " 596,766. Toeplitz Matrix_2.java,"public boolean isToeplitzMatrix(int[][] matrix) { for (int i = 0; i < matrix.length - 1; i++) { for (int j = 0; j < matrix[i].length - 1; j++) { if (matrix[i][j] != matrix[i + 1][j + 1]) return false; } } return true; }","public boolean var_0 ( int [ ] [ ] var_1 ) { for ( int var_3 = 0 ; var_3 < var_1 . length - 1 ; var_3 ++ ) { for ( int var_6 = 0 ; var_6 < var_1 [ var_3 ] . length - 1 ; var_6 ++ ) { if ( var_1 [ var_3 ] [ var_6 ] != var_1 [ var_3 + 1 ] [ var_6 + 1 ] ) return false ; } } return true ; } " 597,Fraction to Recurring Decimal_2.java,"public String fractionToDecimal(int numerator, int denominator) { long nume = Math.abs((long)numerator); long deno = Math.abs((long)denominator); String sign = (numerator < 0) ^ (denominator < 0) ? ""-"" : """"; if (deno == 0) { return """"; } else if (nume == 0) { return ""0""; } else if (nume % deno == 0) { return sign + nume/deno + """"; } String rst = sign + nume/deno + "".""; long end = nume%deno * 10; HashMap map = new HashMap(); boolean repeat = false; String endRepeat = """"; int n = 0; while (true){ if (end == 0) { break; } else if (map.containsValue(end)) { repeat = true; break; } map.put(n++, end); end = (end % deno) * 10; } for (int i = 0; i < n; i++) { if (repeat && map.get(i) == end) { rst += ""("" + map.get(i)/deno; endRepeat = "")""; repeat = false; } else { rst += map.get(i)/deno; } } return rst + endRepeat; }","public String var_0 ( int var_1 , int var_2 ) { long var_5 = Math . abs ( ( long ) var_1 ) ; long var_6 = Math . abs ( ( long ) var_2 ) ; String var_11 = ( var_1 < 0 ) ^ ( var_2 < 0 ) ? ""-"" : """" ; if ( var_6 == 0 ) { return """" ; } else if ( var_5 == 0 ) { return ""0"" ; } else if ( var_5 % var_6 == 0 ) { return var_11 + var_5 / var_6 + """" ; } String var_14 = var_11 + var_5 / var_6 + ""."" ; long var_16 = var_5 % var_6 * 10 ; HashMap < Integer , Long > var_20 = new HashMap < Integer , Long > ( ) ; boolean var_27 = false ; String var_22 = """" ; int var_23 = 0 ; while ( true ) { if ( var_16 == 0 ) { break ; } else if ( var_20 . containsValue ( var_16 ) ) { var_27 = true ; break ; } var_20 . put ( var_23 ++ , var_16 ) ; var_16 = ( var_16 % var_6 ) * 10 ; } for ( int var_26 = 0 ; var_26 < var_23 ; var_26 ++ ) { if ( var_27 && var_20 . get ( var_26 ) == var_16 ) { var_14 += ""("" + var_20 . get ( var_26 ) / var_6 ; var_22 = "")"" ; var_27 = false ; } else { var_14 += var_20 . get ( var_26 ) / var_6 ; } } return var_14 + var_22 ; } " 598,Word Search_1.java,"private boolean validate(char[][] board, int x, int y, char c) { return x < 0 || x >= board.length || y < 0 || y >= board[0].length || board[x][y] != c || board[x][y] == '#'; }","private boolean var_0 ( char [ ] [ ] var_1 , int var_2 , int var_3 , char var_4 ) { return var_2 < 0 || var_2 >= var_1 . length || var_3 < 0 || var_3 >= var_1 [ 0 ] . length || var_1 [ var_2 ] [ var_3 ] != var_4 || var_1 [ var_2 ] [ var_3 ] == '#' ; } " 599,Nim Game_1.java,"public boolean canWinNim(int n) { return n % 4 != 0; }","public boolean var_0 ( int var_1 ) { return var_1 % 4 != 0 ; } " 600,Subsets II_5.java,"public void helper(ArrayList> rst, ArrayList list, ArrayList S, int level) { if (!rst.contains(list)) { rst.add(new ArrayList(list)); } if (level == S.size()) { return; } list.add(S.get(level)); helper(rst, list, S, level + 1); list.remove(list.size() - 1); helper(rst, list, S, level + 1); }","public void sample_funcname ( ArrayList < ArrayList < Integer >> rst , ArrayList < Integer > list , ArrayList < Integer > S , int level ) { if ( ! rst . contains ( list ) ) { rst . add ( new ArrayList < Integer > ( list ) ) ; } if ( level == S . size ( ) ) { return ; } list . add ( S . get ( level ) ) ; helper ( rst , list , S , level + 1 ) ; list . remove ( list . size ( ) - 1 ) ; helper ( rst , list , S , level + 1 ) ; } " 601,Longest Increasing Subsequence_2.java,"public int binarySearch(List list, int target) { int start = 0; int end = list.size() - 1; while (start + 1 < end) { int mid = start + (end - start) / 2; if (list.get(mid) == target) { return mid; } else if (list.get(mid) < target) { start = mid; } else { end = mid; } } return list.get(start) >= target ? start : end; }","public int sample_funcname ( List < Integer > var_2 , int var_3 ) { int var_5 = 0 ; int var_8 = var_2 . size ( ) - 1 ; while ( var_5 + 1 < var_8 ) { int var_10 = var_5 + ( var_8 - var_5 ) / 2 ; if ( var_2 . get ( var_10 ) == var_3 ) { return var_10 ; } else if ( var_2 . get ( var_10 ) < var_3 ) { var_5 = var_10 ; } else { var_8 = var_10 ; } } return var_2 . get ( var_5 ) >= var_3 ? var_5 : var_8 ; } " 602,674. Longest Continuous Increasing Subsequence_1.java,"public int findLengthOfLCIS(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length, windowStart = 0; int max = 1; for (int i = 1; i < n; i++) { if (nums[i] <= nums[i - 1]) windowStart = i; max = Math.max(max, i - windowStart + 1); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = 0 ; int max = 1 ; for ( int var_8 = 1 ; var_8 < var_4 ; var_8 ++ ) { if ( var_0 [ var_8 ] <= var_0 [ var_8 - 1 ] ) var_5 = var_8 ; max = Math . max ( max , var_8 - var_5 + 1 ) ; } return max ; } " 603,319. Bulb Switcher_1.java,"public int bulbSwitch(int n) { return (int)Math.sqrt(n); }","public int sample_funcname ( int var_0 ) { return ( int ) Math . sqrt ( var_0 ) ; } " 604,Word Ladder II_1.java,"public void DFS(String start, String str, Map distance, Map> pastMap, ArrayList path, List> rst) { path.add(str); if (str.equals(start)) { Collections.reverse(path); rst.add(new ArrayList(path)); Collections.reverse(path); } else { for (String s : pastMap.get(str)) { if (distance.containsKey(s) && distance.get(str) == distance.get(s) + 1) { DFS(start, s, distance, pastMap, path, rst); } } } path.remove(path.size() - 1); }","public void sample_funcname ( String start , String str , Map < String , Integer > distance , Map < String , ArrayList < String >> pastMap , ArrayList < String > path , List < List < String >> rst ) { path . add ( str ) ; if ( str . equals ( start ) ) { Collections . reverse ( path ) ; rst . add ( new ArrayList < String > ( path ) ) ; Collections . reverse ( path ) ; } else { for ( String s : pastMap . get ( str ) ) { if ( distance . containsKey ( s ) && distance . get ( str ) == distance . get ( s ) + 1 ) { DFS ( start , s , distance , pastMap , path , rst ) ; } } } path . remove ( path . size ( ) - 1 ) ; } " 605,Trapping Rain Water II_1.java,"private boolean isValidCoordinate(int x, int y, boolean[][] visited) { int m = visited.length, n = visited[0].length; return x >= 0 && x < m && y >= 0 && y < n && !visited[x][y]; }","private boolean var_0 ( int var_1 , int var_2 , boolean [ ] [ ] var_4 ) { int var_6 = var_4 . length , var_8 = var_4 [ 0 ] . length ; return var_1 >= 0 && var_1 < var_6 && var_2 >= 0 && var_2 < var_8 && ! var_4 [ var_1 ] [ var_2 ] ; } " 606,Coins in a Line_3.java,"public boolean firstWillWin(int n) { if (n <= 0) { return false; } if (n <= 2) { return true; } int start = 0; int mid = 1; int end = 2; boolean[] dp = new boolean[3]; dp[start] = false; dp[mid] = true; for (int i = 2; i <= n; i++) { dp[end] = !dp[start] || !dp[mid]; if (i != n) { start = (start + 1) % 3; mid = (mid + 1) % 3; end = (end + 1) % 3; } } return dp[end]; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 0 ) { return false ; } if ( var_1 <= 2 ) { return true ; } int var_4 = 0 ; int var_6 = 1 ; int var_7 = 2 ; boolean [ ] var_10 = new boolean [ 3 ] ; var_10 [ var_4 ] = false ; var_10 [ var_6 ] = true ; for ( int var_11 = 2 ; var_11 <= var_1 ; var_11 ++ ) { var_10 [ var_7 ] = ! var_10 [ var_4 ] || ! var_10 [ var_6 ] ; if ( var_11 != var_1 ) { var_4 = ( var_4 + 1 ) % 3 ; var_6 = ( var_6 + 1 ) % 3 ; var_7 = ( var_7 + 1 ) % 3 ; } } return var_10 [ var_7 ] ; } " 607,k Sum_1.java,"public int kSum(int[] A, int k, int target) { if (A == null || A.length == 0 || k <= 0) { return 0; } final int[][][] dp = new int[target + 1][A.length + 1][k + 1]; for (int j = 0; j <= A.length; j++) { dp[0][j][0] = 1; } for (int i = 1; i <= target; i++) { for (int j = 1; j <= A.length; j++) { for (int m = 1; m <= j && m <= k; m++) { dp[i][j][m] = dp[i][j - 1][m]; if (i - A[j - 1] >= 0) { dp[i][j][m] += dp[i - A[j - 1]][j - 1][m - 1]; } } } } return dp[target][A.length][k]; }","public int sample_funcname ( int [ ] var_0 , int var_1 , int var_2 ) { if ( var_0 == null || var_0 . length == 0 || var_1 <= 0 ) { return 0 ; } final int [ ] [ ] [ ] var_7 = new int [ var_2 + 1 ] [ var_0 . length + 1 ] [ var_1 + 1 ] ; for ( int var_8 = 0 ; var_8 <= var_0 . length ; var_8 ++ ) { var_7 [ 0 ] [ var_8 ] [ 0 ] = 1 ; } for ( int var_9 = 1 ; var_9 <= var_2 ; var_9 ++ ) { for ( int var_8 = 1 ; var_8 <= var_0 . length ; var_8 ++ ) { for ( int var_10 = 1 ; var_10 <= var_8 && var_10 <= var_1 ; var_10 ++ ) { var_7 [ var_9 ] [ var_8 ] [ var_10 ] = var_7 [ var_9 ] [ var_8 - 1 ] [ var_10 ] ; if ( var_9 - var_0 [ var_8 - 1 ] >= 0 ) { var_7 [ var_9 ] [ var_8 ] [ var_10 ] += var_7 [ var_9 - var_0 [ var_8 - 1 ] ] [ var_8 - 1 ] [ var_10 - 1 ] ; } } } } return var_7 [ var_2 ] [ var_0 . length ] [ var_1 ] ; } " 608,301. Remove Invalid Parentheses_3.java,"private boolean validate(String s) { int count = 0; for (char c : s.toCharArray()) { count += c == '(' ? 1 : 0; count -= c == ')' ? 1 : 0; if (count < 0) return false; } return count == 0; }","private boolean var_0 ( String var_2 ) { int var_4 = 0 ; for ( char var_6 : var_2 . toCharArray ( ) ) { var_4 += var_6 == '(' ? 1 : 0 ; var_4 -= var_6 == ')' ? 1 : 0 ; if ( var_4 < 0 ) return false ; } return var_4 == 0 ; } " 609,373. Find K Pairs with Smallest Sums_1.java,"private PriorityQueue> initQueue(int k) { return new PriorityQueue<>(k, new Comparator>() { public int compare(List a, List b) { return a.get(0) + a.get(1) - b.get(0) - b.get(1); } }); }","private PriorityQueue < List < Integer >> var_2 ( int var_3 ) { return new PriorityQueue < > ( var_3 , new Comparator < List < Integer >> ( ) { public int compare ( List < Integer > var_7 , List < Integer > var_8 ) { return var_7 . get ( 0 ) + var_7 . get ( 1 ) - var_8 . get ( 0 ) - var_8 . get ( 1 ) ; } } ) ; } " 610,689. Maximum Sum of 3 Non-Overlapping Subarrays_3.java,"private int[] calcPresum(int[] nums) { int[] presum = new int[nums.length + 1]; for (int i = 1; i <= nums.length; i++) presum[i] += presum[i - 1] + nums[i - 1]; return presum; }","private int [ ] sample_funcname ( int [ ] var_0 ) { int [ ] var_3 = new int [ var_0 . length + 1 ] ; for ( int var_4 = 1 ; var_4 <= var_0 . length ; var_4 ++ ) var_3 [ var_4 ] += var_3 [ var_4 - 1 ] + var_0 [ var_4 - 1 ] ; return var_3 ; } " 611,245. Shortest Word Distance III_1.java,"public int shortestWordDistance(String[] words, String word1, String word2) { Integer p1 = null, p2 = null; int distance = Integer.MAX_VALUE; for (int i = 0; i < words.length; i++) { String word = words[i]; if (word.equals(word1) && word.equals(word2)) { if (p1 != null) distance = Math.min(distance, i - p1); p1 = i; continue; } if (words[i].equals(word1)) p1 = i; if (words[i].equals(word2)) p2 = i; if (p1 != null && p2 != null) distance = Math.min(distance, Math.abs(p1 - p2)); } return distance; }","public int sample_funcname ( String [ ] var_1 , String var_2 , String var_3 ) { Integer var_6 = null , var_7 = null ; int var_9 = Integer . MAX_VALUE ; for ( int var_11 = 0 ; var_11 < var_1 . length ; var_11 ++ ) { String var_13 = var_1 [ var_11 ] ; if ( var_13 . equals ( var_2 ) && var_13 . equals ( var_3 ) ) { if ( var_6 != null ) var_9 = Math . min ( var_9 , var_11 - var_6 ) ; var_6 = var_11 ; continue ; } if ( var_1 [ var_11 ] . equals ( var_2 ) ) var_6 = var_11 ; if ( var_1 [ var_11 ] . equals ( var_3 ) ) var_7 = var_11 ; if ( var_6 != null && var_7 != null ) var_9 = Math . min ( var_9 , Math . abs ( var_6 - var_7 ) ) ; } return var_9 ; } " 612,140. Word Break II_3.java,"public boolean[][] isWord(List wordDict, String s) { int n = s.length(); boolean[][] isWord = new boolean[n][n]; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { isWord[i][j] = wordDict.contains(s.substring(i, j + 1)); } } return isWord; }","public boolean [ ] [ ] var_0 ( List < String > var_3 , String var_4 ) { int var_6 = var_4 . length ( ) ; boolean [ ] [ ] var_8 = new boolean [ var_6 ] [ var_6 ] ; for ( int var_10 = 0 ; var_10 < var_6 ; var_10 ++ ) { for ( int var_11 = var_10 ; var_11 < var_6 ; var_11 ++ ) { var_8 [ var_10 ] [ var_11 ] = var_3 . contains ( var_4 . substring ( var_10 , var_11 + 1 ) ) ; } } return var_8 ; } " 613,Distinct Subsequences_3.java,"public int numDistinct(String S, String T) { int[][] DP = new int[T.length() + 1][S.length() + 1]; DP[0][0] = 1; for(int i = 1; i < S.length(); i++) { DP[0][i] = 1; } for (int i = 1; i < T.length(); i++) { DP[i][0] = 0; } for (int i = 1; i <= T.length(); i++) { for (int j = 1; j <= S.length(); j++){ DP[i][j] = DP[i][j - 1]; if (T.charAt(i - 1) == S.charAt(j - 1)) { DP[i][j] += DP[i - 1][j - 1]; } } } return DP[T.length()][S.length()]; }","public int sample_funcname ( String var_1 , String var_2 ) { int [ ] [ ] var_5 = new int [ var_2 . length ( ) + 1 ] [ var_1 . length ( ) + 1 ] ; var_5 [ 0 ] [ 0 ] = 1 ; for ( int var_7 = 1 ; var_7 < var_1 . length ( ) ; var_7 ++ ) { var_5 [ 0 ] [ var_7 ] = 1 ; } for ( int var_7 = 1 ; var_7 < var_2 . length ( ) ; var_7 ++ ) { var_5 [ var_7 ] [ 0 ] = 0 ; } for ( int var_7 = 1 ; var_7 <= var_2 . length ( ) ; var_7 ++ ) { for ( int var_8 = 1 ; var_8 <= var_1 . length ( ) ; var_8 ++ ) { var_5 [ var_7 ] [ var_8 ] = var_5 [ var_7 ] [ var_8 - 1 ] ; if ( var_2 . charAt ( var_7 - 1 ) == var_1 . charAt ( var_8 - 1 ) ) { var_5 [ var_7 ] [ var_8 ] += var_5 [ var_7 - 1 ] [ var_8 - 1 ] ; } } } return var_5 [ var_2 . length ( ) ] [ var_1 . length ( ) ] ; } " 614,34. Find First and Last Position of Element in Sorted Array_1.java,"private int binarySearch(int[] nums, int target, boolean isLeft) { int n = nums.length, start = 0, end = n - 1; while (start + 1 < end) { int mid = start + (end - start) / 2, val = nums[mid]; if (val == target) { if (isLeft) end = mid; else start = mid; } else if (val < target) start = mid; else end = mid; } if (nums[start] == target && nums[end] == target) return isLeft ? start : end; if (nums[start] == target) return start; if (nums[end] == target) return end; return -1; }","private int sample_funcname ( int [ ] var_0 , int var_1 , boolean var_3 ) { int var_5 = var_0 . length , var_7 = 0 , var_9 = var_5 - 1 ; while ( var_7 + 1 < var_9 ) { int var_11 = var_7 + ( var_9 - var_7 ) / 2 , var_12 = var_0 [ var_11 ] ; if ( var_12 == var_1 ) { if ( var_3 ) var_9 = var_11 ; else var_7 = var_11 ; } else if ( var_12 < var_1 ) var_7 = var_11 ; else var_9 = var_11 ; } if ( var_0 [ var_7 ] == var_1 && var_0 [ var_9 ] == var_1 ) return var_3 ? var_7 : var_9 ; if ( var_0 [ var_7 ] == var_1 ) return var_7 ; if ( var_0 [ var_9 ] == var_1 ) return var_9 ; return - 1 ; } " 615,53. Maximum Subarray_10.java,"public int maxSubArray(int[] nums) { if (nums == null || nums.length == 0) return 0; int preSum = 0, minPreSum = 0; int max = Integer.MIN_VALUE; for (int num : nums) { preSum += num; max = Math.max(max, preSum - minPreSum); minPreSum = Math.min(minPreSum, preSum); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = 0 , var_5 = 0 ; int max = Integer . MIN_VALUE ; for ( int var_9 : var_0 ) { var_4 += var_9 ; max = Math . max ( max , var_4 - var_5 ) ; var_5 = Math . min ( var_5 , var_4 ) ; } return max ; } " 616,516. Longest Palindromic Subsequence_1.java,"public int longestPalindromeSubseq(String s) { char[] ss = s.toCharArray(); int n = s.length(); int[][] dp = new int[n][n]; for (int i = n - 1; i >= 0; i--) { dp[i][i] = 1; for (int j = i + 1; j < n; j++) { if (ss[i] == ss[j]) dp[i][j] = dp[i + 1][j - 1] + 2; else dp[i][j] = Math.max(dp[i + 1][j], dp[i][j - 1]); } } return dp[0][n - 1]; }","public int sample_funcname ( String var_1 ) { char [ ] var_3 = var_1 . toCharArray ( ) ; int var_5 = var_1 . length ( ) ; int [ ] [ ] var_6 = new int [ var_5 ] [ var_5 ] ; for ( int var_8 = var_5 - 1 ; var_8 >= 0 ; var_8 -- ) { var_6 [ var_8 ] [ var_8 ] = 1 ; for ( int var_10 = var_8 + 1 ; var_10 < var_5 ; var_10 ++ ) { if ( var_3 [ var_8 ] == var_3 [ var_10 ] ) var_6 [ var_8 ] [ var_10 ] = var_6 [ var_8 + 1 ] [ var_10 - 1 ] + 2 ; else var_6 [ var_8 ] [ var_10 ] = Math . max ( var_6 [ var_8 + 1 ] [ var_10 ] , var_6 [ var_8 ] [ var_10 - 1 ] ) ; } } return var_6 [ 0 ] [ var_5 - 1 ] ; } " 617,169. Majority Element_5.java,"public int majorityNumber(ArrayList nums) { if (nums == null || nums.size() == 0) { return -1; } int majorNum = nums.get(0); int count = 1; for (int i = 1; i < nums.size(); i++) { if (majorNum == nums.get(i)) { count++; } else { count--; } if (count == 0) { majorNum = nums.get(i); count = 1; } } return majorNum; }","public int sample_funcname ( ArrayList < Integer > var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return - 1 ; } int var_8 = var_2 . get ( 0 ) ; int var_9 = 1 ; for ( int var_10 = 1 ; var_10 < var_2 . size ( ) ; var_10 ++ ) { if ( var_8 == var_2 . get ( var_10 ) ) { var_9 ++ ; } else { var_9 -- ; } if ( var_9 == 0 ) { var_8 = var_2 . get ( var_10 ) ; var_9 = 1 ; } } return var_8 ; } " 618,Number Of Corner Rectangles_3.java,"private boolean validate(int[][] grid) { return grid == null || grid.length == 0 || grid[0] == null || grid[0].length == 0; }","private boolean var_0 ( int [ ] [ ] var_1 ) { return var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 ; } " 619,Longest Common Subsequence_4.java,"public int longestCommonSubsequence(String A, String B) { if (A == null || B == null || A.length() == 0 || B.length() == 0) { return 0; } int[][] check = new int[A.length() + 1][B.length() + 1]; for (int i = 1; i <= A.length(); i++) { for (int j = 1; j <= B.length(); j++) { if (A.charAt(i - 1) == B.charAt(j - 1)) { check[i][j] = check[i - 1][j - 1] + 1; } else { check[i][j] = Math.max(check[i][j], check[i - 1][j]); check[i][j] = Math.max(check[i][j], check[i][j - 1]); } } } return check[A.length()][B.length()]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) == 0 || var_2 . length ( ) == 0 ) { return 0 ; } int [ ] [ ] var_7 = new int [ var_1 . length ( ) + 1 ] [ var_2 . length ( ) + 1 ] ; for ( int var_8 = 1 ; var_8 <= var_1 . length ( ) ; var_8 ++ ) { for ( int var_9 = 1 ; var_9 <= var_2 . length ( ) ; var_9 ++ ) { if ( var_1 . charAt ( var_8 - 1 ) == var_2 . charAt ( var_9 - 1 ) ) { var_7 [ var_8 ] [ var_9 ] = var_7 [ var_8 - 1 ] [ var_9 - 1 ] + 1 ; } else { var_7 [ var_8 ] [ var_9 ] = Math . max ( var_7 [ var_8 ] [ var_9 ] , var_7 [ var_8 - 1 ] [ var_9 ] ) ; var_7 [ var_8 ] [ var_9 ] = Math . max ( var_7 [ var_8 ] [ var_9 ] , var_7 [ var_8 ] [ var_9 - 1 ] ) ; } } } return var_7 [ var_1 . length ( ) ] [ var_2 . length ( ) ] ; } " 620,53. Maximum Subarray_8.java,"public int maxSubArray(int[] nums) { if (nums == null || nums.length == 0) { return 0; } final int[] sums = new int[nums.length]; sums[0] = nums[0]; int maxSum = sums[0]; for (int i = 1; i < nums.length; i++) { if (sums[i - 1] < 0) { sums[i] = nums[i]; } else { sums[i] = sums[i - 1] + nums[i]; } maxSum = Math.max(maxSum, sums[i]); } return maxSum; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } final int [ ] var_4 = new int [ var_0 . length ] ; var_4 [ 0 ] = var_0 [ 0 ] ; int var_5 = var_4 [ 0 ] ; for ( int var_7 = 1 ; var_7 < var_0 . length ; var_7 ++ ) { if ( var_4 [ var_7 - 1 ] < 0 ) { var_4 [ var_7 ] = var_0 [ var_7 ] ; } else { var_4 [ var_7 ] = var_4 [ var_7 - 1 ] + var_0 [ var_7 ] ; } var_5 = Math . max ( var_5 , var_4 [ var_7 ] ) ; } return var_5 ; } " 621,IndexMatch_1.java,"public int indexMatch(int[] nums) { if (nums == null || nums.length == 0) { return -1; } int start = 0; int end = nums.length - 1; while (start + 1 < end) { int mid = start + (end - start)/2; if (nums[mid] == mid) { return mid; } else if (nums[mid] < mid) { start = mid; } else { end = mid; } } return -1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int var_5 = 0 ; int var_6 = var_0 . length - 1 ; while ( var_5 + 1 < var_6 ) { int var_8 = var_5 + ( var_6 - var_5 ) / 2 ; if ( var_0 [ var_8 ] == var_8 ) { return var_8 ; } else if ( var_0 [ var_8 ] < var_8 ) { var_5 = var_8 ; } else { var_6 = var_8 ; } } return - 1 ; } " 622,239. Sliding Window Maximum_1.java,"private void inQueue(Deque deque, int num) { while (!deque.isEmpty() && deque.peekLast() < num) { deque.pollLast(); } deque.offerLast(num); }","private void var_0 ( Deque < Integer > var_3 , int var_4 ) { while ( ! var_3 . isEmpty ( ) && var_3 . peekLast ( ) < var_4 ) { var_3 . pollLast ( ) ; } var_3 . offerLast ( var_4 ) ; } " 623,8. String to Integer (atoi)_2.java,"public int atoi(String str) { if (str == null || str.length() == 0) { return 0; } str = str.replaceAll(""\\s"",""""); if (!str.matches(""[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)"")) { return 0; } double rst = Double.parseDouble(str); if (rst > Integer.MAX_VALUE) { return Integer.MAX_VALUE; } else if (rst < Integer.MIN_VALUE) { return Integer.MIN_VALUE; } else { return (int)rst; } }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } var_1 = var_1 . replaceAll ( ""\\s"" , """" ) ; if ( ! var_1 . matches ( ""[+-]?(?:\\d+(?:\\.\\d*)?|\\.\\d+)"" ) ) { return 0 ; } double var_12 = Double . parseDouble ( var_1 ) ; if ( var_12 > Integer . MAX_VALUE ) { return Integer . MAX_VALUE ; } else if ( var_12 < Integer . MIN_VALUE ) { return Integer . MIN_VALUE ; } else { return ( int ) var_12 ; } } " 624,57. Insert Interval_1.java,"private boolean isEnd(int[][] intervals, int end, int i) { return i + 1 < intervals.length && end < intervals[i+1][0]; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_3 + 1 < var_1 . length && var_2 < var_1 [ var_3 + 1 ] [ 0 ] ; } " 625,727. Minimum Window Subsequence_3.java,"public String minWindow(String s, String t) { int sIndex = 0, tIndex = 0, start = -1; int m = s.length(), n = t.length(), minLength = m; char[] ss = s.toCharArray(), tt = t.toCharArray(); while (sIndex < m) { if(ss[sIndex] == tt[tIndex]) { if(++tIndex == n) { int end = sIndex + 1; while(--tIndex >= 0) { while(ss[sIndex--] != tt[tIndex]); } sIndex++; tIndex++; if (end - sIndex < minLength) { minLength = end - sIndex; start = sIndex; } } } ++sIndex; } return start == -1 ? """" : s.substring(start, start + minLength); }","public String var_0 ( String var_2 , String var_3 ) { int var_5 = 0 , var_6 = 0 , var_8 = - 1 ; int var_10 = var_2 . length ( ) , var_11 = var_3 . length ( ) , var_12 = var_10 ; char [ ] var_14 = var_2 . toCharArray ( ) , var_15 = var_3 . toCharArray ( ) ; while ( var_5 < var_10 ) { if ( var_14 [ var_5 ] == var_15 [ var_6 ] ) { if ( ++ var_6 == var_11 ) { int var_16 = var_5 + 1 ; while ( -- var_6 >= 0 ) { while ( var_14 [ var_5 -- ] != var_15 [ var_6 ] ) ; } var_5 ++ ; var_6 ++ ; if ( var_16 - var_5 < var_12 ) { var_12 = var_16 - var_5 ; var_8 = var_5 ; } } } ++ var_5 ; } return var_8 == - 1 ? """" : var_2 . substring ( var_8 , var_8 + var_12 ) ; } " 626,The Maze_1.java,"private boolean verify(int[] pos, int[] dest) { return pos[0] == dest[0] && pos[1] == dest[1]; }","private boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { return var_1 [ 0 ] == var_2 [ 0 ] && var_1 [ 1 ] == var_2 [ 1 ] ; } " 627,Best Time to Buy and Sell Stock III_2.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length == 0) { return 0; } int profit = 0; int n = prices.length; int[][] dp = new int[2][5]; dp[0][0] = 0; for (int i = 1; i < n; i++) { for (int j = 1; j < 5; j++) { int dailyPartialProfit = prices[i] - prices[i - 1]; if (j % 2 == 0) { dp[i % 2][j] = Math.max(dp[(i - 1) % 2][j], dp[(i - 1) % 2][j - 1] + dailyPartialProfit); profit = Math.max(profit, dp[i % 2][j]); } else { dp[i % 2][j] = Math.max(dp[(i - 1) % 2][j] + dailyPartialProfit, dp[(i - 1) % 2][j - 1]); } } } return profit; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = 0 ; int var_5 = var_0 . length ; int [ ] [ ] var_8 = new int [ 2 ] [ 5 ] ; var_8 [ 0 ] [ 0 ] = 0 ; for ( int var_10 = 1 ; var_10 < var_5 ; var_10 ++ ) { for ( int var_11 = 1 ; var_11 < 5 ; var_11 ++ ) { int var_12 = var_0 [ var_10 ] - var_0 [ var_10 - 1 ] ; if ( var_11 % 2 == 0 ) { var_8 [ var_10 % 2 ] [ var_11 ] = Math . max ( var_8 [ ( var_10 - 1 ) % 2 ] [ var_11 ] , var_8 [ ( var_10 - 1 ) % 2 ] [ var_11 - 1 ] + var_12 ) ; var_4 = Math . max ( var_4 , var_8 [ var_10 % 2 ] [ var_11 ] ) ; } else { var_8 [ var_10 % 2 ] [ var_11 ] = Math . max ( var_8 [ ( var_10 - 1 ) % 2 ] [ var_11 ] + var_12 , var_8 [ ( var_10 - 1 ) % 2 ] [ var_11 - 1 ] ) ; } } } return var_4 ; } " 628,[lint]. Unique Characters_3.java,"public boolean isUnique(String str) { if (str == null || str.length() == 0) { return true; } for (int i = 0; i < str.length(); i++) { for (int j = i + 1; j < str.length(); j++) { if (str.charAt(i) == str.charAt(j)) { return false; } } } return true; }","public boolean var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) { return true ; } for ( int var_6 = 0 ; var_6 < var_2 . length ( ) ; var_6 ++ ) { for ( int var_8 = var_6 + 1 ; var_8 < var_2 . length ( ) ; var_8 ++ ) { if ( var_2 . charAt ( var_6 ) == var_2 . charAt ( var_8 ) ) { return false ; } } } return true ; } " 629,159. Longest Substring with At Most Two Distinct Characters_1.java,"public int lengthOfLongestSubstringTwoDistinct(String s) { if (s == null) return 0; int left = 0, right = 0, max = 0, n = s.length(); Map freq = new HashMap<>(); while (right < n) { char head = s.charAt(right++); freq.put(head, freq.getOrDefault(head, 0) + 1); if (freq.size() <= 2) max = Math.max(max, right - left); if (freq.size() > 2) { char tail = s.charAt(left++); freq.put(tail, freq.get(tail) - 1); if (freq.get(tail) == 0) freq.remove(tail); } } return max; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null ) return 0 ; int var_4 = 0 , var_5 = 0 , max = 0 , var_8 = var_1 . length ( ) ; Map < Character , Integer > var_13 = new HashMap < > ( ) ; while ( var_5 < var_8 ) { char var_15 = var_1 . charAt ( var_5 ++ ) ; var_13 . put ( var_15 , var_13 . getOrDefault ( var_15 , 0 ) + 1 ) ; if ( var_13 . size ( ) <= 2 ) max = Math . max ( max , var_5 - var_4 ) ; if ( var_13 . size ( ) > 2 ) { char var_22 = var_1 . charAt ( var_4 ++ ) ; var_13 . put ( var_22 , var_13 . get ( var_22 ) - 1 ) ; if ( var_13 . get ( var_22 ) == 0 ) var_13 . remove ( var_22 ) ; } } return max ; } " 630,Partition Array by Odd and Even_1.java,"public void partitionArray(int[] nums) { if (nums == null || nums.length == 0){ return; } int nextOddPt = -1; int firstEvenPt = -1; for (int i = 0; i < nums.length; i++) { if (nums[i] % 2 == 1) { nextOddPt = i; } else { if (firstEvenPt == -1) { firstEvenPt = i; } } if (nextOddPt > firstEvenPt && firstEvenPt != -1) { int temp = nums[nextOddPt]; nums[nextOddPt] = nums[firstEvenPt]; nums[firstEvenPt] = temp; i = firstEvenPt - 1; firstEvenPt = -1; } } }","public void var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return ; } int var_6 = - 1 ; int var_7 = - 1 ; for ( int var_8 = 0 ; var_8 < var_1 . length ; var_8 ++ ) { if ( var_1 [ var_8 ] % 2 == 1 ) { var_6 = var_8 ; } else { if ( var_7 == - 1 ) { var_7 = var_8 ; } } if ( var_6 > var_7 && var_7 != - 1 ) { int var_10 = var_1 [ var_6 ] ; var_1 [ var_6 ] = var_1 [ var_7 ] ; var_1 [ var_7 ] = var_10 ; var_8 = var_7 - 1 ; var_7 = - 1 ; } } } " 631,Permutation Sequence_2.java,"public String getPermutation(int n, int k) { if (n <= 0 || k <= 0) { return """"; } ArrayList nums = new ArrayList(); for (int i = 1; i <= n; i++) { nums.add(i); } int frontInd = 0; for (; frontInd < nums.size(); frontInd++) { int factorio = 1; for (int i = 1; i < n; i++) { factorio = factorio * i; } int startInd = frontInd; int numPermute = factorio; while (numPermute < k) { numPermute += factorio; startInd++; } if (startInd != frontInd) { int temp = nums.get(startInd); nums.remove(startInd); nums.add(frontInd, temp); k = k - numPermute; n--; } } StringBuffer sb = new StringBuffer(); for (int num : nums) { sb.append(num); } return sb.toString(); }","public String var_0 ( int var_1 , int var_2 ) { if ( var_1 <= 0 || var_2 <= 0 ) { return """" ; } ArrayList < Integer > var_7 = new ArrayList < Integer > ( ) ; for ( int var_9 = 1 ; var_9 <= var_1 ; var_9 ++ ) { var_7 . add ( var_9 ) ; } int var_11 = 0 ; for ( ; var_11 < var_7 . size ( ) ; var_11 ++ ) { int var_13 = 1 ; for ( int var_9 = 1 ; var_9 < var_1 ; var_9 ++ ) { var_13 = var_13 * var_9 ; } int var_14 = var_11 ; int var_15 = var_13 ; while ( var_15 < var_2 ) { var_15 += var_13 ; var_14 ++ ; } if ( var_14 != var_11 ) { int var_17 = var_7 . get ( var_14 ) ; var_7 . remove ( var_14 ) ; var_7 . add ( var_11 , var_17 ) ; var_2 = var_2 - var_15 ; var_1 -- ; } } StringBuffer var_20 = new StringBuffer ( ) ; for ( int var_21 : var_7 ) { var_20 . append ( var_21 ) ; } return var_20 . toString ( ) ; } " 632,207. Course Schedule_2.java,"private boolean dfs(List[] edges, int[] visited, int node) { if (visited[node] == 1) return true; if (visited[node] == -1) return false; visited[node] = -1; List childNodes = edges[node]; for (int childNode : childNodes) { if (!dfs(edges, visited, childNode)) return false; } visited[node] = 1; return true; }","private boolean sample_funcname ( List [ ] edges , int [ ] visited , int node ) { if ( visited [ node ] == 1 ) return true ; if ( visited [ node ] == - 1 ) return false ; visited [ node ] = - 1 ; List < Integer > childNodes = edges [ node ] ; for ( int childNode : childNodes ) { if ( ! dfs ( edges , visited , childNode ) ) return false ; } visited [ node ] = 1 ; return true ; } " 633,Encode and Decode Strings_3.java,"public static String encode(List strs) { if (strs == null || strs.size() == 0) { return ""NULL""; } StringBuffer sb = new StringBuffer(); for (String str : strs) { char[] arr = str.toCharArray(); for (int i = 0; i < arr.length; i++) { if (arr[i] >= 100) { sb.append("""" + (int)arr[i]); } else if (arr[i] >= 10) { sb.append(""0"" + (int)arr[i]); } else { sb.append(""00"" + (int)arr[i]); } } sb.append(""LINE""); } if (sb.length() == 0) { sb.append(""LINE""); } return sb.toString(); }","public static String var_0 ( List < String > var_3 ) { if ( var_3 == null || var_3 . size ( ) == 0 ) { return ""NULL"" ; } StringBuffer var_9 = new StringBuffer ( ) ; for ( String var_10 : var_3 ) { char [ ] var_12 = var_10 . toCharArray ( ) ; for ( int var_13 = 0 ; var_13 < var_12 . length ; var_13 ++ ) { if ( var_12 [ var_13 ] >= 100 ) { var_9 . append ( """" + ( int ) var_12 [ var_13 ] ) ; } else if ( var_12 [ var_13 ] >= 10 ) { var_9 . append ( ""0"" + ( int ) var_12 [ var_13 ] ) ; } else { var_9 . append ( ""00"" + ( int ) var_12 [ var_13 ] ) ; } } var_9 . append ( ""LINE"" ) ; } if ( var_9 . length ( ) == 0 ) { var_9 . append ( ""LINE"" ) ; } return var_9 . toString ( ) ; } " 634,Cracking the Safe_2.java,"private void dfs(int n, int k, double total, Set visited, StringBuffer sb) { if (visited.size() == total) return; String tail = sb.substring(sb.length() - n + 1); for (int j = k - 1; j >= 0; j--) { String newStr = tail + j; if (visited.contains(newStr)) continue; visited.add(newStr); sb.append(j); dfs(n, k, total, visited, sb); } }","private void sample_funcname ( int n , int k , double total , Set < String > visited , StringBuffer sb ) { if ( visited . size ( ) == total ) return ; String tail = sb . substring ( sb . length ( ) - n + 1 ) ; for ( int j = k - 1 ; j >= 0 ; j -- ) { String newStr = tail + j ; if ( visited . contains ( newStr ) ) continue ; visited . add ( newStr ) ; sb . append ( j ) ; dfs ( n , k , total , visited , sb ) ; } } " 635,Bricks Falling When Hit_1.java,"private boolean validate(int[][] grid, int x, int y) { return x >= 0 && x < grid.length && y >= 0 && y < grid[0].length && grid[x][y] == 1; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 >= 0 && var_2 < var_1 . length && var_3 >= 0 && var_3 < var_1 [ 0 ] . length && var_1 [ var_2 ] [ var_3 ] == 1 ; } " 636,743. Network Delay Time_1.java,"private Map> buildGraph(int[][] times) { Map> graph = new HashMap<>(); for (int[] record : times) { graph.putIfAbsent(record[0], new ArrayList<>()); graph.get(record[0]).add(new int[]{record[1], record[2]}); } return graph; }","private Map < Integer , List < int [ ] >> var_2 ( int [ ] [ ] var_3 ) { Map < Integer , List < int [ ] >> var_6 = new HashMap < > ( ) ; for ( int [ ] var_7 : var_3 ) { var_6 . putIfAbsent ( var_7 [ 0 ] , new ArrayList < > ( ) ) ; var_6 . get ( var_7 [ 0 ] ) . add ( new int [ ] { var_7 [ 1 ] , var_7 [ 2 ] } ) ; } return var_6 ; } " 637,151. Reverse Words in a String_1.java,"public String reverseWords(String s) { if (s == null) return s; String[] strs = s.split("" ""); StringBuffer sb = new StringBuffer(); for (String str : strs) { if (str.length() != 0) sb.insert(0, str + "" ""); } return sb.toString().trim(); }","public String var_0 ( String var_2 ) { if ( var_2 == null ) return var_2 ; String [ ] var_6 = var_2 . split ( "" "" ) ; StringBuffer var_8 = new StringBuffer ( ) ; for ( String var_9 : var_6 ) { if ( var_9 . length ( ) != 0 ) var_8 . insert ( 0 , var_9 + "" "" ) ; } return var_8 . toString ( ) . trim ( ) ; } " 638,611. Valid Triangle Number_1.java,"public int triangleNumber(int[] nums) { Arrays.sort(nums); int n = nums.length, count = 0; for (int k = n - 1; k >= 2; k--) { for (int i = 0, j = k - 1; i < j;) { if (nums[i] + nums[j] > nums[k]) { count += j - i; j--; } else i++; } } return count; }","public int sample_funcname ( int [ ] var_0 ) { Arrays . sort ( var_0 ) ; int var_4 = var_0 . length , var_6 = 0 ; for ( int var_8 = var_4 - 1 ; var_8 >= 2 ; var_8 -- ) { for ( int var_10 = 0 , var_11 = var_8 - 1 ; var_10 < var_11 ; ) { if ( var_0 [ var_10 ] + var_0 [ var_11 ] > var_0 [ var_8 ] ) { var_6 += var_11 - var_10 ; var_11 -- ; } else var_10 ++ ; } } return var_6 ; } " 639,210. Course Schedule II_2.java,"private List[] buildInDegreeEdges(int numCourses, int[][] prerequisites) { List[] inDegreeEdges = new ArrayList[numCourses]; for (int i = 0; i < numCourses; i++) inDegreeEdges[i] = new ArrayList(); for (int[] prerequisite : prerequisites) inDegreeEdges[prerequisite[1]].add(prerequisite[0]); return inDegreeEdges; }","private List [ ] var_0 ( int var_1 , int [ ] [ ] var_2 ) { List [ ] var_5 = new ArrayList [ var_1 ] ; for ( int var_7 = 0 ; var_7 < var_1 ; var_7 ++ ) var_5 [ var_7 ] = new ArrayList < Integer > ( ) ; for ( int [ ] var_9 : var_2 ) var_5 [ var_9 [ 1 ] ] . add ( var_9 [ 0 ] ) ; return var_5 ; } " 640,217. Contains Duplicate_1.java,"public boolean containsDuplicate(int[] nums) { if (nums == null || nums.length == 0) { return false; } HashSet set = new HashSet<>(); for (int num : nums) { if (set.contains(num)) { return true; } set.add(num); } return false; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return false ; } HashSet < Integer > var_7 = new HashSet < > ( ) ; for ( int var_8 : var_1 ) { if ( var_7 . contains ( var_8 ) ) { return true ; } var_7 . add ( var_8 ) ; } return false ; } " 641,76. Minimum Window Substring_1.java,"public String minWindow(String s, String t) { int left = 0, right = 0, start = 0, counter = t.length(); int minLen = Integer.MAX_VALUE, n = s.length(); int[] freq = new int[256]; for (char c : t.toCharArray()) freq[c]++; while (right < n) { char head = s.charAt(right++); if (freq[head] > 0) counter--; freq[head]--; while (counter == 0) { int len = right - left; if (len < minLen) { minLen = len; start = left; } char tail = s.charAt(left++); if (freq[tail] == 0) counter++; freq[tail]++; } } return minLen == Integer.MAX_VALUE ? """" : s.substring(start, start + minLen); }","public String var_0 ( String var_2 , String var_3 ) { int var_5 = 0 , var_6 = 0 , var_7 = 0 , var_9 = var_3 . length ( ) ; int var_12 = Integer . MAX_VALUE , var_13 = var_2 . length ( ) ; int [ ] var_15 = new int [ 256 ] ; for ( char var_17 : var_3 . toCharArray ( ) ) var_15 [ var_17 ] ++ ; while ( var_6 < var_13 ) { char var_19 = var_2 . charAt ( var_6 ++ ) ; if ( var_15 [ var_19 ] > 0 ) var_9 -- ; var_15 [ var_19 ] -- ; while ( var_9 == 0 ) { int var_20 = var_6 - var_5 ; if ( var_20 < var_12 ) { var_12 = var_20 ; var_7 = var_5 ; } char var_21 = var_2 . charAt ( var_5 ++ ) ; if ( var_15 [ var_21 ] == 0 ) var_9 ++ ; var_15 [ var_21 ] ++ ; } } return var_12 == Integer . MAX_VALUE ? """" : var_2 . substring ( var_7 , var_7 + var_12 ) ; } " 642,Sort Colors II_2.java,"public void swap(int[] colors, int x, int y){ int temp = colors[x]; colors[x] = colors[y]; colors[y] = temp; }","public void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 643,Scramble String_1.java,"public boolean isScramble(String s1, String s2) { if (s1 == null || s2 == null) { return s1 == null && s2 == null; } if (s1.length() != s2.length()) { return false; } if (s1.equals(s2)) { return true; } int n = s1.length(); boolean[][][] dp = new boolean[n][n][n + 1]; int len = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { dp[i][j][1] = s1.charAt(i) == s2.charAt(j); } } for (len = 2; len <= n; len++) { for (int i = 0; i <= n - len; i++) { for (int j = 0; j <= n - len; j++) { for (int w = 1; w < len; w++) { dp[i][j][len] |= dp[i][j][w] && dp[i + w][j + w][len - w]; dp[i][j][len] |= dp[i][j + (len - w)][w] && dp[i + w][j][len - w]; } } } } return dp[0][0][n]; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null ) { return var_2 == null && var_3 == null ; } if ( var_2 . length ( ) != var_3 . length ( ) ) { return false ; } if ( var_2 . equals ( var_3 ) ) { return true ; } int var_7 = var_2 . length ( ) ; boolean [ ] [ ] [ ] var_10 = new boolean [ var_7 ] [ var_7 ] [ var_7 + 1 ] ; int var_11 = 1 ; for ( int var_13 = 0 ; var_13 < var_7 ; var_13 ++ ) { for ( int var_14 = 0 ; var_14 < var_7 ; var_14 ++ ) { var_10 [ var_13 ] [ var_14 ] [ 1 ] = var_2 . charAt ( var_13 ) == var_3 . charAt ( var_14 ) ; } } for ( var_11 = 2 ; var_11 <= var_7 ; var_11 ++ ) { for ( int var_13 = 0 ; var_13 <= var_7 - var_11 ; var_13 ++ ) { for ( int var_14 = 0 ; var_14 <= var_7 - var_11 ; var_14 ++ ) { for ( int var_17 = 1 ; var_17 < var_11 ; var_17 ++ ) { var_10 [ var_13 ] [ var_14 ] [ var_11 ] |= var_10 [ var_13 ] [ var_14 ] [ var_17 ] && var_10 [ var_13 + var_17 ] [ var_14 + var_17 ] [ var_11 - var_17 ] ; var_10 [ var_13 ] [ var_14 ] [ var_11 ] |= var_10 [ var_13 ] [ var_14 + ( var_11 - var_17 ) ] [ var_17 ] && var_10 [ var_13 + var_17 ] [ var_14 ] [ var_11 - var_17 ] ; } } } } return var_10 [ 0 ] [ 0 ] [ var_7 ] ; } " 644,Sliding Puzzle_1.java,"private void swap(int[] nums, int x, int y, int mX, int mY) { int oldIndex = x * 3 + y; int newIndex = mX * 3 + mY; int temp = nums[oldIndex]; nums[oldIndex] = nums[newIndex]; nums[newIndex] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 , int var_4 , int var_5 ) { int var_7 = var_2 * 3 + var_3 ; int var_8 = var_4 * 3 + var_5 ; int var_9 = var_1 [ var_7 ] ; var_1 [ var_7 ] = var_1 [ var_8 ] ; var_1 [ var_8 ] = var_9 ; } " 645,246. Strobogrammatic Number_1.java,"private HashMap buildMap() { HashMap map = new HashMap<>(); map.put('0','0'); map.put('1','1'); map.put('8','8'); map.put('6','9'); map.put('9','6'); return map; }","private HashMap < Character , Character > var_1 ( ) { HashMap < Character , Character > var_3 = new HashMap < > ( ) ; var_3 . put ( '0' , '0' ) ; var_3 . put ( '1' , '1' ) ; var_3 . put ( '8' , '8' ) ; var_3 . put ( '6' , '9' ) ; var_3 . put ( '9' , '6' ) ; return var_3 ; } " 646,58. Length of Last Word_1.java,"public int lengthOfLastWord(String s) { if (s == null || s.length() == 0) { return 0; } s = s.trim(); for (int i = s.length() - 1; i >= 0; i--) { if (s.charAt(i) == ' ') { return s.length() - i - 1; } } return s.length(); }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } var_1 = var_1 . trim ( ) ; for ( int var_7 = var_1 . length ( ) - 1 ; var_7 >= 0 ; var_7 -- ) { if ( var_1 . charAt ( var_7 ) == ' ' ) { return var_1 . length ( ) - var_7 - 1 ; } } return var_1 . length ( ) ; } " 647,Word Search II_1.java,"private boolean validateInput(char[][] board, String[] words) { return board == null || board.length == 0 || board[0] == null || board[0].length == 0 || words == null || words.length == 0; }","private boolean var_0 ( char [ ] [ ] var_1 , String [ ] var_3 ) { return var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 || var_3 == null || var_3 . length == 0 ; } " 648,Longest Common Substring_3.java,"public int longestCommonSubstring(String A, String B) { if (A == null || B == null || A.length() == 0 || B.length() == 0) { return 0; } int n = A.length(); int max = 0; for (int i = 0; i < n; i++) { for(int j = 0; j <= i; j++) { String subStr = A.substring(j, i + 1); if (B.contains(subStr)) { max = Math.max(max, subStr.length()); } } } return max; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) == 0 || var_2 . length ( ) == 0 ) { return 0 ; } int var_6 = var_1 . length ( ) ; int max = 0 ; for ( int var_8 = 0 ; var_8 < var_6 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 <= var_8 ; var_9 ++ ) { String var_12 = var_1 . substring ( var_9 , var_8 + 1 ) ; if ( var_2 . contains ( var_12 ) ) { max = Math . max ( max , var_12 . length ( ) ) ; } } } return max ; } " 649,Median of two Sorted Arrays_1.java,"private int findKth(int[] numsA, int startA, int[] numsB, int startB, int k) { if (startA >= numsA.length) return numsB[startB + k - 1]; if (startB >= numsB.length) return numsA[startA + k - 1]; if (k == 1) return Math.min(numsA[startA], numsB[startB]); int halfKthOfA = startA + k / 2 - 1 < numsA.length ? numsA[startA + k / 2 - 1] : Integer.MAX_VALUE; int halfKthOfB = startB + k / 2 - 1 < numsB.length ? numsB[startB + k / 2 - 1] : Integer.MAX_VALUE; if (halfKthOfA < halfKthOfB) { return findKth(numsA, startA + k / 2, numsB, startB, k - k / 2); } else { return findKth(numsA, startA, numsB, startB + k / 2, k - k / 2); } }","private int sample_funcname ( int [ ] numsA , int startA , int [ ] numsB , int startB , int k ) { if ( startA >= numsA . length ) return numsB [ startB + k - 1 ] ; if ( startB >= numsB . length ) return numsA [ startA + k - 1 ] ; if ( k == 1 ) return Math . min ( numsA [ startA ] , numsB [ startB ] ) ; int halfKthOfA = startA + k / 2 - 1 < numsA . length ? numsA [ startA + k / 2 - 1 ] : Integer . MAX_VALUE ; int halfKthOfB = startB + k / 2 - 1 < numsB . length ? numsB [ startB + k / 2 - 1 ] : Integer . MAX_VALUE ; if ( halfKthOfA < halfKthOfB ) { return findKth ( numsA , startA + k / 2 , numsB , startB , k - k / 2 ) ; } else { return findKth ( numsA , startA , numsB , startB + k / 2 , k - k / 2 ) ; } } " 650,311. Sparse Matrix Multiplication_2.java,"private int multiple(int[][] A, int[][] B, int row, int col) { int sum = 0; for (int i = 0; i < B.length; i++) sum += A[row][i] * B[i][col]; return sum; }","private int sample_funcname ( int [ ] [ ] var_0 , int [ ] [ ] var_1 , int var_2 , int var_3 ) { int var_5 = 0 ; for ( int var_6 = 0 ; var_6 < var_1 . length ; var_6 ++ ) var_5 += var_0 [ var_2 ] [ var_6 ] * var_1 [ var_6 ] [ var_3 ] ; return var_5 ; } " 651,265. Paint House II_4.java,"public int minCostII(int[][] costs) { if (costs == null || costs.length == 0) { return 0; } else if (costs.length == 1 && costs[0].length == 1) { return costs[0][0]; } int minCost = Integer.MAX_VALUE; int n = costs.length, k = costs[0].length; int[][] dp = new int[2][k]; for (int i = 1; i <= n; i++) { int minIndex = -1, minSecIndex = -1; for (int j = 0; j < k; j++) { if (minIndex == -1 || dp[(i - 1) % 2][j] < dp[(i - 1) % 2][minIndex]) { minSecIndex = minIndex; minIndex = j; } else if (minSecIndex == -1 || dp[(i - 1) % 2][j] < dp[(i - 1) % 2][minSecIndex]) { minSecIndex = j; } } for (int j = 0; j < k; j++) { if (j == minIndex) dp[i % 2][j] = dp[(i - 1) % 2][minSecIndex] + costs[i - 1][j]; else dp[i % 2][j] = dp[(i - 1) % 2][minIndex] + costs[i - 1][j]; if (i == n) minCost = Math.min(minCost, dp[i % 2][j]); } } return minCost; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } else if ( var_0 . length == 1 && var_0 [ 0 ] . length == 1 ) { return var_0 [ 0 ] [ 0 ] ; } int var_7 = Integer . MAX_VALUE ; int var_8 = var_0 . length , var_9 = var_0 [ 0 ] . length ; int [ ] [ ] var_11 = new int [ 2 ] [ var_9 ] ; for ( int var_12 = 1 ; var_12 <= var_8 ; var_12 ++ ) { int var_13 = - 1 , var_14 = - 1 ; for ( int var_15 = 0 ; var_15 < var_9 ; var_15 ++ ) { if ( var_13 == - 1 || var_11 [ ( var_12 - 1 ) % 2 ] [ var_15 ] < var_11 [ ( var_12 - 1 ) % 2 ] [ var_13 ] ) { var_14 = var_13 ; var_13 = var_15 ; } else if ( var_14 == - 1 || var_11 [ ( var_12 - 1 ) % 2 ] [ var_15 ] < var_11 [ ( var_12 - 1 ) % 2 ] [ var_14 ] ) { var_14 = var_15 ; } } for ( int var_15 = 0 ; var_15 < var_9 ; var_15 ++ ) { if ( var_15 == var_13 ) var_11 [ var_12 % 2 ] [ var_15 ] = var_11 [ ( var_12 - 1 ) % 2 ] [ var_14 ] + var_0 [ var_12 - 1 ] [ var_15 ] ; else var_11 [ var_12 % 2 ] [ var_15 ] = var_11 [ ( var_12 - 1 ) % 2 ] [ var_13 ] + var_0 [ var_12 - 1 ] [ var_15 ] ; if ( var_12 == var_8 ) var_7 = Math . min ( var_7 , var_11 [ var_12 % 2 ] [ var_15 ] ) ; } } return var_7 ; } " 652,Minimum Swaps To Make Sequences Increasing_1.java,"public int minSwap(int[] A, int[] B) { if (A.length != B.length) return 0; int n = A.length; int[][] dp = new int[n][2]; dp[0][0] = 0; dp[0][1] = 1; for (int i = 1; i < n; i++) { dp[i][0] = dp[i][1] = Integer.MAX_VALUE; if (A[i] > A[i - 1] && B[i] > B[i - 1]) { dp[i][0] = dp[i - 1][0]; dp[i][1] = dp[i - 1][1] + 1; } if (A[i] > B[i - 1] && B[i] > A[i - 1]) { dp[i][0] = Math.min(dp[i][0], dp[i - 1][1]); dp[i][1] = Math.min(dp[i][1], dp[i - 1][0] + 1); } } return Math.min(dp[n-1][0], dp[n-1][1]); }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { if ( var_0 . length != var_1 . length ) return 0 ; int var_4 = var_0 . length ; int [ ] [ ] var_6 = new int [ var_4 ] [ 2 ] ; var_6 [ 0 ] [ 0 ] = 0 ; var_6 [ 0 ] [ 1 ] = 1 ; for ( int var_8 = 1 ; var_8 < var_4 ; var_8 ++ ) { var_6 [ var_8 ] [ 0 ] = var_6 [ var_8 ] [ 1 ] = Integer . MAX_VALUE ; if ( var_0 [ var_8 ] > var_0 [ var_8 - 1 ] && var_1 [ var_8 ] > var_1 [ var_8 - 1 ] ) { var_6 [ var_8 ] [ 0 ] = var_6 [ var_8 - 1 ] [ 0 ] ; var_6 [ var_8 ] [ 1 ] = var_6 [ var_8 - 1 ] [ 1 ] + 1 ; } if ( var_0 [ var_8 ] > var_1 [ var_8 - 1 ] && var_1 [ var_8 ] > var_0 [ var_8 - 1 ] ) { var_6 [ var_8 ] [ 0 ] = Math . min ( var_6 [ var_8 ] [ 0 ] , var_6 [ var_8 - 1 ] [ 1 ] ) ; var_6 [ var_8 ] [ 1 ] = Math . min ( var_6 [ var_8 ] [ 1 ] , var_6 [ var_8 - 1 ] [ 0 ] + 1 ) ; } } return Math . min ( var_6 [ var_4 - 1 ] [ 0 ] , var_6 [ var_4 - 1 ] [ 1 ] ) ; } " 653,134. Gas Station_1.java,"public int canCompleteCircuit(int[] gas, int[] cost) { if (gas == null || cost == null || gas.length == 0 || cost.length == 0) { return -1; } int startIndex = 0, remain = 0, total = 0; for (int i = 0; i < gas.length; i++) { total += gas[i] - cost[i]; remain += gas[i] - cost[i]; if (remain < 0) { remain = 0; startIndex = i + 1; } } return total < 0 ? -1 : startIndex; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { if ( var_0 == null || var_1 == null || var_0 . length == 0 || var_1 . length == 0 ) { return - 1 ; } int var_6 = 0 , var_7 = 0 , var_8 = 0 ; for ( int var_9 = 0 ; var_9 < var_0 . length ; var_9 ++ ) { var_8 += var_0 [ var_9 ] - var_1 [ var_9 ] ; var_7 += var_0 [ var_9 ] - var_1 [ var_9 ] ; if ( var_7 < 0 ) { var_7 = 0 ; var_6 = var_9 + 1 ; } } return var_8 < 0 ? - 1 : var_6 ; } " 654,311. Sparse Matrix Multiplication_3.java,"private boolean validate(int[][] A, int[][] B) { if (A == null || B == null) return true; if (A[0].length != B.length) return true; return false; }","private boolean var_0 ( int [ ] [ ] var_1 , int [ ] [ ] var_2 ) { if ( var_1 == null || var_2 == null ) return true ; if ( var_1 [ 0 ] . length != var_2 . length ) return true ; return false ; } " 655,350. Intersection of Two Arrays II_1.java,"private Map buildCountMap(int[] nums) { Map map = new HashMap<>(); for (int num : nums) { map.putIfAbsent(num, 0); map.put(num, map.get(num) + 1); } return map; }","private Map < Integer , Integer > var_1 ( int [ ] var_2 ) { Map < Integer , Integer > var_5 = new HashMap < > ( ) ; for ( int var_6 : var_2 ) { var_5 . putIfAbsent ( var_6 , 0 ) ; var_5 . put ( var_6 , var_5 . get ( var_6 ) + 1 ) ; } return var_5 ; } " 656,621. Task Scheduler_2.java,"public int leastInterval(char[] tasks, int n) { if (tasks == null) return 0; int[] count = new int[26]; for (char c : tasks) count[c - 'A']++; Arrays.sort(count); int max = count[25], i = 25; while (i >= 0 && count[i] == max) i--; int countRepeatedTopTask = 25 - i; return Math.max(tasks.length, (max - 1) * (n + 1) + countRepeatedTopTask); }","public int sample_funcname ( char [ ] var_0 , int var_1 ) { if ( var_0 == null ) return 0 ; int [ ] var_5 = new int [ 26 ] ; for ( char var_6 : var_0 ) var_5 [ var_6 - 'A' ] ++ ; Arrays . sort ( var_5 ) ; int max = var_5 [ 25 ] , var_12 = 25 ; while ( var_12 >= 0 && var_5 [ var_12 ] == max ) var_12 -- ; int var_13 = 25 - var_12 ; return Math . max ( var_0 . length , ( max - 1 ) * ( var_1 + 1 ) + var_13 ) ; } " 657,64. Minimum Path Sum_1.java,"public int minPathSum(int[][] grid) { if (grid == null || grid.length == 0 || grid[0] == null || grid[0].length == 0) return 0; int m = grid.length, n = grid[0].length; int[][] dp = new int[m][n]; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { dp[i][j] = grid[i][j]; if (i == 0 && j == 0) continue; int fromUp = i == 0 ? Integer.MAX_VALUE : dp[i - 1][j]; int fromLeft = j == 0 ? Integer.MAX_VALUE : dp[i][j - 1]; dp[i][j] += Math.min(fromUp, fromLeft); } } return dp[m - 1][n - 1]; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ; int [ ] [ ] var_6 = new int [ var_4 ] [ var_5 ] ; for ( int var_7 = 0 ; var_7 < var_4 ; var_7 ++ ) { for ( int var_8 = 0 ; var_8 < var_5 ; var_8 ++ ) { var_6 [ var_7 ] [ var_8 ] = var_0 [ var_7 ] [ var_8 ] ; if ( var_7 == 0 && var_8 == 0 ) continue ; int var_12 = var_7 == 0 ? Integer . MAX_VALUE : var_6 [ var_7 - 1 ] [ var_8 ] ; int var_13 = var_8 == 0 ? Integer . MAX_VALUE : var_6 [ var_7 ] [ var_8 - 1 ] ; var_6 [ var_7 ] [ var_8 ] += Math . min ( var_12 , var_13 ) ; } } return var_6 [ var_4 - 1 ] [ var_5 - 1 ] ; } " 658,361. Bomb Enemy_2.java,"public int maxKilledEnemies(char[][] grid) { if (grid == null || grid.length == 0 || grid[0].length == 0) return 0; int m = grid.length, n = grid[0].length; int[] colSum = new int[n]; int max = 0; int row = 0; for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (j == 0 || grid[i][j - 1] == 'W') { row = 0; for (int k = j; k < n && grid[i][k] != 'W'; k++) { row += grid[i][k] == 'E' ? 1 : 0; } } if (i == 0 || grid[i - 1][j] == 'W') { colSum[j] = 0; for (int k = i; k < m && grid[k][j] != 'W'; k++) { colSum[j] += grid[k][j] == 'E' ? 1 : 0; } } if (grid[i][j] == '0') max = Math.max(max, colSum[j] + row); } } return max; }","public int sample_funcname ( char [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ; int [ ] var_6 = new int [ var_5 ] ; int max = 0 ; int var_8 = 0 ; for ( int var_9 = 0 ; var_9 < var_4 ; var_9 ++ ) { for ( int var_10 = 0 ; var_10 < var_5 ; var_10 ++ ) { if ( var_10 == 0 || var_0 [ var_9 ] [ var_10 - 1 ] == 'W' ) { var_8 = 0 ; for ( int var_13 = var_10 ; var_13 < var_5 && var_0 [ var_9 ] [ var_13 ] != 'W' ; var_13 ++ ) { var_8 += var_0 [ var_9 ] [ var_13 ] == 'E' ? 1 : 0 ; } } if ( var_9 == 0 || var_0 [ var_9 - 1 ] [ var_10 ] == 'W' ) { var_6 [ var_10 ] = 0 ; for ( int var_13 = var_9 ; var_13 < var_4 && var_0 [ var_13 ] [ var_10 ] != 'W' ; var_13 ++ ) { var_6 [ var_10 ] += var_0 [ var_13 ] [ var_10 ] == 'E' ? 1 : 0 ; } } if ( var_0 [ var_9 ] [ var_10 ] == '0' ) max = Math . max ( max , var_6 [ var_10 ] + var_8 ) ; } } return max ; } " 659,518. Coin Change 2_1.java,"public int change(int amount, int[] coins) { if (amount == 0) return 1; int[] dp = new int[amount + 1]; dp[0] = 1; for (int coin : coins) { for (int i = coin; i <= amount; i++) { dp[i] += dp[i - coin]; } } return dp[amount]; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_0 == 0 ) return 1 ; int [ ] var_4 = new int [ var_0 + 1 ] ; var_4 [ 0 ] = 1 ; for ( int var_5 : var_1 ) { for ( int var_6 = var_5 ; var_6 <= var_0 ; var_6 ++ ) { var_4 [ var_6 ] += var_4 [ var_6 - var_5 ] ; } } return var_4 [ var_0 ] ; } " 660,Longest Common Substring_2.java,"public int longestCommonSubstring(String A, String B) { if (A == null || B == null || A.length() == 0 || B.length() == 0) { return 0; } int m = A.length(); int n = B.length(); int[][] dp = new int[2][n + 1]; int max = 0; for (int i = 0; i <= m; i++) { for(int j = 0; j <= n; j++) { if (i == 0 || j == 0) { dp[i % 2][j] = 0; continue; } if (A.charAt(i - 1) == B.charAt(j - 1)) { dp[i % 2][j] = dp[(i - 1) % 2][j - 1] + 1; } else { dp[i % 2][j] = 0; } max = Math.max(max, dp[i % 2][j]); } } return max; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) == 0 || var_2 . length ( ) == 0 ) { return 0 ; } int var_6 = var_1 . length ( ) ; int var_7 = var_2 . length ( ) ; int [ ] [ ] var_10 = new int [ 2 ] [ var_7 + 1 ] ; int max = 0 ; for ( int var_12 = 0 ; var_12 <= var_6 ; var_12 ++ ) { for ( int var_13 = 0 ; var_13 <= var_7 ; var_13 ++ ) { if ( var_12 == 0 || var_13 == 0 ) { var_10 [ var_12 % 2 ] [ var_13 ] = 0 ; continue ; } if ( var_1 . charAt ( var_12 - 1 ) == var_2 . charAt ( var_13 - 1 ) ) { var_10 [ var_12 % 2 ] [ var_13 ] = var_10 [ ( var_12 - 1 ) % 2 ] [ var_13 - 1 ] + 1 ; } else { var_10 [ var_12 % 2 ] [ var_13 ] = 0 ; } max = Math . max ( max , var_10 [ var_12 % 2 ] [ var_13 ] ) ; } } return max ; } " 661,Power of Two_1.java,"public boolean isPowerOfTwo(int n) { if (n <= 0) { return false; } while (n != 1) { if (n % 2 != 0 || n / 2 == 0) { return false; } n/=2; } return true; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 0 ) { return false ; } while ( var_1 != 1 ) { if ( var_1 % 2 != 0 || var_1 / 2 == 0 ) { return false ; } var_1 /= 2 ; } return true ; } " 662,Backpack_1.java,"public int backPack(int m, int[] A) { if (A == null || A.length < 0) { return 0; } int n = A.length; int[][] dp = new int[n + 1][m + 1]; for (int i = 1; i <= n; i++) { for (int j = 0; j <= m; j++) { dp[i][j] = dp[i - 1][j]; if (j - A[i - 1] >= 0) { dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - A[i - 1]] + A[i - 1]); } } } return dp[n][m]; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length < 0 ) { return 0 ; } int var_5 = var_1 . length ; int [ ] [ ] var_7 = new int [ var_5 + 1 ] [ var_0 + 1 ] ; for ( int var_8 = 1 ; var_8 <= var_5 ; var_8 ++ ) { for ( int var_9 = 0 ; var_9 <= var_0 ; var_9 ++ ) { var_7 [ var_8 ] [ var_9 ] = var_7 [ var_8 - 1 ] [ var_9 ] ; if ( var_9 - var_1 [ var_8 - 1 ] >= 0 ) { var_7 [ var_8 ] [ var_9 ] = Math . max ( var_7 [ var_8 ] [ var_9 ] , var_7 [ var_8 - 1 ] [ var_9 - var_1 [ var_8 - 1 ] ] + var_1 [ var_8 - 1 ] ) ; } } } return var_7 [ var_5 ] [ var_0 ] ; } " 663,850. Rectangle Area II_1.java,"private int calcHeightDiff(TreeMap map) { int height = 0, pre = 0, count = 0; for (Map.Entry e : map.entrySet()) { if (count > 0) height += e.getKey() - pre; count += e.getValue(); pre = e.getKey(); } return height; }","private int sample_funcname ( TreeMap < Integer , Integer > var_2 ) { int var_4 = 0 , var_5 = 0 , var_6 = 0 ; for ( Map . Entry < Integer , Integer > var_8 : var_2 . entrySet ( ) ) { if ( var_6 > 0 ) var_4 += var_8 . getKey ( ) - var_5 ; var_6 += var_8 . getValue ( ) ; var_5 = var_8 . getKey ( ) ; } return var_4 ; } " 664,Find Minimum in Rotated Sorted Array II_2.java,"public int findMin(int[] num) { if (num == null || num.length == 0) { return -1; } int min = Integer.MAX_VALUE; for (int i = 0; i < num.length; i++) { if (min > num[i]) { min = num[i]; } } return min; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int var_7 = Integer . MAX_VALUE ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { if ( var_7 > var_0 [ var_8 ] ) { var_7 = var_0 [ var_8 ] ; } } return var_7 ; } " 665,Gray Code_1.java,"public void helper(List rst, char[] list, int index) { rst.add(Integer.parseInt(new String(list), 2)); list[index] = list[index] == '0' ? '1' : '0'; int num = Integer.parseInt(new String(list), 2); if (!rst.contains(num)) { helper(rst, list, index); } list[index] = list[index] == '0' ? '1' : '0'; if (index -1 >= 0) { list[index - 1] = list[index - 1] == '0' ? '1' : '0'; num = Integer.parseInt(new String(list), 2); if (!rst.contains(num)) { helper(rst, list, index - 1); } list[index - 1] = list[index - 1] == '0' ? '1' : '0'; } if (index + 1 < list.length) { list[index + 1] = list[index + 1] == '0' ? '1' : '0'; num = Integer.parseInt(new String(list), 2); if (!rst.contains(num)) { helper(rst, list, index + 1); } list[index + 1] = list[index + 1] == '0' ? '1' : '0'; } }","public void sample_funcname ( List < Integer > rst , char [ ] list , int index ) { rst . add ( Integer . parseInt ( new String ( list ) , 2 ) ) ; list [ index ] = list [ index ] == '0' ? '1' : '0' ; int num = Integer . parseInt ( new String ( list ) , 2 ) ; if ( ! rst . contains ( num ) ) { helper ( rst , list , index ) ; } list [ index ] = list [ index ] == '0' ? '1' : '0' ; if ( index - 1 >= 0 ) { list [ index - 1 ] = list [ index - 1 ] == '0' ? '1' : '0' ; num = Integer . parseInt ( new String ( list ) , 2 ) ; if ( ! rst . contains ( num ) ) { helper ( rst , list , index - 1 ) ; } list [ index - 1 ] = list [ index - 1 ] == '0' ? '1' : '0' ; } if ( index + 1 < list . length ) { list [ index + 1 ] = list [ index + 1 ] == '0' ? '1' : '0' ; num = Integer . parseInt ( new String ( list ) , 2 ) ; if ( ! rst . contains ( num ) ) { helper ( rst , list , index + 1 ) ; } list [ index + 1 ] = list [ index + 1 ] == '0' ? '1' : '0' ; } } " 666,80.Remove Duplicates from Sorted Array II_1.java,"public int removeDuplicates(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int index = 1; for (int i = 2; i < nums.length; i++) { if (nums[i] != nums[index] || (nums[i] == nums[index] && nums[i] != nums[index - 1])) { nums[++index] = nums[i]; } } return index + 1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = 1 ; for ( int var_7 = 2 ; var_7 < var_0 . length ; var_7 ++ ) { if ( var_0 [ var_7 ] != var_0 [ var_5 ] || ( var_0 [ var_7 ] == var_0 [ var_5 ] && var_0 [ var_7 ] != var_0 [ var_5 - 1 ] ) ) { var_0 [ ++ var_5 ] = var_0 [ var_7 ] ; } } return var_5 + 1 ; } " 667,Kth Largest Element in an Array_1.java,"public int findKthLargest(int[] nums, int k) { if (nums == null || nums.length == 0) return -1; PriorityQueue queue = new PriorityQueue<>(); for (int i = 0; i < nums.length; i++) { if (i < k || nums[i] > queue.peek()) queue.offer(nums[i]); if (queue.size() > k) queue.poll(); } return queue.poll(); }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) return - 1 ; PriorityQueue < Integer > var_8 = new PriorityQueue < > ( ) ; for ( int var_9 = 0 ; var_9 < var_0 . length ; var_9 ++ ) { if ( var_9 < var_1 || var_0 [ var_9 ] > var_8 . peek ( ) ) var_8 . offer ( var_0 [ var_9 ] ) ; if ( var_8 . size ( ) > var_1 ) var_8 . poll ( ) ; } return var_8 . poll ( ) ; } " 668,Encode and Decode Strings_2.java,"public List decode(String s) { List strs = new ArrayList<>(); if (s == null || s.length() == 0) { return strs; } int start = 0; while (start < s.length()) { int ind = s.indexOf(""#"", start); int leng = Integer.parseInt(s.substring(start, ind)); int end = ind + 1 + leng; strs.add(s.substring(ind + 1, end)); start = end; } return strs; }","public List < String > var_1 ( String var_2 ) { List < String > var_5 = new ArrayList < > ( ) ; if ( var_2 == null || var_2 . length ( ) == 0 ) { return var_5 ; } int var_9 = 0 ; while ( var_9 < var_2 . length ( ) ) { int var_12 = var_2 . indexOf ( ""#"" , var_9 ) ; int var_16 = Integer . parseInt ( var_2 . substring ( var_9 , var_12 ) ) ; int var_18 = var_12 + 1 + var_16 ; var_5 . add ( var_2 . substring ( var_12 + 1 , var_18 ) ) ; var_9 = var_18 ; } return var_5 ; } " 669,698. Partition to K Equal Sum Subsets_1.java,"private boolean dfs(Queue queue, int size, int k, int sum, int target) { if (k == 0) return true; if (sum == target) return dfs(queue, queue.size(), k - 1, 0, target); while (size-- > 0) { int num = queue.poll(); if (sum + num <= target && dfs(queue, size+1, k, sum + num, target)) return true; queue.offer(num); } return false; }","private boolean sample_funcname ( Queue < Integer > queue , int size , int k , int sum , int target ) { if ( k == 0 ) return true ; if ( sum == target ) return dfs ( queue , queue . size ( ) , k - 1 , 0 , target ) ; while ( size -- > 0 ) { int num = queue . poll ( ) ; if ( sum + num <= target && dfs ( queue , size + 1 , k , sum + num , target ) ) return true ; queue . offer ( num ) ; } return false ; } " 670,105. Construct Binary Tree from Preorder and Inorder Traversal_2.java,"private Map buildMap(int[] inorder) { Map map = new HashMap<>(); for (int i = 0; i < inorder.length; i++) map.put(inorder[i], i); return map; }","private Map < Integer , Integer > var_1 ( int [ ] var_2 ) { Map < Integer , Integer > var_5 = new HashMap < > ( ) ; for ( int var_7 = 0 ; var_7 < var_2 . length ; var_7 ++ ) var_5 . put ( var_2 [ var_7 ] , var_7 ) ; return var_5 ; } " 671,[lint]. Unique Characters_2.java,"public boolean isUnique(String str) { if (str == null || str.length() == 0) { return true; } HashSet set = new HashSet(); for (int i = 0; i < str.length(); i++) { if (!set.contains(str.charAt(i))) { set.add(str.charAt(i)); } else { return false; } } return true; }","public boolean var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) { return true ; } HashSet < Character > var_8 = new HashSet < Character > ( ) ; for ( int var_9 = 0 ; var_9 < var_2 . length ( ) ; var_9 ++ ) { if ( ! var_8 . contains ( var_2 . charAt ( var_9 ) ) ) { var_8 . add ( var_2 . charAt ( var_9 ) ) ; } else { return false ; } } return true ; } " 672,207. Course Schedule_3.java,"private List[] buildIndegreeEdges(int numCourses, int[][] prerequisites) { List[] edges = new ArrayList[numCourses]; for (int i = 0; i < numCourses; i++) edges[i] = new ArrayList<>(); for (int[] prerequisite : prerequisites) { edges[prerequisite[1]].add(prerequisite[0]); } return edges; }","private List [ ] var_0 ( int var_1 , int [ ] [ ] var_2 ) { List [ ] var_5 = new ArrayList [ var_1 ] ; for ( int var_7 = 0 ; var_7 < var_1 ; var_7 ++ ) var_5 [ var_7 ] = new ArrayList < > ( ) ; for ( int [ ] var_8 : var_2 ) { var_5 [ var_8 [ 1 ] ] . add ( var_8 [ 0 ] ) ; } return var_5 ; } " 673,Unique Binary Search Tree_1.java,"public int numTrees(int n) { if ( n <= 1) { return 1; } final int[] numTree = new int[n + 1]; numTree[0] = 1; for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) { numTree[i] += numTree[j] * numTree[i - j - 1]; } } return numTree[n]; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 1 ) { return 1 ; } final int [ ] var_2 = new int [ var_0 + 1 ] ; var_2 [ 0 ] = 1 ; for ( int var_4 = 1 ; var_4 <= var_0 ; var_4 ++ ) { for ( int var_5 = 0 ; var_5 < var_4 ; var_5 ++ ) { var_2 [ var_4 ] += var_2 [ var_5 ] * var_2 [ var_4 - var_5 - 1 ] ; } } return var_2 [ var_0 ] ; } " 674,139. Word Break_1.java,"public boolean wordBreak(String s, List dict) { Set words = new HashSet<>(dict); int n = s.length(); boolean[] dp = new boolean[n + 1]; dp[0] = true; for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) { dp[i] |= dp[j] && words.contains(s.substring(j, i)); if (dp[i]) break; } } return dp[n]; }","public boolean var_0 ( String var_2 , List < String > var_4 ) { Set < String > var_7 = new HashSet < > ( var_4 ) ; int var_9 = var_2 . length ( ) ; boolean [ ] var_12 = new boolean [ var_9 + 1 ] ; var_12 [ 0 ] = true ; for ( int var_13 = 1 ; var_13 <= var_9 ; var_13 ++ ) { for ( int var_15 = 0 ; var_15 < var_13 ; var_15 ++ ) { var_12 [ var_13 ] |= var_12 [ var_15 ] && var_7 . contains ( var_2 . substring ( var_15 , var_13 ) ) ; if ( var_12 [ var_13 ] ) break ; } } return var_12 [ var_9 ] ; } " 675,Add Digits_2.java,"public int addDigits(int num) { return (num - 1) % 9 + 1; }","public int sample_funcname ( int var_0 ) { return ( var_0 - 1 ) % 9 + 1 ; } " 676,Majority Number II_1.java,"public int majorityNumber(List nums) { if (nums == null || nums.size() == 0) { return -1; } int valA = 0; int valB = 0; int countA = 0; int countB = 0; for (int num : nums) { if (num == valA) { countA++; } else if (num == valB) { countB++; } else if (countA == 0) { valA = num; countA++; } else if (countB == 0){ valB = num; countB++; } else { countA--; countB--; } } countA = 0; countB = 0; for (int num : nums) { if (num == valA) { countA++; } else if (num == valB) { countB++; } } return countA > countB ? valA : valB; }","public int sample_funcname ( List < Integer > var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return - 1 ; } int var_7 = 0 ; int var_8 = 0 ; int var_9 = 0 ; int var_10 = 0 ; for ( int var_11 : var_2 ) { if ( var_11 == var_7 ) { var_9 ++ ; } else if ( var_11 == var_8 ) { var_10 ++ ; } else if ( var_9 == 0 ) { var_7 = var_11 ; var_9 ++ ; } else if ( var_10 == 0 ) { var_8 = var_11 ; var_10 ++ ; } else { var_9 -- ; var_10 -- ; } } var_9 = 0 ; var_10 = 0 ; for ( int var_11 : var_2 ) { if ( var_11 == var_7 ) { var_9 ++ ; } else if ( var_11 == var_8 ) { var_10 ++ ; } } return var_9 > var_10 ? var_7 : var_8 ; } " 677,Basic Calculator_2.java,"private boolean isDigit(char c) { return c >= '0' && c <= '9'; }","private boolean var_0 ( char var_1 ) { return var_1 >= '0' && var_1 <= '9' ; } " 678,727. Minimum Window Subsequence_2.java,"public String minWindow(String s, String t) { int sIndex = 0, tIndex = 0, start = -1; int m = s.length(), n = t.length(), minLength = m; char[] ss = s.toCharArray(), tt = t.toCharArray(); while (sIndex < m) { if(ss[sIndex] == tt[tIndex]) { if(tIndex++ == n - 1) { int end = sIndex + 1; while(tIndex-- > 0) { while(ss[sIndex--] != tt[tIndex]); } sIndex++; tIndex++; if (end - sIndex < minLength) { minLength = end - sIndex; start = sIndex; } } } sIndex++; } return start == -1 ? """" : s.substring(start, start + minLength); }","public String var_0 ( String var_2 , String var_3 ) { int var_5 = 0 , var_6 = 0 , var_8 = - 1 ; int var_10 = var_2 . length ( ) , var_11 = var_3 . length ( ) , var_12 = var_10 ; char [ ] var_14 = var_2 . toCharArray ( ) , var_15 = var_3 . toCharArray ( ) ; while ( var_5 < var_10 ) { if ( var_14 [ var_5 ] == var_15 [ var_6 ] ) { if ( var_6 ++ == var_11 - 1 ) { int var_16 = var_5 + 1 ; while ( var_6 -- > 0 ) { while ( var_14 [ var_5 -- ] != var_15 [ var_6 ] ) ; } var_5 ++ ; var_6 ++ ; if ( var_16 - var_5 < var_12 ) { var_12 = var_16 - var_5 ; var_8 = var_5 ; } } } var_5 ++ ; } return var_8 == - 1 ? """" : var_2 . substring ( var_8 , var_8 + var_12 ) ; } " 679,Best Time to Buy and Sell Stock III_3.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length == 0) { return 0; } int[] leftProfit = new int[prices.length]; int[] rightProfit = new int[prices.length]; int min = prices[0]; for (int i = 1; i < prices.length; i++) { min = Math.min(min, prices[i]); leftProfit[i] = Math.max(leftProfit[i - 1], prices[i] - min); } int max = prices[prices.length - 1]; for (int i = prices.length - 2; i >= 0; i--) { max = Math.max(max, prices[i]); rightProfit[i] = Math.max(rightProfit[i + 1], max - prices[i]); } int profit = 0; for (int i = 0; i < prices.length; i++) { profit = Math.max(profit, leftProfit[i] + rightProfit[i]); } return profit; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int [ ] var_4 = new int [ var_0 . length ] ; int [ ] var_5 = new int [ var_0 . length ] ; int min = var_0 [ 0 ] ; for ( int var_8 = 1 ; var_8 < var_0 . length ; var_8 ++ ) { min = Math . min ( min , var_0 [ var_8 ] ) ; var_4 [ var_8 ] = Math . max ( var_4 [ var_8 - 1 ] , var_0 [ var_8 ] - min ) ; } int max = var_0 [ var_0 . length - 1 ] ; for ( int var_8 = var_0 . length - 2 ; var_8 >= 0 ; var_8 -- ) { max = Math . max ( max , var_0 [ var_8 ] ) ; var_5 [ var_8 ] = Math . max ( var_5 [ var_8 + 1 ] , max - var_0 [ var_8 ] ) ; } int var_12 = 0 ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { var_12 = Math . max ( var_12 , var_4 [ var_8 ] + var_5 [ var_8 ] ) ; } return var_12 ; } " 680,Restore IP Addresses_1.java,"public boolean isValid(String str) { if (str.charAt(0) == '0') { return str.equals(""0""); } int num = Integer.parseInt(str); return num <= 255 && num >= 0; }","public boolean var_0 ( String var_2 ) { if ( var_2 . charAt ( 0 ) == '0' ) { return var_2 . equals ( ""0"" ) ; } int var_10 = Integer . parseInt ( var_2 ) ; return var_10 <= 255 && var_10 >= 0 ; } " 681,Walls and Gates_6.java,"private boolean validate(int[][] rooms) { return rooms == null || rooms.length == 0 || rooms[0] == null || rooms[0].length == 0; }","private boolean var_0 ( int [ ] [ ] var_1 ) { return var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 ; } " 682,[lint]. Longest Words_1.java,"public List longestWords(String[] dictionary) { if (dictionary == null || dictionary.length == 0) { return null; } Map> map = new HashMap<>(); int max = 0; for (String word : dictionary) { int length = word.length(); map.putIfAbsent(length, new ArrayList<>()); map.get(length).add(word); max = Math.max(max, length); } return map.get(max); }","public List < String > var_1 ( String [ ] var_2 ) { if ( var_2 == null || var_2 . length == 0 ) { return null ; } Map < Integer , List < String >> var_10 = new HashMap < > ( ) ; int max = 0 ; for ( String var_12 : var_2 ) { int length = var_12 . length ( ) ; var_10 . putIfAbsent ( length , new ArrayList < > ( ) ) ; var_10 . get ( length ) . add ( var_12 ) ; max = Math . max ( max , length ) ; } return var_10 . get ( max ) ; } " 683,1021. Remove Outermost Parentheses_2.java,"public String removeOuterParentheses(String S) { StringBuilder s = new StringBuilder(); int count = 0; for (char c : S.toCharArray()) { if (c == '(' && count++ > 0) s.append(c); if (c == ')' && count-- > 1) s.append(c); } return s.toString(); }","public String var_0 ( String var_2 ) { StringBuilder var_4 = new StringBuilder ( ) ; int var_6 = 0 ; for ( char var_8 : var_2 . toCharArray ( ) ) { if ( var_8 == '(' && var_6 ++ > 0 ) var_4 . append ( var_8 ) ; if ( var_8 == ')' && var_6 -- > 1 ) var_4 . append ( var_8 ) ; } return var_4 . toString ( ) ; } " 684,739. Daily Temperatures_1.java,"public int[] dailyTemperatures(int[] T) { int n = T.length; int[] rst = new int[n]; Stack stack = new Stack<>(); for (int i = n - 1; i >= 0; i--) { int num = T[i]; while (!stack.isEmpty() && num >= T[stack.peek()]) stack.pop(); if (!stack.isEmpty() && num < T[stack.peek()]) rst[i] = stack.peek() - i; else rst[i] = 0; stack.push(i); } return rst; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; int [ ] var_3 = new int [ var_2 ] ; Stack < Integer > var_6 = new Stack < > ( ) ; for ( int var_8 = var_2 - 1 ; var_8 >= 0 ; var_8 -- ) { int var_10 = var_0 [ var_8 ] ; while ( ! var_6 . isEmpty ( ) && var_10 >= var_0 [ var_6 . peek ( ) ] ) var_6 . pop ( ) ; if ( ! var_6 . isEmpty ( ) && var_10 < var_0 [ var_6 . peek ( ) ] ) var_3 [ var_8 ] = var_6 . peek ( ) - var_8 ; else var_3 [ var_8 ] = 0 ; var_6 . push ( var_8 ) ; } return var_3 ; } " 685,Convert Expression to Reverse Polish Notation_1.java,"public int getWeight(int base, String s) { if (s.equals(""+"") || s.equals(""-"")) { return base + 1; } if (s.equals(""*"") || s.equals(""/"")) { return base + 2; } return Integer.MAX_VALUE; }","public int sample_funcname ( int var_0 , String var_2 ) { if ( var_2 . equals ( ""+"" ) || var_2 . equals ( ""-"" ) ) { return var_0 + 1 ; } if ( var_2 . equals ( ""*"" ) || var_2 . equals ( ""/"" ) ) { return var_0 + 2 ; } return Integer . MAX_VALUE ; } " 686,788. Rotated Digits_2.java,"private boolean validate(int[] count) { int failure = count[3] + + count[4] + count[7]; if (failure != 0) return false; int success = count[2] + + count[5] + count[6] + count[9]; return success != 0; }","private boolean var_0 ( int [ ] var_1 ) { int var_5 = var_1 [ 3 ] + + var_1 [ 4 ] + var_1 [ 7 ] ; if ( var_5 != 0 ) return false ; int var_11 = var_1 [ 2 ] + + var_1 [ 5 ] + var_1 [ 6 ] + var_1 [ 9 ] ; return var_11 != 0 ; } " 687,Search Insert Position_2.java,"public int searchInsert(ArrayList A, int target) { int start = 0; int end = A.size() - 1; int mid; if (A == null || A.size() == 0 || target <= A.get(0)) { return 0; } while (start + 1 < end) { mid = start + (end - start) / 2; if (A.get(mid) == target) { return mid; } else if (A.get(mid) < target) { start = mid; } else { end = mid; } } if (A.get(end) == target) { return end; } if (A.get(end) < target) { return end + 1; } if (A.get(start) == target) { return start; } return start + 1; }","public int sample_funcname ( ArrayList < Integer > var_2 , int var_3 ) { int var_5 = 0 ; int var_8 = var_2 . size ( ) - 1 ; int var_9 ; if ( var_2 == null || var_2 . size ( ) == 0 || var_3 <= var_2 . get ( 0 ) ) { return 0 ; } while ( var_5 + 1 < var_8 ) { var_9 = var_5 + ( var_8 - var_5 ) / 2 ; if ( var_2 . get ( var_9 ) == var_3 ) { return var_9 ; } else if ( var_2 . get ( var_9 ) < var_3 ) { var_5 = var_9 ; } else { var_8 = var_9 ; } } if ( var_2 . get ( var_8 ) == var_3 ) { return var_8 ; } if ( var_2 . get ( var_8 ) < var_3 ) { return var_8 + 1 ; } if ( var_2 . get ( var_5 ) == var_3 ) { return var_5 ; } return var_5 + 1 ; } " 688,238. Product of Array Except Self_1.java,"private int multiply(int[] rst, int nums[], int i, int carry) { rst[i] *= carry; return carry * nums[i]; }","private int sample_funcname ( int [ ] var_0 , int var_1 [ ] , int var_2 , int var_3 ) { var_0 [ var_2 ] *= var_3 ; return var_3 * var_1 [ var_2 ] ; } " 689,169. Majority Element_4.java,"public int majorityElement(int[] nums) { if (nums == null || nums.length == 0) { return -1; } int majorityNum = nums[0]; int vote = 0; for (int num : nums) { vote += num == majorityNum ? 1 : -1; if (vote == 0) { majorityNum = num; vote = 1; } } return majorityNum; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int var_5 = var_0 [ 0 ] ; int var_6 = 0 ; for ( int var_7 : var_0 ) { var_6 += var_7 == var_5 ? 1 : - 1 ; if ( var_6 == 0 ) { var_5 = var_7 ; var_6 = 1 ; } } return var_5 ; } " 690,Number Of Corner Rectangles_2.java,"private boolean validateRect(int[][] grid, int i, int j, int h, int k) { return grid[i][j] == 1 && grid[h][k] == 1 && grid[i][k] == 1 && grid[h][j] == 1; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 , int var_4 , int var_5 ) { return var_1 [ var_2 ] [ var_3 ] == 1 && var_1 [ var_4 ] [ var_5 ] == 1 && var_1 [ var_2 ] [ var_5 ] == 1 && var_1 [ var_4 ] [ var_3 ] == 1 ; } " 691,Power of Three_4.java,"public boolean isPowerOfThree(int n) { return (n > 0 && Math.pow(3, 19) % n == 0); }","public boolean var_0 ( int var_1 ) { return ( var_1 > 0 && Math . pow ( 3 , 19 ) % var_1 == 0 ) ; } " 692,Reverse Words in a String II_1.java,"public void reverse(char[] s, int start, int end) { while (start < end) { char temp = s[start]; s[start] = s[end]; s[end] = temp; start++; end--; } }","public void var_0 ( char [ ] var_1 , int var_2 , int var_3 ) { while ( var_2 < var_3 ) { char var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; var_2 ++ ; var_3 -- ; } } " 693,53. Maximum Subarray_9.java,"public int maxSubArray(ArrayList nums) { if (nums == null || nums.size() == 0) { return 0; } int[] sums = new int[nums.size()]; sums[0] = nums.get(0); int maxSum = sums[0]; for (int i = 1; i < sums.length; i++) { if (sums[i - 1] < 0) { sums[i] = nums.get(i); } else { sums[i] = sums[i - 1] + nums.get(i); } maxSum = Math.max(maxSum, sums[i]); } return maxSum; }","public int sample_funcname ( ArrayList < Integer > var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return 0 ; } int [ ] var_6 = new int [ var_2 . size ( ) ] ; var_6 [ 0 ] = var_2 . get ( 0 ) ; int var_8 = var_6 [ 0 ] ; for ( int var_10 = 1 ; var_10 < var_6 . length ; var_10 ++ ) { if ( var_6 [ var_10 - 1 ] < 0 ) { var_6 [ var_10 ] = var_2 . get ( var_10 ) ; } else { var_6 [ var_10 ] = var_6 [ var_10 - 1 ] + var_2 . get ( var_10 ) ; } var_8 = Math . max ( var_8 , var_6 [ var_10 ] ) ; } return var_8 ; } " 694,Distinct Subsequences_2.java,"public int numDistinct(String s, String t) { if (s == null || t == null || t.length() > s.length()) { return 0; } else if (s.equals(t)) { return 1; } int m = s.length(); int n = t.length(); int[][] dp = new int[2][n + 1]; int curr = 0; int prev = 0; for (int i = 0; i <= m; i++) { prev = curr; curr = 1 - prev; for (int j = 0; j <= n; j++) { if (j == 0) { dp[curr][j] = 1; continue; } if (i == 0) { dp[curr][j] = 0; continue; } dp[curr][j] = dp[prev][j]; if (s.charAt(i - 1) == t.charAt(j - 1)) { dp[curr][j] += dp[prev][j - 1]; } } } return dp[curr][n]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_2 . length ( ) > var_1 . length ( ) ) { return 0 ; } else if ( var_1 . equals ( var_2 ) ) { return 1 ; } int var_8 = var_1 . length ( ) ; int var_9 = var_2 . length ( ) ; int [ ] [ ] var_11 = new int [ 2 ] [ var_9 + 1 ] ; int var_12 = 0 ; int var_13 = 0 ; for ( int var_14 = 0 ; var_14 <= var_8 ; var_14 ++ ) { var_13 = var_12 ; var_12 = 1 - var_13 ; for ( int var_15 = 0 ; var_15 <= var_9 ; var_15 ++ ) { if ( var_15 == 0 ) { var_11 [ var_12 ] [ var_15 ] = 1 ; continue ; } if ( var_14 == 0 ) { var_11 [ var_12 ] [ var_15 ] = 0 ; continue ; } var_11 [ var_12 ] [ var_15 ] = var_11 [ var_13 ] [ var_15 ] ; if ( var_1 . charAt ( var_14 - 1 ) == var_2 . charAt ( var_15 - 1 ) ) { var_11 [ var_12 ] [ var_15 ] += var_11 [ var_13 ] [ var_15 - 1 ] ; } } } return var_11 [ var_12 ] [ var_9 ] ; } " 695,9. Palindrome Number_1.java,"public boolean isPalindrome(int x) { if (x < 0 || (x != 0 && x % 10 == 0)) return false; int reverse = 0; while (x > reverse){ reverse = reverse * 10 + x % 10; x = x/10; } return (x == reverse || x == reverse / 10); }","public boolean var_0 ( int var_1 ) { if ( var_1 < 0 || ( var_1 != 0 && var_1 % 10 == 0 ) ) return false ; int var_4 = 0 ; while ( var_1 > var_4 ) { var_4 = var_4 * 10 + var_1 % 10 ; var_1 = var_1 / 10 ; } return ( var_1 == var_4 || var_1 == var_4 / 10 ) ; } " 696,Coins in a Line_2.java,"public boolean firstWillWin(int n) { if (n <= 0) { return false; } boolean[] dp = new boolean[2]; dp[0] = false; dp[1] = true; for (int i = 2; i <= n; i++) { dp[i % 2] = !dp[(i - 1) % 2] || !dp[(i - 2) % 2]; } return dp[n % 2]; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 0 ) { return false ; } boolean [ ] var_5 = new boolean [ 2 ] ; var_5 [ 0 ] = false ; var_5 [ 1 ] = true ; for ( int var_6 = 2 ; var_6 <= var_1 ; var_6 ++ ) { var_5 [ var_6 % 2 ] = ! var_5 [ ( var_6 - 1 ) % 2 ] || ! var_5 [ ( var_6 - 2 ) % 2 ] ; } return var_5 [ var_1 % 2 ] ; } " 697,785. Is Graph Bipartite_1.java,"private boolean dfs(int[][] graph, int[] states, int state, int node) { if (states[node] != 0) return states[node] == state; if (graph[node].length == 0) return true; states[node] = state; for (int val : graph[node]) { if (!dfs(graph, states, - state, val)) return false; } return true; }","private boolean sample_funcname ( int [ ] [ ] graph , int [ ] states , int state , int node ) { if ( states [ node ] != 0 ) return states [ node ] == state ; if ( graph [ node ] . length == 0 ) return true ; states [ node ] = state ; for ( int val : graph [ node ] ) { if ( ! dfs ( graph , states , - state , val ) ) return false ; } return true ; } " 698,301. Remove Invalid Parentheses_2.java,"private void dfs(List rst, String s, int x, int y, char open, char close) { for (int count = 0, i = x; i < s.length(); i++) { if (s.charAt(i) == open) count++; if (s.charAt(i) == close) count--; if (count < 0) { for (int j = y; j <= i; j++) { if (s.charAt(j) == close && (j == y || s.charAt(j - 1) != close)) { dfs(rst, s.substring(0, j) + s.substring(j+1), i, j, open, close); } } return; } } String reverse = new StringBuffer(s).reverse().toString(); if (open == '(') { dfs(rst, reverse, 0, 0, close, open); } else { rst.add(reverse); } }","private void sample_funcname ( List < String > rst , String s , int x , int y , char open , char close ) { for ( int count = 0 , i = x ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == open ) count ++ ; if ( s . charAt ( i ) == close ) count -- ; if ( count < 0 ) { for ( int j = y ; j <= i ; j ++ ) { if ( s . charAt ( j ) == close && ( j == y || s . charAt ( j - 1 ) != close ) ) { dfs ( rst , s . substring ( 0 , j ) + s . substring ( j + 1 ) , i , j , open , close ) ; } } return ; } } String reverse = new StringBuffer ( s ) . reverse ( ) . toString ( ) ; if ( open == '(' ) { dfs ( rst , reverse , 0 , 0 , close , open ) ; } else { rst . add ( reverse ) ; } } " 699,Counting Bits_1.java,"public int[] countBits(int num) { if (num < 0) { return null; } int[] dp = new int[num + 1]; dp[0] = 0; for (int i = 1; i <= num; i++) { int prevNum = i >> 1; dp[i] = dp[prevNum] + (i % 2); } return dp; }","public int [ ] sample_funcname ( int var_0 ) { if ( var_0 < 0 ) { return null ; } int [ ] var_4 = new int [ var_0 + 1 ] ; var_4 [ 0 ] = 0 ; for ( int var_5 = 1 ; var_5 <= var_0 ; var_5 ++ ) { int var_6 = var_5 >> 1 ; var_4 [ var_5 ] = var_4 [ var_6 ] + ( var_5 % 2 ) ; } return var_4 ; } " 700,689. Maximum Sum of 3 Non-Overlapping Subarrays_2.java,"private int[] calcRight(int[] nums, int[] presum, int k) { int n = nums.length; int[] right = new int[n]; right[n - k] = n - k; for (int i = n - k - 1, total = presum[n] - presum[n - k]; i>= 0; i--) { int sum = presum[i + k] - presum[i]; if (sum >= total) { right[i] = i; total = sum; } else right[i] = right[i + 1]; } return right; }","private int [ ] sample_funcname ( int [ ] var_0 , int [ ] var_1 , int var_2 ) { int var_4 = var_0 . length ; int [ ] var_5 = new int [ var_4 ] ; var_5 [ var_4 - var_2 ] = var_4 - var_2 ; for ( int var_7 = var_4 - var_2 - 1 , var_8 = var_1 [ var_4 ] - var_1 [ var_4 - var_2 ] ; var_7 >= 0 ; var_7 -- ) { int var_10 = var_1 [ var_7 + var_2 ] - var_1 [ var_7 ] ; if ( var_10 >= var_8 ) { var_5 [ var_7 ] = var_7 ; var_8 = var_10 ; } else var_5 [ var_7 ] = var_5 [ var_7 + 1 ] ; } return var_5 ; } " 701,140. Word Break II_2.java,"public void helper(List result, List list, boolean[][] isWord, boolean[] isValid, String s, int start) { if (!isValid[start]) { return; } if (start >= s.length()) { StringBuffer sb = new StringBuffer(); for (String word : list) { sb.append(word + "" ""); } result.add(sb.toString().trim()); return; } for (int i = start; i < s.length(); i++) { if (!isWord[start][i]) { continue; } list.add(s.substring(start, i + 1)); helper(result, list, isWord, isValid, s, i + 1); list.remove(list.size() - 1); } }","public void sample_funcname ( List < String > result , List < String > list , boolean [ ] [ ] isWord , boolean [ ] isValid , String s , int start ) { if ( ! isValid [ start ] ) { return ; } if ( start >= s . length ( ) ) { StringBuffer sb = new StringBuffer ( ) ; for ( String word : list ) { sb . append ( word + "" "" ) ; } result . add ( sb . toString ( ) . trim ( ) ) ; return ; } for ( int i = start ; i < s . length ( ) ; i ++ ) { if ( ! isWord [ start ] [ i ] ) { continue ; } list . add ( s . substring ( start , i + 1 ) ) ; helper ( result , list , isWord , isValid , s , i + 1 ) ; list . remove ( list . size ( ) - 1 ) ; } } " 702,[lint]. Product of Array Exclude Itself_1.java,"public ArrayList productExcludeItself(ArrayList A) { if (A == null || A.size() == 0) { return null; } ArrayList rst = new ArrayList(); for (int i = 0; i < A.size(); i++) { long num = 1; for (int j = 0; j < A.size(); j++) { if (j != i) { num *= A.get(j); } } rst.add(num); } return rst; }","public ArrayList < Long > var_1 ( ArrayList < Integer > var_4 ) { if ( var_4 == null || var_4 . size ( ) == 0 ) { return null ; } ArrayList < Long > var_8 = new ArrayList < Long > ( ) ; for ( int var_9 = 0 ; var_9 < var_4 . size ( ) ; var_9 ++ ) { long var_11 = 1 ; for ( int var_12 = 0 ; var_12 < var_4 . size ( ) ; var_12 ++ ) { if ( var_12 != var_9 ) { var_11 *= var_4 . get ( var_12 ) ; } } var_8 . add ( var_11 ) ; } return var_8 ; } " 703,1040. Moving Stones Until Consecutive II_1.java,"public int[] numMovesStonesII(int[] stones) { Arrays.sort(stones); int n = stones.length, left = 0, right = 0, min = n; int max = Math.max(stones[n - 1] - stones[1] - n + 2, stones[n - 2] - stones[0] - n + 2); while (right < n) { while (stones[right] - stones[left] + 1 > n) left++; int count = right - left + 1; if (count == n - 1 && stones[right] - stones[left] + 1 == n - 1) { min = Math.min(min, 2); } else { min = Math.min(min, n - count); } right++; } return new int[]{min, max}; }","public int [ ] sample_funcname ( int [ ] var_0 ) { Arrays . sort ( var_0 ) ; int var_4 = var_0 . length , var_6 = 0 , var_7 = 0 , min = var_4 ; int max = Math . max ( var_0 [ var_4 - 1 ] - var_0 [ 1 ] - var_4 + 2 , var_0 [ var_4 - 2 ] - var_0 [ 0 ] - var_4 + 2 ) ; while ( var_7 < var_4 ) { while ( var_0 [ var_7 ] - var_0 [ var_6 ] + 1 > var_4 ) var_6 ++ ; int var_13 = var_7 - var_6 + 1 ; if ( var_13 == var_4 - 1 && var_0 [ var_7 ] - var_0 [ var_6 ] + 1 == var_4 - 1 ) { min = Math . min ( min , 2 ) ; } else { min = Math . min ( min , var_4 - var_13 ) ; } var_7 ++ ; } return new int [ ] { min , max }; } " 704,Subsets II_4.java,"public ArrayList> subsetsWithDup(ArrayList S) { ArrayList> rst = new ArrayList>(); if (S == null || S.size() == 0) { return rst; } Collections.sort(S); Queue> queue = new LinkedList>(); ArrayList list = new ArrayList(); queue.offer(new ArrayList(list)); rst.add(new ArrayList(list)); for (int i = 0; i < S.size(); i++) { int num = S.get(i); int size = queue.size(); while(size > 0) { list = queue.poll(); list.add(num); if (!rst.contains(list)) { rst.add(new ArrayList(list)); } queue.offer(new ArrayList(list)); list.remove(list.size() - 1); queue.offer(new ArrayList(list)); size--; } } return rst; }","public ArrayList < ArrayList < Integer >> var_2 ( ArrayList < Integer > var_3 ) { ArrayList < ArrayList < Integer >> var_4 = new ArrayList < ArrayList < Integer >> ( ) ; if ( var_3 == null || var_3 . size ( ) == 0 ) { return var_4 ; } Collections . sort ( var_3 ) ; Queue < ArrayList < Integer >> var_12 = new LinkedList < ArrayList < Integer >> ( ) ; ArrayList < Integer > var_13 = new ArrayList < Integer > ( ) ; var_12 . offer ( new ArrayList < Integer > ( var_13 ) ) ; var_4 . add ( new ArrayList < Integer > ( var_13 ) ) ; for ( int var_16 = 0 ; var_16 < var_3 . size ( ) ; var_16 ++ ) { int var_18 = var_3 . get ( var_16 ) ; int size = var_12 . size ( ) ; while ( size > 0 ) { var_13 = var_12 . poll ( ) ; var_13 . add ( var_18 ) ; if ( ! var_4 . contains ( var_13 ) ) { var_4 . add ( new ArrayList < Integer > ( var_13 ) ) ; } var_12 . offer ( new ArrayList < Integer > ( var_13 ) ) ; var_13 . remove ( var_13 . size ( ) - 1 ) ; var_12 . offer ( new ArrayList < Integer > ( var_13 ) ) ; size -- ; } } return var_4 ; } " 705,[tool]. Hash Function_1.java,"public int hashCode(char[] key, int HASH_SIZE) { if (key.length == 0) { return 0; } long hashRst = 0; for (int i = 0; i < key.length ; i++) { hashRst = hashRst * 33 + (int)(key[i]); hashRst = hashRst % HASH_SIZE; } return (int)hashRst; }","public int sample_funcname ( char [ ] var_0 , int var_1 ) { if ( var_0 . length == 0 ) { return 0 ; } long var_4 = 0 ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { var_4 = var_4 * 33 + ( int ) ( var_0 [ var_5 ] ) ; var_4 = var_4 % var_1 ; } return ( int ) var_4 ; } " 706,The Maze III_1.java,"private boolean isEnd(int[] hole, int x, int y) { return x == hole[0] && y == hole[1]; }","private boolean var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { return var_2 == var_1 [ 0 ] && var_3 == var_1 [ 1 ] ; } " 707,438. Find All Anagrams in a String_1.java,"public List findAnagrams(String s, String p) { List rst = new ArrayList<>(); if (s == null || s.length() == 0 || s.length() < p.length()) return rst; int n = s.length(), m = p.length(); int[] hash = new int[256]; for (char c : p.toCharArray()) hash[c]++; int left = 0, right = 0; int count = m; while (right < n) { char c = s.charAt(right++); if (hash[c] > 0) count--; hash[c]--; if (count == 0) rst.add(left); if (right - left == m) { c = s.charAt(left++); if (hash[c] >= 0) count++; hash[c]++; } } return rst; }","public List < Integer > var_1 ( String var_3 , String var_4 ) { List < Integer > var_7 = new ArrayList < > ( ) ; if ( var_3 == null || var_3 . length ( ) == 0 || var_3 . length ( ) < var_4 . length ( ) ) return var_7 ; int var_11 = var_3 . length ( ) , var_12 = var_4 . length ( ) ; int [ ] var_14 = new int [ 256 ] ; for ( char var_16 : var_4 . toCharArray ( ) ) var_14 [ var_16 ] ++ ; int var_17 = 0 , var_18 = 0 ; int var_19 = var_12 ; while ( var_18 < var_11 ) { char var_16 = var_3 . charAt ( var_18 ++ ) ; if ( var_14 [ var_16 ] > 0 ) var_19 -- ; var_14 [ var_16 ] -- ; if ( var_19 == 0 ) var_7 . add ( var_17 ) ; if ( var_18 - var_17 == var_12 ) { var_16 = var_3 . charAt ( var_17 ++ ) ; if ( var_14 [ var_16 ] >= 0 ) var_19 ++ ; var_14 [ var_16 ] ++ ; } } return var_7 ; } " 708,Flip Game II_5.java,"public static boolean checkP1Win(String str, int x, boolean isP1) { String s = str.substring(0,x) + ""--"" + str.substring(x + 2); if (s.indexOf(""++"") == -1) { return isP1; } if (isP1) { String temp = s; for (int i = temp.indexOf(""++""); i >= 0 && i < temp.length() - 1; i = temp.indexOf(""++"")) { if (checkP1Win(s, i, !isP1)) { return true; } temp = temp.substring(0, i) + ""-"" + temp.substring(i + 1); } return false; } else { String temp = s; for (int i = temp.indexOf(""++""); i >= 0 && i < temp.length() - 1; i = temp.indexOf(""++"")) { if (!checkP1Win(s, i, !isP1)) { return false; } temp = temp.substring(0, i) + ""-"" + temp.substring(i + 1); } return true; } }","public static boolean sample_funcname ( String str , int x , boolean isP1 ) { String s = str . substring ( 0 , x ) + ""--"" + str . substring ( x + 2 ) ; if ( s . indexOf ( ""++"" ) == - 1 ) { return isP1 ; } if ( isP1 ) { String temp = s ; for ( int i = temp . indexOf ( ""++"" ) ; i >= 0 && i < temp . length ( ) - 1 ; i = temp . indexOf ( ""++"" ) ) { if ( checkP1Win ( s , i , ! isP1 ) ) { return true ; } temp = temp . substring ( 0 , i ) + ""-"" + temp . substring ( i + 1 ) ; } return false ; } else { String temp = s ; for ( int i = temp . indexOf ( ""++"" ) ; i >= 0 && i < temp . length ( ) - 1 ; i = temp . indexOf ( ""++"" ) ) { if ( ! checkP1Win ( s , i , ! isP1 ) ) { return false ; } temp = temp . substring ( 0 , i ) + ""-"" + temp . substring ( i + 1 ) ; } return true ; } } " 709,Frog Jump_2.java,"public boolean canCross(int[] stones) { if (stones == null || stones.length == 0) return false; int n = stones.length; Map> dp = new HashMap<>(); for (int stone : stones) { dp.put(stone, new HashSet<>()); } dp.get(0).add(0); for (int stone : stones) { for (int k : dp.get(stone)) { if (k - 1 > 0 && dp.containsKey(stone + k - 1)) { dp.get(stone + k - 1).add(k - 1); } if (k > 0 && dp.containsKey(stone + k)) { dp.get(stone + k).add(k); } if (k + 1 > 0 && dp.containsKey(stone + k + 1)) { dp.get(stone + k + 1).add(k + 1); } } } int lastStone = stones[n - 1]; return !dp.get(lastStone).isEmpty(); }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) return false ; int var_5 = var_1 . length ; Map < Integer , Set < Integer >> var_10 = new HashMap < > ( ) ; for ( int var_11 : var_1 ) { var_10 . put ( var_11 , new HashSet < > ( ) ) ; } var_10 . get ( 0 ) . add ( 0 ) ; for ( int var_11 : var_1 ) { for ( int var_16 : var_10 . get ( var_11 ) ) { if ( var_16 - 1 > 0 && var_10 . containsKey ( var_11 + var_16 - 1 ) ) { var_10 . get ( var_11 + var_16 - 1 ) . add ( var_16 - 1 ) ; } if ( var_16 > 0 && var_10 . containsKey ( var_11 + var_16 ) ) { var_10 . get ( var_11 + var_16 ) . add ( var_16 ) ; } if ( var_16 + 1 > 0 && var_10 . containsKey ( var_11 + var_16 + 1 ) ) { var_10 . get ( var_11 + var_16 + 1 ) . add ( var_16 + 1 ) ; } } } int var_19 = var_1 [ var_5 - 1 ] ; return ! var_10 . get ( var_19 ) . isEmpty ( ) ; } " 710,254. Factor Combinations_2.java,"private List> calcFactors(int lastFactor, int num) { List> rst = new ArrayList<>(); int sqrt = (int)Math.sqrt(num); for (int i = lastFactor; i <= sqrt; i++) { int remain = num / i; if (i * remain == num) rst.add(Arrays.asList(i, remain)); } return rst; }","private List < List < Integer >> var_2 ( int var_3 , int var_4 ) { List < List < Integer >> var_6 = new ArrayList < > ( ) ; int sqrt = ( int ) Math . sqrt ( var_4 ) ; for ( int var_9 = var_3 ; var_9 <= sqrt ; var_9 ++ ) { int var_10 = var_4 / var_9 ; if ( var_9 * var_10 == var_4 ) var_6 . add ( Arrays . asList ( var_9 , var_10 ) ) ; } return var_6 ; } " 711,Longest Substring Without Repeating Characters_1.java,"public int lengthOfLongestSubstring(String s) { if (s == null || s.length() == 0) { return 0; } boolean[] chars = new boolean[256]; int rst = 0; int start = 0; int end = 0; while (start < s.length()) { while (end < s.length() && !chars[s.charAt(end)]) { chars[s.charAt(end)] = true; rst = Math.max(rst, end - start + 1); end++; } chars[s.charAt(start)] = false; start++; } return rst; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } boolean [ ] var_7 = new boolean [ 256 ] ; int var_8 = 0 ; int var_9 = 0 ; int var_10 = 0 ; while ( var_9 < var_1 . length ( ) ) { while ( var_10 < var_1 . length ( ) && ! var_7 [ var_1 . charAt ( var_10 ) ] ) { var_7 [ var_1 . charAt ( var_10 ) ] = true ; var_8 = Math . max ( var_8 , var_10 - var_9 + 1 ) ; var_10 ++ ; } var_7 [ var_1 . charAt ( var_9 ) ] = false ; var_9 ++ ; } return var_8 ; } " 712,Plus One_2.java,"public int[] plusOne(int[] digits) { if(digits.length==0) return digits; digits[digits.length-1] += 1; for(int i = digits.length-1; i>0; i--){ if(digits[i] == 10){ digits[i]=0; digits[i-1]+=1; } else return digits; } if(digits[0]==10){ int[] output = new int[digits.length+1]; output[0] = 1; output[1] = 0; for(int i=2; i 0 ; var_4 -- ) { if ( var_0 [ var_4 ] == 10 ) { var_0 [ var_4 ] = 0 ; var_0 [ var_4 - 1 ] += 1 ; } else return var_0 ; } if ( var_0 [ 0 ] == 10 ) { int [ ] var_6 = new int [ var_0 . length + 1 ] ; var_6 [ 0 ] = 1 ; var_6 [ 1 ] = 0 ; for ( int var_4 = 2 ; var_4 < var_6 . length - 1 ; var_4 ++ ) { var_6 [ var_4 ] = var_0 [ var_4 - 1 ] ; } return var_6 ; } else return var_0 ; } " 713,1219. Path with Maximum Gold_1.java,"private boolean check(int[][] grid, int i, int j) { return i < 0 || j < 0 || i >= grid.length || j >= grid[0].length || grid[i][j] == 0; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 < 0 || var_3 < 0 || var_2 >= var_1 . length || var_3 >= var_1 [ 0 ] . length || var_1 [ var_2 ] [ var_3 ] == 0 ; } " 714,122. Best Time to Buy and Sell Stock II_2.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length <= 1) { return 0; } int curr = 0; int profit = 0; int peek = 1; while(curr < prices.length) { while (peek < prices.length && prices[peek - 1] <= prices[peek]) { peek++; } profit += prices[peek - 1] - prices[curr]; curr = peek; peek = curr + 1; } return profit; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length <= 1 ) { return 0 ; } int var_5 = 0 ; int var_6 = 0 ; int var_7 = 1 ; while ( var_5 < var_0 . length ) { while ( var_7 < var_0 . length && var_0 [ var_7 - 1 ] <= var_0 [ var_7 ] ) { var_7 ++ ; } var_6 += var_0 [ var_7 - 1 ] - var_0 [ var_5 ] ; var_5 = var_7 ; var_7 = var_5 + 1 ; } return var_6 ; } " 715,Contiguous Array_1.java,"public int findMaxLength(int[] nums) { if (nums == null || nums.length == 0) return 0; for (int i = 0; i < nums.length; i++) { if (nums[i] == 0) nums[i] = -1; } Map map = new HashMap<>(); map.put(0, -1); int preSum = 0, max = 0; for (int i = 0; i < nums.length; i++) { preSum += nums[i]; if (map.containsKey(preSum)) { max = Math.max(max, i - map.get(preSum)); } if (!map.containsKey(preSum)) { map.put(preSum, i); } } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { if ( var_0 [ var_4 ] == 0 ) var_0 [ var_4 ] = - 1 ; } Map < Integer , Integer > var_9 = new HashMap < > ( ) ; var_9 . put ( 0 , - 1 ) ; int var_11 = 0 , max = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { var_11 += var_0 [ var_4 ] ; if ( var_9 . containsKey ( var_11 ) ) { max = Math . max ( max , var_4 - var_9 . get ( var_11 ) ) ; } if ( ! var_9 . containsKey ( var_11 ) ) { var_9 . put ( var_11 , var_4 ) ; } } return max ; } " 716,[lint]. Heapify_2.java,"public void heapify(int[] A) { if (A == null || A.length == 0) { return; } int child = 0; int currId = 0; int leftId = 0; int rightId = 0; int n = A.length; for (int i = n/2 - 1; i >= 0; i--) { currId = i; while (currId * 2 + 1 < n) { leftId = currId * 2 + 1; rightId = currId * 2 + 2; if (rightId >= n || A[leftId] <= A[rightId]) { child = leftId; } else { child = rightId; } if (A[currId] <= A[child]) { break; } else { int temp = A[currId]; A[currId] = A[child]; A[child] = temp; } currId = child; } } }","public void var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return ; } int var_5 = 0 ; int var_6 = 0 ; int var_7 = 0 ; int var_8 = 0 ; int var_9 = var_1 . length ; for ( int var_12 = var_9 / 2 - 1 ; var_12 >= 0 ; var_12 -- ) { var_6 = var_12 ; while ( var_6 * 2 + 1 < var_9 ) { var_7 = var_6 * 2 + 1 ; var_8 = var_6 * 2 + 2 ; if ( var_8 >= var_9 || var_1 [ var_7 ] <= var_1 [ var_8 ] ) { var_5 = var_7 ; } else { var_5 = var_8 ; } if ( var_1 [ var_6 ] <= var_1 [ var_5 ] ) { break ; } else { int var_13 = var_1 [ var_6 ] ; var_1 [ var_6 ] = var_1 [ var_5 ] ; var_1 [ var_5 ] = var_13 ; } var_6 = var_5 ; } } } " 717,1170. Compare Strings by Frequency of the Smallest Character_3.java,"private int count(String w) { int[] count = new int[26]; for (char c : w.toCharArray()) count[c - 'a']++; for (int num : count) if (num != 0) return num; return 0; }","private int sample_funcname ( String var_1 ) { int [ ] var_3 = new int [ 26 ] ; for ( char var_5 : var_1 . toCharArray ( ) ) var_3 [ var_5 - 'a' ] ++ ; for ( int var_7 : var_3 ) if ( var_7 != 0 ) return var_7 ; return 0 ; } " 718,218. The Skyline Problem_4.java,"int lson(int id) { return id * 2 + 1; }","int sample_funcname ( int var_0 ) { return var_0 * 2 + 1 ; } " 719,293. Flip Game_2.java,"public List generatePossibleNextMoves(String s) { List rst = new ArrayList(); if (s == null || s.length() == 0) { return rst; } ArrayList list = new ArrayList(); StringBuffer sb = new StringBuffer(s); while (sb.indexOf(""++"") != -1) { int index = sb.indexOf(""++""); list.add(index); sb.replace(index, index + 1, ""*""); } for (int index : list) { rst.add(s.substring(0, index) + ""--"" + s.substring(index + 2)); } return rst; }","public List < String > var_1 ( String var_2 ) { List < String > var_5 = new ArrayList < String > ( ) ; if ( var_2 == null || var_2 . length ( ) == 0 ) { return var_5 ; } ArrayList < Integer > var_10 = new ArrayList < Integer > ( ) ; StringBuffer var_12 = new StringBuffer ( var_2 ) ; while ( var_12 . indexOf ( ""++"" ) != - 1 ) { int var_16 = var_12 . indexOf ( ""++"" ) ; var_10 . add ( var_16 ) ; var_12 . replace ( var_16 , var_16 + 1 , ""*"" ) ; } for ( int var_16 : var_10 ) { var_5 . add ( var_2 . substring ( 0 , var_16 ) + ""--"" + var_2 . substring ( var_16 + 2 ) ) ; } return var_5 ; } " 720,Binary Representation_1.java,"public String parseInteger(String n) { if (n.length() == 0 || n.equals(""0"")) { return n; } int num = Integer.parseInt(n); StringBuffer sb = new StringBuffer(); while (num != 0) { sb.insert(0, num % 2); num = num / 2; } return sb.toString(); }","public String var_0 ( String var_2 ) { if ( var_2 . length ( ) == 0 || var_2 . equals ( ""0"" ) ) { return var_2 ; } int var_9 = Integer . parseInt ( var_2 ) ; StringBuffer var_11 = new StringBuffer ( ) ; while ( var_9 != 0 ) { var_11 . insert ( 0 , var_9 % 2 ) ; var_9 = var_9 / 2 ; } return var_11 . toString ( ) ; } " 721,Search a 2D Matrix II_3.java,"public int searchMatrix(int[][] matrix, int target) { if (matrix == null || matrix.length == 0 || matrix[0].length == 0) { return 0; } int row = matrix.length; int col = matrix[0].length; int x = row - 1; int y = 0; int count = 0; while (x >= 0 && y < col) { if (matrix[x][y] < target) { y++; } else if (matrix[x][y] > target) { x--; } else { count++; x--; y++; } } return count; }","public int sample_funcname ( int [ ] [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] . length == 0 ) { return 0 ; } int var_5 = var_0 . length ; int var_6 = var_0 [ 0 ] . length ; int var_8 = var_5 - 1 ; int var_9 = 0 ; int var_10 = 0 ; while ( var_8 >= 0 && var_9 < var_6 ) { if ( var_0 [ var_8 ] [ var_9 ] < var_1 ) { var_9 ++ ; } else if ( var_0 [ var_8 ] [ var_9 ] > var_1 ) { var_8 -- ; } else { var_10 ++ ; var_8 -- ; var_9 ++ ; } } return var_10 ; } " 722,Maximum Subarray III_1.java,"public int maxSubArray(int[] nums, int k) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int[][] dp = new int[n + 1][k + 1]; for (int j = 1; j <= k; j++) { for (int i = j; i <= n; i++) { dp[i][j] = Integer.MIN_VALUE; int endMax = 0; int max = Integer.MIN_VALUE; for (int x = i - 1; x >= j - 1; x--) { endMax = Math.max(nums[x], nums[x] + endMax); max = Math.max(max, endMax); dp[i][j] = dp[i][j] < dp[x][j - 1] + max ? dp[x][j - 1] + max : dp[i][j]; } } } return dp[n][k]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = var_0 . length ; int [ ] [ ] var_7 = new int [ var_5 + 1 ] [ var_1 + 1 ] ; for ( int var_8 = 1 ; var_8 <= var_1 ; var_8 ++ ) { for ( int var_9 = var_8 ; var_9 <= var_5 ; var_9 ++ ) { var_7 [ var_9 ] [ var_8 ] = Integer . MIN_VALUE ; int var_12 = 0 ; int max = Integer . MIN_VALUE ; for ( int var_14 = var_9 - 1 ; var_14 >= var_8 - 1 ; var_14 -- ) { var_12 = Math . max ( var_0 [ var_14 ] , var_0 [ var_14 ] + var_12 ) ; max = Math . max ( max , var_12 ) ; var_7 [ var_9 ] [ var_8 ] = var_7 [ var_9 ] [ var_8 ] < var_7 [ var_14 ] [ var_8 - 1 ] + max ? var_7 [ var_14 ] [ var_8 - 1 ] + max : var_7 [ var_9 ] [ var_8 ] ; } } } return var_7 [ var_5 ] [ var_1 ] ; } " 723,72. Edit Distance_3.java,"public int minDistance(String word1, String word2) { if (word1 == null && word2 == null) return 0; if (word1 == null || word2 == null) return word1 == null ? word2.length() : word1.length(); int m = word1.length(); int n = word2.length(); int[][] dp = new int[m + 1][n + 1]; for (int i = 0; i <= m; i++) { dp[i][0] = i; } for (int j = 0; j <= n; j++) { dp[0][j] = j; } for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { if (word1.charAt(i - 1) == word2.charAt(j - 1)) { dp[i][j] = dp[i - 1][j - 1]; } else { dp[i][j] = Math.min(dp[i - 1][j - 1], Math.min(dp[i][j - 1], dp[i - 1][j])) + 1; } } } return dp[m][n]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null && var_2 == null ) return 0 ; if ( var_1 == null || var_2 == null ) return var_1 == null ? var_2 . length ( ) : var_1 . length ( ) ; int var_6 = var_1 . length ( ) ; int var_7 = var_2 . length ( ) ; int [ ] [ ] var_9 = new int [ var_6 + 1 ] [ var_7 + 1 ] ; for ( int var_10 = 0 ; var_10 <= var_6 ; var_10 ++ ) { var_9 [ var_10 ] [ 0 ] = var_10 ; } for ( int var_11 = 0 ; var_11 <= var_7 ; var_11 ++ ) { var_9 [ 0 ] [ var_11 ] = var_11 ; } for ( int var_10 = 1 ; var_10 <= var_6 ; var_10 ++ ) { for ( int var_11 = 1 ; var_11 <= var_7 ; var_11 ++ ) { if ( var_1 . charAt ( var_10 - 1 ) == var_2 . charAt ( var_11 - 1 ) ) { var_9 [ var_10 ] [ var_11 ] = var_9 [ var_10 - 1 ] [ var_11 - 1 ] ; } else { var_9 [ var_10 ] [ var_11 ] = Math . min ( var_9 [ var_10 - 1 ] [ var_11 - 1 ] , Math . min ( var_9 [ var_10 ] [ var_11 - 1 ] , var_9 [ var_10 - 1 ] [ var_11 ] ) ) + 1 ; } } } return var_9 [ var_6 ] [ var_7 ] ; } " 724,Maximum Size Subarray Sum Equals k_1.java,"public int maxSubArrayLen(int[] nums, int k) { if (nums == null || nums.length == 0) return 0; Map map = new HashMap<>(); map.put(0, -1); int preSum = 0, max = 0; for (int i = 0; i < nums.length; i++) { preSum += nums[i]; if (map.containsKey(preSum - k)) { max = Math.max(max, i - map.get(preSum - k)); } if (!map.containsKey(preSum)) { map.put(preSum, i); } } return max; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; Map < Integer , Integer > var_8 = new HashMap < > ( ) ; var_8 . put ( 0 , - 1 ) ; int var_11 = 0 , max = 0 ; for ( int var_13 = 0 ; var_13 < var_0 . length ; var_13 ++ ) { var_11 += var_0 [ var_13 ] ; if ( var_8 . containsKey ( var_11 - var_1 ) ) { max = Math . max ( max , var_13 - var_8 . get ( var_11 - var_1 ) ) ; } if ( ! var_8 . containsKey ( var_11 ) ) { var_8 . put ( var_11 , var_13 ) ; } } return max ; } " 725,760. Find Anagram Mappings_1.java,"public int[] anagramMappings(int[] A, int[] B) { if (A == null || B == null || A.length == 0) { return null; } int[] result = new int[A.length]; Map> map = new HashMap<>(); for (int i = 0; i < B.length; i++) { map.putIfAbsent(B[i], new ArrayList<>()); map.get(B[i]).add(i); } for (int i = 0; i < A.length; i++) { ArrayList list = map.get(A[i]); result[i] = list.get(0); list.remove(0); } return result; }","public int [ ] sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { if ( var_0 == null || var_1 == null || var_0 . length == 0 ) { return null ; } int [ ] var_5 = new int [ var_0 . length ] ; Map < Integer , ArrayList < Integer >> var_10 = new HashMap < > ( ) ; for ( int var_11 = 0 ; var_11 < var_1 . length ; var_11 ++ ) { var_10 . putIfAbsent ( var_1 [ var_11 ] , new ArrayList < > ( ) ) ; var_10 . get ( var_1 [ var_11 ] ) . add ( var_11 ) ; } for ( int var_11 = 0 ; var_11 < var_0 . length ; var_11 ++ ) { ArrayList < Integer > var_15 = var_10 . get ( var_0 [ var_11 ] ) ; var_5 [ var_11 ] = var_15 . get ( 0 ) ; var_15 . remove ( 0 ) ; } return var_5 ; } " 726,Maximum Subarray II_1.java,"public int maxTwoSubArrays(List nums) { if (nums == null || nums.size() == 0) { return 0; } int n = nums.size(); int[] dpLeft = new int[n + 1]; int[] dpRight = new int[n + 1]; dpLeft[0] = 0; dpRight[n] = 0; int[] maxLeft = new int[n + 1];; int[] maxRight = new int[n + 1]; maxLeft[0] = Integer.MIN_VALUE; maxRight[n] = Integer.MIN_VALUE; for (int i = 1; i <= n; i++) { dpLeft[i] = Math.max(dpLeft[i - 1] + nums.get(i - 1), nums.get(i - 1)); maxLeft[i] = Math.max(maxLeft[i - 1], dpLeft[i]); } for (int j = n - 1; j >= 0; j--) { dpRight[j] = Math.max(dpRight[j + 1] + nums.get(j), nums.get(j)); maxRight[j] = Math.max(maxRight[j + 1], dpRight[j]); } int max = Integer.MIN_VALUE; for (int i = 1; i < n; i++) { max = Math.max(max, maxLeft[i] + maxRight[i]); } return max; }","public int sample_funcname ( List < Integer > var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return 0 ; } int var_6 = var_2 . size ( ) ; int [ ] var_8 = new int [ var_6 + 1 ] ; int [ ] var_9 = new int [ var_6 + 1 ] ; var_8 [ 0 ] = 0 ; var_9 [ var_6 ] = 0 ; int [ ] var_10 = new int [ var_6 + 1 ] ; ; int [ ] var_11 = new int [ var_6 + 1 ] ; var_10 [ 0 ] = Integer . MIN_VALUE ; var_11 [ var_6 ] = Integer . MIN_VALUE ; for ( int var_13 = 1 ; var_13 <= var_6 ; var_13 ++ ) { var_8 [ var_13 ] = Math . max ( var_8 [ var_13 - 1 ] + var_2 . get ( var_13 - 1 ) , var_2 . get ( var_13 - 1 ) ) ; var_10 [ var_13 ] = Math . max ( var_10 [ var_13 - 1 ] , var_8 [ var_13 ] ) ; } for ( int var_17 = var_6 - 1 ; var_17 >= 0 ; var_17 -- ) { var_9 [ var_17 ] = Math . max ( var_9 [ var_17 + 1 ] + var_2 . get ( var_17 ) , var_2 . get ( var_17 ) ) ; var_11 [ var_17 ] = Math . max ( var_11 [ var_17 + 1 ] , var_9 [ var_17 ] ) ; } int max = Integer . MIN_VALUE ; for ( int var_13 = 1 ; var_13 < var_6 ; var_13 ++ ) { max = Math . max ( max , var_10 [ var_13 ] + var_11 [ var_13 ] ) ; } return max ; } " 727,198. House Robber_2.java,"public int rob(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length; long[] dp = new long[2]; dp[0] = 0; dp[1] = nums[0]; for (int i = 2; i <= n; i++) { dp[i % 2] = Math.max(dp[(i - 1)%2], dp[(i - 2)%2] + nums[i - 1]); } return (int) dp[n % 2]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length ; long [ ] var_6 = new long [ 2 ] ; var_6 [ 0 ] = 0 ; var_6 [ 1 ] = var_0 [ 0 ] ; for ( int var_8 = 2 ; var_8 <= var_4 ; var_8 ++ ) { var_6 [ var_8 % 2 ] = Math . max ( var_6 [ ( var_8 - 1 ) % 2 ] , var_6 [ ( var_8 - 2 ) % 2 ] + var_0 [ var_8 - 1 ] ) ; } return ( int ) var_6 [ var_4 % 2 ] ; } " 728,[HackerRank]. Change to Anagram_1.java,"public int validate(String str) { if (str.length() % 2 == 1) { return -1; } String sA = str.substring(0, str.length()/2); String sB = str.substring(str.length()/2); int[] arr = new int[26]; for (int i = 0; i < sA.length(); i++) { char cA = sA.charAt(i); char cB = sB.charAt(i); if (cA < 'a' || cA > 'z' || cB < 'a' || cB > 'z') { return -1; } arr[cA - 'a']++; arr[cB - 'a']--; } int count = 0; for (int num : arr) { count += Math.abs(num); } return count/2; }","public int sample_funcname ( String var_1 ) { if ( var_1 . length ( ) % 2 == 1 ) { return - 1 ; } String var_7 = var_1 . substring ( 0 , var_1 . length ( ) / 2 ) ; String var_8 = var_1 . substring ( var_1 . length ( ) / 2 ) ; int [ ] var_10 = new int [ 26 ] ; for ( int var_11 = 0 ; var_11 < var_7 . length ( ) ; var_11 ++ ) { char var_13 = var_7 . charAt ( var_11 ) ; char var_14 = var_8 . charAt ( var_11 ) ; if ( var_13 < 'a' || var_13 > 'z' || var_14 < 'a' || var_14 > 'z' ) { return - 1 ; } var_10 [ var_13 - 'a' ] ++ ; var_10 [ var_14 - 'a' ] -- ; } int var_17 = 0 ; for ( int var_18 : var_10 ) { var_17 += Math . abs ( var_18 ) ; } return var_17 / 2 ; } " 729,51. N-Queens_2.java,"private List createBoard(int[] columns){ int n = columns.length; List board = new ArrayList<>(); for (int row = 0; row < n; row++) { StringBuffer sb = new StringBuffer(); int queenCol = columns[row]; for (int col = 0; col < n; col++) { sb.append(queenCol == col ? ""Q"" : "".""); } board.add(sb.toString()); } return board; }","private List < String > var_1 ( int [ ] var_2 ) { int var_4 = var_2 . length ; List < String > var_7 = new ArrayList < > ( ) ; for ( int var_9 = 0 ; var_9 < var_4 ; var_9 ++ ) { StringBuffer var_11 = new StringBuffer ( ) ; int var_12 = var_2 [ var_9 ] ; for ( int var_13 = 0 ; var_13 < var_4 ; var_13 ++ ) { var_11 . append ( var_12 == var_13 ? ""Q"" : ""."" ) ; } var_7 . add ( var_11 . toString ( ) ) ; } return var_7 ; } " 730,415. Add Strings_2.java,"private int[] convertToInt(String num) { if (num == null || num.length() == 0) { return new int[1]; } int n = num.length(); int[] nums = new int[n + 1]; for (int i = 0; i < n; i++) { nums[i] = num.charAt(n - i - 1) - '0'; } return nums; }","private int [ ] sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return new int [ 1 ] ; } int var_6 = var_1 . length ( ) ; int [ ] var_7 = new int [ var_6 + 1 ] ; for ( int var_8 = 0 ; var_8 < var_6 ; var_8 ++ ) { var_7 [ var_8 ] = var_1 . charAt ( var_6 - var_8 - 1 ) - '0' ; } return var_7 ; } " 731,1216. Valid Palindrome III_2.java,"private String getKey(int left, int right, int k) { return String.format(""%s@%s@%s"", left, right, k); }","private String var_0 ( int var_1 , int var_2 , int var_3 ) { return String . format ( ""%s@%s@%s"" , var_1 , var_2 , var_3 ) ; } " 732,Evaluate Reverse Polish Notation_2.java,"private long eval(long a, long b, String s) { long rst = 0; char operator = s.charAt(0); if (operator == '+') rst = a + b; if (operator == '-') rst = a - b; if (operator == '*') rst = a * b; if (operator == '/') rst = a / b; return rst; }","private long sample_funcname ( long var_0 , long var_1 , String var_3 ) { long var_5 = 0 ; char var_7 = var_3 . charAt ( 0 ) ; if ( var_7 == '+' ) var_5 = var_0 + var_1 ; if ( var_7 == '-' ) var_5 = var_0 - var_1 ; if ( var_7 == '*' ) var_5 = var_0 * var_1 ; if ( var_7 == '/' ) var_5 = var_0 / var_1 ; return var_5 ; } " 733,Backpack II_2.java,"public int backPackII(int m, int[] A, int V[]) { if (A == null || V == null || A.length != V.length) { return 0; } int n = A.length; int[][] dp = new int[2][m + 1]; for (int i = 1; i <= n; i++) { for (int j = 0; j <= m; j++) { dp[i % 2][j] = dp[(i - 1) % 2][j]; if (j - A[i - 1] >= 0) { dp[i % 2][j] = Math.max(dp[i % 2][j], dp[(i - 1) % 2][j - A[i - 1]] + V[i - 1]); } } } return dp[n % 2][m]; }","public int sample_funcname ( int var_0 , int [ ] var_1 , int var_2 [ ] ) { if ( var_1 == null || var_2 == null || var_1 . length != var_2 . length ) { return 0 ; } int var_6 = var_1 . length ; int [ ] [ ] var_9 = new int [ 2 ] [ var_0 + 1 ] ; for ( int var_10 = 1 ; var_10 <= var_6 ; var_10 ++ ) { for ( int var_11 = 0 ; var_11 <= var_0 ; var_11 ++ ) { var_9 [ var_10 % 2 ] [ var_11 ] = var_9 [ ( var_10 - 1 ) % 2 ] [ var_11 ] ; if ( var_11 - var_1 [ var_10 - 1 ] >= 0 ) { var_9 [ var_10 % 2 ] [ var_11 ] = Math . max ( var_9 [ var_10 % 2 ] [ var_11 ] , var_9 [ ( var_10 - 1 ) % 2 ] [ var_11 - var_1 [ var_10 - 1 ] ] + var_2 [ var_10 - 1 ] ) ; } } } return var_9 [ var_6 % 2 ] [ var_0 ] ; } " 734,39. Combination Sum_2.java,"private boolean validate(int[] candidates, int target) { return candidates == null || candidates.length == 0 || target <= 0; }","private boolean var_0 ( int [ ] var_1 , int var_2 ) { return var_1 == null || var_1 . length == 0 || var_2 <= 0 ; } " 735,986. Interval List Intersections_1.java,"public int[][] intervalIntersection(int[][] A, int[][] B) { List list = new ArrayList<>(); int i = 0, j = 0; int m = A.length, n = B.length; while (i < m && j < n) { int lo = Math.max(A[i][0], B[j][0]); int hi = Math.min(A[i][1], B[j][1]); if (lo <= hi) list.add(new int[]{lo, hi}); if (A[i][1] < B[j][1]) i++; else j++; } int[][] rst = new int[list.size()][2]; for (int k = 0; k < list.size(); k++) { rst[k] = list.get(k); } return rst; }","public int [ ] [ ] sample_funcname ( int [ ] [ ] var_0 , int [ ] [ ] var_1 ) { List < int [ ] > var_4 = new ArrayList < > ( ) ; int var_6 = 0 , var_7 = 0 ; int var_9 = var_0 . length , var_10 = var_1 . length ; while ( var_6 < var_9 && var_7 < var_10 ) { int var_13 = Math . max ( var_0 [ var_6 ] [ 0 ] , var_1 [ var_7 ] [ 0 ] ) ; int var_16 = Math . min ( var_0 [ var_6 ] [ 1 ] , var_1 [ var_7 ] [ 1 ] ) ; if ( var_13 <= var_16 ) var_4 . add ( new int [ ] { var_13 , var_16 } ) ; if ( var_0 [ var_6 ] [ 1 ] < var_1 [ var_7 ] [ 1 ] ) var_6 ++ ; else var_7 ++ ; } int [ ] [ ] var_20 = new int [ var_4 . size ( ) ] [ 2 ] ; for ( int var_21 = 0 ; var_21 < var_4 . size ( ) ; var_21 ++ ) { var_20 [ var_21 ] = var_4 . get ( var_21 ) ; } return var_20 ; } " 736,347. Top K Frequent Elements_2.java,"private Map buildFreqMap(int[] nums) { Map map = new HashMap<>(); for (int num : nums) map.put(num, map.getOrDefault(num, 0) + 1); return map; }","private Map < Integer , Integer > var_1 ( int [ ] var_2 ) { Map < Integer , Integer > var_5 = new HashMap < > ( ) ; for ( int var_6 : var_2 ) var_5 . put ( var_6 , var_5 . getOrDefault ( var_6 , 0 ) + 1 ) ; return var_5 ; } " 737,28. Implement strStr()_1.java,"public int strStr(String haystack, String needle) { if (needle == null || needle.length() == 0) { return 0; } if (needle.length() > haystack.length()) { return -1; } int n = haystack.length(); int m = needle.length(); for (int i = 0; i < n; i++) { if (n - i < m) { return -1; } if (haystack.charAt(i) != needle.charAt(0)) { continue; } if (haystack.substring(i, i + m).equals(needle)) { return i; } } return -1; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) { return 0 ; } if ( var_2 . length ( ) > var_1 . length ( ) ) { return - 1 ; } int var_7 = var_1 . length ( ) ; int var_8 = var_2 . length ( ) ; for ( int var_9 = 0 ; var_9 < var_7 ; var_9 ++ ) { if ( var_7 - var_9 < var_8 ) { return - 1 ; } if ( var_1 . charAt ( var_9 ) != var_2 . charAt ( 0 ) ) { continue ; } if ( var_1 . substring ( var_9 , var_9 + var_8 ) . equals ( var_2 ) ) { return var_9 ; } } return - 1 ; } " 738,767. Reorganize String_3.java,"private PriorityQueue buildCharQueue (Map map) { PriorityQueue queue = new PriorityQueue<>((a,b) -> b[1] - a[1]); for (char c : map.keySet()) { queue.add(new int[]{c, map.get(c)}); } return queue; }","private PriorityQueue < int [ ] > var_0 ( Map < Character , Integer > var_4 ) { PriorityQueue < int [ ] > var_9 = new PriorityQueue < > ( ( var_8 , var_6 ) -> var_6 [ 1 ] - var_8 [ 1 ] ) ; for ( char var_11 : var_4 . keySet ( ) ) { var_9 . add ( new int [ ] { var_11 , var_4 . get ( var_11 ) } ) ; } return var_9 ; } " 739,Longest Consecutive Sequence_1.java,"public int longestConsecutive(int[] nums) { if (nums == null || nums.length == 0) { return 0; } Set set = new HashSet<>(); for (int num : nums) { set.add(num); } int longest = 0; for (int num : nums) { int start = num; while (set.contains(start - 1)) { start--; set.remove(start); } int end = num; while (set.contains(end + 1)) { end++; set.remove(end); } longest = Math.max(longest, end - start + 1); } return longest; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } Set < Integer > var_7 = new HashSet < > ( ) ; for ( int var_8 : var_0 ) { var_7 . add ( var_8 ) ; } int var_10 = 0 ; for ( int var_8 : var_0 ) { int var_11 = var_8 ; while ( var_7 . contains ( var_11 - 1 ) ) { var_11 -- ; var_7 . remove ( var_11 ) ; } int var_15 = var_8 ; while ( var_7 . contains ( var_15 + 1 ) ) { var_15 ++ ; var_7 . remove ( var_15 ) ; } var_10 = Math . max ( var_10 , var_15 - var_11 + 1 ) ; } return var_10 ; } " 740,53. Maximum Subarray_5.java,"public int maxSubArray(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length, max = Integer.MIN_VALUE; int[] dp = new int[n + 1]; dp[0] = 0; for (int i = 1; i <= n; i++) { dp[i] = nums[i - 1] + (dp[i - 1] >= 0 ? dp[i - 1] : 0); max = Math.max(max, dp[i]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length , max = Integer . MIN_VALUE ; int [ ] var_9 = new int [ var_4 + 1 ] ; var_9 [ 0 ] = 0 ; for ( int var_10 = 1 ; var_10 <= var_4 ; var_10 ++ ) { var_9 [ var_10 ] = var_0 [ var_10 - 1 ] + ( var_9 [ var_10 - 1 ] >= 0 ? var_9 [ var_10 - 1 ] : 0 ) ; max = Math . max ( max , var_9 [ var_10 ] ) ; } return max ; } " 741,46. Permutations_4.java,"public List> permute(int[] nums) { List> rst = new ArrayList<>(); if (nums == null || nums.length == 0) return rst; rst.add(new ArrayList<>()); for (int i = 0; i < nums.length; i++) { int rstSize = rst.size(); for (int j = 0; j < rstSize; j++) { List baselist = rst.get(j); for (int index = 0; index < baselist.size(); index++) { baselist.add(index, nums[i]); rst.add(new ArrayList<>(baselist)); baselist.remove(index); } baselist.add(nums[i]); } } return rst; }","public List < List < Integer >> var_2 ( int [ ] var_3 ) { List < List < Integer >> var_5 = new ArrayList < > ( ) ; if ( var_3 == null || var_3 . length == 0 ) return var_5 ; var_5 . add ( new ArrayList < > ( ) ) ; for ( int var_10 = 0 ; var_10 < var_3 . length ; var_10 ++ ) { int var_12 = var_5 . size ( ) ; for ( int var_13 = 0 ; var_13 < var_12 ; var_13 ++ ) { List < Integer > var_15 = var_5 . get ( var_13 ) ; for ( int var_16 = 0 ; var_16 < var_15 . size ( ) ; var_16 ++ ) { var_15 . add ( var_16 , var_3 [ var_10 ] ) ; var_5 . add ( new ArrayList < > ( var_15 ) ) ; var_15 . remove ( var_16 ) ; } var_15 . add ( var_3 [ var_10 ] ) ; } } return var_5 ; } " 742,152. Maximum Product Subarray_2.java,"public int maxProduct(int[] nums) { int n = nums.length; int[] maxProduct = new int[2], minProduct = new int[2]; maxProduct[0] = nums[0]; minProduct[0] = nums[0]; int max = nums[0]; for (int i = 1; i < n; i++) { int num = nums[i]; if (num > 0) { maxProduct[i % 2] = Math.max(num, maxProduct[(i - 1) % 2] * num); minProduct[i % 2] = Math.min(num, minProduct[(i - 1) % 2] * num); } else { maxProduct[i % 2] = Math.max(num, minProduct[(i - 1) % 2] * num); minProduct[i % 2] = Math.min(num, maxProduct[(i - 1) % 2] * num); } max = Math.max(max, maxProduct[i % 2]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; int [ ] var_4 = new int [ 2 ] , var_5 = new int [ 2 ] ; var_4 [ 0 ] = var_0 [ 0 ] ; var_5 [ 0 ] = var_0 [ 0 ] ; int max = var_0 [ 0 ] ; for ( int var_9 = 1 ; var_9 < var_2 ; var_9 ++ ) { int var_10 = var_0 [ var_9 ] ; if ( var_10 > 0 ) { var_4 [ var_9 % 2 ] = Math . max ( var_10 , var_4 [ ( var_9 - 1 ) % 2 ] * var_10 ) ; var_5 [ var_9 % 2 ] = Math . min ( var_10 , var_5 [ ( var_9 - 1 ) % 2 ] * var_10 ) ; } else { var_4 [ var_9 % 2 ] = Math . max ( var_10 , var_5 [ ( var_9 - 1 ) % 2 ] * var_10 ) ; var_5 [ var_9 % 2 ] = Math . min ( var_10 , var_4 [ ( var_9 - 1 ) % 2 ] * var_10 ) ; } max = Math . max ( max , var_4 [ var_9 % 2 ] ) ; } return max ; } " 743,200. Number of Islands_1.java,"private boolean validateInput(char[][] grid, int x, int y) { return x < 0 || x >= grid.length || y < 0 || y >= grid[0].length || grid[x][y] == '0'; }","private boolean var_0 ( char [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 < 0 || var_2 >= var_1 . length || var_3 < 0 || var_3 >= var_1 [ 0 ] . length || var_1 [ var_2 ] [ var_3 ] == '0' ; } " 744,259. 3Sum Smaller_1.java,"public int threeSumSmaller(int[] nums, int target) { if (nums == null || nums.length <= 2) { return 0; } Arrays.sort(nums); int count = 0; for (int i = 0; i < nums.length - 2; i++) { int start = i + 1, end = nums.length - 1; while (start < end) { if (nums[i] + nums[start] + nums[end] < target) { count += end - start; start++; } else { end--; } } } return count; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length <= 2 ) { return 0 ; } Arrays . sort ( var_0 ) ; int var_8 = 0 ; for ( int var_9 = 0 ; var_9 < var_0 . length - 2 ; var_9 ++ ) { int var_11 = var_9 + 1 , var_12 = var_0 . length - 1 ; while ( var_11 < var_12 ) { if ( var_0 [ var_9 ] + var_0 [ var_11 ] + var_0 [ var_12 ] < var_1 ) { var_8 += var_12 - var_11 ; var_11 ++ ; } else { var_12 -- ; } } } return var_8 ; } " 745,91. Decode Ways_1.java,"private boolean check(String s, int i) { int twoDigit = (s.charAt(i - 1) - '0') * 10 + (s.charAt(i) - '0'); return twoDigit <= 26 && twoDigit >= 10; }","private boolean var_0 ( String var_2 , int var_3 ) { int var_8 = ( var_2 . charAt ( var_3 - 1 ) - '0' ) * 10 + ( var_2 . charAt ( var_3 ) - '0' ) ; return var_8 <= 26 && var_8 >= 10 ; } " 746,K Empty Slots_2.java,"public int kEmptySlots(int[] flowers, int k) { if (flowers == null || flowers.length == 0 || k < 0) { return - 1; } int n = flowers.length; int[] days = new int[n]; for (int i = 0; i < n; i++) { days[flowers[i] - 1] = i + 1; } int left = 0, right = k + 1, result = Integer.MAX_VALUE; for (int i = 0; right < n; i++) { if (days[i] < days[left] || days[i] <= days[right]) { if (i == right) { result = Math.min(result, Math.max(days[left], days[right])); } left = i; right = k + 1 + i; } } return result == Integer.MAX_VALUE ? - 1 : result; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 || var_1 < 0 ) { return - 1 ; } int var_6 = var_0 . length ; int [ ] var_7 = new int [ var_6 ] ; for ( int var_8 = 0 ; var_8 < var_6 ; var_8 ++ ) { var_7 [ var_0 [ var_8 ] - 1 ] = var_8 + 1 ; } int var_9 = 0 , var_10 = var_1 + 1 , var_13 = Integer . MAX_VALUE ; for ( int var_8 = 0 ; var_10 < var_6 ; var_8 ++ ) { if ( var_7 [ var_8 ] < var_7 [ var_9 ] || var_7 [ var_8 ] <= var_7 [ var_10 ] ) { if ( var_8 == var_10 ) { var_13 = Math . min ( var_13 , Math . max ( var_7 [ var_9 ] , var_7 [ var_10 ] ) ) ; } var_9 = var_8 ; var_10 = var_1 + 1 + var_8 ; } } return var_13 == Integer . MAX_VALUE ? - 1 : var_13 ; } " 747,1. Two Sum_1.java,"public int[] twoSum(int[] nums, int target) { int[] rst = new int[2]; if (nums == null || nums.length <= 1) return rst; Map map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { if (map.containsKey(target - nums[i])) { rst[0] = map.get(target - nums[i]); rst[1] = i; break; } map.put(nums[i], i); } return rst; }","public int [ ] sample_funcname ( int [ ] var_0 , int var_1 ) { int [ ] var_3 = new int [ 2 ] ; if ( var_0 == null || var_0 . length <= 1 ) return var_3 ; Map < Integer , Integer > var_10 = new HashMap < > ( ) ; for ( int var_12 = 0 ; var_12 < var_0 . length ; var_12 ++ ) { if ( var_10 . containsKey ( var_1 - var_0 [ var_12 ] ) ) { var_3 [ 0 ] = var_10 . get ( var_1 - var_0 [ var_12 ] ) ; var_3 [ 1 ] = var_12 ; break ; } var_10 . put ( var_0 [ var_12 ] , var_12 ) ; } return var_3 ; } " 748,Paint Fence_1.java,"public int numWays(int n, int k) { if (n <= 1 || k <= 0) { return n * k; } int[] dp = new int[n + 1]; dp[0] = 0; dp[1] = k; dp[2] = k + k * (k - 1); for (int i = 3; i <= n; i++) { dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]); } return dp[n]; }","public int sample_funcname ( int var_0 , int var_1 ) { if ( var_0 <= 1 || var_1 <= 0 ) { return var_0 * var_1 ; } int [ ] var_4 = new int [ var_0 + 1 ] ; var_4 [ 0 ] = 0 ; var_4 [ 1 ] = var_1 ; var_4 [ 2 ] = var_1 + var_1 * ( var_1 - 1 ) ; for ( int var_7 = 3 ; var_7 <= var_0 ; var_7 ++ ) { var_4 [ var_7 ] = ( var_1 - 1 ) * ( var_4 [ var_7 - 1 ] + var_4 [ var_7 - 2 ] ) ; } return var_4 [ var_0 ] ; } " 749,121. Best Time to Buy and Sell Stock_4.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length == 0) { return 0; } int n = prices.length; int[] dp = new int[2]; dp[0] = Integer.MAX_VALUE; int profit = 0; for (int i = 1; i <= n; i++) { dp[i % 2] = Math.min(dp[(i - 1) % 2], prices[i - 1]); profit = Math.max(profit, prices[i - 1] - dp[i % 2]); } return profit; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int [ ] var_6 = new int [ 2 ] ; var_6 [ 0 ] = Integer . MAX_VALUE ; int var_9 = 0 ; for ( int var_11 = 1 ; var_11 <= var_4 ; var_11 ++ ) { var_6 [ var_11 % 2 ] = Math . min ( var_6 [ ( var_11 - 1 ) % 2 ] , var_0 [ var_11 - 1 ] ) ; var_9 = Math . max ( var_9 , var_0 [ var_11 - 1 ] - var_6 [ var_11 % 2 ] ) ; } return var_9 ; } " 750,567. Permutation in String_3.java,"private boolean zeroCount(int[] count) { for (int i = 0; i < 26; i++) { if (count[i] != 0) return false; } return true; }","private boolean var_0 ( int [ ] var_1 ) { for ( int var_3 = 0 ; var_3 < 26 ; var_3 ++ ) { if ( var_1 [ var_3 ] != 0 ) return false ; } return true ; } " 751,1213. Intersection of Three Sorted Arrays_1.java,"private Set toSet(int[] nums) { Set set = new HashSet<>(); for (int num : nums) set.add(num); return set; }","private Set < Integer > var_1 ( int [ ] var_2 ) { Set < Integer > var_5 = new HashSet < > ( ) ; for ( int var_6 : var_2 ) var_5 . add ( var_6 ) ; return var_5 ; } " 752,Best Time to Buy and Sell Stock with Transaction Fee_2.java,"public int maxProfit(int[] prices, int fee) { if (prices == null || prices.length <= 1) return 0; int n = prices.length; int[][] dp = new int[2][2]; dp[0][0] = dp[0][1] = 0; dp[1][1] = 0; dp[1][0] = - prices[0]; for (int i = 2; i <= n; i++) { dp[i%2][0] = Math.max(dp[(i - 1)%2][0], dp[(i - 1)%2][1] - prices[i - 1]); dp[i%2][1] = Math.max(dp[(i - 1)%2][1], dp[(i - 1)%2][0] + prices[i - 1] - fee); } return dp[n%2][1]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length <= 1 ) return 0 ; int var_6 = var_0 . length ; int [ ] [ ] var_8 = new int [ 2 ] [ 2 ] ; var_8 [ 0 ] [ 0 ] = var_8 [ 0 ] [ 1 ] = 0 ; var_8 [ 1 ] [ 1 ] = 0 ; var_8 [ 1 ] [ 0 ] = - var_0 [ 0 ] ; for ( int var_9 = 2 ; var_9 <= var_6 ; var_9 ++ ) { var_8 [ var_9 % 2 ] [ 0 ] = Math . max ( var_8 [ ( var_9 - 1 ) % 2 ] [ 0 ] , var_8 [ ( var_9 - 1 ) % 2 ] [ 1 ] - var_0 [ var_9 - 1 ] ) ; var_8 [ var_9 % 2 ] [ 1 ] = Math . max ( var_8 [ ( var_9 - 1 ) % 2 ] [ 1 ] , var_8 [ ( var_9 - 1 ) % 2 ] [ 0 ] + var_0 [ var_9 - 1 ] - var_1 ) ; } return var_8 [ var_6 % 2 ] [ 1 ] ; } " 753,Coins in a Line_5.java,"public boolean firstWillWin(int n) { if (n <= 0) { return false; } return n % 3 != 0; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 0 ) { return false ; } return var_1 % 3 != 0 ; } " 754,Count 1 in Binary_2.java,"public int countOnes(int num) { if (num < 0) { return 0; } String bits = Integer.toBinaryString(num); char[] bitArray = bits.toCharArray(); int sum = 0; for (int i = 0; i < bitArray.length; i++) { sum += Character.getNumericValue(bitArray[i]); } return sum; }","public int sample_funcname ( int var_0 ) { if ( var_0 < 0 ) { return 0 ; } String var_5 = Integer . toBinaryString ( var_0 ) ; char [ ] var_7 = var_5 . toCharArray ( ) ; int var_8 = 0 ; for ( int var_9 = 0 ; var_9 < var_7 . length ; var_9 ++ ) { var_8 += Character . getNumericValue ( var_7 [ var_9 ] ) ; } return var_8 ; } " 755,Letter Combinations of a Phone Number_1.java,"public List letterCombinations(String digits) { List rst = new ArrayList(); if (digits == null || digits.length() == 0) { return rst; } HashMap map = new HashMap(); map.put('2',""abc""); map.put('3',""def""); map.put('4',""ghi""); map.put('5',""jkl""); map.put('6',""mno""); map.put('7',""pqrs""); map.put('8',""tuv""); map.put('9',""wxyz""); Queue queue = new LinkedList(); char c = digits.charAt(0); String s = map.get(c); for (int i = 0; i < s.length(); i++) { queue.offer(s.charAt(i) + """"); } int size = 0; for (int i = 1; i < digits.length(); i++) { c = digits.charAt(i); s = map.get(c); size = queue.size(); for (int j = 0; j < size; j++) { String str = queue.poll(); for (int k = 0; k < s.length(); k++) { queue.offer(str + s.charAt(k)); } } } while (!queue.isEmpty()) { rst.add(queue.poll()); } return rst; }","public List < String > var_1 ( String var_2 ) { List < String > var_5 = new ArrayList < String > ( ) ; if ( var_2 == null || var_2 . length ( ) == 0 ) { return var_5 ; } HashMap < Character , String > var_11 = new HashMap < Character , String > ( ) ; var_11 . put ( '2' , ""abc"" ) ; var_11 . put ( '3' , ""def"" ) ; var_11 . put ( '4' , ""ghi"" ) ; var_11 . put ( '5' , ""jkl"" ) ; var_11 . put ( '6' , ""mno"" ) ; var_11 . put ( '7' , ""pqrs"" ) ; var_11 . put ( '8' , ""tuv"" ) ; var_11 . put ( '9' , ""wxyz"" ) ; Queue < String > var_31 = new LinkedList < String > ( ) ; char var_33 = var_2 . charAt ( 0 ) ; String var_35 = var_11 . get ( var_33 ) ; for ( int var_36 = 0 ; var_36 < var_35 . length ( ) ; var_36 ++ ) { var_31 . offer ( var_35 . charAt ( var_36 ) + """" ) ; } int size = 0 ; for ( int var_36 = 1 ; var_36 < var_2 . length ( ) ; var_36 ++ ) { var_33 = var_2 . charAt ( var_36 ) ; var_35 = var_11 . get ( var_33 ) ; size = var_31 . size ( ) ; for ( int var_41 = 0 ; var_41 < size ; var_41 ++ ) { String var_43 = var_31 . poll ( ) ; for ( int var_44 = 0 ; var_44 < var_35 . length ( ) ; var_44 ++ ) { var_31 . offer ( var_43 + var_35 . charAt ( var_44 ) ) ; } } } while ( ! var_31 . isEmpty ( ) ) { var_5 . add ( var_31 . poll ( ) ) ; } return var_5 ; } " 756,402. Remove K Digits_1.java,"public String removeKdigits(String num, int k) { Stack stack = new Stack<>(); int i = 0, n = num.length(); while (i < n) { char c = num.charAt(i++); while (k > 0 && !stack.isEmpty() && stack.peek() > c) { stack.pop(); k--; } stack.push(c); } while (k-- > 0) stack.pop(); StringBuffer sb = new StringBuffer(); while(!stack.isEmpty()) sb.append(stack.pop()); sb.reverse(); while(sb.length() > 0 && sb.charAt(0) == '0') sb.deleteCharAt(0); return sb.length() == 0 ? ""0"" : sb.toString(); }","public String var_0 ( String var_2 , int var_3 ) { Stack < Character > var_6 = new Stack < > ( ) ; int var_8 = 0 , var_10 = var_2 . length ( ) ; while ( var_8 < var_10 ) { char var_12 = var_2 . charAt ( var_8 ++ ) ; while ( var_3 > 0 && ! var_6 . isEmpty ( ) && var_6 . peek ( ) > var_12 ) { var_6 . pop ( ) ; var_3 -- ; } var_6 . push ( var_12 ) ; } while ( var_3 -- > 0 ) var_6 . pop ( ) ; StringBuffer var_18 = new StringBuffer ( ) ; while ( ! var_6 . isEmpty ( ) ) var_18 . append ( var_6 . pop ( ) ) ; var_18 . reverse ( ) ; while ( var_18 . length ( ) > 0 && var_18 . charAt ( 0 ) == '0' ) var_18 . deleteCharAt ( 0 ) ; return var_18 . length ( ) == 0 ? ""0"" : var_18 . toString ( ) ; } " 757,169. Majority Element_3.java,"private int countInRange(int[] nums, int value, int lo, int hi) { int count = 0; for (int i = lo; i <= hi; i++) { if (nums[i] == value) count++; } return count; }","private int sample_funcname ( int [ ] var_0 , int var_1 , int var_2 , int var_3 ) { int var_5 = 0 ; for ( int var_6 = var_2 ; var_6 <= var_3 ; var_6 ++ ) { if ( var_0 [ var_6 ] == var_1 ) var_5 ++ ; } return var_5 ; } " 758,921. Minimum Add to Make Parentheses Valid_1.java,"public int minAddToMakeValid(String s) { if (s == null || s.length() == 0) { return 0; } Stack stack = new Stack<>(); int count = 0; for (char c : s.toCharArray()) { if (c == '(') stack.push(c); else if (stack.isEmpty()) count++; else stack.pop(); } return count + stack.size(); }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } Stack < Character > var_7 = new Stack < > ( ) ; int var_8 = 0 ; for ( char var_10 : var_1 . toCharArray ( ) ) { if ( var_10 == '(' ) var_7 . push ( var_10 ) ; else if ( var_7 . isEmpty ( ) ) var_8 ++ ; else var_7 . pop ( ) ; } return var_8 + var_7 . size ( ) ; } " 759,Longest Common Subsequence_2.java,"public int longestCommonSubsequence(String A, String B) { if (A == null || B == null || A.length() == 0 || B.length() == 0) { return 0; } int m = A.length(); int n = B.length(); int[][] dp = new int[2][n + 1]; int curr = 1; int prev = 0; for (int i = 1; i <= m; i++) { prev = curr; curr = 1 - prev; for (int j = 1; j <= n; j++) { if(i == 0 || j == 0) { dp[i][j] = 0; continue; } dp[curr][j] = Math.max(dp[prev][j], dp[curr][j - 1]); if (A.charAt(i - 1) == B.charAt(j - 1)) { dp[curr][j] = Math.max(dp[curr][j], dp[prev][j - 1] + 1); } } } return dp[curr][n]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) == 0 || var_2 . length ( ) == 0 ) { return 0 ; } int var_6 = var_1 . length ( ) ; int var_7 = var_2 . length ( ) ; int [ ] [ ] var_10 = new int [ 2 ] [ var_7 + 1 ] ; int var_11 = 1 ; int var_12 = 0 ; for ( int var_13 = 1 ; var_13 <= var_6 ; var_13 ++ ) { var_12 = var_11 ; var_11 = 1 - var_12 ; for ( int var_14 = 1 ; var_14 <= var_7 ; var_14 ++ ) { if ( var_13 == 0 || var_14 == 0 ) { var_10 [ var_13 ] [ var_14 ] = 0 ; continue ; } var_10 [ var_11 ] [ var_14 ] = Math . max ( var_10 [ var_12 ] [ var_14 ] , var_10 [ var_11 ] [ var_14 - 1 ] ) ; if ( var_1 . charAt ( var_13 - 1 ) == var_2 . charAt ( var_14 - 1 ) ) { var_10 [ var_11 ] [ var_14 ] = Math . max ( var_10 [ var_11 ] [ var_14 ] , var_10 [ var_12 ] [ var_14 - 1 ] + 1 ) ; } } } return var_10 [ var_11 ] [ var_7 ] ; } " 760,Power of Three_3.java,"public boolean isPowerOfThree(int n) { while (n/3>=1){ if (n%3!=0) return false; n/=3; } return n==1; }","public boolean var_0 ( int var_1 ) { while ( var_1 / 3 >= 1 ) { if ( var_1 % 3 != 0 ) return false ; var_1 /= 3 ; } return var_1 == 1 ; } " 761,274.H-Index_1.java,"public int hIndex(int[] citations) { if (citations == null || citations.length == 0) { return 0; } int n = citations.length; int[] bucket = new int[n + 1]; for (int i = 0; i < n; i++) { int bucketSlot = citations[i]; if (bucketSlot <= n) bucket[bucketSlot]++; else bucket[n]++; } int sum = 0; for (int h = n; h >= 0; h--) { sum += bucket[h]; if (sum >= h) return h; } return 0; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int [ ] var_6 = new int [ var_4 + 1 ] ; for ( int var_7 = 0 ; var_7 < var_4 ; var_7 ++ ) { int var_8 = var_0 [ var_7 ] ; if ( var_8 <= var_4 ) var_6 [ var_8 ] ++ ; else var_6 [ var_4 ] ++ ; } int var_9 = 0 ; for ( int var_10 = var_4 ; var_10 >= 0 ; var_10 -- ) { var_9 += var_6 [ var_10 ] ; if ( var_9 >= var_10 ) return var_10 ; } return 0 ; } " 762,[lint]. Recover Rotated Sorted Array_1.java,"public void reverse(ArrayList nums, int start, int end){ for (int i = start, j = end; i < j; i++,j--) { int temp = nums.get(i); nums.set(i, nums.get(j)); nums.set(j, temp); } }","public void var_0 ( ArrayList < Integer > var_3 , int var_4 , int var_5 ) { for ( int var_6 = var_4 , var_7 = var_5 ; var_6 < var_7 ; var_6 ++ , var_7 -- ) { int var_9 = var_3 . get ( var_6 ) ; var_3 . set ( var_6 , var_3 . get ( var_7 ) ) ; var_3 . set ( var_7 , var_9 ) ; } } " 763,Find Minimum in Rotated Sorted Array_2.java,"public int findMin(int[] num) { if (num == null || num.length == 0) { return -1; } int start = 0; int end = num.length - 1; int mid = 0; while (start + 1 < end) { mid = start + (end - start) / 2; if (num[mid] > num[end]) { start = mid; } else { end = mid; } } if (num[start] < num[end]) { return num[start]; } else { return num[end]; } }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int var_5 = 0 ; int var_6 = var_0 . length - 1 ; int var_7 = 0 ; while ( var_5 + 1 < var_6 ) { var_7 = var_5 + ( var_6 - var_5 ) / 2 ; if ( var_0 [ var_7 ] > var_0 [ var_6 ] ) { var_5 = var_7 ; } else { var_6 = var_7 ; } } if ( var_0 [ var_5 ] < var_0 [ var_6 ] ) { return var_0 [ var_5 ] ; } else { return var_0 [ var_6 ] ; } } " 764,Palindrome Partitioning II_3.java,"public int minCut(String s) { if (s == null || s.length() == 0) { return 0; } int length = s.length(); boolean[][] isPal = new boolean[length][length]; int[] cut = new int[length]; for (int j = 0; j < length; j++) { cut[j] = j; for (int i = 0; i <= j; i++) { if (s.charAt(i) == s.charAt(j) && (j - i <= 1 || isPal[i + 1][j - 1])) { isPal[i][j] = true; if (i > 0) { cut[j] = Math.min(cut[j], cut[i - 1] + 1); } else { cut[j] = 0; } } } } return cut[length - 1]; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } int length = var_1 . length ( ) ; boolean [ ] [ ] var_6 = new boolean [ length ] [ length ] ; int [ ] var_7 = new int [ length ] ; for ( int var_8 = 0 ; var_8 < length ; var_8 ++ ) { var_7 [ var_8 ] = var_8 ; for ( int var_9 = 0 ; var_9 <= var_8 ; var_9 ++ ) { if ( var_1 . charAt ( var_9 ) == var_1 . charAt ( var_8 ) && ( var_8 - var_9 <= 1 || var_6 [ var_9 + 1 ] [ var_8 - 1 ] ) ) { var_6 [ var_9 ] [ var_8 ] = true ; if ( var_9 > 0 ) { var_7 [ var_8 ] = Math . min ( var_7 [ var_8 ] , var_7 [ var_9 - 1 ] + 1 ) ; } else { var_7 [ var_8 ] = 0 ; } } } } return var_7 [ length - 1 ] ; } " 765,Walls and Gates_1.java,"private boolean validateCoordinate(int[][] rooms, int x, int y) { return x < 0 || x >= rooms.length || y < 0 || y >= rooms[0].length || rooms[x][y] == -1 || rooms[x][y] == 0; }","private boolean var_0 ( int [ ] [ ] var_1 , int var_2 , int var_3 ) { return var_2 < 0 || var_2 >= var_1 . length || var_3 < 0 || var_3 >= var_1 [ 0 ] . length || var_1 [ var_2 ] [ var_3 ] == - 1 || var_1 [ var_2 ] [ var_3 ] == 0 ; } " 766,Search for a Range_1.java,"public int[] searchRange(int[] A, int target) { int[] rst = new int[]{-1, -1}; if (A == null || A.length == 0) { return rst; } int start = 0; int end = A.length - 1; int mid = start + (end - start)/2; int first = 0; while (start + 1 < end) { mid = start + (end - start)/2; if (A[mid] == target) { if (mid - 1 >= 0 && A[mid - 1] == target) { end = mid; continue; } break; } else if (A[mid] < target) { start = mid; } else { end = mid; } } if (A[start] == target) { first = start; } else if (A[mid] == target) { first = mid; } else if (A[end] == target) { first = end; } else { return rst; } int last = first; start = first; end = A.length - 1; while (start + 1 < end) { mid = start + (end - start)/2; if (A[mid] == target) { if (mid + 1 < A.length && A[mid + 1] == target) { start = mid; continue; } break; } else if (A[mid] < target) { start = mid; } else { end = mid; } } if (A[end] == target) { last = end; } else if (A[mid] == target) { last = mid; } else if (A[start] == target) { last = start; } rst[0] = first; rst[1] = last; return rst; }","public int [ ] sample_funcname ( int [ ] var_0 , int var_1 ) { int [ ] var_3 = new int [ ] { - 1 , - 1 }; if ( var_0 == null || var_0 . length == 0 ) { return var_3 ; } int var_7 = 0 ; int var_8 = var_0 . length - 1 ; int var_10 = var_7 + ( var_8 - var_7 ) / 2 ; int var_11 = 0 ; while ( var_7 + 1 < var_8 ) { var_10 = var_7 + ( var_8 - var_7 ) / 2 ; if ( var_0 [ var_10 ] == var_1 ) { if ( var_10 - 1 >= 0 && var_0 [ var_10 - 1 ] == var_1 ) { var_8 = var_10 ; continue ; } break ; } else if ( var_0 [ var_10 ] < var_1 ) { var_7 = var_10 ; } else { var_8 = var_10 ; } } if ( var_0 [ var_7 ] == var_1 ) { var_11 = var_7 ; } else if ( var_0 [ var_10 ] == var_1 ) { var_11 = var_10 ; } else if ( var_0 [ var_8 ] == var_1 ) { var_11 = var_8 ; } else { return var_3 ; } int var_12 = var_11 ; var_7 = var_11 ; var_8 = var_0 . length - 1 ; while ( var_7 + 1 < var_8 ) { var_10 = var_7 + ( var_8 - var_7 ) / 2 ; if ( var_0 [ var_10 ] == var_1 ) { if ( var_10 + 1 < var_0 . length && var_0 [ var_10 + 1 ] == var_1 ) { var_7 = var_10 ; continue ; } break ; } else if ( var_0 [ var_10 ] < var_1 ) { var_7 = var_10 ; } else { var_8 = var_10 ; } } if ( var_0 [ var_8 ] == var_1 ) { var_12 = var_8 ; } else if ( var_0 [ var_10 ] == var_1 ) { var_12 = var_10 ; } else if ( var_0 [ var_7 ] == var_1 ) { var_12 = var_7 ; } var_3 [ 0 ] = var_11 ; var_3 [ 1 ] = var_12 ; return var_3 ; } " 767,Ugly Number II_2.java,"private void populate(PriorityQueue candidate, HashSet set, long[] dp, long last, int factor) { long nextCandidate = last * factor; if (!set.contains(nextCandidate)) { candidate.add(nextCandidate); set.add(nextCandidate); } }","private void var_0 ( PriorityQueue < Long > var_3 , HashSet < Long > var_5 , long [ ] var_6 , long var_7 , int var_8 ) { long var_9 = var_7 * var_8 ; if ( ! var_5 . contains ( var_9 ) ) { var_3 . add ( var_9 ) ; var_5 . add ( var_9 ) ; } } " 768,Longest Increasing Continuous subsequence II_1.java,"public int dfs(int[][] A, int[][] dp, int[][] flag, int i, int j, int n, int m) { if (flag[i][j] == 1) { return dp[i][j]; } int ans = 1; flag[i][j] = -1; int[] dx = {0, 0, 1, -1}; int[] dy = {1, -1, 0, 0}; for (int k = 0; k < dx.length; k++) { int id = i + dx[k]; int jd = j + dy[k]; if (id >= 0 && id < n && jd >= 0 && jd < m && A[i][j] < A[id][jd]) { ans = Math.max(ans, dfs(A, dp, flag, id, jd, n, m) + 1); } } flag[i][j] = 1; dp[i][j] = ans; return dp[i][j]; }","public int sample_funcname ( int [ ] [ ] A , int [ ] [ ] dp , int [ ] [ ] flag , int i , int j , int n , int m ) { if ( flag [ i ] [ j ] == 1 ) { return dp [ i ] [ j ] ; } int ans = 1 ; flag [ i ] [ j ] = - 1 ; int [ ] dx = { 0 , 0 , 1 , - 1 }; int [ ] dy = { 1 , - 1 , 0 , 0 }; for ( int k = 0 ; k < dx . length ; k ++ ) { int id = i + dx [ k ] ; int jd = j + dy [ k ] ; if ( id >= 0 && id < n && jd >= 0 && jd < m && A [ i ] [ j ] < A [ id ] [ jd ] ) { ans = Math . max ( ans , dfs ( A , dp , flag , id , jd , n , m ) + 1 ) ; } } flag [ i ] [ j ] = 1 ; dp [ i ] [ j ] = ans ; return dp [ i ] [ j ] ; } " 769,125. Valid Palindrome_3.java,"public boolean isPalindrome(String s) { if (s == null || s.length() == 0) { return true; } StringBuffer sb = new StringBuffer(); s = s.toLowerCase(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if ((c <= 'z' && c >= 'a') || (c >= '0' && c <= '9')) { sb.append(s.charAt(i)); } } s = sb.toString(); int start = 0; int end = s.length() - 1; while (start < end) { if (s.charAt(start) != s.charAt(end)) { return false; } start++; end--; } return true; }","public boolean var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) { return true ; } StringBuffer var_7 = new StringBuffer ( ) ; var_2 = var_2 . toLowerCase ( ) ; for ( int var_9 = 0 ; var_9 < var_2 . length ( ) ; var_9 ++ ) { char var_11 = var_2 . charAt ( var_9 ) ; if ( ( var_11 <= 'z' && var_11 >= 'a' ) || ( var_11 >= '0' && var_11 <= '9' ) ) { var_7 . append ( var_2 . charAt ( var_9 ) ) ; } } var_2 = var_7 . toString ( ) ; int var_18 = 0 ; int var_20 = var_2 . length ( ) - 1 ; while ( var_18 < var_20 ) { if ( var_2 . charAt ( var_18 ) != var_2 . charAt ( var_20 ) ) { return false ; } var_18 ++ ; var_20 -- ; } return true ; } " 770,Sum of Two Integers_2.java,"public int aplusb(int a, int b) { int numA = a; int numB = b; int incompleteSum = 0; while (numB != 0) { incompleteSum = numA ^ numB; numB = (numA & numB) << 1; numA = incompleteSum; } return incompleteSum; }","public int sample_funcname ( int var_0 , int var_1 ) { int var_2 = var_0 ; int var_3 = var_1 ; int var_5 = 0 ; while ( var_3 != 0 ) { var_5 = var_2 ^ var_3 ; var_3 = ( var_2 & var_3 ) << 1 ; var_2 = var_5 ; } return var_5 ; } " 771,204. Count Primes_2.java,"public boolean isPrime(int num) { if (num <= 1) return false; for (int i = 2; i * i <= num; i++) { if (num % i == 0) { return false; } } return true; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 1 ) return false ; for ( int var_4 = 2 ; var_4 * var_4 <= var_1 ; var_4 ++ ) { if ( var_1 % var_4 == 0 ) { return false ; } } return true ; } " 772,448. Find All Numbers Disappeared in an Array_2.java,"public List findDisappearedNumbers(int[] nums) { final List rst = new ArrayList(); if (nums == null || nums.length == 0) return rst; for (int i = 0; i < nums.length; i++) { int desiredIndex = Math.abs(nums[i]) - 1; nums[desiredIndex] = -Math.abs(nums[desiredIndex]); } for (int i = 0; i < nums.length; i++) { if (nums[i] > 0) rst.add(i + 1); } return rst; }","public List < Integer > var_1 ( int [ ] var_2 ) { final List < Integer > var_5 = new ArrayList < Integer > ( ) ; if ( var_2 == null || var_2 . length == 0 ) return var_5 ; for ( int var_9 = 0 ; var_9 < var_2 . length ; var_9 ++ ) { int var_13 = Math . abs ( var_2 [ var_9 ] ) - 1 ; var_2 [ var_13 ] = - Math . abs ( var_2 [ var_13 ] ) ; } for ( int var_9 = 0 ; var_9 < var_2 . length ; var_9 ++ ) { if ( var_2 [ var_9 ] > 0 ) var_5 . add ( var_9 + 1 ) ; } return var_5 ; } " 773,Ugly Number_3.java,"public long kthPrimeNumber(int k) { if (k == 0) { return 0; } ArrayList set = new ArrayList(); PriorityQueue queue = new PriorityQueue(); queue.offer((long)3); queue.offer((long)5); queue.offer((long)7); set.add((long)3); set.add((long)5); set.add((long)7); long num = 0; for (int i = 0; i < k; i++) { num = queue.poll(); if (!set.contains(num * 3)) { queue.offer(num * 3); set.add(num * 3); } if (!set.contains(num * 5)) { queue.offer(num * 5); set.add(num * 5); } if (!set.contains(num * 7)) { queue.offer(num * 7); set.add(num * 7); } } return num; }","public long sample_funcname ( int var_0 ) { if ( var_0 == 0 ) { return 0 ; } ArrayList < Long > var_4 = new ArrayList < Long > ( ) ; PriorityQueue < Long > var_6 = new PriorityQueue < Long > ( ) ; var_6 . offer ( ( long ) 3 ) ; var_6 . offer ( ( long ) 5 ) ; var_6 . offer ( ( long ) 7 ) ; var_4 . add ( ( long ) 3 ) ; var_4 . add ( ( long ) 5 ) ; var_4 . add ( ( long ) 7 ) ; long var_12 = 0 ; for ( int var_13 = 0 ; var_13 < var_0 ; var_13 ++ ) { var_12 = var_6 . poll ( ) ; if ( ! var_4 . contains ( var_12 * 3 ) ) { var_6 . offer ( var_12 * 3 ) ; var_4 . add ( var_12 * 3 ) ; } if ( ! var_4 . contains ( var_12 * 5 ) ) { var_6 . offer ( var_12 * 5 ) ; var_4 . add ( var_12 * 5 ) ; } if ( ! var_4 . contains ( var_12 * 7 ) ) { var_6 . offer ( var_12 * 7 ) ; var_4 . add ( var_12 * 7 ) ; } } return var_12 ; } " 774,844. Backspace String Compare_1.java,"private int backtrack(String s, int index) { int i = index, count = 0; while (i >= 0) { if (s.charAt(i) == '#') { count++; i--; } else if (count > 0) { count--; i--; } else break; } return i; }","private int sample_funcname ( String var_1 , int var_2 ) { int var_3 = var_2 , var_5 = 0 ; while ( var_3 >= 0 ) { if ( var_1 . charAt ( var_3 ) == '#' ) { var_5 ++ ; var_3 -- ; } else if ( var_5 > 0 ) { var_5 -- ; var_3 -- ; } else break ; } return var_3 ; } " 775,Longest Increasing Continuous subsequence_3.java,"public int longestIncreasingContinuousSubsequence(int[] A) { if (A == null || A.length == 0) { return -1; } int maxLength1 = 0; int maxLength2 = 0; int track = 1; for (int i = 1; i < A.length; i++) { if (A[i] > A[i - 1]) { track++; } else { maxLength1 = track > maxLength1 ? track : maxLength1; track = 1; } } maxLength1 = track > maxLength1 ? track : maxLength1; track = 1; for (int i = A.length - 2; i >= 0; i--) { if (A[i] > A[i + 1]) { track++; } else { maxLength2 = track > maxLength2 ? track : maxLength2; track = 1; } } maxLength2 = track > maxLength2 ? track : maxLength2; return maxLength1 > maxLength2 ? maxLength1 : maxLength2; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int var_5 = 0 ; int var_6 = 0 ; int var_7 = 1 ; for ( int var_8 = 1 ; var_8 < var_0 . length ; var_8 ++ ) { if ( var_0 [ var_8 ] > var_0 [ var_8 - 1 ] ) { var_7 ++ ; } else { var_5 = var_7 > var_5 ? var_7 : var_5 ; var_7 = 1 ; } } var_5 = var_7 > var_5 ? var_7 : var_5 ; var_7 = 1 ; for ( int var_8 = var_0 . length - 2 ; var_8 >= 0 ; var_8 -- ) { if ( var_0 [ var_8 ] > var_0 [ var_8 + 1 ] ) { var_7 ++ ; } else { var_6 = var_7 > var_6 ? var_7 : var_6 ; var_7 = 1 ; } } var_6 = var_7 > var_6 ? var_7 : var_6 ; return var_5 > var_6 ? var_5 : var_6 ; } " 776,Perfect Squares_1.java,"public int numSquares(int n) { if (n <= 1) { return 1; } int[] dp = new int[n + 1]; dp[0] = 0; for (int i = 1; i <= n; i++) { dp[i] = Integer.MAX_VALUE; for (int j = 1; j <= i; j++) { if (i >= j * j) { dp[i] = Math.min(dp[i], dp[i - j * j] + 1); } else { break; } } } return dp[n]; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 1 ) { return 1 ; } int [ ] var_2 = new int [ var_0 + 1 ] ; var_2 [ 0 ] = 0 ; for ( int var_4 = 1 ; var_4 <= var_0 ; var_4 ++ ) { var_2 [ var_4 ] = Integer . MAX_VALUE ; for ( int var_7 = 1 ; var_7 <= var_4 ; var_7 ++ ) { if ( var_4 >= var_7 * var_7 ) { var_2 [ var_4 ] = Math . min ( var_2 [ var_4 ] , var_2 [ var_4 - var_7 * var_7 ] + 1 ) ; } else { break ; } } } return var_2 [ var_0 ] ; } " 777,31. Next Permutation_3.java,"private void swap(int[] nums, int a, int b) { int temp = nums[a]; nums[a] = nums[b]; nums[b] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 778,52. N-Queens II_1.java,"private boolean validate(int[] columns, int row, int col) { for (int newRow = 0; newRow < row; newRow++) { int newCol = columns[newRow]; if (col == newCol || Math.abs(row - newRow) == Math.abs(col - newCol)) { return false; } } return true; }","private boolean var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { for ( int var_5 = 0 ; var_5 < var_2 ; var_5 ++ ) { int var_6 = var_1 [ var_5 ] ; if ( var_3 == var_6 || Math . abs ( var_2 - var_5 ) == Math . abs ( var_3 - var_6 ) ) { return false ; } } return true ; } " 779,88. Merge Sorted Array_2.java,"public void merge(int[] nums1, int m, int[] nums2, int n) { m--; n--; while (m >= 0 || n >= 0) { if (m >= 0 && n >= 0) { nums1[m + n + 1] = nums1[m] > nums2[n] ? nums1[m--] : nums2[n--]; } else if (m < 0) { nums1[n] = nums2[n--]; } else if (n < 0) { break; } } }","public void var_0 ( int [ ] var_1 , int var_2 , int [ ] var_3 , int var_4 ) { var_2 -- ; var_4 -- ; while ( var_2 >= 0 || var_4 >= 0 ) { if ( var_2 >= 0 && var_4 >= 0 ) { var_1 [ var_2 + var_4 + 1 ] = var_1 [ var_2 ] > var_3 [ var_4 ] ? var_1 [ var_2 -- ] : var_3 [ var_4 -- ] ; } else if ( var_2 < 0 ) { var_1 [ var_4 ] = var_3 [ var_4 -- ] ; } else if ( var_4 < 0 ) { break ; } } } " 780,Classical Binary Search_1.java,"public int findPosition(int[] nums, int target) { if (nums == null || nums.length == 0) { return -1; } int start = 0; int end = nums.length - 1; while (start + 1 < end) { int mid = start + ((end - start) >> 1); if (nums[mid] == target) { return mid; } else if (nums[mid] < target) { start = mid; } else { end = mid; } } if (nums[start] == target) { return start; } if (nums[end] == target) { return end; } return -1; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int var_6 = 0 ; int var_7 = var_0 . length - 1 ; while ( var_6 + 1 < var_7 ) { int var_8 = var_6 + ( ( var_7 - var_6 ) >> 1 ) ; if ( var_0 [ var_8 ] == var_1 ) { return var_8 ; } else if ( var_0 [ var_8 ] < var_1 ) { var_6 = var_8 ; } else { var_7 = var_8 ; } } if ( var_0 [ var_6 ] == var_1 ) { return var_6 ; } if ( var_0 [ var_7 ] == var_1 ) { return var_7 ; } return - 1 ; } " 781,Triangles_1.java,"public int minimumTotal(List> triangle) { if (triangle == null || triangle.size() == 0) { return 0; } int n = triangle.size(); int[][] dp = new int[n][n]; for (int j = 0; j < n; j++) { dp[n - 1][j] = triangle.get(n - 1).get(j); } for (int i = n - 2; i >= 0; i--) { for (int j = 0; j <= i; j++) { dp[i][j] = Math.min(dp[i + 1][j], dp[i + 1][j + 1]) + triangle.get(i).get(j); } } return dp[0][0]; }","public int sample_funcname ( List < List < Integer >> var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return 0 ; } int var_6 = var_2 . size ( ) ; int [ ] [ ] var_7 = new int [ var_6 ] [ var_6 ] ; for ( int var_8 = 0 ; var_8 < var_6 ; var_8 ++ ) { var_7 [ var_6 - 1 ] [ var_8 ] = var_2 . get ( var_6 - 1 ) . get ( var_8 ) ; } for ( int var_12 = var_6 - 2 ; var_12 >= 0 ; var_12 -- ) { for ( int var_8 = 0 ; var_8 <= var_12 ; var_8 ++ ) { var_7 [ var_12 ] [ var_8 ] = Math . min ( var_7 [ var_12 + 1 ] [ var_8 ] , var_7 [ var_12 + 1 ] [ var_8 + 1 ] ) + var_2 . get ( var_12 ) . get ( var_8 ) ; } } return var_7 [ 0 ] [ 0 ] ; } " 782,QuickSort_2.java,"private void printArray(int[] nums, String str) { System.out.print(str); if (nums == null || nums.length == 0) { System.out.println(); return; } for (int num : nums) { System.out.print(num + "", ""); } System.out.println(); }","private void var_0 ( int [ ] var_1 , String var_3 ) { System . out . print ( var_3 ) ; if ( var_1 == null || var_1 . length == 0 ) { System . out . println ( ) ; return ; } for ( int var_11 : var_1 ) { System . out . print ( var_11 + "", "" ) ; } System . out . println ( ) ; } " 783,[tool]. MergeSort_1.java,"private void merge(int[] nums, int[] temp, int start, int end) { int leftEnd = start + (end - start) / 2; int rightStart = leftEnd + 1; int size = end - start + 1; int i = start; int j = rightStart; int index = start; while (i <= leftEnd && j <= end) { if (nums[i] <= nums[j]) { temp[index] = nums[i]; i++; } else { temp[index] = nums[j]; j++; } index++; } System.arraycopy(nums, i, temp, index, leftEnd - i + 1); System.arraycopy(nums, j, temp, index, end - j + 1); System.arraycopy(temp, start, nums, start, end - start + 1); }","private void var_0 ( int [ ] var_1 , int [ ] var_2 , int var_3 , int var_4 ) { int var_6 = var_3 + ( var_4 - var_3 ) / 2 ; int var_8 = var_6 + 1 ; int var_9 = var_4 - var_3 + 1 ; int var_10 = var_3 ; int var_11 = var_8 ; int var_12 = var_3 ; while ( var_10 <= var_6 && var_11 <= var_4 ) { if ( var_1 [ var_10 ] <= var_1 [ var_11 ] ) { var_2 [ var_12 ] = var_1 [ var_10 ] ; var_10 ++ ; } else { var_2 [ var_12 ] = var_1 [ var_11 ] ; var_11 ++ ; } var_12 ++ ; } System . arraycopy ( var_1 , var_10 , var_2 , var_12 , var_6 - var_10 + 1 ) ; System . arraycopy ( var_1 , var_11 , var_2 , var_12 , var_4 - var_11 + 1 ) ; System . arraycopy ( var_2 , var_3 , var_1 , var_3 , var_4 - var_3 + 1 ) ; } " 784,Backpack_6.java,"public int backPack(int m, int[] A) { if (A == null || m == 0) { return 0; } boolean[] DP = new boolean[m + 1]; DP[0] = true; for (int i = 1; i <= A.length; i++) { for (int j = m; j >= 0; j--) { if (j - A[i - 1] >= 0 && DP[j - A[i - 1]]) { DP[j] = true; } } } for (int j = m; j >= 0; j--) { if (DP[j]) { return j; } } return 0; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_0 == 0 ) { return 0 ; } boolean [ ] var_6 = new boolean [ var_0 + 1 ] ; var_6 [ 0 ] = true ; for ( int var_7 = 1 ; var_7 <= var_1 . length ; var_7 ++ ) { for ( int var_9 = var_0 ; var_9 >= 0 ; var_9 -- ) { if ( var_9 - var_1 [ var_7 - 1 ] >= 0 && var_6 [ var_9 - var_1 [ var_7 - 1 ] ] ) { var_6 [ var_9 ] = true ; } } } for ( int var_9 = var_0 ; var_9 >= 0 ; var_9 -- ) { if ( var_6 [ var_9 ] ) { return var_9 ; } } return 0 ; } " 785,Number of Connected Components in an Undirected Graph_2.java,"private void dfs(Map> graph, boolean[] visited, int i) { if (visited[i]) { return; } visited[i] = true; for (int j : graph.get(i)) { dfs(graph, visited, j); } }","private void sample_funcname ( Map < Integer , List < Integer >> graph , boolean [ ] visited , int i ) { if ( visited [ i ] ) { return ; } visited [ i ] = true ; for ( int j : graph . get ( i ) ) { dfs ( graph , visited , j ) ; } } " 786,796. Rotate String_2.java,"public void reverse(char[] A, int start, int end) { for (int i = start, j = end; i < j; i++, j--) { char temp = A[j]; A[j] = A[i]; A[i] = temp; } }","public void var_0 ( char [ ] var_1 , int var_2 , int var_3 ) { for ( int var_4 = var_2 , var_5 = var_3 ; var_4 < var_5 ; var_4 ++ , var_5 -- ) { char var_6 = var_1 [ var_5 ] ; var_1 [ var_5 ] = var_1 [ var_4 ] ; var_1 [ var_4 ] = var_6 ; } } " 787,265. Paint House II_2.java,"public int minCostII(int[][] costs) { if (costs == null || costs.length == 0) return 0; if (costs.length == 1 && costs[0].length == 1) return costs[0][0]; int n = costs.length, k = costs[0].length; int[][] dp = new int[2][k]; for (int i = 1; i <= n; i++) { for (int j = 0; j < k; j++) { dp[i % 2][j] = Integer.MAX_VALUE; for (int m = 0; m < k; m++) { if (j == m) continue; dp[i % 2][j] = Math.min(dp[i % 2][j], dp[(i - 1) % 2][m] + costs[i - 1][j]); } } } int min = Integer.MAX_VALUE; for (int j = 0; j < k; j++) min = Math.min(min, dp[n % 2][j]); return min; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; if ( var_0 . length == 1 && var_0 [ 0 ] . length == 1 ) return var_0 [ 0 ] [ 0 ] ; int var_5 = var_0 . length , var_6 = var_0 [ 0 ] . length ; int [ ] [ ] var_8 = new int [ 2 ] [ var_6 ] ; for ( int var_9 = 1 ; var_9 <= var_5 ; var_9 ++ ) { for ( int var_10 = 0 ; var_10 < var_6 ; var_10 ++ ) { var_8 [ var_9 % 2 ] [ var_10 ] = Integer . MAX_VALUE ; for ( int var_13 = 0 ; var_13 < var_6 ; var_13 ++ ) { if ( var_10 == var_13 ) continue ; var_8 [ var_9 % 2 ] [ var_10 ] = Math . min ( var_8 [ var_9 % 2 ] [ var_10 ] , var_8 [ ( var_9 - 1 ) % 2 ] [ var_13 ] + var_0 [ var_9 - 1 ] [ var_10 ] ) ; } } } int min = Integer . MAX_VALUE ; for ( int var_10 = 0 ; var_10 < var_6 ; var_10 ++ ) min = Math . min ( min , var_8 [ var_5 % 2 ] [ var_10 ] ) ; return min ; } " 788,Longest Valid Parentheses_2.java,"private int addPriorLength(int priorIndex, int[] dp) { return (priorIndex - 1 >= 0) ? dp[priorIndex - 1] : 0; }","private int sample_funcname ( int var_0 , int [ ] var_1 ) { return ( var_0 - 1 >= 0 ) ? var_1 [ var_0 - 1 ] : 0 ; } " 789,Count and Say_2.java,"public String countAndSay(int n) { if (n <= 1) { return n + """"; } String str = ""11""; int ind = 2; while (ind < n) { StringBuffer sb = new StringBuffer(); char[] arr = str.toCharArray(); int count = 1; int type = Character.getNumericValue(arr[0]); for (int i = 1; i < arr.length; i++) { if (arr[i] == arr[i - 1]) { count++; } else { sb.append(count + """" + type); type = Character.getNumericValue(arr[i]); count = 1; } } ind++; sb.append(count + """" + type); str = sb.toString(); } return str; }","public String var_0 ( int var_1 ) { if ( var_1 <= 1 ) { return var_1 + """" ; } String var_6 = ""11"" ; int var_8 = 2 ; while ( var_8 < var_1 ) { StringBuffer var_10 = new StringBuffer ( ) ; char [ ] var_12 = var_6 . toCharArray ( ) ; int var_13 = 1 ; int var_17 = Character . getNumericValue ( var_12 [ 0 ] ) ; for ( int var_18 = 1 ; var_18 < var_12 . length ; var_18 ++ ) { if ( var_12 [ var_18 ] == var_12 [ var_18 - 1 ] ) { var_13 ++ ; } else { var_10 . append ( var_13 + """" + var_17 ) ; var_17 = Character . getNumericValue ( var_12 [ var_18 ] ) ; var_13 = 1 ; } } var_8 ++ ; var_10 . append ( var_13 + """" + var_17 ) ; var_6 = var_10 . toString ( ) ; } return var_6 ; } " 790,62. Unique Path_3.java,"private String getKey(int x, int y) { return x + "","" + y; }","private String var_0 ( int var_1 , int var_2 ) { return var_1 + "","" + var_2 ; } " 791,Find Peak Element_1.java,"public int findPeakElement(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int start = 0; int end = n - 1; while (start + 1 < end) { int mid = (start + end) >> 1; if (nums[mid] > nums[mid - 1] && nums[mid] > nums[mid + 1]) { return mid; } else if (nums[mid] > nums[mid - 1]) { start = mid; } else { end = mid; } } return nums[start] > nums[end] ? start : end; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int var_5 = 0 ; int var_7 = var_4 - 1 ; while ( var_5 + 1 < var_7 ) { int var_8 = ( var_5 + var_7 ) >> 1 ; if ( var_0 [ var_8 ] > var_0 [ var_8 - 1 ] && var_0 [ var_8 ] > var_0 [ var_8 + 1 ] ) { return var_8 ; } else if ( var_0 [ var_8 ] > var_0 [ var_8 - 1 ] ) { var_5 = var_8 ; } else { var_7 = var_8 ; } } return var_0 [ var_5 ] > var_0 [ var_7 ] ? var_5 : var_7 ; } " 792,55. Jump Game_1.java,"public boolean canJump(int[] nums) { if (nums == null || nums.length == 0) { return false; } int farest = 0; for (int i = 0; i < nums.length; i++) { farest = Math.max(farest, i + nums[i]); if (farest >= nums.length - 1) { return true; } if (farest <= i) { return false; } } return true; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return false ; } int var_5 = 0 ; for ( int var_6 = 0 ; var_6 < var_1 . length ; var_6 ++ ) { var_5 = Math . max ( var_5 , var_6 + var_1 [ var_6 ] ) ; if ( var_5 >= var_1 . length - 1 ) { return true ; } if ( var_5 <= var_6 ) { return false ; } } return true ; } " 793,Heaters_1.java,"public int findRadius(int[] houses, int[] heaters) { int heaterIndex = 0; int radius = 0; int heatersLength = heaters.length; Arrays.sort(houses); Arrays.sort(heaters); for (int i = 0; i < houses.length; i++) { int housePos = houses[i]; while (heaterIndex < heatersLength - 1 && Math.abs(heaters[heaterIndex + 1] - housePos) <= Math.abs(heaters[heaterIndex] - housePos)) { heaterIndex++; } radius = Math.max(radius, Math.abs(heaters[heaterIndex] - housePos)); } return radius; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { int var_3 = 0 ; int var_4 = 0 ; int var_6 = var_1 . length ; Arrays . sort ( var_0 ) ; Arrays . sort ( var_1 ) ; for ( int var_9 = 0 ; var_9 < var_0 . length ; var_9 ++ ) { int var_10 = var_0 [ var_9 ] ; while ( var_3 < var_6 - 1 && Math . abs ( var_1 [ var_3 + 1 ] - var_10 ) <= Math . abs ( var_1 [ var_3 ] - var_10 ) ) { var_3 ++ ; } var_4 = Math . max ( var_4 , Math . abs ( var_1 [ var_3 ] - var_10 ) ) ; } return var_4 ; } " 794,Minimum Subarray_2.java,"public int minSubArray(ArrayList nums) { if (nums == null || nums.size() == 0) { return 0; } int curMin = nums.get(0); int minRst = nums.get(0); for (int i = 1; i < nums.size(); i++) { curMin = Math.min(nums.get(i), curMin + nums.get(i)); minRst = Math.min(curMin, minRst); } return minRst; }","public int sample_funcname ( ArrayList < Integer > var_2 ) { if ( var_2 == null || var_2 . size ( ) == 0 ) { return 0 ; } int var_7 = var_2 . get ( 0 ) ; int var_8 = var_2 . get ( 0 ) ; for ( int var_10 = 1 ; var_10 < var_2 . size ( ) ; var_10 ++ ) { var_7 = Math . min ( var_2 . get ( var_10 ) , var_7 + var_2 . get ( var_10 ) ) ; var_8 = Math . min ( var_7 , var_8 ) ; } return var_8 ; } " 795,Two Sum II - Input array is sorted_1.java,"public int[] twoSum(int[] numbers, int target) { if (numbers == null || numbers.length == 0) { return numbers; } final int[] result = new int[2]; int start = 0; int end = numbers.length - 1; while (start < end) { long sum = (long)(numbers[start] + numbers[end]); if (sum == target) { result[0] = start + 1; result[1] = end + 1; break; } else if (sum < target) { start++; } else { end--; } } return result; }","public int [ ] sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return var_0 ; } final int [ ] var_6 = new int [ 2 ] ; int var_7 = 0 ; int var_9 = var_0 . length - 1 ; while ( var_7 < var_9 ) { long var_10 = ( long ) ( var_0 [ var_7 ] + var_0 [ var_9 ] ) ; if ( var_10 == var_1 ) { var_6 [ 0 ] = var_7 + 1 ; var_6 [ 1 ] = var_9 + 1 ; break ; } else if ( var_10 < var_1 ) { var_7 ++ ; } else { var_9 -- ; } } return var_6 ; } " 796,Excel Sheet Column Number_2.java,"public int titleToNumber(String s) { if (s == null || s.length() == 0) { return 0; } int num = 0; for (int i = s.length() - 1; i >= 0; i--) { int digit = s.charAt(i) - 'A' + 1; num += digit * Math.pow(26, s.length() - i - 1); } return num; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) { return 0 ; } int var_5 = 0 ; for ( int var_7 = var_1 . length ( ) - 1 ; var_7 >= 0 ; var_7 -- ) { int var_10 = var_1 . charAt ( var_7 ) - 'A' + 1 ; var_5 += var_10 * Math . pow ( 26 , var_1 . length ( ) - var_7 - 1 ) ; } return var_5 ; } " 797,Shortest Palindrome_1.java,"private boolean validateSubstring(String s, int i, int j) { String end = s.substring(j).toString(); String front = new StringBuffer(s.substring(0, i + 1)).reverse().toString(); if (front.length() <= end.length() && end.indexOf(front) == 0) { return true; } return false; }","private boolean var_0 ( String var_2 , int var_3 , int var_4 ) { String var_7 = var_2 . substring ( var_4 ) . toString ( ) ; String var_12 = new StringBuffer ( var_2 . substring ( 0 , var_3 + 1 ) ) . reverse ( ) . toString ( ) ; if ( var_12 . length ( ) <= var_7 . length ( ) && var_7 . indexOf ( var_12 ) == 0 ) { return true ; } return false ; } " 798,Maximum Average Subarray II_1.java,"private boolean check(int[] nums, int k, double midAvg) { double preSum = 0; double sum = 0; double minPreSum = 0; for (int i = 0; i < k; i++) { sum += nums[i] - midAvg; } if (sum >= 0) { return true; } for (int i = k; i < nums.length; i++) { sum += nums[i] - midAvg; preSum += nums[i - k] - midAvg; minPreSum = Math.min(preSum, minPreSum); if (sum >= minPreSum) { return true; } } return false; }","private boolean var_0 ( int [ ] var_1 , int var_2 , double var_3 ) { double var_5 = 0 ; double var_6 = 0 ; double var_7 = 0 ; for ( int var_8 = 0 ; var_8 < var_2 ; var_8 ++ ) { var_6 += var_1 [ var_8 ] - var_3 ; } if ( var_6 >= 0 ) { return true ; } for ( int var_8 = var_2 ; var_8 < var_1 . length ; var_8 ++ ) { var_6 += var_1 [ var_8 ] - var_3 ; var_5 += var_1 [ var_8 - var_2 ] - var_3 ; var_7 = Math . min ( var_5 , var_7 ) ; if ( var_6 >= var_7 ) { return true ; } } return false ; } " 799,121. Best Time to Buy and Sell Stock_3.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length == 0) return 0; int n = prices.length; int[] dp = new int[n + 1]; dp[0] = Integer.MAX_VALUE; int profit = 0; for (int i = 1; i <= n; i++) { dp[i] = Math.min(dp[i - 1], prices[i - 1]); profit = Math.max(profit, prices[i - 1] - dp[i]); } return profit; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length ; int [ ] var_6 = new int [ var_4 + 1 ] ; var_6 [ 0 ] = Integer . MAX_VALUE ; int var_9 = 0 ; for ( int var_10 = 1 ; var_10 <= var_4 ; var_10 ++ ) { var_6 [ var_10 ] = Math . min ( var_6 [ var_10 - 1 ] , var_0 [ var_10 - 1 ] ) ; var_9 = Math . max ( var_9 , var_0 [ var_10 - 1 ] - var_6 [ var_10 ] ) ; } return var_9 ; } " 800,523. Continuous Subarray Sum_2.java,"public boolean checkSubarraySum(int[] nums, int k) { if (nums == null || nums.length == 0) return false; int n = nums.length; int[] dp = new int[n]; dp[0] = nums[0]; for (int i = 1; i < n; i++) { dp[i] = dp[i - 1] + nums[i]; } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int sum = dp[j] - dp[i] + nums[i]; if (sum == k || (k != 0 && sum % k == 0)) { return true; } } } return false; }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { if ( var_1 == null || var_1 . length == 0 ) return false ; int var_6 = var_1 . length ; int [ ] var_7 = new int [ var_6 ] ; var_7 [ 0 ] = var_1 [ 0 ] ; for ( int var_9 = 1 ; var_9 < var_6 ; var_9 ++ ) { var_7 [ var_9 ] = var_7 [ var_9 - 1 ] + var_1 [ var_9 ] ; } for ( int var_9 = 0 ; var_9 < var_6 ; var_9 ++ ) { for ( int var_10 = var_9 + 1 ; var_10 < var_6 ; var_10 ++ ) { int var_11 = var_7 [ var_10 ] - var_7 [ var_9 ] + var_1 [ var_9 ] ; if ( var_11 == var_2 || ( var_2 != 0 && var_11 % var_2 == 0 ) ) { return true ; } } } return false ; } " 801,46. Permutations_3.java,"private void dfs(List> result, List list, int[] nums, boolean[] visited) { if (list.size() == nums.length) { result.add(new ArrayList<>(list)); return; } for (int i = 0; i < nums.length; i++) { if (visited[i]) continue; list.add(nums[i]); visited[i] = true; dfs(result, list, nums, visited); list.remove(list.size() - 1); visited[i] = false; } }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int [ ] nums , boolean [ ] visited ) { if ( list . size ( ) == nums . length ) { result . add ( new ArrayList < > ( list ) ) ; return ; } for ( int i = 0 ; i < nums . length ; i ++ ) { if ( visited [ i ] ) continue ; list . add ( nums [ i ] ) ; visited [ i ] = true ; dfs ( result , list , nums , visited ) ; list . remove ( list . size ( ) - 1 ) ; visited [ i ] = false ; } } " 802,53. Maximum Subarray_2.java,"public int maxSubArray(int[] nums) { if (nums == null || nums.length == 0) return 0; int preSum = 0, minPreSum = 0; int max = Integer.MIN_VALUE; for (int num : nums) { preSum += num; max = Math.max(max, preSum - minPreSum); minPreSum = Math.min(minPreSum, preSum); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = 0 , var_5 = 0 ; int max = Integer . MIN_VALUE ; for ( int var_9 : var_0 ) { var_4 += var_9 ; max = Math . max ( max , var_4 - var_5 ) ; var_5 = Math . min ( var_5 , var_4 ) ; } return max ; } " 803,1094. Car Pooling_1.java,"public boolean carPooling(int[][] trips, int capacity) { if (trips == null || trips.length == 0) return true; int[] bucket = new int[1000]; for (int[] trip : trips) { bucket[trip[1]] += trip[0]; bucket[trip[2]] += -trip[0]; } int cap = 0; for (int num : bucket) { cap += num; if (cap > capacity) return false; } return true; }","public boolean var_0 ( int [ ] [ ] var_1 , int var_2 ) { if ( var_1 == null || var_1 . length == 0 ) return true ; int [ ] var_7 = new int [ 1000 ] ; for ( int [ ] var_8 : var_1 ) { var_7 [ var_8 [ 1 ] ] += var_8 [ 0 ] ; var_7 [ var_8 [ 2 ] ] += - var_8 [ 0 ] ; } int var_11 = 0 ; for ( int var_12 : var_7 ) { var_11 += var_12 ; if ( var_11 > var_2 ) return false ; } return true ; } " 804,205. Isomorphic Strings_1.java,"public boolean isIsomorphic(String s, String t) { if (s == null || t == null || s.length() != t.length()) return false; Map map = new HashMap<>(); for (int i = 0; i < s.length(); i++) { char charS = s.charAt(i), charT = t.charAt(i); if (map.containsKey(charS)) { if (map.get(charS) != charT) return false; } else { if (map.containsValue(charT)) return false; map.put(charS, charT); } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) != var_3 . length ( ) ) return false ; Map < Character , Character > var_9 = new HashMap < > ( ) ; for ( int var_11 = 0 ; var_11 < var_2 . length ( ) ; var_11 ++ ) { char var_13 = var_2 . charAt ( var_11 ) , var_14 = var_3 . charAt ( var_11 ) ; if ( var_9 . containsKey ( var_13 ) ) { if ( var_9 . get ( var_13 ) != var_14 ) return false ; } else { if ( var_9 . containsValue ( var_14 ) ) return false ; var_9 . put ( var_13 , var_14 ) ; } } return true ; } " 805,[tool] Quick Select - Median_1.java,"private void swap(int[] nums, int x, int y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 806,315. Count of Smaller Numbers After Self_1.java,"private int search(List list, int target) { if (list.size() == 0) return 0; int start = 0, end = list.size() - 1; if (target <= list.get(start)) return start; if (target > list.get(end)) return end + 1; while (start + 1 < end) { int mid = start + (end - start) / 2; int num = list.get(mid); if (num < target) start = mid; else end = mid; } if (target <= list.get(start)) return start; return end; }","private int sample_funcname ( List < Integer > var_2 , int var_3 ) { if ( var_2 . size ( ) == 0 ) return 0 ; int var_6 = 0 , var_8 = var_2 . size ( ) - 1 ; if ( var_3 <= var_2 . get ( var_6 ) ) return var_6 ; if ( var_3 > var_2 . get ( var_8 ) ) return var_8 + 1 ; while ( var_6 + 1 < var_8 ) { int var_11 = var_6 + ( var_8 - var_6 ) / 2 ; int var_12 = var_2 . get ( var_11 ) ; if ( var_12 < var_3 ) var_6 = var_11 ; else var_8 = var_11 ; } if ( var_3 <= var_2 . get ( var_6 ) ) return var_6 ; return var_8 ; } " 807,1060. Missing Element in Sorted Array_2.java,"public int missingElement(int[] nums, int k) { int start = 0, end = nums.length - 1; int count = nums[end] - nums[0] - end; if (count < k) { return nums[end] + k - count; } while (start + 1 < end) { int mid = start + (end - start) / 2; count = nums[mid] - nums[start] - (mid - start); if (count >= k) { end = mid; } else { start = mid; k -= count; } } return nums[start] + k; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = 0 , var_6 = var_0 . length - 1 ; int var_7 = var_0 [ var_6 ] - var_0 [ 0 ] - var_6 ; if ( var_7 < var_1 ) { return var_0 [ var_6 ] + var_1 - var_7 ; } while ( var_3 + 1 < var_6 ) { int var_9 = var_3 + ( var_6 - var_3 ) / 2 ; var_7 = var_0 [ var_9 ] - var_0 [ var_3 ] - ( var_9 - var_3 ) ; if ( var_7 >= var_1 ) { var_6 = var_9 ; } else { var_3 = var_9 ; var_1 -= var_7 ; } } return var_0 [ var_3 ] + var_1 ; } " 808,Backpack II_5.java,"public int backPackII(int m, int[] A, int V[]) { if (A == null || V == null || A.length != V.length) { return 0; } int n = A.length; int[][] dp = new int[n + 1][m + 1]; dp[0][0] = 0; for (int j = 0; j <= m; j++) { dp[0][j] = 0; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp[i][j] = dp[i - 1][j]; if (j - A[i - 1] >= 0) { dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - A[i - 1]] + V[i - 1]); } } } return dp[n][m]; }","public int sample_funcname ( int var_0 , int [ ] var_1 , int var_2 [ ] ) { if ( var_1 == null || var_2 == null || var_1 . length != var_2 . length ) { return 0 ; } int var_6 = var_1 . length ; int [ ] [ ] var_8 = new int [ var_6 + 1 ] [ var_0 + 1 ] ; var_8 [ 0 ] [ 0 ] = 0 ; for ( int var_9 = 0 ; var_9 <= var_0 ; var_9 ++ ) { var_8 [ 0 ] [ var_9 ] = 0 ; } for ( int var_10 = 1 ; var_10 <= var_6 ; var_10 ++ ) { for ( int var_9 = 1 ; var_9 <= var_0 ; var_9 ++ ) { var_8 [ var_10 ] [ var_9 ] = var_8 [ var_10 - 1 ] [ var_9 ] ; if ( var_9 - var_1 [ var_10 - 1 ] >= 0 ) { var_8 [ var_10 ] [ var_9 ] = Math . max ( var_8 [ var_10 ] [ var_9 ] , var_8 [ var_10 - 1 ] [ var_9 - var_1 [ var_10 - 1 ] ] + var_2 [ var_10 - 1 ] ) ; } } } return var_8 [ var_6 ] [ var_0 ] ; } " 809,Coins in a Line III_3.java,"private void search(int i, int j, int[][] dp, int[][] sum, int[] values) { if (dp[i][j] > 0) { return; } if (i == j) { dp[i][j] = values[i]; } else if (i > j) { dp[i][j] = 0; } else if (i + 1 == j) { dp[i][j] = Math.max(values[i], values[j]); } else { search(i + 1, j, dp, sum, values); search(i, j - 1, dp, sum, values); dp[i][j] = sum[i][j] - Math.min(dp[i + 1][j], dp[i][j - 1]); } }","private void sample_funcname ( int i , int j , int [ ] [ ] dp , int [ ] [ ] sum , int [ ] values ) { if ( dp [ i ] [ j ] > 0 ) { return ; } if ( i == j ) { dp [ i ] [ j ] = values [ i ] ; } else if ( i > j ) { dp [ i ] [ j ] = 0 ; } else if ( i + 1 == j ) { dp [ i ] [ j ] = Math . max ( values [ i ] , values [ j ] ) ; } else { search ( i + 1 , j , dp , sum , values ) ; search ( i , j - 1 , dp , sum , values ) ; dp [ i ] [ j ] = sum [ i ] [ j ] - Math . min ( dp [ i + 1 ] [ j ] , dp [ i ] [ j - 1 ] ) ; } } " 810,Perfect Rectangle_1.java,"private String buildKey(int x, int y) { return x + ""@"" + y; }","private String var_0 ( int var_1 , int var_2 ) { return var_1 + ""@"" + var_2 ; } " 811,Two Strings Are Anagrams_1.java,"public boolean anagram(String s, String t) { if (s == null || t == null) { return false; } else if (s.length() != t.length()) { return false; } else if (s.length() == 0 && t.length() == 0) { return true; } int[] count = new int[256]; for (int i = 0; i < s.length(); i++) { count[s.charAt(i)]++; count[t.charAt(i)]--; } for (int num : count) { if (num != 0) { return false; } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null ) { return false ; } else if ( var_2 . length ( ) != var_3 . length ( ) ) { return false ; } else if ( var_2 . length ( ) == 0 && var_3 . length ( ) == 0 ) { return true ; } int [ ] var_8 = new int [ 256 ] ; for ( int var_9 = 0 ; var_9 < var_2 . length ( ) ; var_9 ++ ) { var_8 [ var_2 . charAt ( var_9 ) ] ++ ; var_8 [ var_3 . charAt ( var_9 ) ] -- ; } for ( int var_11 : var_8 ) { if ( var_11 != 0 ) { return false ; } } return true ; } " 812,33. Search in Rotated Sorted Array_2.java,"public int search(int[] A, int target) { if (A == null || A.length == 0) { return -1; } int p1 = 0; int p2 = A.length - 1; int start = p1; int end = p2; int mid = start + (end - start)/2; int breakPoint = 0; while (start + 1 < end) { mid = start + (end - start)/2; if (A[mid] == target) { return mid; } else if (A[mid] >= A[p1]) { start = mid; } else { end = mid; } } if (A[start] > A[end]) { breakPoint = start; } else { breakPoint = end; } if (A[p1] <= target && target <= A[breakPoint]) { start = p1; end = breakPoint; } else { start = breakPoint + 1; end = p2; } while (start + 1 < end) { mid = start + (end - start)/2; if (A[mid] == target) { return mid; } else if (A[mid] > target) { end = mid; } else { start = mid; } } if (A[start] == target) { return start; } else if (A[end] == target) { return end; } return -1; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int var_6 = 0 ; int var_7 = var_0 . length - 1 ; int var_8 = var_6 ; int var_9 = var_7 ; int var_11 = var_8 + ( var_9 - var_8 ) / 2 ; int var_12 = 0 ; while ( var_8 + 1 < var_9 ) { var_11 = var_8 + ( var_9 - var_8 ) / 2 ; if ( var_0 [ var_11 ] == var_1 ) { return var_11 ; } else if ( var_0 [ var_11 ] >= var_0 [ var_6 ] ) { var_8 = var_11 ; } else { var_9 = var_11 ; } } if ( var_0 [ var_8 ] > var_0 [ var_9 ] ) { var_12 = var_8 ; } else { var_12 = var_9 ; } if ( var_0 [ var_6 ] <= var_1 && var_1 <= var_0 [ var_12 ] ) { var_8 = var_6 ; var_9 = var_12 ; } else { var_8 = var_12 + 1 ; var_9 = var_7 ; } while ( var_8 + 1 < var_9 ) { var_11 = var_8 + ( var_9 - var_8 ) / 2 ; if ( var_0 [ var_11 ] == var_1 ) { return var_11 ; } else if ( var_0 [ var_11 ] > var_1 ) { var_9 = var_11 ; } else { var_8 = var_11 ; } } if ( var_0 [ var_8 ] == var_1 ) { return var_8 ; } else if ( var_0 [ var_9 ] == var_1 ) { return var_9 ; } return - 1 ; } " 813,Backpack V_1.java,"public int backPackV(int[] nums, int target) { if (nums == null || nums.length == 0) { return 0; } int n = nums.length; int[][] dp = new int[n + 1][target + 1]; dp[0][0] = 1; for (int j = 1; j <= target; j++) { dp[0][j] = 0; } for (int i = 1; i <= n; i++) { for (int j = 0; j <= target; j++) { dp[i][j] = dp[i - 1][j]; if (j - nums[i - 1] >= 0) { dp[i][j] += dp[i - 1][j - nums[i - 1]]; } } } return dp[n][target]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_5 = var_0 . length ; int [ ] [ ] var_7 = new int [ var_5 + 1 ] [ var_1 + 1 ] ; var_7 [ 0 ] [ 0 ] = 1 ; for ( int var_8 = 1 ; var_8 <= var_1 ; var_8 ++ ) { var_7 [ 0 ] [ var_8 ] = 0 ; } for ( int var_9 = 1 ; var_9 <= var_5 ; var_9 ++ ) { for ( int var_8 = 0 ; var_8 <= var_1 ; var_8 ++ ) { var_7 [ var_9 ] [ var_8 ] = var_7 [ var_9 - 1 ] [ var_8 ] ; if ( var_8 - var_0 [ var_9 - 1 ] >= 0 ) { var_7 [ var_9 ] [ var_8 ] += var_7 [ var_9 - 1 ] [ var_8 - var_0 [ var_9 - 1 ] ] ; } } } return var_7 [ var_5 ] [ var_1 ] ; } " 814,Compare Version Numbers_1.java,"public int compareVersion(String version1, String version2) { if (version1.equals(version2)) { return 0; } String[] subVersion1 = version1.split(""\\.""); String[] subVersion2 = version2.split(""\\.""); int size = Math.max(subVersion1.length, subVersion2.length); int rst = 0; for (int i = 0; i < size; i++) { if (i >= subVersion1.length) { rst = Integer.parseInt(subVersion2[i]) == 0 ? 0 : -1; } else if (i >= subVersion2.length) { rst = Integer.parseInt(subVersion1[i]) == 0 ? 0 : 1; } else { if (Integer.parseInt(subVersion1[i]) != Integer.parseInt(subVersion2[i])) { rst = Integer.parseInt(subVersion1[i]) < Integer.parseInt(subVersion2[i]) ? -1 : 1; } } if (rst != 0) { return rst; } } return rst; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 . equals ( var_2 ) ) { return 0 ; } String [ ] var_7 = var_1 . split ( ""\\."" ) ; String [ ] var_8 = var_2 . split ( ""\\."" ) ; int var_12 = Math . max ( var_7 . length , var_8 . length ) ; int var_13 = 0 ; for ( int var_14 = 0 ; var_14 < var_12 ; var_14 ++ ) { if ( var_14 >= var_7 . length ) { var_13 = Integer . parseInt ( var_8 [ var_14 ] ) == 0 ? 0 : - 1 ; } else if ( var_14 >= var_8 . length ) { var_13 = Integer . parseInt ( var_7 [ var_14 ] ) == 0 ? 0 : 1 ; } else { if ( Integer . parseInt ( var_7 [ var_14 ] ) != Integer . parseInt ( var_8 [ var_14 ] ) ) { var_13 = Integer . parseInt ( var_7 [ var_14 ] ) < Integer . parseInt ( var_8 [ var_14 ] ) ? - 1 : 1 ; } } if ( var_13 != 0 ) { return var_13 ; } } return var_13 ; } " 815,215. Kth Largest Element in an Array_1.java,"public int findKthLargest(int[] nums, int k) { if (nums == null || nums.length == 0) return -1; PriorityQueue queue = new PriorityQueue<>(); for (int i = 0; i < nums.length; i++) { if (i < k || nums[i] > queue.peek()) queue.offer(nums[i]); if (queue.size() > k) queue.poll(); } return queue.poll(); }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) return - 1 ; PriorityQueue < Integer > var_8 = new PriorityQueue < > ( ) ; for ( int var_9 = 0 ; var_9 < var_0 . length ; var_9 ++ ) { if ( var_9 < var_1 || var_0 [ var_9 ] > var_8 . peek ( ) ) var_8 . offer ( var_0 [ var_9 ] ) ; if ( var_8 . size ( ) > var_1 ) var_8 . poll ( ) ; } return var_8 . poll ( ) ; } " 816,1033. Moving Stones Until Consecutive_2.java,"private int calDist(int start, int end) { return end - start - 1; }","private int sample_funcname ( int var_0 , int var_1 ) { return var_1 - var_0 - 1 ; } " 817,Remove Duplicate Letters_1.java,"String removeDuplicateLetters(String s) { if (s == null || s.length() <= 1) { return s; } char[] arr = s.toCharArray(); int[] count = new int[256]; boolean[] visited = new boolean[256]; for (char c : arr) { count[c]++; } StringBuffer sb = new StringBuffer(""0""); for (char c : arr) { count[c]--; if (visited[c]) { continue; } char lastChar = sb.charAt(sb.length() - 1); while (c < lastChar && count[lastChar] > 0) { sb.deleteCharAt(sb.length() - 1); visited[lastChar] = false; lastChar = sb.charAt(sb.length() - 1); } sb.append((char)(c)); visited[c] = true; } return sb.substring(1).toString(); }","String var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) <= 1 ) { return var_2 ; } char [ ] var_7 = var_2 . toCharArray ( ) ; int [ ] var_9 = new int [ 256 ] ; boolean [ ] var_11 = new boolean [ 256 ] ; for ( char var_12 : var_7 ) { var_9 [ var_12 ] ++ ; } StringBuffer var_15 = new StringBuffer ( ""0"" ) ; for ( char var_12 : var_7 ) { var_9 [ var_12 ] -- ; if ( var_11 [ var_12 ] ) { continue ; } char var_17 = var_15 . charAt ( var_15 . length ( ) - 1 ) ; while ( var_12 < var_17 && var_9 [ var_17 ] > 0 ) { var_15 . deleteCharAt ( var_15 . length ( ) - 1 ) ; var_11 [ var_17 ] = false ; var_17 = var_15 . charAt ( var_15 . length ( ) - 1 ) ; } var_15 . append ( ( char ) ( var_12 ) ) ; var_11 [ var_12 ] = true ; } return var_15 . substring ( 1 ) . toString ( ) ; } " 818,12. Integer to Roman_1.java,"private String repeat(String curr, int num) { StringBuffer sb = new StringBuffer(); while (num-- > 0) { sb.append(curr); } return sb.toString(); }","private String var_0 ( String var_2 , int var_3 ) { StringBuffer var_5 = new StringBuffer ( ) ; while ( var_3 -- > 0 ) { var_5 . append ( var_2 ) ; } return var_5 . toString ( ) ; } " 819,256. Paint House_1.java,"public int minCost(int[][] costs) { int n = costs.length; int[][] dp = new int[2][3]; for (int i = 1; i <= n; i++) { int last = (i - 1) % 2, curr = i % 2; for (int j = 0; j < 3; j++) { dp[curr][j] = Math.min(dp[last][(j + 1) % 3], dp[last][(j + 2) % 3]) + costs[i-1][j]; } } return Math.min(Math.min(dp[n%2][0], dp[n%2][1]), dp[n%2][2]); }","public int sample_funcname ( int [ ] [ ] var_0 ) { int var_2 = var_0 . length ; int [ ] [ ] var_5 = new int [ 2 ] [ 3 ] ; for ( int var_7 = 1 ; var_7 <= var_2 ; var_7 ++ ) { int var_8 = ( var_7 - 1 ) % 2 , var_9 = var_7 % 2 ; for ( int var_11 = 0 ; var_11 < 3 ; var_11 ++ ) { var_5 [ var_9 ] [ var_11 ] = Math . min ( var_5 [ var_8 ] [ ( var_11 + 1 ) % 3 ] , var_5 [ var_8 ] [ ( var_11 + 2 ) % 3 ] ) + var_0 [ var_7 - 1 ] [ var_11 ] ; } } return Math . min ( Math . min ( var_5 [ var_2 % 2 ] [ 0 ] , var_5 [ var_2 % 2 ] [ 1 ] ) , var_5 [ var_2 % 2 ] [ 2 ] ) ; } " 820,717. 1-bit and 2-bit Characters_2.java,"public boolean isOneBitCharacter(int[] bits) { if (bits == null || bits.length == 0) { return false; } int n = bits.length; if (n == 1) { return bits[0] == 0; } if (bits[n - 1] != 0) { return false; } boolean[] dp = new boolean[n]; dp[0] = bits[0] == 0; dp[1] = bits[0] != 0 || bits[1] != 1; for (int i = 2; i < n - 1; i++) { if (bits[i] == 0) { dp[i] = dp[i - 2] || dp[i - 1]; } else if (bits[i] == 1) { dp[i] = dp[i - 2] && bits[i - 1] == 1; } } return dp[n - 2]; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return false ; } int var_5 = var_1 . length ; if ( var_5 == 1 ) { return var_1 [ 0 ] == 0 ; } if ( var_1 [ var_5 - 1 ] != 0 ) { return false ; } boolean [ ] var_8 = new boolean [ var_5 ] ; var_8 [ 0 ] = var_1 [ 0 ] == 0 ; var_8 [ 1 ] = var_1 [ 0 ] != 0 || var_1 [ 1 ] != 1 ; for ( int var_10 = 2 ; var_10 < var_5 - 1 ; var_10 ++ ) { if ( var_1 [ var_10 ] == 0 ) { var_8 [ var_10 ] = var_8 [ var_10 - 2 ] || var_8 [ var_10 - 1 ] ; } else if ( var_1 [ var_10 ] == 1 ) { var_8 [ var_10 ] = var_8 [ var_10 - 2 ] && var_1 [ var_10 - 1 ] == 1 ; } } return var_8 [ var_5 - 2 ] ; } " 821,Interleaving Positive and Negative Numbers_2.java,"public void rerange(int[] A) { if (A == null || A.length <= 1) { return; } List positive = new ArrayList<>(); List negative = new ArrayList<>(); for (int num : A) { if (num >= 0) { positive.add(num); } else { negative.add(num); } } int extraPositive = positive.size() > negative.size() ? 0 : 1; for (int i = 0; i < A.length; i++) { if (i % 2 == extraPositive) { A[i] = positive.get(0); positive.remove(0); } else { A[i] = negative.get(0); negative.remove(0); } System.out.println(A[i]); } }","public void var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length <= 1 ) { return ; } List < Integer > var_8 = new ArrayList < > ( ) ; List < Integer > var_9 = new ArrayList < > ( ) ; for ( int var_10 : var_1 ) { if ( var_10 >= 0 ) { var_8 . add ( var_10 ) ; } else { var_9 . add ( var_10 ) ; } } int var_14 = var_8 . size ( ) > var_9 . size ( ) ? 0 : 1 ; for ( int var_15 = 0 ; var_15 < var_1 . length ; var_15 ++ ) { if ( var_15 % 2 == var_14 ) { var_1 [ var_15 ] = var_8 . get ( 0 ) ; var_8 . remove ( 0 ) ; } else { var_1 [ var_15 ] = var_9 . get ( 0 ) ; var_9 . remove ( 0 ) ; } System . out . println ( var_1 [ var_15 ] ) ; } } " 822,Minimum Size Subarray Sum_2.java,"public int minSubArrayLen(int s, int[] nums) { if (nums == null || nums.length == 0) { return 0; } int result = Integer.MAX_VALUE; for (int i = 0; i < nums.length - 1; i++) { int sum = nums[i]; if (sum >= s) { result = 1; break; } for (int j = i + 1; j < nums.length; j++) { if (j - i >= result) { break; } sum += nums[j]; if (sum >= s) { result = Math.min(result, j - i + 1); break; } } } return result == Integer.MAX_VALUE ? 0 : result; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return 0 ; } int var_7 = Integer . MAX_VALUE ; for ( int var_8 = 0 ; var_8 < var_1 . length - 1 ; var_8 ++ ) { int var_10 = var_1 [ var_8 ] ; if ( var_10 >= var_0 ) { var_7 = 1 ; break ; } for ( int var_11 = var_8 + 1 ; var_11 < var_1 . length ; var_11 ++ ) { if ( var_11 - var_8 >= var_7 ) { break ; } var_10 += var_1 [ var_11 ] ; if ( var_10 >= var_0 ) { var_7 = Math . min ( var_7 , var_11 - var_8 + 1 ) ; break ; } } } return var_7 == Integer . MAX_VALUE ? 0 : var_7 ; } " 823,387. First Unique Character in a String_2.java,"public int firstUniqChar(String s) { if (s == null || s.length() == 0) return -1; for (int i = 0; i < s.length(); i++) { if (s.indexOf(s.charAt(i)) == s.lastIndexOf(s.charAt(i))) { return i; } } return -1; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) return - 1 ; for ( int var_6 = 0 ; var_6 < var_1 . length ( ) ; var_6 ++ ) { if ( var_1 . indexOf ( var_1 . charAt ( var_6 ) ) == var_1 . lastIndexOf ( var_1 . charAt ( var_6 ) ) ) { return var_6 ; } } return - 1 ; } " 824,4Sum_1.java,"private String buildKey(List list) { StringBuffer sb = new StringBuffer(); for (int num : list) sb.append(num + ""@""); return sb.toString(); }","private String var_0 ( List < Integer > var_3 ) { StringBuffer var_5 = new StringBuffer ( ) ; for ( int var_6 : var_3 ) var_5 . append ( var_6 + ""@"" ) ; return var_5 . toString ( ) ; } " 825,68. Text Justification_1.java,"private int getRowLength(List list, int width) { return width + (list.size() - 1); }","private int sample_funcname ( List < String > var_2 , int var_3 ) { return var_3 + ( var_2 . size ( ) - 1 ) ; } " 826,Ones and Zeroes_1.java,"public int findMaxForm(String[] strs, int m, int n) { if (strs == null || strs.length == 0 || (m == 0 && n == 0)) { return 0; } int len = strs.length; int[][][] dp = new int[m + 1][n + 1][len + 1]; int[] ones = new int[len]; int[] zeros = new int[len]; for (int k = 0; k < len; k++) { char[] ss = strs[k].toCharArray(); for (char c : ss) { ones[k] += c == '1' ? 1 : 0; zeros[k] += c == '0' ? 1 : 0; } } for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { for (int k = 0; k <= len; k++) { if (k == 0 || (i == 0 && j == 0)) { dp[i][j][k] = 0; continue; } dp[i][j][k] = dp[i][j][k - 1]; int countZero = zeros[k - 1]; int countOne = ones[k - 1]; if (i >= countZero && j >= countOne) { dp[i][j][k] = Math.max(dp[i][j][k], dp[i - countZero][j - countOne][k - 1] + 1); } } } } return dp[m][n][len]; }","public int sample_funcname ( String [ ] var_1 , int var_2 , int var_3 ) { if ( var_1 == null || var_1 . length == 0 || ( var_2 == 0 && var_3 == 0 ) ) { return 0 ; } int var_7 = var_1 . length ; int [ ] [ ] [ ] var_9 = new int [ var_2 + 1 ] [ var_3 + 1 ] [ var_7 + 1 ] ; int [ ] var_10 = new int [ var_7 ] ; int [ ] var_11 = new int [ var_7 ] ; for ( int var_12 = 0 ; var_12 < var_7 ; var_12 ++ ) { char [ ] var_14 = var_1 [ var_12 ] . toCharArray ( ) ; for ( char var_15 : var_14 ) { var_10 [ var_12 ] += var_15 == '1' ? 1 : 0 ; var_11 [ var_12 ] += var_15 == '0' ? 1 : 0 ; } } for ( int var_18 = 0 ; var_18 <= var_2 ; var_18 ++ ) { for ( int var_19 = 0 ; var_19 <= var_3 ; var_19 ++ ) { for ( int var_12 = 0 ; var_12 <= var_7 ; var_12 ++ ) { if ( var_12 == 0 || ( var_18 == 0 && var_19 == 0 ) ) { var_9 [ var_18 ] [ var_19 ] [ var_12 ] = 0 ; continue ; } var_9 [ var_18 ] [ var_19 ] [ var_12 ] = var_9 [ var_18 ] [ var_19 ] [ var_12 - 1 ] ; int var_20 = var_11 [ var_12 - 1 ] ; int var_21 = var_10 [ var_12 - 1 ] ; if ( var_18 >= var_20 && var_19 >= var_21 ) { var_9 [ var_18 ] [ var_19 ] [ var_12 ] = Math . max ( var_9 [ var_18 ] [ var_19 ] [ var_12 ] , var_9 [ var_18 - var_20 ] [ var_19 - var_21 ] [ var_12 - 1 ] + 1 ) ; } } } } return var_9 [ var_2 ] [ var_3 ] [ var_7 ] ; } " 827,720. Longest Word in Dictionary_1.java,"public String longestWord(String[] words) { if (words == null || words.length == 0) { return null; } String result = """"; Arrays.sort(words); Set set = new HashSet<>(); set.add(result); for (String word : words) { if (set.contains(word.substring(0, word.length() - 1))) { if (word.length() > result.length()) { result = word; } set.add(word); } } return result; }","public String var_0 ( String [ ] var_2 ) { if ( var_2 == null || var_2 . length == 0 ) { return null ; } String var_7 = """" ; Arrays . sort ( var_2 ) ; Set < String > var_12 = new HashSet < > ( ) ; var_12 . add ( var_7 ) ; for ( String var_14 : var_2 ) { if ( var_12 . contains ( var_14 . substring ( 0 , var_14 . length ( ) - 1 ) ) ) { if ( var_14 . length ( ) > var_7 . length ( ) ) { var_7 = var_14 ; } var_12 . add ( var_14 ) ; } } return var_7 ; } " 828,69. Sqrt(x)_3.java,"public double mySqrt(double x) { double start = 0; double end = x; double eps = 1e-12; while (end - start > eps) { double mid = start + (end - start) / 2; if (mid * mid < x) { start = mid; } else { end = mid; } } if (end * end <= x) { return end; } else { return start; } }","public double sample_funcname ( double var_0 ) { double var_2 = 0 ; double var_3 = var_0 ; double var_5 = 1e-12 ; while ( var_3 - var_2 > var_5 ) { double var_7 = var_2 + ( var_3 - var_2 ) / 2 ; if ( var_7 * var_7 < var_0 ) { var_2 = var_7 ; } else { var_3 = var_7 ; } } if ( var_3 * var_3 <= var_0 ) { return var_3 ; } else { return var_2 ; } } " 829,72. Edit Distance_4.java,"public int minDistance(String word1, String word2) { if (word1 == null && word2 == null) { return 0; } char[] words1 = word1 == null ? new char[0] : word1.toCharArray(); char[] words2 = word2 == null ? new char[0] : word2.toCharArray(); int m = word1.length(); int n = word2.length(); int[][] dp = new int[m + 1][n + 1]; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0) { dp[i][j] = j; continue; } if (j == 0) { dp[i][j] = i; continue; } dp[i][j] = Math.min(dp[i - 1][j - 1], Math.min(dp[i][j - 1], dp[i - 1][j])) + 1; if (words1[i - 1] == words2[j - 1]) { dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1]); } } } return dp[m][n]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null && var_2 == null ) { return 0 ; } char [ ] var_6 = var_1 == null ? new char [ 0 ] : var_1 . toCharArray ( ) ; char [ ] var_7 = var_2 == null ? new char [ 0 ] : var_2 . toCharArray ( ) ; int var_9 = var_1 . length ( ) ; int var_10 = var_2 . length ( ) ; int [ ] [ ] var_12 = new int [ var_9 + 1 ] [ var_10 + 1 ] ; for ( int var_13 = 0 ; var_13 <= var_9 ; var_13 ++ ) { for ( int var_14 = 0 ; var_14 <= var_10 ; var_14 ++ ) { if ( var_13 == 0 ) { var_12 [ var_13 ] [ var_14 ] = var_14 ; continue ; } if ( var_14 == 0 ) { var_12 [ var_13 ] [ var_14 ] = var_13 ; continue ; } var_12 [ var_13 ] [ var_14 ] = Math . min ( var_12 [ var_13 - 1 ] [ var_14 - 1 ] , Math . min ( var_12 [ var_13 ] [ var_14 - 1 ] , var_12 [ var_13 - 1 ] [ var_14 ] ) ) + 1 ; if ( var_6 [ var_13 - 1 ] == var_7 [ var_14 - 1 ] ) { var_12 [ var_13 ] [ var_14 ] = Math . min ( var_12 [ var_13 ] [ var_14 ] , var_12 [ var_13 - 1 ] [ var_14 - 1 ] ) ; } } } return var_12 [ var_9 ] [ var_10 ] ; } " 830,Sort Letters by Case_3.java,"private void swap(char[] chars, int x, int y) { char temp = chars[x]; chars[x] = chars[y]; chars[y] = temp; }","private void var_0 ( char [ ] var_1 , int var_2 , int var_3 ) { char var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 831,218. The Skyline Problem_3.java,"int parent(int id) { if (id == 0) { return -1; } return (id - 1) / 2; }","int sample_funcname ( int var_0 ) { if ( var_0 == 0 ) { return - 1 ; } return ( var_0 - 1 ) / 2 ; } " 832,88. Search in Rotated Sorted Array II_1.java,"public boolean search(int[] nums, int target) { if (nums == null || nums.length == 0) return false; int start = 0, end = nums.length - 1; while (start + 1 < end) { int mid = start + (end - start) / 2; if (nums[mid] == target) return true; if (nums[start] < nums[mid]) { if (nums[start] <= target && target <= nums[mid]) end = mid; else start = mid; } else if (nums[start] > nums[mid]) { if (nums[mid] <= target && target <= nums[end]) start = mid; else end = mid; } else start++; } return nums[start] == target || nums[end] == target; }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { if ( var_1 == null || var_1 . length == 0 ) return false ; int var_6 = 0 , var_8 = var_1 . length - 1 ; while ( var_6 + 1 < var_8 ) { int var_10 = var_6 + ( var_8 - var_6 ) / 2 ; if ( var_1 [ var_10 ] == var_2 ) return true ; if ( var_1 [ var_6 ] < var_1 [ var_10 ] ) { if ( var_1 [ var_6 ] <= var_2 && var_2 <= var_1 [ var_10 ] ) var_8 = var_10 ; else var_6 = var_10 ; } else if ( var_1 [ var_6 ] > var_1 [ var_10 ] ) { if ( var_1 [ var_10 ] <= var_2 && var_2 <= var_1 [ var_8 ] ) var_6 = var_10 ; else var_8 = var_10 ; } else var_6 ++ ; } return var_1 [ var_6 ] == var_2 || var_1 [ var_8 ] == var_2 ; } " 833,299. Bulls and Cows_1.java,"public String getHint(String secret, String guess) { if (secret == null || guess == null || secret.length() == 0 || guess.length() == 0) { return ""0A0B""; } int[] nums = new int[10]; int bulls = 0, cows = 0; for (int i = 0; i < secret.length(); i++) { int s = Character.getNumericValue(secret.charAt(i)); int g = Character.getNumericValue(guess.charAt(i)); if (s == g) { bulls++; } else { if (nums[s] < 0) cows++; if (nums[g] > 0) cows++; nums[s]++; nums[g]--; } } return String.format(""%sA%sB"", bulls, cows); }","public String var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) == 0 || var_3 . length ( ) == 0 ) { return ""0A0B"" ; } int [ ] var_9 = new int [ 10 ] ; int var_10 = 0 , var_11 = 0 ; for ( int var_12 = 0 ; var_12 < var_2 . length ( ) ; var_12 ++ ) { int var_16 = Character . getNumericValue ( var_2 . charAt ( var_12 ) ) ; int var_17 = Character . getNumericValue ( var_3 . charAt ( var_12 ) ) ; if ( var_16 == var_17 ) { var_10 ++ ; } else { if ( var_9 [ var_16 ] < 0 ) var_11 ++ ; if ( var_9 [ var_17 ] > 0 ) var_11 ++ ; var_9 [ var_16 ] ++ ; var_9 [ var_17 ] -- ; } } return String . format ( ""%sA%sB"" , var_10 , var_11 ) ; } " 834,261. Graph Valid Tree_2.java,"private boolean dfs(Map> graph, Set visited, int curr, int pre) { if (visited.contains(curr)) return false; visited.add(curr); for (int child : graph.get(curr)) { if (child == pre) continue; if (!dfs(graph, visited, child, curr)) return false; } return true; }","private boolean sample_funcname ( Map < Integer , Set < Integer >> graph , Set < Integer > visited , int curr , int pre ) { if ( visited . contains ( curr ) ) return false ; visited . add ( curr ) ; for ( int child : graph . get ( curr ) ) { if ( child == pre ) continue ; if ( ! dfs ( graph , visited , child , curr ) ) return false ; } return true ; } " 835,741. Cherry Pickup_3.java,"private void flipRow(int[] nums) { int i = 0, j = nums.length - 1; while (i != j) { int temp = nums[j]; nums[j--] = nums[i]; nums[i++] = temp; } }","private void var_0 ( int [ ] var_1 ) { int var_3 = 0 , var_6 = var_1 . length - 1 ; while ( var_3 != var_6 ) { int var_7 = var_1 [ var_6 ] ; var_1 [ var_6 -- ] = var_1 [ var_3 ] ; var_1 [ var_3 ++ ] = var_7 ; } } " 836,253. Meeting Rooms II_1.java,"private int[] extract(int[][] intervals, int index) { int[] array = new int[intervals.length]; for (int i = 0; i < intervals.length; i++) { array[i] = intervals[i][index]; } Arrays.sort(array); return array; }","private int [ ] sample_funcname ( int [ ] [ ] var_0 , int var_1 ) { int [ ] var_3 = new int [ var_0 . length ] ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { var_3 [ var_5 ] = var_0 [ var_5 ] [ var_1 ] ; } Arrays . sort ( var_3 ) ; return var_3 ; } " 837,Number of Digit One_1.java,"public int countDigitOne(int n) { int count = 0; for (long i = 1; i <= n; i *= 10) { count += (n / i + 8) / 10 * i; if (n / i % 10 == 1) { count += n % i + 1; } } return count; }","public int sample_funcname ( int var_0 ) { int var_2 = 0 ; for ( long var_4 = 1 ; var_4 <= var_0 ; var_4 *= 10 ) { var_2 += ( var_0 / var_4 + 8 ) / 10 * var_4 ; if ( var_0 / var_4 % 10 == 1 ) { var_2 += var_0 % var_4 + 1 ; } } return var_2 ; } " 838,Rehashing_1.java,"public int hashcode(int key, int capacity) { if (key < 0) { return (key % capacity + capacity) % capacity; } else { return key % capacity; } }","public int sample_funcname ( int var_0 , int var_1 ) { if ( var_0 < 0 ) { return ( var_0 % var_1 + var_1 ) % var_1 ; } else { return var_0 % var_1 ; } } " 839,[lint]. HashHeap_2.java,"int lson(int id) { return id * 2 + 1; }","int sample_funcname ( int var_0 ) { return var_0 * 2 + 1 ; } " 840,122. Best Time to Buy and Sell Stock II_5.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length <= 1) { return 0; } int[] buyOn = new int[prices.length]; int[] sellOn = new int[prices.length]; int length = prices.length; buyOn[length - 1] = 0; sellOn[length - 1] = prices[length - 1]; for (int i = length - 2; i >= 0; i--) { buyOn[i] = Math.max(buyOn[i + 1], sellOn[i + 1] - prices[i]); sellOn[i] = Math.max(sellOn[i + 1], buyOn[i + 1] + prices[i]); } return Math.max(0, buyOn[0]); }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length <= 1 ) { return 0 ; } int [ ] var_5 = new int [ var_0 . length ] ; int [ ] var_6 = new int [ var_0 . length ] ; int length = var_0 . length ; var_5 [ length - 1 ] = 0 ; var_6 [ length - 1 ] = var_0 [ length - 1 ] ; for ( int var_8 = length - 2 ; var_8 >= 0 ; var_8 -- ) { var_5 [ var_8 ] = Math . max ( var_5 [ var_8 + 1 ] , var_6 [ var_8 + 1 ] - var_0 [ var_8 ] ) ; var_6 [ var_8 ] = Math . max ( var_6 [ var_8 + 1 ] , var_5 [ var_8 + 1 ] + var_0 [ var_8 ] ) ; } return Math . max ( 0 , var_5 [ 0 ] ) ; } " 841,Flip Game II_2.java,"public static boolean canWin(String s) { if (s == null || s.length() <= 1) { return false; } StringBuilder sb = new StringBuilder(s); while (sb.indexOf(""++"") != -1) { int index = sb.indexOf(""++""); if(!canWin(s.substring(0, index) + ""--"" + s.substring(index + 2))) { return true; } sb.replace(index, index + 1, ""-""); } return false; }","public static boolean sample_funcname ( String s ) { if ( s == null || s . length ( ) <= 1 ) { return false ; } StringBuilder sb = new StringBuilder ( s ) ; while ( sb . indexOf ( ""++"" ) != - 1 ) { int index = sb . indexOf ( ""++"" ) ; if ( ! canWin ( s . substring ( 0 , index ) + ""--"" + s . substring ( index + 2 ) ) ) { return true ; } sb . replace ( index , index + 1 , ""-"" ) ; } return false ; } " 842,416. Partition Equal Subset Sum_3.java,"public boolean dfs(int[] nums, int index, int target) { if (index == nums.length) return false; if (target == nums[index]) return true; if (target < nums[index]) return false; return dfs(nums, index + 1, target - nums[index]) || dfs(nums, index + 1, target); }","public boolean sample_funcname ( int [ ] nums , int index , int target ) { if ( index == nums . length ) return false ; if ( target == nums [ index ] ) return true ; if ( target < nums [ index ] ) return false ; return dfs ( nums , index + 1 , target - nums [ index ] ) || dfs ( nums , index + 1 , target ) ; } " 843,Triangle Count_2.java,"public int triangleCount(int S[]) { if (S == null || S.length == 0) { return 0; } Arrays.sort(S); int count = 0; for (int i = 0; i < S.length; i++) { int left = 0; int right = i - 1; while (left < right){ if (S[left] + S[right] > S[i]) { count += (right - left); right--; } else { left++; } } } return count; }","public int sample_funcname ( int var_0 [ ] ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } Arrays . sort ( var_0 ) ; int var_6 = 0 ; for ( int var_7 = 0 ; var_7 < var_0 . length ; var_7 ++ ) { int var_8 = 0 ; int var_10 = var_7 - 1 ; while ( var_8 < var_10 ) { if ( var_0 [ var_8 ] + var_0 [ var_10 ] > var_0 [ var_7 ] ) { var_6 += ( var_10 - var_8 ) ; var_10 -- ; } else { var_8 ++ ; } } } return var_6 ; } " 844,41. First Missing Positive_1.java,"public int firstMissingPositive(int[] nums) { if (nums == null || nums.length == 0) { return 1; } if (nums.length == 1) { return nums[0] == 1 ? 2 : 1; } int n = nums.length; int i = 0; while (i < n) { int val = nums[i]; if (val != i && val >= 0 && val < n && val != nums[val]) { int temp = nums[val]; nums[val] = nums[i]; nums[i] = temp; } else { i++; } } for (i = 1; i < n; i++) { if (nums[i] != i) { return i; } } if (nums[0] == n) { return n + 1; } return n; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 1 ; } if ( var_0 . length == 1 ) { return var_0 [ 0 ] == 1 ? 2 : 1 ; } int var_6 = var_0 . length ; int var_7 = 0 ; while ( var_7 < var_6 ) { int var_8 = var_0 [ var_7 ] ; if ( var_8 != var_7 && var_8 >= 0 && var_8 < var_6 && var_8 != var_0 [ var_8 ] ) { int var_9 = var_0 [ var_8 ] ; var_0 [ var_8 ] = var_0 [ var_7 ] ; var_0 [ var_7 ] = var_9 ; } else { var_7 ++ ; } } for ( var_7 = 1 ; var_7 < var_6 ; var_7 ++ ) { if ( var_0 [ var_7 ] != var_7 ) { return var_7 ; } } if ( var_0 [ 0 ] == var_6 ) { return var_6 + 1 ; } return var_6 ; } " 845,Number of Longest Increasing Subsequence_2.java,"public int findNumberOfLIS(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length, maxLen = 0, maxFreq = 0; int[] len = new int[n + 1]; int[] count = new int[n + 1]; for (int i = 1; i <= n; i++) { len[i] = 1; count[i] = 1; for (int j = 1; j < i; j++) { if (nums[j - 1] < nums[i - 1]) { if (len[i] == len[j] + 1) { count[i] += count[j]; } else if (len[i] < len[j] + 1) { len[i] = len[j] + 1; count[i] = count[j]; } } } if (maxLen == len[i]) { maxFreq += count[i]; } else if (maxLen < len[i]) { maxLen = len[i]; maxFreq = count[i]; } } return maxFreq; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length , var_5 = 0 , var_6 = 0 ; int [ ] var_8 = new int [ var_4 + 1 ] ; int [ ] var_9 = new int [ var_4 + 1 ] ; for ( int var_10 = 1 ; var_10 <= var_4 ; var_10 ++ ) { var_8 [ var_10 ] = 1 ; var_9 [ var_10 ] = 1 ; for ( int var_11 = 1 ; var_11 < var_10 ; var_11 ++ ) { if ( var_0 [ var_11 - 1 ] < var_0 [ var_10 - 1 ] ) { if ( var_8 [ var_10 ] == var_8 [ var_11 ] + 1 ) { var_9 [ var_10 ] += var_9 [ var_11 ] ; } else if ( var_8 [ var_10 ] < var_8 [ var_11 ] + 1 ) { var_8 [ var_10 ] = var_8 [ var_11 ] + 1 ; var_9 [ var_10 ] = var_9 [ var_11 ] ; } } } if ( var_5 == var_8 [ var_10 ] ) { var_6 += var_9 [ var_10 ] ; } else if ( var_5 < var_8 [ var_10 ] ) { var_5 = var_8 [ var_10 ] ; var_6 = var_9 [ var_10 ] ; } } return var_6 ; } " 846,Subsets II_3.java,"public void dfs(List> rst, ArrayList list, int index, int[] nums) { rst.add(new ArrayList(list)); for (int i = index; i < nums.length; i++) { if (i != index && nums[i] == nums[i - 1]) { continue; } list.add(nums[i]); dfs(rst, list, i + 1, nums); list.remove(list.size() - 1); } }","public void sample_funcname ( List < List < Integer >> rst , ArrayList < Integer > list , int index , int [ ] nums ) { rst . add ( new ArrayList < Integer > ( list ) ) ; for ( int i = index ; i < nums . length ; i ++ ) { if ( i != index && nums [ i ] == nums [ i - 1 ] ) { continue ; } list . add ( nums [ i ] ) ; dfs ( rst , list , i + 1 , nums ) ; list . remove ( list . size ( ) - 1 ) ; } } " 847,42. Trapping Rain Water_1.java,"public int trap(int[] height) { if (height == null || height.length == 0) return 0; int n = height.length; int[] maxLeft = new int[n], maxRight = new int[n]; maxLeft[0] = height[0]; maxRight[n - 1] = height[n - 1]; for (int i = 1; i < n; i++) maxLeft[i] = Math.max(maxLeft[i - 1], height[i]); for (int i = n - 2; i >= 0; i--) maxRight[i] = Math.max(maxRight[i + 1], height[i]); int total = 0; for (int i = 0; i < n; i++) { int waterDepth = Math.min(maxLeft[i], maxRight[i]); total += height[i] < waterDepth ? waterDepth - height[i] : 0; } return total; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length ; int [ ] var_5 = new int [ var_4 ] , var_6 = new int [ var_4 ] ; var_5 [ 0 ] = var_0 [ 0 ] ; var_6 [ var_4 - 1 ] = var_0 [ var_4 - 1 ] ; for ( int var_8 = 1 ; var_8 < var_4 ; var_8 ++ ) var_5 [ var_8 ] = Math . max ( var_5 [ var_8 - 1 ] , var_0 [ var_8 ] ) ; for ( int var_8 = var_4 - 2 ; var_8 >= 0 ; var_8 -- ) var_6 [ var_8 ] = Math . max ( var_6 [ var_8 + 1 ] , var_0 [ var_8 ] ) ; int var_12 = 0 ; for ( int var_8 = 0 ; var_8 < var_4 ; var_8 ++ ) { int var_14 = Math . min ( var_5 [ var_8 ] , var_6 [ var_8 ] ) ; var_12 += var_0 [ var_8 ] < var_14 ? var_14 - var_0 [ var_8 ] : 0 ; } return var_12 ; } " 848,Kth Smallest Element in a Sorted Matrix_1.java,"private int countSmallerItem(int[][] matrix, int target) { int n = matrix.length; int count = 0; int i = 0, j = n - 1; while (i < n && j >= 0) { if (matrix[i][j] > target) { j--; } else { count += j + 1; i++; } } return count; }","private int sample_funcname ( int [ ] [ ] var_0 , int var_1 ) { int var_3 = var_0 . length ; int var_5 = 0 ; int var_6 = 0 , var_8 = var_3 - 1 ; while ( var_6 < var_3 && var_8 >= 0 ) { if ( var_0 [ var_6 ] [ var_8 ] > var_1 ) { var_8 -- ; } else { var_5 += var_8 + 1 ; var_6 ++ ; } } return var_5 ; } " 849,219. Contains Duplicate II_2.java,"public boolean containsNearbyDuplicate(int[] nums, int k) { if (nums == null || nums.length == 0 || k <= 0) { return false; } Map> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { if (map.containsKey(nums[i])) { for (int index : map.get(nums[i])) { if (Math.abs(index - i) <= k) { return true; } } } else { map.put(nums[i], new ArrayList<>()); } map.get(nums[i]).add(i); } return false; }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { if ( var_1 == null || var_1 . length == 0 || var_2 <= 0 ) { return false ; } Map < Integer , List < Integer >> var_10 = new HashMap < > ( ) ; for ( int var_11 = 0 ; var_11 < var_1 . length ; var_11 ++ ) { if ( var_10 . containsKey ( var_1 [ var_11 ] ) ) { for ( int var_14 : var_10 . get ( var_1 [ var_11 ] ) ) { if ( Math . abs ( var_14 - var_11 ) <= var_2 ) { return true ; } } } else { var_10 . put ( var_1 [ var_11 ] , new ArrayList < > ( ) ) ; } var_10 . get ( var_1 [ var_11 ] ) . add ( var_11 ) ; } return false ; } " 850,70. Climbing Stairs_2.java,"public int climbStairs(int n) { if (n <= 1) { return 1; } int[] dp = new int[2]; dp[0] = 1; dp[1] = 1; for (int i = 2; i <= n; i++) { dp[i % 2] = dp[(i - 1) % 2] + dp[(i - 2) % 2]; } return dp[n % 2]; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 1 ) { return 1 ; } int [ ] var_3 = new int [ 2 ] ; var_3 [ 0 ] = 1 ; var_3 [ 1 ] = 1 ; for ( int var_5 = 2 ; var_5 <= var_0 ; var_5 ++ ) { var_3 [ var_5 % 2 ] = var_3 [ ( var_5 - 1 ) % 2 ] + var_3 [ ( var_5 - 2 ) % 2 ] ; } return var_3 [ var_0 % 2 ] ; } " 851,Subsets II_2.java,"public List> subsetsWithDup(int[] nums) { List> result = new ArrayList<>(); if (nums == null || nums.length == 0) { return result; } Arrays.sort(nums); Queue> queue = new LinkedList<>(); List initialList = new ArrayList<>(); queue.offer(initialList); while (!queue.isEmpty()) { int size = queue.size(); while (size > 0) { List indexRow = queue.poll(); List list = new ArrayList<>(); for (int index : indexRow) { list.add(nums[index]); } result.add(list); int endIndex = indexRow.size() == 0 ? 0 : indexRow.get(indexRow.size() - 1) + 1; for (int i = endIndex; i < nums.length; i++) { if (i > endIndex && nums[i] == nums[i - 1]) { continue; } indexRow.add(i); queue.offer(new ArrayList<>(indexRow)); indexRow.remove(indexRow.size() - 1); } size--; } } return result; }","public List < List < Integer >> var_2 ( int [ ] var_3 ) { List < List < Integer >> var_5 = new ArrayList < > ( ) ; if ( var_3 == null || var_3 . length == 0 ) { return var_5 ; } Arrays . sort ( var_3 ) ; Queue < List < Integer >> var_13 = new LinkedList < > ( ) ; List < Integer > var_14 = new ArrayList < > ( ) ; var_13 . offer ( var_14 ) ; while ( ! var_13 . isEmpty ( ) ) { int size = var_13 . size ( ) ; while ( size > 0 ) { List < Integer > var_19 = var_13 . poll ( ) ; List < Integer > var_20 = new ArrayList < > ( ) ; for ( int var_21 : var_19 ) { var_20 . add ( var_3 [ var_21 ] ) ; } var_5 . add ( var_20 ) ; int var_25 = var_19 . size ( ) == 0 ? 0 : var_19 . get ( var_19 . size ( ) - 1 ) + 1 ; for ( int var_26 = var_25 ; var_26 < var_3 . length ; var_26 ++ ) { if ( var_26 > var_25 && var_3 [ var_26 ] == var_3 [ var_26 - 1 ] ) { continue ; } var_19 . add ( var_26 ) ; var_13 . offer ( new ArrayList < > ( var_19 ) ) ; var_19 . remove ( var_19 . size ( ) - 1 ) ; } size -- ; } } return var_5 ; } " 852,[lint]. Compare Strings_2.java,"public boolean compareStrings(String A, String B) { if (A == null || B == null || A.length() < B.length()) { return false; } int[] countA = new int[26]; int[] countB = new int[26]; for (int i = 0; i < A.length(); i++) { countA[A.charAt(i) - 'A']++; } for (int i = 0; i < B.length(); i++) { countB[B.charAt(i) - 'A']++; if (countB[B.charAt(i) - 'A'] > countA[B.charAt(i) - 'A']) { return false; } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) < var_3 . length ( ) ) { return false ; } int [ ] var_7 = new int [ 26 ] ; int [ ] var_8 = new int [ 26 ] ; for ( int var_10 = 0 ; var_10 < var_2 . length ( ) ; var_10 ++ ) { var_7 [ var_2 . charAt ( var_10 ) - 'A' ] ++ ; } for ( int var_10 = 0 ; var_10 < var_3 . length ( ) ; var_10 ++ ) { var_8 [ var_3 . charAt ( var_10 ) - 'A' ] ++ ; if ( var_8 [ var_3 . charAt ( var_10 ) - 'A' ] > var_7 [ var_3 . charAt ( var_10 ) - 'A' ] ) { return false ; } } return true ; } " 853,416. Partition Equal Subset Sum_2.java,"public boolean dfs(int[] nums, int index, int target) { if (target < 0) return false; if (target == 0) return true; for (int i = index; i < nums.length; i++) { if (dfs(nums, i + 1, target - nums[i])) return true; } return false; }","public boolean sample_funcname ( int [ ] nums , int index , int target ) { if ( target < 0 ) return false ; if ( target == 0 ) return true ; for ( int i = index ; i < nums . length ; i ++ ) { if ( dfs ( nums , i + 1 , target - nums [ i ] ) ) return true ; } return false ; } " 854,26.Remove Duplicates from Sorted Array_1.java,"public int removeDuplicates(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int index = 0; for (int i = 1; i < nums.length; i++) { if (nums[i] != nums[index]) { nums[++index] = nums[i]; } } return index + 1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = 0 ; for ( int var_6 = 1 ; var_6 < var_0 . length ; var_6 ++ ) { if ( var_0 [ var_6 ] != var_0 [ var_4 ] ) { var_0 [ ++ var_4 ] = var_0 [ var_6 ] ; } } return var_4 + 1 ; } " 855,Flip Game II_3.java,"public boolean canWin(String s) { if (s == null || s.length() <= 1) { return false; } String str = new String(s); for (int i = str.indexOf(""++""); i >= 0 && i < str.length() - 1; i = str.indexOf(""++"")) { if (!canWin( s.substring(0, i) + ""--"" + s.substring(i + 2))) { return true; } str = str.substring(0, i) + ""-"" + str.substring(i + 1); } return false; }","public boolean sample_funcname ( String s ) { if ( s == null || s . length ( ) <= 1 ) { return false ; } String str = new String ( s ) ; for ( int i = str . indexOf ( ""++"" ) ; i >= 0 && i < str . length ( ) - 1 ; i = str . indexOf ( ""++"" ) ) { if ( ! canWin ( s . substring ( 0 , i ) + ""--"" + s . substring ( i + 2 ) ) ) { return true ; } str = str . substring ( 0 , i ) + ""-"" + str . substring ( i + 1 ) ; } return false ; } " 856,340. Longest Substring with At Most K Distinct Characters_1.java,"public int lengthOfLongestSubstringKDistinct(String s, int k) { if (s == null) return 0; int left = 0, right = 0, max = 0, n = s.length(); Map freq = new HashMap<>(); while (right < n) { char head = s.charAt(right++); freq.put(head, freq.getOrDefault(head, 0) + 1); if (freq.size() <= k) max = Math.max(max, right - left); if (freq.size() > k) { char tail = s.charAt(left++); freq.put(tail, freq.get(tail) - 1); if (freq.get(tail) == 0) freq.remove(tail); } } return max; }","public int sample_funcname ( String var_1 , int var_2 ) { if ( var_1 == null ) return 0 ; int var_5 = 0 , var_6 = 0 , max = 0 , var_9 = var_1 . length ( ) ; Map < Character , Integer > var_14 = new HashMap < > ( ) ; while ( var_6 < var_9 ) { char var_16 = var_1 . charAt ( var_6 ++ ) ; var_14 . put ( var_16 , var_14 . getOrDefault ( var_16 , 0 ) + 1 ) ; if ( var_14 . size ( ) <= var_2 ) max = Math . max ( max , var_6 - var_5 ) ; if ( var_14 . size ( ) > var_2 ) { char var_22 = var_1 . charAt ( var_5 ++ ) ; var_14 . put ( var_22 , var_14 . get ( var_22 ) - 1 ) ; if ( var_14 . get ( var_22 ) == 0 ) var_14 . remove ( var_22 ) ; } } return max ; } " 857,Fast Power_1.java,"public int fastPower(int a, int b, int n) { if (n == 0) { return 1 % b; } if (n == 1) { return a % b; } long recurPow = fastPower(a, b, n / 2); recurPow = (recurPow * recurPow) % b; if (n % 2 == 1) { recurPow = recurPow * a % b; } return (int)recurPow; }","public int sample_funcname ( int a , int b , int n ) { if ( n == 0 ) { return 1 % b ; } if ( n == 1 ) { return a % b ; } long recurPow = fastPower ( a , b , n / 2 ) ; recurPow = ( recurPow * recurPow ) % b ; if ( n % 2 == 1 ) { recurPow = recurPow * a % b ; } return ( int ) recurPow ; } " 858,Target Sum_1.java,"public int findTargetSumWays(int[] nums, int S) { if (nums == null || nums.length == 0) return 0; int sum = 0; for (int num : nums) sum += num; if (sum < Math.abs(S)) return 0; int n = nums.length, m = (sum << 1) + 1; int[][] dp = new int[n][m]; dp[0][sum - nums[0]] += 1; dp[0][sum + nums[0]] += 1; for (int i = 1; i < n; i++) { for (int j = 0; j < m; j++) { if (j - nums[i] >= 0) { dp[i][j] += dp[i - 1][j - nums[i]]; } if (j + nums[i] < m) { dp[i][j] += dp[i - 1][j + nums[i]]; } } } return dp[n - 1][S + sum]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_5 = 0 ; for ( int var_6 : var_0 ) var_5 += var_6 ; if ( var_5 < Math . abs ( var_1 ) ) return 0 ; int var_9 = var_0 . length , var_11 = ( var_5 << 1 ) + 1 ; int [ ] [ ] var_12 = new int [ var_9 ] [ var_11 ] ; var_12 [ 0 ] [ var_5 - var_0 [ 0 ] ] += 1 ; var_12 [ 0 ] [ var_5 + var_0 [ 0 ] ] += 1 ; for ( int var_13 = 1 ; var_13 < var_9 ; var_13 ++ ) { for ( int var_14 = 0 ; var_14 < var_11 ; var_14 ++ ) { if ( var_14 - var_0 [ var_13 ] >= 0 ) { var_12 [ var_13 ] [ var_14 ] += var_12 [ var_13 - 1 ] [ var_14 - var_0 [ var_13 ] ] ; } if ( var_14 + var_0 [ var_13 ] < var_11 ) { var_12 [ var_13 ] [ var_14 ] += var_12 [ var_13 - 1 ] [ var_14 + var_0 [ var_13 ] ] ; } } } return var_12 [ var_9 - 1 ] [ var_1 + var_5 ] ; } " 859,122. Best Time to Buy and Sell Stock II_4.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length == 0) { return 0; } int n = prices.length; int[][] dp = new int[2][2]; dp[0][0] = dp[0][1] = 0; dp[1][0] = - prices[0]; for (int i = 2; i <= n; i++) { dp[i % 2][0] = Math.max(dp[(i - 1) % 2][0], dp[(i - 1) % 2][1] - prices[i - 1]); dp[i % 2][1] = Math.max(dp[(i - 1) % 2][1], dp[(i - 1) % 2][0] + prices[i - 1]); } return dp[n % 2][1]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = var_0 . length ; int [ ] [ ] var_6 = new int [ 2 ] [ 2 ] ; var_6 [ 0 ] [ 0 ] = var_6 [ 0 ] [ 1 ] = 0 ; var_6 [ 1 ] [ 0 ] = - var_0 [ 0 ] ; for ( int var_8 = 2 ; var_8 <= var_4 ; var_8 ++ ) { var_6 [ var_8 % 2 ] [ 0 ] = Math . max ( var_6 [ ( var_8 - 1 ) % 2 ] [ 0 ] , var_6 [ ( var_8 - 1 ) % 2 ] [ 1 ] - var_0 [ var_8 - 1 ] ) ; var_6 [ var_8 % 2 ] [ 1 ] = Math . max ( var_6 [ ( var_8 - 1 ) % 2 ] [ 1 ] , var_6 [ ( var_8 - 1 ) % 2 ] [ 0 ] + var_0 [ var_8 - 1 ] ) ; } return var_6 [ var_4 % 2 ] [ 1 ] ; } " 860,[lint]. HashHeap_3.java,"int rson(int id) { return id * 2 + 2; }","int sample_funcname ( int var_0 ) { return var_0 * 2 + 2 ; } " 861,218. The Skyline Problem_2.java,"private boolean isInvalid(int[][] buildings) { return buildings == null || buildings.length == 0 || buildings[0] == null || buildings[0].length == 0; }","private boolean var_0 ( int [ ] [ ] var_1 ) { return var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 ; } " 862,261. Graph Valid Tree_3.java,"private Map> buildGraph(int n, int[][] edges) { Map> graph = new HashMap<>(); for (int i = 0; i < n; i++) graph.putIfAbsent(i, new HashSet<>()); for (int[] edge: edges) { graph.get(edge[0]).add(edge[1]); graph.get(edge[1]).add(edge[0]); } return graph; }","private Map < Integer , Set < Integer >> var_2 ( int var_3 , int [ ] [ ] var_4 ) { Map < Integer , Set < Integer >> var_7 = new HashMap < > ( ) ; for ( int var_9 = 0 ; var_9 < var_3 ; var_9 ++ ) var_7 . putIfAbsent ( var_9 , new HashSet < > ( ) ) ; for ( int [ ] var_12 : var_4 ) { var_7 . get ( var_12 [ 0 ] ) . add ( var_12 [ 1 ] ) ; var_7 . get ( var_12 [ 1 ] ) . add ( var_12 [ 0 ] ) ; } return var_7 ; } " 863,741. Cherry Pickup_2.java,"private void updateGrid(int[][] grid, List path) { for (int[] pos : path) { grid[pos[0]][pos[1]] = 0; } }","private void var_0 ( int [ ] [ ] var_1 , List < int [ ] > var_3 ) { for ( int [ ] var_4 : var_3 ) { var_1 [ var_4 [ 0 ] ] [ var_4 [ 1 ] ] = 0 ; } } " 864,Update Bits_1.java,"public int updateBits(int n, int m, int i, int j) { int mask = -1; mask = -1 >>> (32 - (j - i + 1)); mask = mask << i; mask = ~mask; n = n & mask; return n | (m << i); }","public int sample_funcname ( int var_0 , int var_1 , int var_2 , int var_3 ) { int var_5 = - 1 ; var_5 = - 1 >>> ( 32 - ( var_3 - var_2 + 1 ) ) ; var_5 = var_5 << var_2 ; var_5 = ~ var_5 ; var_0 = var_0 & var_5 ; return var_0 | ( var_1 << var_2 ) ; } " 865,House Robber II_1.java,"public int rob(int[] nums) { if (nums == null || nums.length == 0) { return 0; } else if (nums.length == 1) { return nums[0]; } int n = nums.length; long[][] dp = new long[n + 1][2]; dp[0][0] = 0; dp[1][0] = 0; dp[1][1] = nums[0]; for (int i = 2; i < n; i++) { dp[i][0] = Math.max(dp[i - 1][0], dp[i - 2][0] + nums[i - 1]); dp[i][1] = Math.max(dp[i - 1][1], dp[i - 2][1] + nums[i - 1]); } dp[n][0] = Math.max(dp[n - 1][0], dp[n - 2][0] + nums[n - 1]); dp[n][1] = dp[n - 1][1]; return (int) Math.max(dp[n][0], dp[n][1]); }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } else if ( var_0 . length == 1 ) { return var_0 [ 0 ] ; } int var_5 = var_0 . length ; long [ ] [ ] var_7 = new long [ var_5 + 1 ] [ 2 ] ; var_7 [ 0 ] [ 0 ] = 0 ; var_7 [ 1 ] [ 0 ] = 0 ; var_7 [ 1 ] [ 1 ] = var_0 [ 0 ] ; for ( int var_8 = 2 ; var_8 < var_5 ; var_8 ++ ) { var_7 [ var_8 ] [ 0 ] = Math . max ( var_7 [ var_8 - 1 ] [ 0 ] , var_7 [ var_8 - 2 ] [ 0 ] + var_0 [ var_8 - 1 ] ) ; var_7 [ var_8 ] [ 1 ] = Math . max ( var_7 [ var_8 - 1 ] [ 1 ] , var_7 [ var_8 - 2 ] [ 1 ] + var_0 [ var_8 - 1 ] ) ; } var_7 [ var_5 ] [ 0 ] = Math . max ( var_7 [ var_5 - 1 ] [ 0 ] , var_7 [ var_5 - 2 ] [ 0 ] + var_0 [ var_5 - 1 ] ) ; var_7 [ var_5 ] [ 1 ] = var_7 [ var_5 - 1 ] [ 1 ] ; return ( int ) Math . max ( var_7 [ var_5 ] [ 0 ] , var_7 [ var_5 ] [ 1 ] ) ; } " 866,69. Sqrt(x)_2.java,"public int mySqrt(int x) { long start = 0; long end = x; while(start <= end) { long mid = (start + end) / 2; if (mid * mid < x) { start = mid + 1; } else if (mid * mid > x){ end = mid - 1; } else { return (int)mid; } } return (int)end; }","public int sample_funcname ( int var_0 ) { long var_2 = 0 ; long var_3 = var_0 ; while ( var_2 <= var_3 ) { long var_5 = ( var_2 + var_3 ) / 2 ; if ( var_5 * var_5 < var_0 ) { var_2 = var_5 + 1 ; } else if ( var_5 * var_5 > var_0 ) { var_3 = var_5 - 1 ; } else { return ( int ) var_5 ; } } return ( int ) var_3 ; } " 867,Predict the Winner_1.java,"public boolean PredictTheWinner(int[] nums) { if (nums == null || nums.length == 0) { return false; } int n = nums.length; int[][] dp = new int[n][n]; for (int i = 0; i < n; i++) { dp[i][i] = nums[i]; } for (int len = 2; len <= n; len++) { for (int i = 0; i <= n - len; i++) { int j = len + i - 1; dp[i][j] = Math.max(nums[i] - dp[i + 1][j], nums[j] - dp[i][j - 1]); } } return dp[0][n - 1] >= 0; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return false ; } int var_5 = var_1 . length ; int [ ] [ ] var_6 = new int [ var_5 ] [ var_5 ] ; for ( int var_7 = 0 ; var_7 < var_5 ; var_7 ++ ) { var_6 [ var_7 ] [ var_7 ] = var_1 [ var_7 ] ; } for ( int var_9 = 2 ; var_9 <= var_5 ; var_9 ++ ) { for ( int var_7 = 0 ; var_7 <= var_5 - var_9 ; var_7 ++ ) { int var_11 = var_9 + var_7 - 1 ; var_6 [ var_7 ] [ var_11 ] = Math . max ( var_1 [ var_7 ] - var_6 [ var_7 + 1 ] [ var_11 ] , var_1 [ var_11 ] - var_6 [ var_7 ] [ var_11 - 1 ] ) ; } } return var_6 [ 0 ] [ var_5 - 1 ] >= 0 ; } " 868,78. Subsets_1.java,"private void dfs(List> result, List list, int[] nums, int depth) { if (depth >= nums.length) { result.add(new ArrayList<>(list)); return; } list.add(nums[depth]); dfs(result, list, nums, depth + 1); list.remove(list.size() - 1); dfs(result, list, nums, depth + 1); }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int [ ] nums , int depth ) { if ( depth >= nums . length ) { result . add ( new ArrayList < > ( list ) ) ; return ; } list . add ( nums [ depth ] ) ; dfs ( result , list , nums , depth + 1 ) ; list . remove ( list . size ( ) - 1 ) ; dfs ( result , list , nums , depth + 1 ) ; } " 869,72. Edit Distance_5.java,"public int minDistance(String word1, String word2) { if (word1 == null && word2 == null) { return 0; } char[] words1 = word1 == null ? new char[0] : word1.toCharArray(); char[] words2 = word2 == null ? new char[0] : word2.toCharArray(); int m = word1.length(); int n = word2.length(); int[][] dp = new int[2][n + 1]; int curr = 0; int prev = 0; for (int i = 0; i <= m; i++) { prev = curr; curr = 1 - prev; for (int j = 0; j <= n; j++) { if (i == 0) { dp[curr][j] = j; continue; } if (j == 0) { dp[curr][j] = i; continue; } dp[curr][j] = Math.min(dp[prev][j - 1], Math.min(dp[curr][j - 1], dp[prev][j])) + 1; if (words1[i - 1] == words2[j - 1]) { dp[curr][j] = Math.min(dp[curr][j], dp[prev][j - 1]); } } } return dp[curr][n]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null && var_2 == null ) { return 0 ; } char [ ] var_6 = var_1 == null ? new char [ 0 ] : var_1 . toCharArray ( ) ; char [ ] var_7 = var_2 == null ? new char [ 0 ] : var_2 . toCharArray ( ) ; int var_9 = var_1 . length ( ) ; int var_10 = var_2 . length ( ) ; int [ ] [ ] var_13 = new int [ 2 ] [ var_10 + 1 ] ; int var_14 = 0 ; int var_15 = 0 ; for ( int var_16 = 0 ; var_16 <= var_9 ; var_16 ++ ) { var_15 = var_14 ; var_14 = 1 - var_15 ; for ( int var_17 = 0 ; var_17 <= var_10 ; var_17 ++ ) { if ( var_16 == 0 ) { var_13 [ var_14 ] [ var_17 ] = var_17 ; continue ; } if ( var_17 == 0 ) { var_13 [ var_14 ] [ var_17 ] = var_16 ; continue ; } var_13 [ var_14 ] [ var_17 ] = Math . min ( var_13 [ var_15 ] [ var_17 - 1 ] , Math . min ( var_13 [ var_14 ] [ var_17 - 1 ] , var_13 [ var_15 ] [ var_17 ] ) ) + 1 ; if ( var_6 [ var_16 - 1 ] == var_7 [ var_17 - 1 ] ) { var_13 [ var_14 ] [ var_17 ] = Math . min ( var_13 [ var_14 ] [ var_17 ] , var_13 [ var_15 ] [ var_17 - 1 ] ) ; } } } return var_13 [ var_14 ] [ var_10 ] ; } " 870,Sort Letters by Case_2.java,"private void swap(char[] chars, int x, int y) { char temp = chars[x]; chars[x] = chars[y]; chars[y] = temp; }","private void var_0 ( char [ ] var_1 , int var_2 , int var_3 ) { char var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 871,387. First Unique Character in a String_3.java,"public int firstUniqChar(String s) { if (s == null || s.length() == 0) return -1; Map map = new HashMap<>(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); map.putIfAbsent(c, 0); map.put(c, map.get(c) + 1); } for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (map.get(c) == 1) return i; } return -1; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) return - 1 ; Map < Character , Integer > var_10 = new HashMap < > ( ) ; for ( int var_11 = 0 ; var_11 < var_1 . length ( ) ; var_11 ++ ) { char var_13 = var_1 . charAt ( var_11 ) ; var_10 . putIfAbsent ( var_13 , 0 ) ; var_10 . put ( var_13 , var_10 . get ( var_13 ) + 1 ) ; } for ( int var_11 = 0 ; var_11 < var_1 . length ( ) ; var_11 ++ ) { char var_13 = var_1 . charAt ( var_11 ) ; if ( var_10 . get ( var_13 ) == 1 ) return var_11 ; } return - 1 ; } " 872,1203. Sort Items by Groups Respecting Dependencies_1.java,"private Map> buildGroup(int n, int m, int[] group) { Map> map = new HashMap<>(); for (int i = 0; i < n; i++) { int groupId = group[i] == -1 ? m++ : group[i]; group[i] = groupId; map.putIfAbsent(groupId, new ArrayList<>()); map.get(groupId).add(i); } return map; }","private Map < Integer , List < Integer >> var_2 ( int var_3 , int var_4 , int [ ] var_5 ) { Map < Integer , List < Integer >> var_8 = new HashMap < > ( ) ; for ( int var_10 = 0 ; var_10 < var_3 ; var_10 ++ ) { int var_12 = var_5 [ var_10 ] == - 1 ? var_4 ++ : var_5 [ var_10 ] ; var_5 [ var_10 ] = var_12 ; var_8 . putIfAbsent ( var_12 , new ArrayList < > ( ) ) ; var_8 . get ( var_12 ) . add ( var_10 ) ; } return var_8 ; } " 873,7. Reverse Integer_1.java,"public int reverse(int x) { int result = 0; while (x != 0) { int tail = x % 10; int newResult = result * 10 + tail; if ((newResult - tail) / 10 != result) return 0; result = newResult; x = x / 10; } return result; }","public int sample_funcname ( int var_0 ) { int var_2 = 0 ; while ( var_0 != 0 ) { int var_4 = var_0 % 10 ; int var_5 = var_2 * 10 + var_4 ; if ( ( var_5 - var_4 ) / 10 != var_2 ) return 0 ; var_2 = var_5 ; var_0 = var_0 / 10 ; } return var_2 ; } " 874,Interleaving Positive and Negative Numbers_3.java,"public void rerange(int[] A) { if (A == null || A.length == 0) { return; } Arrays.sort(A); int count = 0; for (int num : A){ count += num >= 0 ? 1 : -1; } int start = 0; int end = A.length - 1; if (count < 0) { start++; } else if (count > 0){ end--; } while (start < end) { if (A[start] < 0 && A[end] >= 0) { int temp = A[start]; A[start] = A[end]; A[end] = temp; } start += 2; end -= 2; } }","public void var_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return ; } Arrays . sort ( var_1 ) ; int var_7 = 0 ; for ( int var_8 : var_1 ) { var_7 += var_8 >= 0 ? 1 : - 1 ; } int var_10 = 0 ; int var_11 = var_1 . length - 1 ; if ( var_7 < 0 ) { var_10 ++ ; } else if ( var_7 > 0 ) { var_11 -- ; } while ( var_10 < var_11 ) { if ( var_1 [ var_10 ] < 0 && var_1 [ var_11 ] >= 0 ) { int var_12 = var_1 [ var_10 ] ; var_1 [ var_10 ] = var_1 [ var_11 ] ; var_1 [ var_11 ] = var_12 ; } var_10 += 2 ; var_11 -= 2 ; } } " 875,149. Max Points on a Line_1.java,"private int findGCD(int a, int b) { if (b == 0) return a; return findGCD(b, a % b); }","private int sample_funcname ( int a , int b ) { if ( b == 0 ) return a ; return findGCD ( b , a % b ) ; } " 876,Minimum Size Subarray Sum_3.java,"public int minimumSize(int[] nums, int s) { if (nums == null || nums.length == 0) { return -1; } int start = 0; int end = 0; int min = Integer.MAX_VALUE; int sum = 0; for (; start < nums.length; start++) { while(end < nums.length && sum < s) { sum += nums[end]; end++; } if (sum >= s) { min = Math.min(min, (end-1) - start + 1); } sum -= nums[start]; } return min == Integer.MAX_VALUE ? -1 : min; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int var_6 = 0 ; int var_7 = 0 ; int min = Integer . MAX_VALUE ; int var_11 = 0 ; for ( ; var_6 < var_0 . length ; var_6 ++ ) { while ( var_7 < var_0 . length && var_11 < var_1 ) { var_11 += var_0 [ var_7 ] ; var_7 ++ ; } if ( var_11 >= var_1 ) { min = Math . min ( min , ( var_7 - 1 ) - var_6 + 1 ) ; } var_11 -= var_0 [ var_6 ] ; } return min == Integer . MAX_VALUE ? - 1 : min ; } " 877,13. Roman to Integer_1.java,"private int countCombo(final String pattern, String str) { int count = 0; while (str.contains(pattern)) { count++; str = str.substring(str.indexOf(pattern) + pattern.length()); } return count; }","private int sample_funcname ( final String var_1 , String var_2 ) { int var_4 = 0 ; while ( var_2 . contains ( var_1 ) ) { var_4 ++ ; var_2 = var_2 . substring ( var_2 . indexOf ( var_1 ) + var_1 . length ( ) ) ; } return var_4 ; } " 878,1106. Parsing A Boolean Expression_1.java,"private String findExpBlock(String s, int i) { StringBuffer sb = new StringBuffer(); Stack stack = new Stack<>(); while (sb.length() == 0 || !stack.isEmpty()) { char c = s.charAt(i++); sb.append(c); if (c == '(') stack.push(c); if (c == ')') stack.pop(); if (stack.isEmpty()) break; } return sb.toString(); }","private String var_0 ( String var_2 , int var_3 ) { StringBuffer var_5 = new StringBuffer ( ) ; Stack < Character > var_8 = new Stack < > ( ) ; while ( var_5 . length ( ) == 0 || ! var_8 . isEmpty ( ) ) { char var_13 = var_2 . charAt ( var_3 ++ ) ; var_5 . append ( var_13 ) ; if ( var_13 == '(' ) var_8 . push ( var_13 ) ; if ( var_13 == ')' ) var_8 . pop ( ) ; if ( var_8 . isEmpty ( ) ) break ; } return var_5 . toString ( ) ; } " 879,Search a 2D Matrix_2.java,"public boolean searchMatrix(ArrayList> matrix, int target) { if(matrix.size() == 0) { return false; } int rows = matrix.size(); int cols = matrix.get(0).size(); int start = 0; int end = rows * cols - 1; int mid; while (start + 1 < end) { mid = start + (end - start) / 2; int midVal = matrix.get(mid / cols).get(mid % cols); if (midVal == target) { return true; } else if (midVal < target) { start = mid; } else { end = mid; } } int startVal = matrix.get(start / cols).get(start % cols); int endVal = matrix.get(end / cols).get(end % cols); if (startVal == target || endVal == target) { return true; } else { return false; } }","public boolean var_0 ( ArrayList < ArrayList < Integer >> var_3 , int var_4 ) { if ( var_3 . size ( ) == 0 ) { return false ; } int var_7 = var_3 . size ( ) ; int var_9 = var_3 . get ( 0 ) . size ( ) ; int var_10 = 0 ; int var_12 = var_7 * var_9 - 1 ; int var_13 ; while ( var_10 + 1 < var_12 ) { var_13 = var_10 + ( var_12 - var_10 ) / 2 ; int var_15 = var_3 . get ( var_13 / var_9 ) . get ( var_13 % var_9 ) ; if ( var_15 == var_4 ) { return true ; } else if ( var_15 < var_4 ) { var_10 = var_13 ; } else { var_12 = var_13 ; } } int var_16 = var_3 . get ( var_10 / var_9 ) . get ( var_10 % var_9 ) ; int var_17 = var_3 . get ( var_12 / var_9 ) . get ( var_12 % var_9 ) ; if ( var_16 == var_4 || var_17 == var_4 ) { return true ; } else { return false ; } } " 880,242. Valid Anagram_1.java,"private int[] countChars(String s, String t) { int[] count = new int[26]; for (int i = 0; i < s.length(); i++) { count[s.charAt(i) - 'a'] += 1; count[t.charAt(i) - 'a'] -= 1; } return count; }","private int [ ] sample_funcname ( String var_1 , String var_2 ) { int [ ] var_4 = new int [ 26 ] ; for ( int var_6 = 0 ; var_6 < var_1 . length ( ) ; var_6 ++ ) { var_4 [ var_1 . charAt ( var_6 ) - 'a' ] += 1 ; var_4 [ var_2 . charAt ( var_6 ) - 'a' ] -= 1 ; } return var_4 ; } " 881,345. Reverse Vowels of a String_1.java,"public String reverseVowels(String s) { if (s == null || s.length() == 0) { return s; } List vowels = Arrays.asList('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'); StringBuffer sb = new StringBuffer(s); int maxIndex = sb.length() - 1; int i = 0; int j = maxIndex; while (i < j) { while (i < maxIndex && !vowels.contains(sb.charAt(i))) i++; while (j > 0 && !vowels.contains(sb.charAt(j))) j--; if (i < j && vowels.contains(sb.charAt(i)) && vowels.contains(sb.charAt(j))) { char letter = sb.charAt(j); sb.setCharAt(j, sb.charAt(i)); sb.setCharAt(i, letter); j--; i++; } } return sb.toString(); }","public String var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) == 0 ) { return var_2 ; } List < Character > var_20 = Arrays . asList ( 'a' , 'e' , 'i' , 'o' , 'u' , 'A' , 'E' , 'I' , 'O' , 'U' ) ; StringBuffer var_22 = new StringBuffer ( var_2 ) ; int var_24 = var_22 . length ( ) - 1 ; int var_25 = 0 ; int var_26 = var_24 ; while ( var_25 < var_26 ) { while ( var_25 < var_24 && ! var_20 . contains ( var_22 . charAt ( var_25 ) ) ) var_25 ++ ; while ( var_26 > 0 && ! var_20 . contains ( var_22 . charAt ( var_26 ) ) ) var_26 -- ; if ( var_25 < var_26 && var_20 . contains ( var_22 . charAt ( var_25 ) ) && var_20 . contains ( var_22 . charAt ( var_26 ) ) ) { char var_29 = var_22 . charAt ( var_26 ) ; var_22 . setCharAt ( var_26 , var_22 . charAt ( var_25 ) ) ; var_22 . setCharAt ( var_25 , var_29 ) ; var_26 -- ; var_25 ++ ; } } return var_22 . toString ( ) ; } " 882,560. Subarray Sum Equals K_1.java,"public int subarraySum(int[] nums, int k) { if (nums == null || nums.length == 0) return 0; Map preSumCount = new HashMap<>(); int n = nums.length, sum = 0, count = 0; preSumCount.put(0, 1); for (int num : nums) { sum += num; int priorSum = sum - k; if (preSumCount.containsKey(priorSum)) { count += preSumCount.get(priorSum); } preSumCount.put(sum, preSumCount.getOrDefault(sum, 0) + 1); } return count; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; Map < Integer , Integer > var_8 = new HashMap < > ( ) ; int var_9 = var_0 . length , var_10 = 0 , var_11 = 0 ; var_8 . put ( 0 , 1 ) ; for ( int var_14 : var_0 ) { var_10 += var_14 ; int var_15 = var_10 - var_1 ; if ( var_8 . containsKey ( var_15 ) ) { var_11 += var_8 . get ( var_15 ) ; } var_8 . put ( var_10 , var_8 . getOrDefault ( var_10 , 0 ) + 1 ) ; } return var_11 ; } " 883,Backpack II_4.java,"public int backPackII(int m, int[] A, int V[]) { if (A == null || V == null || A.length != V.length) { return 0; } int n = A.length; int[][] dp = new int[2][m + 1]; for (int j = 0; j <= m; j++) { dp[0][j] = -1; } dp[0][0] = 0; int curr = 0, prev; for (int i = 1; i <= n; i++) { prev = curr; curr = 1 - prev; for (int j = 1; j <= m; j++) { dp[curr][j] = dp[prev][j]; if (j - A[i - 1] >= 0 && dp[prev][j - A[i - 1]] != -1) { dp[curr][j] = Math.max(dp[curr][j], dp[prev][j - A[i - 1]] + V[i - 1]); } } } int rst = 0; for (int j = 0; j <= m; j++) { if (dp[curr][j] != -1) { rst = Math.max(rst, dp[curr][j]); } } return rst; }","public int sample_funcname ( int var_0 , int [ ] var_1 , int var_2 [ ] ) { if ( var_1 == null || var_2 == null || var_1 . length != var_2 . length ) { return 0 ; } int var_6 = var_1 . length ; int [ ] [ ] var_9 = new int [ 2 ] [ var_0 + 1 ] ; for ( int var_10 = 0 ; var_10 <= var_0 ; var_10 ++ ) { var_9 [ 0 ] [ var_10 ] = - 1 ; } var_9 [ 0 ] [ 0 ] = 0 ; int var_11 = 0 , var_12 ; for ( int var_13 = 1 ; var_13 <= var_6 ; var_13 ++ ) { var_12 = var_11 ; var_11 = 1 - var_12 ; for ( int var_10 = 1 ; var_10 <= var_0 ; var_10 ++ ) { var_9 [ var_11 ] [ var_10 ] = var_9 [ var_12 ] [ var_10 ] ; if ( var_10 - var_1 [ var_13 - 1 ] >= 0 && var_9 [ var_12 ] [ var_10 - var_1 [ var_13 - 1 ] ] != - 1 ) { var_9 [ var_11 ] [ var_10 ] = Math . max ( var_9 [ var_11 ] [ var_10 ] , var_9 [ var_12 ] [ var_10 - var_1 [ var_13 - 1 ] ] + var_2 [ var_13 - 1 ] ) ; } } } int var_16 = 0 ; for ( int var_10 = 0 ; var_10 <= var_0 ; var_10 ++ ) { if ( var_9 [ var_11 ] [ var_10 ] != - 1 ) { var_16 = Math . max ( var_16 , var_9 [ var_11 ] [ var_10 ] ) ; } } return var_16 ; } " 884,Coins in a Line III_2.java,"private void search(int i, int j, boolean[][] visited, int[][] dp, int[][] sum, int[] values) { if (visited[i][j]) { return; } visited[i][j] = true; if (i == j) { dp[i][j] = values[i]; } else if (i > j) { dp[i][j] = 0; } else if (i + 1 == j) { dp[i][j] = Math.max(values[i], values[j]); } else { search(i + 1, j, visited, dp, sum, values); search(i, j - 1, visited, dp, sum, values); dp[i][j] = sum[i][j] - Math.min(dp[i + 1][j], dp[i][j - 1]); } }","private void sample_funcname ( int i , int j , boolean [ ] [ ] visited , int [ ] [ ] dp , int [ ] [ ] sum , int [ ] values ) { if ( visited [ i ] [ j ] ) { return ; } visited [ i ] [ j ] = true ; if ( i == j ) { dp [ i ] [ j ] = values [ i ] ; } else if ( i > j ) { dp [ i ] [ j ] = 0 ; } else if ( i + 1 == j ) { dp [ i ] [ j ] = Math . max ( values [ i ] , values [ j ] ) ; } else { search ( i + 1 , j , visited , dp , sum , values ) ; search ( i , j - 1 , visited , dp , sum , values ) ; dp [ i ] [ j ] = sum [ i ] [ j ] - Math . min ( dp [ i + 1 ] [ j ] , dp [ i ] [ j - 1 ] ) ; } } " 885,287. Find the Duplicate Number_2.java,"private boolean validate(int candidate, int[] nums) { int count = 0; for (int num: nums) { count += num <= candidate ? 1 : 0; } return count <= candidate; }","private boolean var_0 ( int var_1 , int [ ] var_2 ) { int var_4 = 0 ; for ( int var_5 : var_2 ) { var_4 += var_5 <= var_1 ? 1 : 0 ; } return var_4 <= var_1 ; } " 886,[lint]. Subarray Sum_1.java,"public List subarraySum(int[] nums) { List rst = new ArrayList<>(); if (nums == null || nums.length == 0) { return rst; } int preSum = 0; Map map = new HashMap<>(); map.put(preSum, -1); for (int i = 0; i < nums.length; i++) { preSum += nums[i]; if (map.containsKey(preSum)) { rst.add(map.get(preSum) + 1); rst.add(i); return rst; } map.put(preSum, i); } return rst; }","public List < Integer > var_1 ( int [ ] var_2 ) { List < Integer > var_5 = new ArrayList < > ( ) ; if ( var_2 == null || var_2 . length == 0 ) { return var_5 ; } int var_9 = 0 ; Map < Integer , Integer > var_12 = new HashMap < > ( ) ; var_12 . put ( var_9 , - 1 ) ; for ( int var_15 = 0 ; var_15 < var_2 . length ; var_15 ++ ) { var_9 += var_2 [ var_15 ] ; if ( var_12 . containsKey ( var_9 ) ) { var_5 . add ( var_12 . get ( var_9 ) + 1 ) ; var_5 . add ( var_15 ) ; return var_5 ; } var_12 . put ( var_9 , var_15 ) ; } return var_5 ; } " 887,Wiggle Sort_1.java,"private void swap(int[] nums, int x, int y) { int temp = nums[x]; nums[x] = nums[y]; nums[y] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 888,Redundant Connection_2.java,"public int[] findRedundantConnection(int[][] edges) { Map> graph = new HashMap<>(); for (int[] edge : edges) { int x = edge[0], y = edge[1]; Set visited = new HashSet<>(); Queue queue = new LinkedList<>(); queue.offer(x); while (!queue.isEmpty()) { int node = queue.poll(); if (!graph.containsKey(node)) continue; if (graph.get(node).contains(y)) return edge; for (int num : graph.get(node)) { if (visited.contains(num)) continue; queue.offer(num); visited.add(num); } } graph.putIfAbsent(x, new HashSet<>()); graph.putIfAbsent(y, new HashSet<>()); graph.get(x).add(y); graph.get(y).add(x); } return new int[] {-1, -1}; }","public int [ ] sample_funcname ( int [ ] [ ] var_0 ) { Map < Integer , Set < Integer >> var_5 = new HashMap < > ( ) ; for ( int [ ] var_6 : var_0 ) { int var_8 = var_6 [ 0 ] , var_10 = var_6 [ 1 ] ; Set < Integer > var_12 = new HashSet < > ( ) ; Queue < Integer > var_15 = new LinkedList < > ( ) ; var_15 . offer ( var_8 ) ; while ( ! var_15 . isEmpty ( ) ) { int var_19 = var_15 . poll ( ) ; if ( ! var_5 . containsKey ( var_19 ) ) continue ; if ( var_5 . get ( var_19 ) . contains ( var_10 ) ) return var_6 ; for ( int var_23 : var_5 . get ( var_19 ) ) { if ( var_12 . contains ( var_23 ) ) continue ; var_15 . offer ( var_23 ) ; var_12 . add ( var_23 ) ; } } var_5 . putIfAbsent ( var_8 , new HashSet < > ( ) ) ; var_5 . putIfAbsent ( var_10 , new HashSet < > ( ) ) ; var_5 . get ( var_8 ) . add ( var_10 ) ; var_5 . get ( var_10 ) . add ( var_8 ) ; } return new int [ ] { - 1 , - 1 }; } " 889,39. Combination Sum_4.java,"private boolean validate(int[] candidates, int target) { return candidates == null || candidates.length == 0 || target <= 0; }","private boolean var_0 ( int [ ] var_1 , int var_2 ) { return var_1 == null || var_1 . length == 0 || var_2 <= 0 ; } " 890,47. Permutations II_2.java,"private void swap(List list, int x, int y) { int temp = list.get(x); list.set(x, list.get(y)); list.set(y, temp); }","private void var_0 ( List < Integer > var_3 , int var_4 , int var_5 ) { int var_7 = var_3 . get ( var_4 ) ; var_3 . set ( var_4 , var_3 . get ( var_5 ) ) ; var_3 . set ( var_5 , var_7 ) ; } " 891,523. Continuous Subarray Sum_3.java,"public boolean checkSubarraySum(int[] nums, int k) { if (nums == null || nums.length == 0) { return false; } int n = nums.length; for (int i = 0; i < n; i++) { int sum = nums[i]; for (int j = i + 1; j < n; j++) { sum += nums[j]; if (sum == k || (k != 0 && sum % k == 0)) { return true; } } } return false; }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { if ( var_1 == null || var_1 . length == 0 ) { return false ; } int var_6 = var_1 . length ; for ( int var_7 = 0 ; var_7 < var_6 ; var_7 ++ ) { int var_8 = var_1 [ var_7 ] ; for ( int var_10 = var_7 + 1 ; var_10 < var_6 ; var_10 ++ ) { var_8 += var_1 [ var_10 ] ; if ( var_8 == var_2 || ( var_2 != 0 && var_8 % var_2 == 0 ) ) { return true ; } } } return false ; } " 892,14. Longest Common Prefix_2.java,"public String longestCommonPrefix(String[] strs) { if (strs == null || strs.length == 0) { return """"; } if (strs.length == 1) { return strs[0]; } String prefix = """"; int ind = 0; while (ind < strs[0].length()) { char c = strs[0].charAt(ind); boolean valid = false; for (int i = 1; i < strs.length; i++) { if (strs[i].length() > ind && strs[i].charAt(ind) == c) { valid = true; } else { valid = false; break; } } if (valid) { prefix += """" + c; } else { break; } ind++; } return prefix; }","public String var_0 ( String [ ] var_2 ) { if ( var_2 == null || var_2 . length == 0 ) { return """" ; } if ( var_2 . length == 1 ) { return var_2 [ 0 ] ; } String var_8 = """" ; int var_9 = 0 ; while ( var_9 < var_2 [ 0 ] . length ( ) ) { char var_11 = var_2 [ 0 ] . charAt ( var_9 ) ; boolean var_14 = false ; for ( int var_13 = 1 ; var_13 < var_2 . length ; var_13 ++ ) { if ( var_2 [ var_13 ] . length ( ) > var_9 && var_2 [ var_13 ] . charAt ( var_9 ) == var_11 ) { var_14 = true ; } else { var_14 = false ; break ; } } if ( var_14 ) { var_8 += """" + var_11 ; } else { break ; } var_9 ++ ; } return var_8 ; } " 893,46. Permutations_2.java,"private void dfs(List> result, List list, int[] nums) { if (list.size() == nums.length) { result.add(new ArrayList<>(list)); return; } for (int i = 0; i < nums.length; i++) { if (list.contains(nums[i])) continue; list.add(nums[i]); dfs(result, list, nums); list.remove(list.size() - 1); } }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int [ ] nums ) { if ( list . size ( ) == nums . length ) { result . add ( new ArrayList < > ( list ) ) ; return ; } for ( int i = 0 ; i < nums . length ; i ++ ) { if ( list . contains ( nums [ i ] ) ) continue ; list . add ( nums [ i ] ) ; dfs ( result , list , nums ) ; list . remove ( list . size ( ) - 1 ) ; } } " 894,152. Maximum Product Subarray_4.java,"int maxProduct(int nums[]) { int max = nums[0]; for (int i = 1, imax = max, imin = max; i < nums.length; i++) { if (nums[i] < 0) { int temp = imax; imax = imin; imin = temp; } imax = Math.max(nums[i], imax * nums[i]); imin = Math.min(nums[i], imin * nums[i]); max = Math.max(max, imax); } return max; }","int sample_funcname ( int var_0 [ ] ) { int max = var_0 [ 0 ] ; for ( int var_4 = 1 , var_5 = max , var_6 = max ; var_4 < var_0 . length ; var_4 ++ ) { if ( var_0 [ var_4 ] < 0 ) { int var_8 = var_5 ; var_5 = var_6 ; var_6 = var_8 ; } var_5 = Math . max ( var_0 [ var_4 ] , var_5 * var_0 [ var_4 ] ) ; var_6 = Math . min ( var_0 [ var_4 ] , var_6 * var_0 [ var_4 ] ) ; max = Math . max ( max , var_5 ) ; } return max ; } " 895,53. Maximum Subarray_3.java,"public int maxSubArray(int[] nums) { if (nums == null || nums.length == 0) return 0; int n = nums.length, max = Integer.MIN_VALUE; int[] dp = new int[n + 1]; dp[0] = 0; for (int i = 1; i <= n; i++) { dp[i] = Math.max(dp[i - 1] + nums[i - 1], nums[i - 1]); max = Math.max(max, dp[i]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return 0 ; int var_4 = var_0 . length , max = Integer . MIN_VALUE ; int [ ] var_9 = new int [ var_4 + 1 ] ; var_9 [ 0 ] = 0 ; for ( int var_10 = 1 ; var_10 <= var_4 ; var_10 ++ ) { var_9 [ var_10 ] = Math . max ( var_9 [ var_10 - 1 ] + var_0 [ var_10 - 1 ] , var_0 [ var_10 - 1 ] ) ; max = Math . max ( max , var_9 [ var_10 ] ) ; } return max ; } " 896,1306. Jump Game III_2.java,"private boolean dfs(int[] arr, Set visited, int index) { if (arr[index] == 0) return true; if (!visited.add(index)) return false; if (visited.size() == arr.length) return false; int left = index - arr[index], right = index + arr[index]; return (left >= 0 && dfs(arr, visited, left)) || (right < arr.length && dfs(arr, visited, right)); }","private boolean sample_funcname ( int [ ] arr , Set < Integer > visited , int index ) { if ( arr [ index ] == 0 ) return true ; if ( ! visited . add ( index ) ) return false ; if ( visited . size ( ) == arr . length ) return false ; int left = index - arr [ index ] , right = index + arr [ index ] ; return ( left >= 0 && dfs ( arr , visited , left ) ) || ( right < arr . length && dfs ( arr , visited , right ) ) ; } " 897,Word Pattern_2.java,"public boolean wordPattern(String pattern, String str) { if (pattern != null && str != null && pattern.length() == 0 && str.length() == 0) { return true; } if (pattern == null || pattern.length() == 0 || str == null || str.length() == 0) { return false; } String[] strArr = str.split("" ""); if (pattern.length() != strArr.length) { return false; } HashMap map = new HashMap(); HashMap mapStr = new HashMap(); for (int i = 0; i < strArr.length; i++){ if (!map.containsKey(pattern.charAt(i))) { map.put(pattern.charAt(i), strArr[i]); } else { if (!map.get(pattern.charAt(i)).equals(strArr[i])) { return false; } } if (!mapStr.containsKey(strArr[i])) { mapStr.put(strArr[i], pattern.charAt(i)); } else { if (mapStr.get(strArr[i]) != pattern.charAt(i)) { return false; } } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 != null && var_3 != null && var_2 . length ( ) == 0 && var_3 . length ( ) == 0 ) { return true ; } if ( var_2 == null || var_2 . length ( ) == 0 || var_3 == null || var_3 . length ( ) == 0 ) { return false ; } String [ ] var_9 = var_3 . split ( "" "" ) ; if ( var_2 . length ( ) != var_9 . length ) { return false ; } HashMap < Character , String > var_12 = new HashMap < Character , String > ( ) ; HashMap < String , Character > var_13 = new HashMap < String , Character > ( ) ; for ( int var_14 = 0 ; var_14 < var_9 . length ; var_14 ++ ) { if ( ! var_12 . containsKey ( var_2 . charAt ( var_14 ) ) ) { var_12 . put ( var_2 . charAt ( var_14 ) , var_9 [ var_14 ] ) ; } else { if ( ! var_12 . get ( var_2 . charAt ( var_14 ) ) . equals ( var_9 [ var_14 ] ) ) { return false ; } } if ( ! var_13 . containsKey ( var_9 [ var_14 ] ) ) { var_13 . put ( var_9 [ var_14 ] , var_2 . charAt ( var_14 ) ) ; } else { if ( var_13 . get ( var_9 [ var_14 ] ) != var_2 . charAt ( var_14 ) ) { return false ; } } } return true ; } " 898,121. Best Time to Buy and Sell Stock_2.java,"public int maxProfit(int[] prices) { if (prices == null || prices.length <= 1) return 0; int profit = 0, min = prices[0]; for (int i = 1; i < prices.length; i++) { if (prices[i] < min) min = prices[i]; else profit = Math.max(profit, prices[i] - min); } return profit; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length <= 1 ) return 0 ; int var_5 = 0 , var_6 = var_0 [ 0 ] ; for ( int var_7 = 1 ; var_7 < var_0 . length ; var_7 ++ ) { if ( var_0 [ var_7 ] < var_6 ) var_6 = var_0 [ var_7 ] ; else var_5 = Math . max ( var_5 , var_0 [ var_7 ] - var_6 ) ; } return var_5 ; } " 899,Jump Game II_1.java,"public int jump(int[] nums) { if (nums == null || nums.length <= 1) return 0; int count = 0, farest = 0, maxRange = 0, n = nums.length; for (int i = 0; i < n - 1; i++) { maxRange = Math.max(maxRange, i + nums[i]); if (i == farest) { count++; farest = maxRange; } } return count; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length <= 1 ) return 0 ; int var_5 = 0 , var_6 = 0 , var_7 = 0 , var_8 = var_0 . length ; for ( int var_9 = 0 ; var_9 < var_8 - 1 ; var_9 ++ ) { var_7 = Math . max ( var_7 , var_9 + var_0 [ var_9 ] ) ; if ( var_9 == var_6 ) { var_5 ++ ; var_6 = var_7 ; } } return var_5 ; } " 900,509. Fibonacci Number_1.java,"public int fibonacci(int n) { if (n <= 1) { return 0; } int first = 0; int second = 1; for (int i = 2; i < n; i++) { int temp = second; second = first + second; first = temp; } return second; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 1 ) { return 0 ; } int var_3 = 0 ; int var_4 = 1 ; for ( int var_6 = 2 ; var_6 < var_0 ; var_6 ++ ) { int var_7 = var_4 ; var_4 = var_3 + var_4 ; var_3 = var_7 ; } return var_4 ; } " 901,Minimum Height Trees_1.java,"public List findMinHeightTrees(int n, int[][] edges) { List rst = new ArrayList(); if (n == 1) { rst.add(0); return rst; }else if (n == 0 || edges == null || edges.length == 0 || edges.length != n - 1) { return rst; } boolean[] nodes = new boolean[n]; HashMap> map = new HashMap>(); for (int i = 0; i < n; i++) { map.put(i, new ArrayList()); nodes[i] = true; } for (int i = 0; i < edges.length; i++) { if (!map.get(edges[i][0]).contains(edges[i][1])) { map.get(edges[i][0]).add(edges[i][1]); } if (!map.get(edges[i][1]).contains(edges[i][0])) { map.get(edges[i][1]).add(edges[i][0]); } } Queue queue = new LinkedList(); while (n > 2) { for (Map.Entry> entry : map.entrySet()) { if (entry.getValue().size() == 1) { queue.offer(entry.getKey()); } } while (!queue.isEmpty()) { n--; Integer key = queue.poll(); nodes[key] = false; int from = map.get(key).get(0); map.get(from).remove(key); map.get(key).remove(0); } } for (int i = 0; i < nodes.length; i++) { if (nodes[i]) { rst.add(i); } } return rst; }","public List < Integer > var_1 ( int var_2 , int [ ] [ ] var_3 ) { List < Integer > var_6 = new ArrayList < Integer > ( ) ; if ( var_2 == 1 ) { var_6 . add ( 0 ) ; return var_6 ; } else if ( var_2 == 0 || var_3 == null || var_3 . length == 0 || var_3 . length != var_2 - 1 ) { return var_6 ; } boolean [ ] var_13 = new boolean [ var_2 ] ; HashMap < Integer , ArrayList < Integer >> var_15 = new HashMap < Integer , ArrayList < Integer >> ( ) ; for ( int var_16 = 0 ; var_16 < var_2 ; var_16 ++ ) { var_15 . put ( var_16 , new ArrayList < Integer > ( ) ) ; var_13 [ var_16 ] = true ; } for ( int var_16 = 0 ; var_16 < var_3 . length ; var_16 ++ ) { if ( ! var_15 . get ( var_3 [ var_16 ] [ 0 ] ) . contains ( var_3 [ var_16 ] [ 1 ] ) ) { var_15 . get ( var_3 [ var_16 ] [ 0 ] ) . add ( var_3 [ var_16 ] [ 1 ] ) ; } if ( ! var_15 . get ( var_3 [ var_16 ] [ 1 ] ) . contains ( var_3 [ var_16 ] [ 0 ] ) ) { var_15 . get ( var_3 [ var_16 ] [ 1 ] ) . add ( var_3 [ var_16 ] [ 0 ] ) ; } } Queue < Integer > var_22 = new LinkedList < Integer > ( ) ; while ( var_2 > 2 ) { for ( Map . Entry < Integer , ArrayList < Integer >> var_25 : var_15 . entrySet ( ) ) { if ( var_25 . getValue ( ) . size ( ) == 1 ) { var_22 . offer ( var_25 . getKey ( ) ) ; } } while ( ! var_22 . isEmpty ( ) ) { var_2 -- ; Integer var_32 = var_22 . poll ( ) ; var_13 [ var_32 ] = false ; int var_33 = var_15 . get ( var_32 ) . get ( 0 ) ; var_15 . get ( var_33 ) . remove ( var_32 ) ; var_15 . get ( var_32 ) . remove ( 0 ) ; } } for ( int var_16 = 0 ; var_16 < var_13 . length ; var_16 ++ ) { if ( var_13 [ var_16 ] ) { var_6 . add ( var_16 ) ; } } return var_6 ; } " 902,40. Combination Sum II_1.java,"private void dfs(List> result, List list, int[] candidates, int index, int target) { if (target == 0) { result.add(new ArrayList<>(list)); return; } for (int i = index; i < candidates.length; i++) { if (i > index && candidates[i] == candidates[i - 1]) continue; int value = candidates[i]; list.add(value); if (target - value >= 0) dfs(result, list, candidates, i + 1, target - value); list.remove(list.size() - 1); } }","private void sample_funcname ( List < List < Integer >> result , List < Integer > list , int [ ] candidates , int index , int target ) { if ( target == 0 ) { result . add ( new ArrayList < > ( list ) ) ; return ; } for ( int i = index ; i < candidates . length ; i ++ ) { if ( i > index && candidates [ i ] == candidates [ i - 1 ] ) continue ; int value = candidates [ i ] ; list . add ( value ) ; if ( target - value >= 0 ) dfs ( result , list , candidates , i + 1 , target - value ) ; list . remove ( list . size ( ) - 1 ) ; } } " 903,One Edit Distance_1.java,"private boolean compareStr(String s, String t, int x, int y) { return s.substring(x).equals(t.substring(y)); }","private boolean var_0 ( String var_2 , String var_3 , int var_4 , int var_5 ) { return var_2 . substring ( var_4 ) . equals ( var_3 . substring ( var_5 ) ) ; } " 904,Max Sum of Rectangle No Larger Than K_2.java,"public int maxSumSubmatrix(int[][] matrix, int k) { if (matrix == null || matrix.length == 0 || matrix[0] == null || matrix[0].length == 0) { return -1; } int m = matrix.length, n = matrix[0].length; int max = Integer.MIN_VALUE; for (int row = 0; row < m; row++) { int[] preSum = new int[n]; for (int i = row; i < m; i++) { TreeSet areaSet = new TreeSet<>(); int newSum = 0; for (int j = 0; j < n; j++) { preSum[j] += matrix[i][j]; newSum += preSum[j]; if (newSum <= k) max = Math.max(max, newSum); Integer extraArea = areaSet.ceiling(newSum - k); if (extraArea != null) { max = Math.max(max, newSum - extraArea); } areaSet.add(newSum); } } } return max == Integer.MIN_VALUE ? -1 : max; }","public int sample_funcname ( int [ ] [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return - 1 ; } int var_6 = var_0 . length , var_7 = var_0 [ 0 ] . length ; int max = Integer . MIN_VALUE ; for ( int var_11 = 0 ; var_11 < var_6 ; var_11 ++ ) { int [ ] var_12 = new int [ var_7 ] ; for ( int var_13 = var_11 ; var_13 < var_6 ; var_13 ++ ) { TreeSet < Integer > var_15 = new TreeSet < > ( ) ; int var_16 = 0 ; for ( int var_17 = 0 ; var_17 < var_7 ; var_17 ++ ) { var_12 [ var_17 ] += var_0 [ var_13 ] [ var_17 ] ; var_16 += var_12 [ var_17 ] ; if ( var_16 <= var_1 ) max = Math . max ( max , var_16 ) ; Integer var_20 = var_15 . ceiling ( var_16 - var_1 ) ; if ( var_20 != null ) { max = Math . max ( max , var_16 - var_20 ) ; } var_15 . add ( var_16 ) ; } } } return max == Integer . MIN_VALUE ? - 1 : max ; } " 905,265. Paint House II_3.java,"public int minCostII(int[][] costs) { if (costs == null || costs.length == 0) { return 0; } else if (costs.length == 1 && costs[0].length == 1) { return costs[0][0]; } int minCost = Integer.MAX_VALUE; int n = costs.length; int k = costs[0].length; int[][] dp = new int[n + 1][k]; for (int j = 0; j < k; j++) { dp[0][j] = 0; } for (int i = 1; i <= n; i++) { int minIndex = -1; int minSecIndex = -1; for (int j = 0; j < k; j++) { if (minIndex == -1 || dp[i - 1][j] < dp[i - 1][minIndex]) { minSecIndex = minIndex; minIndex = j; } else if (minSecIndex == -1 || dp[i - 1][j] < dp[i - 1][minSecIndex]) { minSecIndex = j; } } for (int j = 0; j < k; j++) { if (j == minIndex) { dp[i][j] = dp[i - 1][minSecIndex] + costs[i - 1][j]; } else { dp[i][j] = dp[i - 1][minIndex] + costs[i - 1][j]; } if (i == n) { minCost = Math.min(minCost, dp[i][j]); } } } return minCost; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } else if ( var_0 . length == 1 && var_0 [ 0 ] . length == 1 ) { return var_0 [ 0 ] [ 0 ] ; } int var_7 = Integer . MAX_VALUE ; int var_8 = var_0 . length ; int var_9 = var_0 [ 0 ] . length ; int [ ] [ ] var_10 = new int [ var_8 + 1 ] [ var_9 ] ; for ( int var_11 = 0 ; var_11 < var_9 ; var_11 ++ ) { var_10 [ 0 ] [ var_11 ] = 0 ; } for ( int var_12 = 1 ; var_12 <= var_8 ; var_12 ++ ) { int var_13 = - 1 ; int var_14 = - 1 ; for ( int var_11 = 0 ; var_11 < var_9 ; var_11 ++ ) { if ( var_13 == - 1 || var_10 [ var_12 - 1 ] [ var_11 ] < var_10 [ var_12 - 1 ] [ var_13 ] ) { var_14 = var_13 ; var_13 = var_11 ; } else if ( var_14 == - 1 || var_10 [ var_12 - 1 ] [ var_11 ] < var_10 [ var_12 - 1 ] [ var_14 ] ) { var_14 = var_11 ; } } for ( int var_11 = 0 ; var_11 < var_9 ; var_11 ++ ) { if ( var_11 == var_13 ) { var_10 [ var_12 ] [ var_11 ] = var_10 [ var_12 - 1 ] [ var_14 ] + var_0 [ var_12 - 1 ] [ var_11 ] ; } else { var_10 [ var_12 ] [ var_11 ] = var_10 [ var_12 - 1 ] [ var_13 ] + var_0 [ var_12 - 1 ] [ var_11 ] ; } if ( var_12 == var_8 ) { var_7 = Math . min ( var_7 , var_10 [ var_12 ] [ var_11 ] ) ; } } } return var_7 ; } " 906,Longest Valid Parentheses_3.java,"public int longestValidParentheses(String s) { if (s == null || s.length() == 0) return 0; int n = s.length(); Stack stack = new Stack<>(); char[] arr = s.toCharArray(); for (int i = 0; i < n; i++) { if (arr[i] == ')' && !stack.isEmpty() && arr[stack.peek()] == '(') { stack.pop(); continue; } stack.push(i); } int max = stack.isEmpty() ? n : 0; int end = n, start = 0; while (!stack.isEmpty()) { start = stack.pop(); max = Math.max(max, end - start - 1); end = start; } return Math.max(max, end); }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . length ( ) == 0 ) return 0 ; int var_5 = var_1 . length ( ) ; Stack < Integer > var_8 = new Stack < > ( ) ; char [ ] var_10 = var_1 . toCharArray ( ) ; for ( int var_11 = 0 ; var_11 < var_5 ; var_11 ++ ) { if ( var_10 [ var_11 ] == ')' && ! var_8 . isEmpty ( ) && var_10 [ var_8 . peek ( ) ] == '(' ) { var_8 . pop ( ) ; continue ; } var_8 . push ( var_11 ) ; } int max = var_8 . isEmpty ( ) ? var_5 : 0 ; int var_19 = var_5 , var_20 = 0 ; while ( ! var_8 . isEmpty ( ) ) { var_20 = var_8 . pop ( ) ; max = Math . max ( max , var_19 - var_20 - 1 ) ; var_19 = var_20 ; } return Math . max ( max , var_19 ) ; } " 907,62. Unique Path_2.java,"public int uniquePaths(int m, int n) { if (m == 0 || n == 0) return 0; int[][] dp = new int[2][n]; for (int i = 0; i < 2; i++) dp[i][0] = 1; for (int i = 0; i < n; i++) dp[0][i] = 1; for (int i = 1; i < m; i++) { for (int j = 1; j < n; j++) { dp[i%2][j] = dp[(i - 1)%2][j] + dp[i%2][j - 1]; } } return dp[(m-1)%2][n-1]; }","public int sample_funcname ( int var_0 , int var_1 ) { if ( var_0 == 0 || var_1 == 0 ) return 0 ; int [ ] [ ] var_4 = new int [ 2 ] [ var_1 ] ; for ( int var_5 = 0 ; var_5 < 2 ; var_5 ++ ) var_4 [ var_5 ] [ 0 ] = 1 ; for ( int var_5 = 0 ; var_5 < var_1 ; var_5 ++ ) var_4 [ 0 ] [ var_5 ] = 1 ; for ( int var_5 = 1 ; var_5 < var_0 ; var_5 ++ ) { for ( int var_7 = 1 ; var_7 < var_1 ; var_7 ++ ) { var_4 [ var_5 % 2 ] [ var_7 ] = var_4 [ ( var_5 - 1 ) % 2 ] [ var_7 ] + var_4 [ var_5 % 2 ] [ var_7 - 1 ] ; } } return var_4 [ ( var_0 - 1 ) % 2 ] [ var_1 - 1 ] ; } " 908,Longest Common Substring_4.java,"public int longestCommonSubstring(String A, String B) { if (A == null || B == null || A.length() == 0 || B.length() == 0) { return 0; } int [][] D = new int[A.length() + 1][B.length() + 1]; int max = 0; for (int i = 0; i <= A.length(); i++) { for(int j = 0; j <= B.length(); j++) { if (i == 0 || j == 0) { D[i][j] = 0; } else { if (A.charAt(i - 1) == B.charAt(j - 1)) { D[i][j] = D[i - 1][j - 1] + 1; } else { D[i][j] = 0; } max = Math.max(max, D[i][j]); } } } return max; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) == 0 || var_2 . length ( ) == 0 ) { return 0 ; } int [ ] [ ] var_7 = new int [ var_1 . length ( ) + 1 ] [ var_2 . length ( ) + 1 ] ; int max = 0 ; for ( int var_9 = 0 ; var_9 <= var_1 . length ( ) ; var_9 ++ ) { for ( int var_10 = 0 ; var_10 <= var_2 . length ( ) ; var_10 ++ ) { if ( var_9 == 0 || var_10 == 0 ) { var_7 [ var_9 ] [ var_10 ] = 0 ; } else { if ( var_1 . charAt ( var_9 - 1 ) == var_2 . charAt ( var_10 - 1 ) ) { var_7 [ var_9 ] [ var_10 ] = var_7 [ var_9 - 1 ] [ var_10 - 1 ] + 1 ; } else { var_7 [ var_9 ] [ var_10 ] = 0 ; } max = Math . max ( max , var_7 [ var_9 ] [ var_10 ] ) ; } } } return max ; } " 909,Last Position of Target_1.java,"public int lastPosition(int[] A, int target) { if (A == null || A.length == 0) { return -1; } int start = 0; int end = A.length - 1; int mid; while(start + 1 < end) { mid = start + (end - start)/2; if (A[mid] == target) { if (mid + 1 < A.length && A[mid + 1] == target) { start = mid; } else { return mid; } } else if (A[mid] < target) { start = mid; } else { end = mid; } } if (A[end] == target) { return end; } else if (A[start] == target) { return start; } return -1; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } int var_6 = 0 ; int var_7 = var_0 . length - 1 ; int var_8 ; while ( var_6 + 1 < var_7 ) { var_8 = var_6 + ( var_7 - var_6 ) / 2 ; if ( var_0 [ var_8 ] == var_1 ) { if ( var_8 + 1 < var_0 . length && var_0 [ var_8 + 1 ] == var_1 ) { var_6 = var_8 ; } else { return var_8 ; } } else if ( var_0 [ var_8 ] < var_1 ) { var_6 = var_8 ; } else { var_7 = var_8 ; } } if ( var_0 [ var_7 ] == var_1 ) { return var_7 ; } else if ( var_0 [ var_6 ] == var_1 ) { return var_6 ; } return - 1 ; } " 910,"Pow(x, n)_2.java","public double pow(double x, int n) { if (n == 0) { return 1; } double num = pow(x, n/2); if (n % 2 == 0) { return num * num; } return num * num * x; }","public double sample_funcname ( double x , int n ) { if ( n == 0 ) { return 1 ; } double num = pow ( x , n / 2 ) ; if ( n % 2 == 0 ) { return num * num ; } return num * num * x ; } " 911,31. Next Permutation_2.java,"private int findHigh(int[] nums, int low) { int end = nums.length - 1; while (end > low) { if (nums[end] > nums[low]) return end; end--; } return -1; }","private int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_4 = var_0 . length - 1 ; while ( var_4 > var_1 ) { if ( var_0 [ var_4 ] > var_0 [ var_1 ] ) return var_4 ; var_4 -- ; } return - 1 ; } " 912,88. Merge Sorted Array_3.java,"public void merge(int[] nums1, int m, int[] nums2, int n) { if (nums1 == null || nums1.length == 0 || nums2 == null || nums2.length == 0) { return; } int end = m + n - 1; m--; n--; for (int i = end; i >= 0; i--) { if (m >= 0 && n >= 0) { nums1[i] = nums1[m] >= nums2[n] ? nums1[m--] : nums2[n--]; } else { nums1[i] = m >= 0 ? nums1[m--] : nums2[n--]; } } }","public void var_0 ( int [ ] var_1 , int var_2 , int [ ] var_3 , int var_4 ) { if ( var_1 == null || var_1 . length == 0 || var_3 == null || var_3 . length == 0 ) { return ; } int var_9 = var_2 + var_4 - 1 ; var_2 -- ; var_4 -- ; for ( int var_10 = var_9 ; var_10 >= 0 ; var_10 -- ) { if ( var_2 >= 0 && var_4 >= 0 ) { var_1 [ var_10 ] = var_1 [ var_2 ] >= var_3 [ var_4 ] ? var_1 [ var_2 -- ] : var_3 [ var_4 -- ] ; } else { var_1 [ var_10 ] = var_2 >= 0 ? var_1 [ var_2 -- ] : var_3 [ var_4 -- ] ; } } } " 913,Line Reflection_1.java,"public boolean isReflected(int[][] points) { if (points == null || points.length == 0 || points[0] == null || points[0].length == 0) return true; Map> map = new HashMap<>(); for (int[] point : points) { map.putIfAbsent(point[1], new HashSet<>()); map.get(point[1]).add((double)point[0]); } List sampleRow = new ArrayList<>(map.get(points[0][1])); Collections.sort(sampleRow); double mid = (sampleRow.get(0) + sampleRow.get(sampleRow.size() - 1)) / 2; for (Set row: map.values()) { int left = 0, right = row.size() - 1; List sortedRow = new ArrayList<>(row); Collections.sort(sortedRow); while (left <= right) { if ((sortedRow.get(left) + sortedRow.get(right)) / 2 != mid) { return false; } left++; right--; } } return true; }","public boolean var_0 ( int [ ] [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 || var_1 [ 0 ] == null || var_1 [ 0 ] . length == 0 ) return true ; Map < Integer , Set < Double >> var_10 = new HashMap < > ( ) ; for ( int [ ] var_11 : var_1 ) { var_10 . putIfAbsent ( var_11 [ 1 ] , new HashSet < > ( ) ) ; var_10 . get ( var_11 [ 1 ] ) . add ( ( double ) var_11 [ 0 ] ) ; } List < Double > var_19 = new ArrayList < > ( var_10 . get ( var_1 [ 0 ] [ 1 ] ) ) ; Collections . sort ( var_19 ) ; double var_24 = ( var_19 . get ( 0 ) + var_19 . get ( var_19 . size ( ) - 1 ) ) / 2 ; for ( Set < Double > var_26 : var_10 . values ( ) ) { int var_27 = 0 , var_28 = var_26 . size ( ) - 1 ; List < Double > var_29 = new ArrayList < > ( var_26 ) ; Collections . sort ( var_29 ) ; while ( var_27 <= var_28 ) { if ( ( var_29 . get ( var_27 ) + var_29 . get ( var_28 ) ) / 2 != var_24 ) { return false ; } var_27 ++ ; var_28 -- ; } } return true ; } " 914,Longest Increasing Continuous subsequence_2.java,"public int dfs(int[] A, int[] dp, int[] flag, int i){ if (flag[i] == 1) { return dp[i]; } int ansLeft = 1; int ansRight = 1; flag[i] = -1; if (i - 1 >= 0 && A[i - 1] < A[i] && flag[i - 1] != -1) { ansLeft = dfs(A, dp, flag, i - 1) + 1; } if (i + 1 < A.length && A[i] > A[i + 1] && flag[i + 1] != -1) { ansRight = dfs(A, dp, flag, i + 1) + 1; } flag[i] = 1; dp[i] = Math.max(ansLeft, ansRight); return dp[i]; }","public int sample_funcname ( int [ ] A , int [ ] dp , int [ ] flag , int i ) { if ( flag [ i ] == 1 ) { return dp [ i ] ; } int ansLeft = 1 ; int ansRight = 1 ; flag [ i ] = - 1 ; if ( i - 1 >= 0 && A [ i - 1 ] < A [ i ] && flag [ i - 1 ] != - 1 ) { ansLeft = dfs ( A , dp , flag , i - 1 ) + 1 ; } if ( i + 1 < A . length && A [ i ] > A [ i + 1 ] && flag [ i + 1 ] != - 1 ) { ansRight = dfs ( A , dp , flag , i + 1 ) + 1 ; } flag [ i ] = 1 ; dp [ i ] = Math . max ( ansLeft , ansRight ) ; return dp [ i ] ; } " 915,1048. Longest String Chain_1.java,"public int longestStrChain(String[] words) { int rst = 0; Arrays.sort(words, Comparator.comparing(a -> a.length())); HashMap wordChainMap = new HashMap(); for (String word : words) { if (wordChainMap.containsKey(word)) continue; wordChainMap.put(word, 1); for (int i = 0; i < word.length(); i++) { StringBuilder sb = new StringBuilder(word); sb.deleteCharAt(i); String lastWord = sb.toString(); if (wordChainMap.containsKey(lastWord) && wordChainMap.get(lastWord) + 1 > wordChainMap.get(word)) { wordChainMap.put(word, wordChainMap.get(lastWord) + 1); } } if (wordChainMap.get(word) > rst) rst = wordChainMap.get(word); } return rst; }","public int sample_funcname ( String [ ] var_1 ) { int var_3 = 0 ; Arrays . sort ( var_1 , Comparator . comparing ( var_8 -> var_8 . length ( ) ) ) ; HashMap < String , Integer > var_12 = new HashMap ( ) ; for ( String var_13 : var_1 ) { if ( var_12 . containsKey ( var_13 ) ) continue ; var_12 . put ( var_13 , 1 ) ; for ( int var_17 = 0 ; var_17 < var_13 . length ( ) ; var_17 ++ ) { StringBuilder var_19 = new StringBuilder ( var_13 ) ; var_19 . deleteCharAt ( var_17 ) ; String var_22 = var_19 . toString ( ) ; if ( var_12 . containsKey ( var_22 ) && var_12 . get ( var_22 ) + 1 > var_12 . get ( var_13 ) ) { var_12 . put ( var_13 , var_12 . get ( var_22 ) + 1 ) ; } } if ( var_12 . get ( var_13 ) > var_3 ) var_3 = var_12 . get ( var_13 ) ; } return var_3 ; } " 916,1007. Minimum Domino Rotations For Equal Row_1.java,"public int minDominoRotations(int[] A, int[] B) { int[] countA = new int[7], countB = new int[7], overlap = new int[7]; int n = A.length; for (int i = 0; i < n; ++i) { countA[A[i]]++; countB[B[i]]++; if (A[i] == B[i]) overlap[A[i]]++; } for (int i = 1; i < 7; ++i) { if (countA[i] + countB[i] - overlap[i] == n) return n - Math.max(countA[i], countB[i]); } return -1; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { int [ ] var_3 = new int [ 7 ] , var_4 = new int [ 7 ] , var_5 = new int [ 7 ] ; int var_7 = var_0 . length ; for ( int var_9 = 0 ; var_9 < var_7 ; ++ var_9 ) { var_3 [ var_0 [ var_9 ] ] ++ ; var_4 [ var_1 [ var_9 ] ] ++ ; if ( var_0 [ var_9 ] == var_1 [ var_9 ] ) var_5 [ var_0 [ var_9 ] ] ++ ; } for ( int var_9 = 1 ; var_9 < 7 ; ++ var_9 ) { if ( var_3 [ var_9 ] + var_4 [ var_9 ] - var_5 [ var_9 ] == var_7 ) return var_7 - Math . max ( var_3 [ var_9 ] , var_4 [ var_9 ] ) ; } return - 1 ; } " 917,Interleaving String_1.java,"public boolean isInterleave(String s1, String s2, String s3) { if (s1 == null || s2 == null || s1.length() + s2.length() != s3.length()) { return false; } int m = s1.length(); int n = s2.length(); boolean[][] dp = new boolean[m + 1][n + 1]; for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0 && j == 0) { dp[i][j] = true; continue; } dp[i][j] = false; if (i > 0 && s1.charAt(i - 1) == s3.charAt(i + j - 1)) { dp[i][j] |= dp[i - 1][j]; } if (j > 0 && s2.charAt(j - 1) == s3.charAt(i + j - 1)) { dp[i][j] |= dp[i][j - 1]; } } } return dp[m][n]; }","public boolean var_0 ( String var_2 , String var_3 , String var_4 ) { if ( var_2 == null || var_3 == null || var_2 . length ( ) + var_3 . length ( ) != var_4 . length ( ) ) { return false ; } int var_7 = var_2 . length ( ) ; int var_8 = var_3 . length ( ) ; boolean [ ] [ ] var_11 = new boolean [ var_7 + 1 ] [ var_8 + 1 ] ; for ( int var_13 = 0 ; var_13 <= var_7 ; var_13 ++ ) { for ( int var_14 = 0 ; var_14 <= var_8 ; var_14 ++ ) { if ( var_13 == 0 && var_14 == 0 ) { var_11 [ var_13 ] [ var_14 ] = true ; continue ; } var_11 [ var_13 ] [ var_14 ] = false ; if ( var_13 > 0 && var_2 . charAt ( var_13 - 1 ) == var_4 . charAt ( var_13 + var_14 - 1 ) ) { var_11 [ var_13 ] [ var_14 ] |= var_11 [ var_13 - 1 ] [ var_14 ] ; } if ( var_14 > 0 && var_3 . charAt ( var_14 - 1 ) == var_4 . charAt ( var_13 + var_14 - 1 ) ) { var_11 [ var_13 ] [ var_14 ] |= var_11 [ var_13 ] [ var_14 - 1 ] ; } } } return var_11 [ var_7 ] [ var_8 ] ; } " 918,Decode String_1.java,"private String popStack(Stack stack) { StringBuffer sb = new StringBuffer(); while (!stack.isEmpty() && (stack.peek() instanceof String)) { sb.insert(0, stack.pop()); } return sb.toString(); }","private String var_0 ( Stack < Object > var_3 ) { StringBuffer var_5 = new StringBuffer ( ) ; while ( ! var_3 . isEmpty ( ) && ( var_3 . peek ( ) instanceof String ) ) { var_5 . insert ( 0 , var_3 . pop ( ) ) ; } return var_5 . toString ( ) ; } " 919,125. Valid Palindrome_2.java,"public boolean isPalindrome(String s) { if (s == null || s.length() <= 1) { return true; } String str = s.replaceAll(""[^a-zA-Z0-9]"", """").toLowerCase(); int start = 0; int end = str.length() - 1; while (start < end) { if (str.charAt(start) != str.charAt(end)) { return false; } start++; end--; } return true; }","public boolean var_0 ( String var_2 ) { if ( var_2 == null || var_2 . length ( ) <= 1 ) { return true ; } String var_10 = var_2 . replaceAll ( ""[^a-zA-Z0-9]"" , """" ) . toLowerCase ( ) ; int var_12 = 0 ; int var_13 = var_10 . length ( ) - 1 ; while ( var_12 < var_13 ) { if ( var_10 . charAt ( var_12 ) != var_10 . charAt ( var_13 ) ) { return false ; } var_12 ++ ; var_13 -- ; } return true ; } " 920,Find Peak Element II_2.java,"private List find(int x1, int x2, int y1, int y2, int[][] A) { int midX = x1 + ((x2 - x1) >> 1); int midY = y1 + ((y2 - y1) >> 1); int x = midX, y = midY; int max = A[x][y]; for (int j = y1; j <= y2; j++) { if (A[midX][j] > max) { max = A[midX][j]; x = midX; y = j; } } for (int i = x1; i <= x2; i++) { if (A[i][midY] > max) { max = A[i][midY]; y = midY; x = i; } } boolean isPeak = true; if (A[x - 1][y] > A[x][y]) { isPeak = false; x -= 1; } else if (A[x + 1][y] > A[x][y]) { isPeak = false; x += 1; } else if (A[x][y - 1] > A[x][y]) { isPeak = false; y -= 1; } else if (A[x][y + 1] > A[x][y]) { isPeak = false; y += 1; } if (isPeak) { return new ArrayList(Arrays.asList(x, y)); } if (x >= x1 && x < midX && y >= y1 && y < midY) { return find(x1, midX - 1, y1, midY - 1, A); } if (x >= x1 && x < midX && y > midY && y <= y2) { return find(x1, midX - 1, midY + 1, y2, A); } if (x > midX && x <= x2 && y >= y1 && y < midY) { return find(midX + 1, x2, y1, midY - 1, A); } if (x >= midX && x <= x2 && y > midY && y <= y2) { return find(midX + 1, x2, midY + 1, y2, A); } return new ArrayList<>(); }","private List < Integer > sample_funcname ( int x1 , int x2 , int y1 , int y2 , int [ ] [ ] A ) { int midX = x1 + ( ( x2 - x1 ) >> 1 ) ; int midY = y1 + ( ( y2 - y1 ) >> 1 ) ; int x = midX , y = midY ; int max = A [ x ] [ y ] ; for ( int j = y1 ; j <= y2 ; j ++ ) { if ( A [ midX ] [ j ] > max ) { max = A [ midX ] [ j ] ; x = midX ; y = j ; } } for ( int i = x1 ; i <= x2 ; i ++ ) { if ( A [ i ] [ midY ] > max ) { max = A [ i ] [ midY ] ; y = midY ; x = i ; } } boolean isPeak = true ; if ( A [ x - 1 ] [ y ] > A [ x ] [ y ] ) { isPeak = false ; x -= 1 ; } else if ( A [ x + 1 ] [ y ] > A [ x ] [ y ] ) { isPeak = false ; x += 1 ; } else if ( A [ x ] [ y - 1 ] > A [ x ] [ y ] ) { isPeak = false ; y -= 1 ; } else if ( A [ x ] [ y + 1 ] > A [ x ] [ y ] ) { isPeak = false ; y += 1 ; } if ( isPeak ) { return new ArrayList < Integer > ( Arrays . asList ( x , y ) ) ; } if ( x >= x1 && x < midX && y >= y1 && y < midY ) { return find ( x1 , midX - 1 , y1 , midY - 1 , A ) ; } if ( x >= x1 && x < midX && y > midY && y <= y2 ) { return find ( x1 , midX - 1 , midY + 1 , y2 , A ) ; } if ( x > midX && x <= x2 && y >= y1 && y < midY ) { return find ( midX + 1 , x2 , y1 , midY - 1 , A ) ; } if ( x >= midX && x <= x2 && y > midY && y <= y2 ) { return find ( midX + 1 , x2 , midY + 1 , y2 , A ) ; } return new ArrayList < > ( ) ; } " 921,Ugly Number_2.java,"public long kthPrimeNumber(int k) { if (k == 0) { return 0; } PriorityQueue queue = new PriorityQueue(); queue.offer((long)3); queue.offer((long)5); queue.offer((long)7); long num = 0; for (int i = 0; i < k; i++) { num = queue.poll(); if (num % 3 == 0) { queue.offer(num * 3); } else if (num % 5 == 0) { queue.offer(num * 3); queue.offer(num * 5); } else if (num % 7 == 0) { queue.offer(num * 3); queue.offer(num * 5); queue.offer(num * 7); } } return num; }","public long sample_funcname ( int var_0 ) { if ( var_0 == 0 ) { return 0 ; } PriorityQueue < Long > var_4 = new PriorityQueue < Long > ( ) ; var_4 . offer ( ( long ) 3 ) ; var_4 . offer ( ( long ) 5 ) ; var_4 . offer ( ( long ) 7 ) ; long var_9 = 0 ; for ( int var_10 = 0 ; var_10 < var_0 ; var_10 ++ ) { var_9 = var_4 . poll ( ) ; if ( var_9 % 3 == 0 ) { var_4 . offer ( var_9 * 3 ) ; } else if ( var_9 % 5 == 0 ) { var_4 . offer ( var_9 * 3 ) ; var_4 . offer ( var_9 * 5 ) ; } else if ( var_9 % 7 == 0 ) { var_4 . offer ( var_9 * 3 ) ; var_4 . offer ( var_9 * 5 ) ; var_4 . offer ( var_9 * 7 ) ; } } return var_9 ; } " 922,Encode and Decode Strings_4.java,"public static List decode(String s) { List rst = new ArrayList(); if (s.equals(""NULL"")) { return rst; } int index = s.indexOf(""LINE""); while (index != -1) { String str = s.substring(0, index); StringBuffer sb = new StringBuffer(); int i = 0; while (i + 3 <= str.length()) { int letter = Integer.parseInt(str.substring(i, i + 3)); sb.append((char)letter); i+=3; } rst.add(sb.toString()); s = s.substring(index + 4); index = s.indexOf(""LINE""); } return rst; }","public static List < String > var_1 ( String var_2 ) { List < String > var_5 = new ArrayList < String > ( ) ; if ( var_2 . equals ( ""NULL"" ) ) { return var_5 ; } int var_10 = var_2 . indexOf ( ""LINE"" ) ; while ( var_10 != - 1 ) { String var_14 = var_2 . substring ( 0 , var_10 ) ; StringBuffer var_16 = new StringBuffer ( ) ; int var_17 = 0 ; while ( var_17 + 3 <= var_14 . length ( ) ) { int var_22 = Integer . parseInt ( var_14 . substring ( var_17 , var_17 + 3 ) ) ; var_16 . append ( ( char ) var_22 ) ; var_17 += 3 ; } var_5 . add ( var_16 . toString ( ) ) ; var_2 = var_2 . substring ( var_10 + 4 ) ; var_10 = var_2 . indexOf ( ""LINE"" ) ; } return var_5 ; } " 923,Backpack III_1.java,"public int backPackIII(int[] A, int[] V, int m) { if (A == null || A.length == 0 || V == null || V.length == 0 || m <= 0) { return 0; } int n = A.length; int[][] dp = new int[n + 1][m + 1]; dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { dp[i][j] = dp[i - 1][j]; for (int k = 1; k * A[i - 1] <= j; k++) { dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - k * A[i - 1]] + k * V[i - 1]); } } } return dp[n][m]; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 , int var_2 ) { if ( var_0 == null || var_0 . length == 0 || var_1 == null || var_1 . length == 0 || var_2 <= 0 ) { return 0 ; } int var_6 = var_0 . length ; int [ ] [ ] var_8 = new int [ var_6 + 1 ] [ var_2 + 1 ] ; var_8 [ 0 ] [ 0 ] = 0 ; for ( int var_9 = 1 ; var_9 <= var_6 ; var_9 ++ ) { for ( int var_10 = 1 ; var_10 <= var_2 ; var_10 ++ ) { var_8 [ var_9 ] [ var_10 ] = var_8 [ var_9 - 1 ] [ var_10 ] ; for ( int var_11 = 1 ; var_11 * var_0 [ var_9 - 1 ] <= var_10 ; var_11 ++ ) { var_8 [ var_9 ] [ var_10 ] = Math . max ( var_8 [ var_9 ] [ var_10 ] , var_8 [ var_9 - 1 ] [ var_10 - var_11 * var_0 [ var_9 - 1 ] ] + var_11 * var_1 [ var_9 - 1 ] ) ; } } } return var_8 [ var_6 ] [ var_2 ] ; } " 924,Wildcard Matching_1.java,"public boolean isMatch(String s, String p) { if (s == null || p == null) return false; int m = s.length(), n = p.length(); boolean[][] dp = new boolean[m + 1][n + 1]; char[] ss = s.toCharArray(); char[] pp = p.toCharArray(); for (int i = 0; i <= m; i++) { for (int j = 0; j <= n; j++) { if (i == 0 && j == 0) { dp[i][j] = true; continue; } if (j == 0) { dp[i][j] = false; continue; } dp[i][j] = false; if (pp[j - 1] != '*') { if (i >= 1 && (ss[i - 1] == pp[j - 1] || pp[j - 1] == '?')) { dp[i][j] |= dp[i - 1][j - 1]; } } else { dp[i][j] |= dp[i][j - 1]; if (i >= 1) { dp[i][j] |= dp[i - 1][j]; } } } } return dp[m][n]; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 == null || var_3 == null ) return false ; int var_6 = var_2 . length ( ) , var_7 = var_3 . length ( ) ; boolean [ ] [ ] var_10 = new boolean [ var_6 + 1 ] [ var_7 + 1 ] ; char [ ] var_12 = var_2 . toCharArray ( ) ; char [ ] var_13 = var_3 . toCharArray ( ) ; for ( int var_15 = 0 ; var_15 <= var_6 ; var_15 ++ ) { for ( int var_16 = 0 ; var_16 <= var_7 ; var_16 ++ ) { if ( var_15 == 0 && var_16 == 0 ) { var_10 [ var_15 ] [ var_16 ] = true ; continue ; } if ( var_16 == 0 ) { var_10 [ var_15 ] [ var_16 ] = false ; continue ; } var_10 [ var_15 ] [ var_16 ] = false ; if ( var_13 [ var_16 - 1 ] != '*' ) { if ( var_15 >= 1 && ( var_12 [ var_15 - 1 ] == var_13 [ var_16 - 1 ] || var_13 [ var_16 - 1 ] == '?' ) ) { var_10 [ var_15 ] [ var_16 ] |= var_10 [ var_15 - 1 ] [ var_16 - 1 ] ; } } else { var_10 [ var_15 ] [ var_16 ] |= var_10 [ var_15 ] [ var_16 - 1 ] ; if ( var_15 >= 1 ) { var_10 [ var_15 ] [ var_16 ] |= var_10 [ var_15 - 1 ] [ var_16 ] ; } } } } return var_10 [ var_6 ] [ var_7 ] ; } " 925,Word Ladder_1.java,"private List transform(Set words, String word) { List candidates = new ArrayList<>(); StringBuffer sb = new StringBuffer(word); for (int i = 0; i < sb.length(); i++) { char temp = sb.charAt(i); for (char c = 'a'; c <= 'z'; c++) { if (temp == c) { continue; } sb.setCharAt(i, c); String newWord = sb.toString(); if (words.remove(newWord)) { candidates.add(newWord); } } sb.setCharAt(i, temp); } return candidates; }","private List < String > var_1 ( Set < String > var_3 , String var_4 ) { List < String > var_7 = new ArrayList < > ( ) ; StringBuffer var_9 = new StringBuffer ( var_4 ) ; for ( int var_11 = 0 ; var_11 < var_9 . length ( ) ; var_11 ++ ) { char var_14 = var_9 . charAt ( var_11 ) ; for ( char var_16 = 'a' ; var_16 <= 'z' ; var_16 ++ ) { if ( var_14 == var_16 ) { continue ; } var_9 . setCharAt ( var_11 , var_16 ) ; String var_20 = var_9 . toString ( ) ; if ( var_3 . remove ( var_20 ) ) { var_7 . add ( var_20 ) ; } } var_9 . setCharAt ( var_11 , var_14 ) ; } return var_7 ; } " 926,Ugly Number II_3.java,"public int nthUglyNumber(int n) { if (n <= 0) { return 0; } else if (n == 1) { return 1; } long[] dp = new long[n + 1]; dp[0] = 0; dp[1] = 1; PriorityQueue candidate = new PriorityQueue(); HashSet set = new HashSet(); set.add(dp[1]); for (int i = 2; i <= n; i++) { if (!set.contains(dp[i - 1] * 2)) { candidate.add(dp[i - 1] * 2); set.add(dp[i - 1] * 2); } if (!set.contains(dp[i - 1] * 3)) { candidate.add(dp[i - 1] * 3); set.add(dp[i - 1] * 3); } if (!set.contains(dp[i - 1] * 5)) { candidate.add(dp[i - 1] * 5); set.add(dp[i - 1] * 5); } dp[i] = candidate.poll(); } return (int)dp[n]; }","public int sample_funcname ( int var_0 ) { if ( var_0 <= 0 ) { return 0 ; } else if ( var_0 == 1 ) { return 1 ; } long [ ] var_3 = new long [ var_0 + 1 ] ; var_3 [ 0 ] = 0 ; var_3 [ 1 ] = 1 ; PriorityQueue < Long > var_6 = new PriorityQueue < Long > ( ) ; HashSet < Long > var_8 = new HashSet < Long > ( ) ; var_8 . add ( var_3 [ 1 ] ) ; for ( int var_11 = 2 ; var_11 <= var_0 ; var_11 ++ ) { if ( ! var_8 . contains ( var_3 [ var_11 - 1 ] * 2 ) ) { var_6 . add ( var_3 [ var_11 - 1 ] * 2 ) ; var_8 . add ( var_3 [ var_11 - 1 ] * 2 ) ; } if ( ! var_8 . contains ( var_3 [ var_11 - 1 ] * 3 ) ) { var_6 . add ( var_3 [ var_11 - 1 ] * 3 ) ; var_8 . add ( var_3 [ var_11 - 1 ] * 3 ) ; } if ( ! var_8 . contains ( var_3 [ var_11 - 1 ] * 5 ) ) { var_6 . add ( var_3 [ var_11 - 1 ] * 5 ) ; var_8 . add ( var_3 [ var_11 - 1 ] * 5 ) ; } var_3 [ var_11 ] = var_6 . poll ( ) ; } return ( int ) var_3 [ var_0 ] ; } " 927,Palindrome Partitioning II_2.java,"private boolean[][] calcPalindrome(char[] s) { int n = s.length; boolean[][] palindrome = new boolean[n][n]; for (int mid = 0; mid < n; mid++) { int i = mid, j = mid; while (i >= 0 && j < n && s[i] == s[j]) { palindrome[i][j] = true; i--; j++; } i = mid; j = mid + 1; while (i >= 0 && j < n && s[i] == s[j]) { palindrome[i][j] = true; i--; j++; } } return palindrome; }","private boolean [ ] [ ] var_0 ( char [ ] var_1 ) { int var_3 = var_1 . length ; boolean [ ] [ ] var_5 = new boolean [ var_3 ] [ var_3 ] ; for ( int var_7 = 0 ; var_7 < var_3 ; var_7 ++ ) { int var_8 = var_7 , var_9 = var_7 ; while ( var_8 >= 0 && var_9 < var_3 && var_1 [ var_8 ] == var_1 [ var_9 ] ) { var_5 [ var_8 ] [ var_9 ] = true ; var_8 -- ; var_9 ++ ; } var_8 = var_7 ; var_9 = var_7 + 1 ; while ( var_8 >= 0 && var_9 < var_3 && var_1 [ var_8 ] == var_1 [ var_9 ] ) { var_5 [ var_8 ] [ var_9 ] = true ; var_8 -- ; var_9 ++ ; } } return var_5 ; } " 928,727. Minimum Window Subsequence_4.java,"private int backtrack(char[] ss, char[] tt, int sIndex) { for (int i = tt.length - 1; i >= 0; i--) { while(ss[sIndex--] != tt[i]); } return ++sIndex; }","private int sample_funcname ( char [ ] var_0 , char [ ] var_1 , int var_2 ) { for ( int var_5 = var_1 . length - 1 ; var_5 >= 0 ; var_5 -- ) { while ( var_0 [ var_2 -- ] != var_1 [ var_5 ] ) ; } return ++ var_2 ; } " 929,Backpack II_8.java,"public int backPackII(int m, int[] A, int V[]) { if (A == null || V == null || A.length == 0 || V.length == 0 || A.length != V.length || m <= 0) { return 0; } int[]dp = new int[m + 1]; dp[0] = 0; for (int i = 1; i <= A.length; i++) { for (int j = m; j >= 0; j--) { if (j - A[i - 1] >= 0 && dp[j - A[i - 1]] + V[i - 1] > dp[j]) { dp[j] = dp[j - A[i - 1]] + V[i - 1]; } } } return dp[m]; }","public int sample_funcname ( int var_0 , int [ ] var_1 , int var_2 [ ] ) { if ( var_1 == null || var_2 == null || var_1 . length == 0 || var_2 . length == 0 || var_1 . length != var_2 . length || var_0 <= 0 ) { return 0 ; } int [ ] var_7 = new int [ var_0 + 1 ] ; var_7 [ 0 ] = 0 ; for ( int var_8 = 1 ; var_8 <= var_1 . length ; var_8 ++ ) { for ( int var_9 = var_0 ; var_9 >= 0 ; var_9 -- ) { if ( var_9 - var_1 [ var_8 - 1 ] >= 0 && var_7 [ var_9 - var_1 [ var_8 - 1 ] ] + var_2 [ var_8 - 1 ] > var_7 [ var_9 ] ) { var_7 [ var_9 ] = var_7 [ var_9 - var_1 [ var_8 - 1 ] ] + var_2 [ var_8 - 1 ] ; } } } return var_7 [ var_0 ] ; } " 930,229. Majority Element II_2.java,"private void addResult(List result, int n, int value, int count) { if (!result.contains(value) && count > n / 3) { result.add(value); } }","private void var_0 ( List < Integer > var_3 , int var_4 , int var_5 , int var_6 ) { if ( ! var_3 . contains ( var_5 ) && var_6 > var_4 / 3 ) { var_3 . add ( var_5 ) ; } } " 931,169. Majority Element_2.java,"public int majorityElement(int[] nums) { if (nums == null || nums.length == 0) { return -1; } Arrays.sort(nums); return nums[nums.length / 2]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return - 1 ; } Arrays . sort ( var_0 ) ; return var_0 [ var_0 . length / 2 ] ; } " 932,Longest Common Subsequence_3.java,"public int longestCommonSubsequence(String A, String B) { if (A == null || B == null || A.length() == 0 || B.length() == 0) { return 0; } int m = A.length(); int n = B.length(); int[][] dp = new int[m + 1][n + 1]; int[][] pi = new int[m + 1][n + 1]; for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { if(i == 0 || j == 0) { dp[i][j] = 0; continue; } dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]); pi[i][j] = dp[i - 1][j] > dp[i][j - 1] ? 1 : 2; if (A.charAt(i - 1) == B.charAt(j - 1)) { dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - 1] + 1); if (dp[i][j] == dp[i - 1][j - 1] + 1) { pi[i][j] = 3; } } } } char[] res = new char[dp[m][n]]; int i = m; int j = n; int w = dp[m][n] - 1; while (i > 0 && j > 0) { if (pi[i][j] == 1) { i--; } else if (pi[i][j] == 2) { j--; } else { res[w] = A.charAt(i - 1); i--; j--; w--; } } for (int k = 0; k < dp[m][n]; k++) { System.out.print(res[k]); } System.out.println(); return dp[m][n]; }","public int sample_funcname ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) == 0 || var_2 . length ( ) == 0 ) { return 0 ; } int var_6 = var_1 . length ( ) ; int var_7 = var_2 . length ( ) ; int [ ] [ ] var_9 = new int [ var_6 + 1 ] [ var_7 + 1 ] ; int [ ] [ ] var_10 = new int [ var_6 + 1 ] [ var_7 + 1 ] ; for ( int var_11 = 1 ; var_11 <= var_6 ; var_11 ++ ) { for ( int var_12 = 1 ; var_12 <= var_7 ; var_12 ++ ) { if ( var_11 == 0 || var_12 == 0 ) { var_9 [ var_11 ] [ var_12 ] = 0 ; continue ; } var_9 [ var_11 ] [ var_12 ] = Math . max ( var_9 [ var_11 - 1 ] [ var_12 ] , var_9 [ var_11 ] [ var_12 - 1 ] ) ; var_10 [ var_11 ] [ var_12 ] = var_9 [ var_11 - 1 ] [ var_12 ] > var_9 [ var_11 ] [ var_12 - 1 ] ? 1 : 2 ; if ( var_1 . charAt ( var_11 - 1 ) == var_2 . charAt ( var_12 - 1 ) ) { var_9 [ var_11 ] [ var_12 ] = Math . max ( var_9 [ var_11 ] [ var_12 ] , var_9 [ var_11 - 1 ] [ var_12 - 1 ] + 1 ) ; if ( var_9 [ var_11 ] [ var_12 ] == var_9 [ var_11 - 1 ] [ var_12 - 1 ] + 1 ) { var_10 [ var_11 ] [ var_12 ] = 3 ; } } } } char [ ] var_18 = new char [ var_9 [ var_6 ] [ var_7 ] ] ; int var_11 = var_6 ; int var_12 = var_7 ; int var_19 = var_9 [ var_6 ] [ var_7 ] - 1 ; while ( var_11 > 0 && var_12 > 0 ) { if ( var_10 [ var_11 ] [ var_12 ] == 1 ) { var_11 -- ; } else if ( var_10 [ var_11 ] [ var_12 ] == 2 ) { var_12 -- ; } else { var_18 [ var_19 ] = var_1 . charAt ( var_11 - 1 ) ; var_11 -- ; var_12 -- ; var_19 -- ; } } for ( int var_20 = 0 ; var_20 < var_9 [ var_6 ] [ var_7 ] ; var_20 ++ ) { System . out . print ( var_18 [ var_20 ] ) ; } System . out . println ( ) ; return var_9 [ var_6 ] [ var_7 ] ; } " 933,Power of Three_2.java,"public boolean isPowerOfThree(int n) { if (n <= 0) { return false; } if (n == 1) { return true; } if (n % 3 != 0) { return false; } return isPowerOfThree(n / 3); }","public boolean sample_funcname ( int n ) { if ( n <= 0 ) { return false ; } if ( n == 1 ) { return true ; } if ( n % 3 != 0 ) { return false ; } return isPowerOfThree ( n / 3 ) ; } " 934,Group Shifted Strings_2.java,"public List> groupStrings(String[] strings) { List> rst = new ArrayList>(); if (strings == null || strings.length == 0) { return rst; } Arrays.sort(strings); HashMap> map = new HashMap>(); for (String s : strings) { char[] arr = s.toCharArray(); char head = arr[0]; for (int i = 0; i < arr.length; i++) { if (arr[i] - head < 0) { arr[i] = (char)((arr[i] - head) + 26); } else { arr[i] = (char)(arr[i] - head); } } String key = new String(arr); if (!map.containsKey(key)) { map.put(key, new ArrayList()); } map.get(key).add(s); } for (Map.Entry> entry : map.entrySet()) { rst.add(entry.getValue()); } return rst; }","public List < List < String >> var_2 ( String [ ] var_3 ) { List < List < String >> var_5 = new ArrayList < List < String >> ( ) ; if ( var_3 == null || var_3 . length == 0 ) { return var_5 ; } Arrays . sort ( var_3 ) ; HashMap < String , ArrayList < String >> var_12 = new HashMap < String , ArrayList < String >> ( ) ; for ( String var_13 : var_3 ) { char [ ] var_15 = var_13 . toCharArray ( ) ; char var_16 = var_15 [ 0 ] ; for ( int var_17 = 0 ; var_17 < var_15 . length ; var_17 ++ ) { if ( var_15 [ var_17 ] - var_16 < 0 ) { var_15 [ var_17 ] = ( char ) ( ( var_15 [ var_17 ] - var_16 ) + 26 ) ; } else { var_15 [ var_17 ] = ( char ) ( var_15 [ var_17 ] - var_16 ) ; } } String var_19 = new String ( var_15 ) ; if ( ! var_12 . containsKey ( var_19 ) ) { var_12 . put ( var_19 , new ArrayList < String > ( ) ) ; } var_12 . get ( var_19 ) . add ( var_13 ) ; } for ( Map . Entry < String , ArrayList < String >> var_25 : var_12 . entrySet ( ) ) { var_5 . add ( var_25 . getValue ( ) ) ; } return var_5 ; } " 935,Shuffle an Array_1.java,"private void swap(int[] nums, int x, int y) { int temp = nums[y]; nums[y] = nums[x]; nums[x] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_4 ; } " 936,Distinct Subsequences_4.java,"public int numDistinct(String S, String T) { if (S.length() == 0) { return T.length() == 0 ? 1 : 0; } if (T.length() == 0) { return 1; } int count = 0; for (int i = 0; i < S.length(); i++) { if (S.charAt(i) == T.charAt(0)) { count += numDistinct(S.substring(i + 1), T.substring(1)); } } return count; }","public int sample_funcname ( String S , String T ) { if ( S . length ( ) == 0 ) { return T . length ( ) == 0 ? 1 : 0 ; } if ( T . length ( ) == 0 ) { return 1 ; } int count = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == T . charAt ( 0 ) ) { count += numDistinct ( S . substring ( i + 1 ) , T . substring ( 1 ) ) ; } } return count ; } " 937,305. Number of Islands II_2.java,"private boolean validateInput(int m, int n, int[][] positions) { return m <= 0 || n <= 0 || positions == null || positions.length == 0 || positions[0] == null || positions[0].length == 0; }","private boolean var_0 ( int var_1 , int var_2 , int [ ] [ ] var_3 ) { return var_1 <= 0 || var_2 <= 0 || var_3 == null || var_3 . length == 0 || var_3 [ 0 ] == null || var_3 [ 0 ] . length == 0 ; } " 938,485. Max Consecutive Ones_1.java,"public int findMaxConsecutiveOnes(int[] nums) { if (nums == null || nums.length == 0) { return 0; } int maxCount = 0; int count = 0; for (int i = 0; i < nums.length; i++) { if (nums[i] == 0) { maxCount = Math.max(count, maxCount); count = 0; } else { count++; } } return Math.max(count, maxCount); }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) { return 0 ; } int var_4 = 0 ; int var_5 = 0 ; for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { if ( var_0 [ var_6 ] == 0 ) { var_4 = Math . max ( var_5 , var_4 ) ; var_5 = 0 ; } else { var_5 ++ ; } } return Math . max ( var_5 , var_4 ) ; } " 939,43. Multiply Strings_1.java,"private char toChar(int num) { return (char)(num + '0'); }","private char sample_funcname ( int var_0 ) { return ( char ) ( var_0 + '0' ) ; } " 940,Coins in a Line_4.java,"public boolean firstWillWin(int n) { if (n <= 0) { return false; } if (n <= 2) { return true; } boolean[] dp = new boolean[n + 1]; dp[1] = true; dp[2] = true; dp[3] = false; for (int i = 4; i <= n; i++) { dp[i] = dp[i - 3]; } return dp[n]; }","public boolean var_0 ( int var_1 ) { if ( var_1 <= 0 ) { return false ; } if ( var_1 <= 2 ) { return true ; } boolean [ ] var_6 = new boolean [ var_1 + 1 ] ; var_6 [ 1 ] = true ; var_6 [ 2 ] = true ; var_6 [ 3 ] = false ; for ( int var_8 = 4 ; var_8 <= var_1 ; var_8 ++ ) { var_6 [ var_8 ] = var_6 [ var_8 - 3 ] ; } return var_6 [ var_1 ] ; } " 941,140. Word Break II_4.java,"public boolean[] validatePossibility(List wordDict, boolean[][] isWord, String s) { int maxLen = 0; for (String word : wordDict) { maxLen = Math.max(maxLen, word.length()); } int n = s.length(); boolean[] isValid = new boolean[n + 1]; isValid[n] = true; for (int i = n - 1; i >= 0; i--) { for (int j = i; j < n; j++) { if (isWord[i][j] && isValid[j + 1]) { isValid[i] = true; break; } } } return isValid; }","public boolean [ ] var_0 ( List < String > var_3 , boolean [ ] [ ] var_5 , String var_6 ) { int var_8 = 0 ; for ( String var_9 : var_3 ) { var_8 = Math . max ( var_8 , var_9 . length ( ) ) ; } int var_13 = var_6 . length ( ) ; boolean [ ] var_15 = new boolean [ var_13 + 1 ] ; var_15 [ var_13 ] = true ; for ( int var_16 = var_13 - 1 ; var_16 >= 0 ; var_16 -- ) { for ( int var_17 = var_16 ; var_17 < var_13 ; var_17 ++ ) { if ( var_5 [ var_16 ] [ var_17 ] && var_15 [ var_17 + 1 ] ) { var_15 [ var_16 ] = true ; break ; } } } return var_15 ; } " 942,15. 3Sum_2.java,"public ArrayList> calTwoSum(int[] num, int end, int target) { ArrayList> rst = new ArrayList>(); ArrayList match; HashMap map = new HashMap(); for (int i = 0; i <= end; i++) { if (map.containsKey(num[i])) { match = new ArrayList(); match.add(num[map.get(num[i])]); match.add(num[i]); if (!rst.contains(match)) { rst.add(new ArrayList(match)); } } else { map.put(target - num[i], i); } if (i < end && num[i] == num[i + 1]) { continue; } } return rst; }","public ArrayList < ArrayList < Integer >> var_2 ( int [ ] var_3 , int var_4 , int var_5 ) { ArrayList < ArrayList < Integer >> var_6 = new ArrayList < ArrayList < Integer >> ( ) ; ArrayList < Integer > var_7 ; HashMap < Integer , Integer > var_9 = new HashMap < Integer , Integer > ( ) ; for ( int var_11 = 0 ; var_11 <= var_4 ; var_11 ++ ) { if ( var_9 . containsKey ( var_3 [ var_11 ] ) ) { var_7 = new ArrayList < Integer > ( ) ; var_7 . add ( var_3 [ var_9 . get ( var_3 [ var_11 ] ) ] ) ; var_7 . add ( var_3 [ var_11 ] ) ; if ( ! var_6 . contains ( var_7 ) ) { var_6 . add ( new ArrayList < Integer > ( var_7 ) ) ; } } else { var_9 . put ( var_5 - var_3 [ var_11 ] , var_11 ) ; } if ( var_11 < var_4 && var_3 [ var_11 ] == var_3 [ var_11 + 1 ] ) { continue ; } } return var_6 ; } " 943,405. Convert a Number to Hexadecimal_1.java,"private String convert(int digit) { if (digit <= 9) return String.valueOf((char)(digit + '0')); return String.valueOf((char)(digit - 10 + 'a')); }","private String var_0 ( int var_1 ) { if ( var_1 <= 9 ) return String . valueOf ( ( char ) ( var_1 + '0' ) ) ; return String . valueOf ( ( char ) ( var_1 - 10 + 'a' ) ) ; } " 944,496. Next Greater Element I_1.java,"private Map generateSubMap(int[] base) { Stack stack = new Stack<>(); Map baseMap = new HashMap<>(); for (int num : base) { while (!stack.isEmpty() && stack.peek() < num) { int pop = stack.pop(); baseMap.put(pop, num); } stack.push(num); } return baseMap; }","private Map < Integer , Integer > var_1 ( int [ ] var_2 ) { Stack < Integer > var_4 = new Stack < > ( ) ; Map < Integer , Integer > var_7 = new HashMap < > ( ) ; for ( int var_8 : var_2 ) { while ( ! var_4 . isEmpty ( ) && var_4 . peek ( ) < var_8 ) { int pop = var_4 . pop ( ) ; var_7 . put ( pop , var_8 ) ; } var_4 . push ( var_8 ) ; } return var_7 ; } " 945,two_pointers_NumberOfMatchingSubsequences_1.java,"private boolean isSubsequence(String S, String P) { int i = 0, j = 0; if (P.length() > S.length()) return false; for (; ; ) { if (j >= P.length()) return true; else if (i >= S.length()) return false; else { if (S.charAt(i) == P.charAt(j)) { i++; j++; } else { i++; } } } }","private boolean var_0 ( String var_2 , String var_3 ) { int var_5 = 0 , var_6 = 0 ; if ( var_3 . length ( ) > var_2 . length ( ) ) return false ; for ( ; ; ) { if ( var_6 >= var_3 . length ( ) ) return true ; else if ( var_5 >= var_2 . length ( ) ) return false ; else { if ( var_2 . charAt ( var_5 ) == var_3 . charAt ( var_6 ) ) { var_5 ++ ; var_6 ++ ; } else { var_5 ++ ; } } } } " 946,array_BattleshipsInABoard_1.java,"public int countBattleships(char[][] board) { int count = 0; for (int i = 0; i < board.length; i++) { for (int j = 0; j < board[0].length; j++) { if (board[i][j] == 'X') { if (i - 1 >= 0) { if (board[i - 1][j] == 'X') continue; } if (j - 1 >= 0) { if (board[i][j - 1] == 'X') { continue; } } count++; } } } return count; }","public int sample_funcname ( char [ ] [ ] var_0 ) { int var_2 = 0 ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { for ( int var_5 = 0 ; var_5 < var_0 [ 0 ] . length ; var_5 ++ ) { if ( var_0 [ var_3 ] [ var_5 ] == 'X' ) { if ( var_3 - 1 >= 0 ) { if ( var_0 [ var_3 - 1 ] [ var_5 ] == 'X' ) continue ; } if ( var_5 - 1 >= 0 ) { if ( var_0 [ var_3 ] [ var_5 - 1 ] == 'X' ) { continue ; } } var_2 ++ ; } } } return var_2 ; } " 947,binary_search_MedianOfTwoSortedArrays_1.java,"public double findMedianSortedArrays(int[] nums1, int[] nums2) { if (nums1.length > nums2.length) return findMedianSortedArrays(nums2, nums1); int T = nums1.length + nums2.length, low = -1, high = -1; int median = (T - 1) / 2; boolean isOdd = false; if ((T % 2) != 0) isOdd = true; int s = 0, e = nums1.length - 1; while (s <= e) { int m = s + (e - s) / 2; if ((median - m - 1) < 0 || nums1[m] >= nums2[median - m - 1]) { e = m - 1; low = m; high = median - m; } else s = m + 1; } if (low == -1) { if (isOdd) return nums2[median - nums1.length]; else return (double) (nums2[median - nums1.length] + nums2[median - nums1.length + 1]) / 2.0D; } else { if (isOdd) return nums1[low] < nums2[high] ? nums1[low] : nums2[high]; else { List list = new ArrayList<>(); list.add(nums1[low]); if (low + 1 < nums1.length) list.add(nums1[low + 1]); list.add(nums2[high]); if (high + 1 < nums2.length) list.add(nums2[high + 1]); Collections.sort(list); return (double) (list.get(0) + list.get(1)) / 2.0; } } }","public double sample_funcname ( int [ ] nums1 , int [ ] nums2 ) { if ( nums1 . length > nums2 . length ) return findMedianSortedArrays ( nums2 , nums1 ) ; int T = nums1 . length + nums2 . length , low = - 1 , high = - 1 ; int median = ( T - 1 ) / 2 ; boolean isOdd = false ; if ( ( T % 2 ) != 0 ) isOdd = true ; int s = 0 , e = nums1 . length - 1 ; while ( s <= e ) { int m = s + ( e - s ) / 2 ; if ( ( median - m - 1 ) < 0 || nums1 [ m ] >= nums2 [ median - m - 1 ] ) { e = m - 1 ; low = m ; high = median - m ; } else s = m + 1 ; } if ( low == - 1 ) { if ( isOdd ) return nums2 [ median - nums1 . length ] ; else return ( double ) ( nums2 [ median - nums1 . length ] + nums2 [ median - nums1 . length + 1 ] ) / 2.0D ; } else { if ( isOdd ) return nums1 [ low ] < nums2 [ high ] ? nums1 [ low ] : nums2 [ high ] ; else { List < Integer > list = new ArrayList < > ( ) ; list . add ( nums1 [ low ] ) ; if ( low + 1 < nums1 . length ) list . add ( nums1 [ low + 1 ] ) ; list . add ( nums2 [ high ] ) ; if ( high + 1 < nums2 . length ) list . add ( nums2 [ high + 1 ] ) ; Collections . sort ( list ) ; return ( double ) ( list . get ( 0 ) + list . get ( 1 ) ) / 2.0 ; } } } " 948,dynamic_programming_PaintHouseII_1.java,"public int minCostII(int[][] costs) { if (costs.length == 0) return 0; int[][] lMin = new int[costs.length][costs[0].length]; int[][] rMin = new int[costs.length][costs[0].length]; for (int i = costs.length - 2; i >= 0; i--) { int min = Integer.MAX_VALUE; for (int j = 0; j < costs[0].length; j++) { lMin[i + 1][j] = min; min = Math.min(min, costs[i + 1][j]); } min = Integer.MAX_VALUE; for (int j = costs[0].length - 1; j >= 0; j--) { rMin[i + 1][j] = min; min = Math.min(min, costs[i + 1][j]); } for (int j = 0; j < costs[0].length; j++) { if (j == 0) { costs[i][j] = costs[i][j] + rMin[i + 1][j]; } else if (j == costs[0].length - 1) { costs[i][j] = costs[i][j] + lMin[i + 1][j]; } else { costs[i][j] = costs[i][j] + Math.min(lMin[i + 1][j], rMin[i + 1][j]); } } } int min = Integer.MAX_VALUE; for (int i = 0; i < costs[0].length; i++) { min = Math.min(min, costs[0][i]); } return min; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int [ ] [ ] var_3 = new int [ var_0 . length ] [ var_0 [ 0 ] . length ] ; int [ ] [ ] var_4 = new int [ var_0 . length ] [ var_0 [ 0 ] . length ] ; for ( int var_6 = var_0 . length - 2 ; var_6 >= 0 ; var_6 -- ) { int min = Integer . MAX_VALUE ; for ( int var_10 = 0 ; var_10 < var_0 [ 0 ] . length ; var_10 ++ ) { var_3 [ var_6 + 1 ] [ var_10 ] = min ; min = Math . min ( min , var_0 [ var_6 + 1 ] [ var_10 ] ) ; } min = Integer . MAX_VALUE ; for ( int var_10 = var_0 [ 0 ] . length - 1 ; var_10 >= 0 ; var_10 -- ) { var_4 [ var_6 + 1 ] [ var_10 ] = min ; min = Math . min ( min , var_0 [ var_6 + 1 ] [ var_10 ] ) ; } for ( int var_10 = 0 ; var_10 < var_0 [ 0 ] . length ; var_10 ++ ) { if ( var_10 == 0 ) { var_0 [ var_6 ] [ var_10 ] = var_0 [ var_6 ] [ var_10 ] + var_4 [ var_6 + 1 ] [ var_10 ] ; } else if ( var_10 == var_0 [ 0 ] . length - 1 ) { var_0 [ var_6 ] [ var_10 ] = var_0 [ var_6 ] [ var_10 ] + var_3 [ var_6 + 1 ] [ var_10 ] ; } else { var_0 [ var_6 ] [ var_10 ] = var_0 [ var_6 ] [ var_10 ] + Math . min ( var_3 [ var_6 + 1 ] [ var_10 ] , var_4 [ var_6 + 1 ] [ var_10 ] ) ; } } } int min = Integer . MAX_VALUE ; for ( int var_6 = 0 ; var_6 < var_0 [ 0 ] . length ; var_6 ++ ) { min = Math . min ( min , var_0 [ 0 ] [ var_6 ] ) ; } return min ; } " 949,dynamic_programming_LongestIncreasingSubsequence_1.java,"public int lengthOfLIS(int[] nums) { if (nums.length == 0) return 0; int[] A = new int[nums.length]; int max = Integer.MIN_VALUE; for (int i = 0, l = nums.length; i < l; i++) { int lis = 1; for (int j = 0; j < i; j++) { if (nums[i] > nums[j]) lis = Math.max(lis, A[j] + 1); } A[i] = lis; max = Math.max(max, A[i]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int [ ] var_3 = new int [ var_0 . length ] ; int max = Integer . MIN_VALUE ; for ( int var_7 = 0 , var_8 = var_0 . length ; var_7 < var_8 ; var_7 ++ ) { int var_10 = 1 ; for ( int var_11 = 0 ; var_11 < var_7 ; var_11 ++ ) { if ( var_0 [ var_7 ] > var_0 [ var_11 ] ) var_10 = Math . max ( var_10 , var_3 [ var_11 ] + 1 ) ; } var_3 [ var_7 ] = var_10 ; max = Math . max ( max , var_3 [ var_7 ] ) ; } return max ; } " 950,dynamic_programming_PalindromePartitioningIII_1.java,"private int count(String s) { int cnt = 0; for (int i = 0, j = s.length() - 1; i < j; i++, j--) { if (s.charAt(i) != s.charAt(j)) { cnt++; } } return cnt; }","private int sample_funcname ( String var_1 ) { int var_3 = 0 ; for ( int var_4 = 0 , var_7 = var_1 . length ( ) - 1 ; var_4 < var_7 ; var_4 ++ , var_7 -- ) { if ( var_1 . charAt ( var_4 ) != var_1 . charAt ( var_7 ) ) { var_3 ++ ; } } return var_3 ; } " 951,binary_search_HIndexII_1.java,"public int hIndex(int[] citations) { if (citations.length == 0) return 0; int s = 0, e = citations.length; int ans = -1; while (s < e) { int m = (s + e) >>> 1; int cit = citations.length - m; if (citations[m] > cit) { if (ans < cit) { ans = cit; } e = m; } else { if (ans < citations[m]) { ans = citations[m]; } s = m + 1; } } return ans; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int var_3 = 0 , var_4 = var_0 . length ; int var_6 = - 1 ; while ( var_3 < var_4 ) { int var_7 = ( var_3 + var_4 ) >>> 1 ; int var_8 = var_0 . length - var_7 ; if ( var_0 [ var_7 ] > var_8 ) { if ( var_6 < var_8 ) { var_6 = var_8 ; } var_4 = var_7 ; } else { if ( var_6 < var_0 [ var_7 ] ) { var_6 = var_0 [ var_7 ] ; } var_3 = var_7 + 1 ; } } return var_6 ; } " 952,array_IncreasingTripletSubsequence_1.java,"public boolean increasingTriplet(int[] nums) { int[] A = new int[3]; Arrays.fill(A, Integer.MAX_VALUE); for (int num : nums) { if (num < A[0]) { A[0] = num; } else if (num < A[1] && num > A[0]) { A[1] = num; } else if (num < A[2] && num > A[1]) { return true; } } return false; }","public boolean var_0 ( int [ ] var_1 ) { int [ ] var_3 = new int [ 3 ] ; Arrays . fill ( var_3 , Integer . MAX_VALUE ) ; for ( int var_8 : var_1 ) { if ( var_8 < var_3 [ 0 ] ) { var_3 [ 0 ] = var_8 ; } else if ( var_8 < var_3 [ 1 ] && var_8 > var_3 [ 0 ] ) { var_3 [ 1 ] = var_8 ; } else if ( var_8 < var_3 [ 2 ] && var_8 > var_3 [ 1 ] ) { return true ; } } return false ; } " 953,string_ZigZagConversion_1.java,"public String convert(String s, int numRows) { if (s == null || s.length() <= numRows || numRows == 1) return s; List list = new ArrayList<>(); char[] A = new char[numRows]; int direction = 1; int n = 1; A[0] = s.charAt(0); for (int j = 1; j < numRows; ) { if (n >= s.length()) break; A[j] = s.charAt(n++); if (j == numRows - 1) { list.add(String.valueOf(A)); A = new char[numRows]; Arrays.fill(A, ' '); direction = 0; } else if (j == 0) { list.add(String.valueOf(A)); A = new char[numRows]; Arrays.fill(A, ' '); direction = 1; } j = direction == 1 ? j + 1 : j - 1; } if (!String.valueOf(A).trim().isEmpty()) list.add(String.valueOf(A)); char[] arr = new char[s.length()]; int k = 0; for (int j = 0; j < numRows; j++) { for (String aList : list) { if (aList.charAt(j) != ' ') arr[k++] = aList.charAt(j); } } return new String(arr).trim(); }","public String var_0 ( String var_2 , int var_3 ) { if ( var_2 == null || var_2 . length ( ) <= var_3 || var_3 == 1 ) return var_2 ; List < String > var_9 = new ArrayList < > ( ) ; char [ ] var_10 = new char [ var_3 ] ; int var_11 = 1 ; int var_12 = 1 ; var_10 [ 0 ] = var_2 . charAt ( 0 ) ; for ( int var_15 = 1 ; var_15 < var_3 ; ) { if ( var_12 >= var_2 . length ( ) ) break ; var_10 [ var_15 ] = var_2 . charAt ( var_12 ++ ) ; if ( var_15 == var_3 - 1 ) { var_9 . add ( String . valueOf ( var_10 ) ) ; var_10 = new char [ var_3 ] ; Arrays . fill ( var_10 , ' ' ) ; var_11 = 0 ; } else if ( var_15 == 0 ) { var_9 . add ( String . valueOf ( var_10 ) ) ; var_10 = new char [ var_3 ] ; Arrays . fill ( var_10 , ' ' ) ; var_11 = 1 ; } var_15 = var_11 == 1 ? var_15 + 1 : var_15 - 1 ; } if ( ! String . valueOf ( var_10 ) . trim ( ) . isEmpty ( ) ) var_9 . add ( String . valueOf ( var_10 ) ) ; char [ ] var_23 = new char [ var_2 . length ( ) ] ; int var_24 = 0 ; for ( int var_15 = 0 ; var_15 < var_3 ; var_15 ++ ) { for ( String var_25 : var_9 ) { if ( var_25 . charAt ( var_15 ) != ' ' ) var_23 [ var_24 ++ ] = var_25 . charAt ( var_15 ) ; } } return new String ( var_23 ) . trim ( ) ; } " 954,dynamic_programming_MaximumSubarray_1.java,"public int maxSubArray(int[] nums) { if (nums.length == 1) return nums[0]; int max = nums[nums.length - 1]; for (int i = nums.length - 2; i >= 0; i--) { nums[i] = Math.max(nums[i], nums[i] + nums[i + 1]); max = Math.max(max, nums[i]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 1 ) return var_0 [ 0 ] ; int max = var_0 [ var_0 . length - 1 ] ; for ( int var_6 = var_0 . length - 2 ; var_6 >= 0 ; var_6 -- ) { var_0 [ var_6 ] = Math . max ( var_0 [ var_6 ] , var_0 [ var_6 ] + var_0 [ var_6 + 1 ] ) ; max = Math . max ( max , var_0 [ var_6 ] ) ; } return max ; } " 955,greedy_StringWithout3A3B_1.java,"public String strWithout3a3b(int A, int B) { StringBuilder sb = new StringBuilder(); while (A > 0 || B > 0) { if (A > B && A > 1 && B > 0) { sb.append(""a"").append(""a""); sb.append(""b""); A -= 2; B -= 1; } else if (B > A && B > 1 && A > 0) { sb.append(""b"").append(""b""); sb.append(""a""); B -= 2; A -= 1; } else { if (A > B && A > 1) { sb.append(""a""); sb.append(""a""); A -= 2; } else if (A > B && A > 0) { sb.append(""a""); A -= 1; } else if (B > A && B > 1) { sb.append(""b""); sb.append(""b""); B -= 2; } else { sb.append(""b""); B -= 1; } } } return sb.toString(); }","public String var_0 ( int var_1 , int var_2 ) { StringBuilder var_4 = new StringBuilder ( ) ; while ( var_1 > 0 || var_2 > 0 ) { if ( var_1 > var_2 && var_1 > 1 && var_2 > 0 ) { var_4 . append ( ""a"" ) . append ( ""a"" ) ; var_4 . append ( ""b"" ) ; var_1 -= 2 ; var_2 -= 1 ; } else if ( var_2 > var_1 && var_2 > 1 && var_1 > 0 ) { var_4 . append ( ""b"" ) . append ( ""b"" ) ; var_4 . append ( ""a"" ) ; var_2 -= 2 ; var_1 -= 1 ; } else { if ( var_1 > var_2 && var_1 > 1 ) { var_4 . append ( ""a"" ) ; var_4 . append ( ""a"" ) ; var_1 -= 2 ; } else if ( var_1 > var_2 && var_1 > 0 ) { var_4 . append ( ""a"" ) ; var_1 -= 1 ; } else if ( var_2 > var_1 && var_2 > 1 ) { var_4 . append ( ""b"" ) ; var_4 . append ( ""b"" ) ; var_2 -= 2 ; } else { var_4 . append ( ""b"" ) ; var_2 -= 1 ; } } } return var_4 . toString ( ) ; } " 956,string_ReverseWordsII_1.java,"public void reverseWords(char[] s) { for (int i = 0, j = s.length - 1; i < j; i++, j--) { char temp = s[i]; s[i] = s[j]; s[j] = temp; } for (int i = 0, j = 0, l = s.length; i < l; ) { if (s[i] == ' ') { if (s[i - 1] == ' ') { j = i; i++; j++; } else { i = i - 1; for (int p = j, q = i; p < q; p++, q--) { char temp = s[p]; s[p] = s[q]; s[q] = temp; } i = i + 1; j = i; i++; j++; } } else if (i == l - 1) { for (int p = j, q = i; p < q; p++, q--) { char temp = s[p]; s[p] = s[q]; s[q] = temp; } j = i; i++; j++; } else { i++; } } }","public void var_0 ( char [ ] var_1 ) { for ( int var_3 = 0 , var_6 = var_1 . length - 1 ; var_3 < var_6 ; var_3 ++ , var_6 -- ) { char var_7 = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_1 [ var_6 ] ; var_1 [ var_6 ] = var_7 ; } for ( int var_3 = 0 , var_6 = 0 , var_8 = var_1 . length ; var_3 < var_8 ; ) { if ( var_1 [ var_3 ] == ' ' ) { if ( var_1 [ var_3 - 1 ] == ' ' ) { var_6 = var_3 ; var_3 ++ ; var_6 ++ ; } else { var_3 = var_3 - 1 ; for ( int var_10 = var_6 , var_11 = var_3 ; var_10 < var_11 ; var_10 ++ , var_11 -- ) { char var_7 = var_1 [ var_10 ] ; var_1 [ var_10 ] = var_1 [ var_11 ] ; var_1 [ var_11 ] = var_7 ; } var_3 = var_3 + 1 ; var_6 = var_3 ; var_3 ++ ; var_6 ++ ; } } else if ( var_3 == var_8 - 1 ) { for ( int var_10 = var_6 , var_11 = var_3 ; var_10 < var_11 ; var_10 ++ , var_11 -- ) { char var_7 = var_1 [ var_10 ] ; var_1 [ var_10 ] = var_1 [ var_11 ] ; var_1 [ var_11 ] = var_7 ; } var_6 = var_3 ; var_3 ++ ; var_6 ++ ; } else { var_3 ++ ; } } } " 957,math_NthMagicalNumber_1.java,"private int check(int N, long num, int A, int B, long lcm) { long sum = (num / A) + (num / B); long common = num / lcm; sum -= common; if (sum == N) return 0; else if (sum > N) return 1; else return -1; }","private int sample_funcname ( int var_0 , long var_1 , int var_2 , int var_3 , long var_4 ) { long var_5 = ( var_1 / var_2 ) + ( var_1 / var_3 ) ; long var_6 = var_1 / var_4 ; var_5 -= var_6 ; if ( var_5 == var_0 ) return 0 ; else if ( var_5 > var_0 ) return 1 ; else return - 1 ; } " 958,string_OneEditDistance_1.java,"private boolean hasDiffOne(String s, String t, boolean sameLength) { int count = 0, i = 0, j = 0; for (int l1 = s.length(), l2 = t.length(); i < l1 && j < l2; ) { if (s.charAt(i) == t.charAt(j)) { i++; j++; } else { if (count > 0) return false; count++; if (sameLength) { i++; j++; } else { i++; } } } if (i == j) { return true; } else { return (s.charAt(s.length() - 1) == t.charAt(t.length() - 1)); } }","private boolean var_0 ( String var_2 , String var_3 , boolean var_5 ) { int var_7 = 0 , var_8 = 0 , var_9 = 0 ; for ( int var_11 = var_2 . length ( ) , var_12 = var_3 . length ( ) ; var_8 < var_11 && var_9 < var_12 ; ) { if ( var_2 . charAt ( var_8 ) == var_3 . charAt ( var_9 ) ) { var_8 ++ ; var_9 ++ ; } else { if ( var_7 > 0 ) return false ; var_7 ++ ; if ( var_5 ) { var_8 ++ ; var_9 ++ ; } else { var_8 ++ ; } } } if ( var_8 == var_9 ) { return true ; } else { return ( var_2 . charAt ( var_2 . length ( ) - 1 ) == var_3 . charAt ( var_3 . length ( ) - 1 ) ) ; } } " 959,two_pointers_SubarraysWithKDifferentIntegers_1.java,"private int calculate(int[] A, int K) { int count = 0; int[] frequency = new int[A.length + 1]; int currCount = 0; for (int i = 0, j = 0; i < A.length; i++) { frequency[A[i]]++; if (frequency[A[i]] == 1) { currCount++; } while (currCount > K) { frequency[A[j]]--; if (frequency[A[j]] == 0) { currCount--; } j++; } count += (i - j + 1); } return count; }","private int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = 0 ; int [ ] var_6 = new int [ var_0 . length + 1 ] ; int var_7 = 0 ; for ( int var_8 = 0 , var_9 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { var_6 [ var_0 [ var_8 ] ] ++ ; if ( var_6 [ var_0 [ var_8 ] ] == 1 ) { var_7 ++ ; } while ( var_7 > var_1 ) { var_6 [ var_0 [ var_9 ] ] -- ; if ( var_6 [ var_0 [ var_9 ] ] == 0 ) { var_7 -- ; } var_9 ++ ; } var_3 += ( var_8 - var_9 + 1 ) ; } return var_3 ; } " 960,dynamic_programming_LargestSumOfAverages_1.java,"public double largestSumOfAverages(int[] A, int K) { double[][] dp = new double[K][A.length]; for (int i = dp[0].length - 1; i >= 0; i--) { dp[0][i] = A[i]; if (i + 1 < dp[0].length) { dp[0][i] += dp[0][i + 1]; } } for (int i = dp[0].length - 1, j = 1; i >= 0; i--, j++) { dp[0][i] = dp[0][i] / j; } for (int i = dp[0].length - 1; i >= 0; i--) { for (int j = 1; j < dp.length; j++) { double sum = 0.0D; for (int k = i, c = 1; k < dp[0].length; k++, c++) { sum += A[k]; if (k + 1 < dp[0].length) { double avg = sum / c; avg += dp[j - 1][k + 1]; dp[j][i] = Math.max(dp[j][i], avg); } } } } return dp[K - 1][0]; }","public double sample_funcname ( int [ ] var_0 , int var_1 ) { double [ ] [ ] var_3 = new double [ var_1 ] [ var_0 . length ] ; for ( int var_6 = var_3 [ 0 ] . length - 1 ; var_6 >= 0 ; var_6 -- ) { var_3 [ 0 ] [ var_6 ] = var_0 [ var_6 ] ; if ( var_6 + 1 < var_3 [ 0 ] . length ) { var_3 [ 0 ] [ var_6 ] += var_3 [ 0 ] [ var_6 + 1 ] ; } } for ( int var_6 = var_3 [ 0 ] . length - 1 , var_7 = 1 ; var_6 >= 0 ; var_6 -- , var_7 ++ ) { var_3 [ 0 ] [ var_6 ] = var_3 [ 0 ] [ var_6 ] / var_7 ; } for ( int var_6 = var_3 [ 0 ] . length - 1 ; var_6 >= 0 ; var_6 -- ) { for ( int var_7 = 1 ; var_7 < var_3 . length ; var_7 ++ ) { double var_9 = 0.0D ; for ( int var_10 = var_6 , var_11 = 1 ; var_10 < var_3 [ 0 ] . length ; var_10 ++ , var_11 ++ ) { var_9 += var_0 [ var_10 ] ; if ( var_10 + 1 < var_3 [ 0 ] . length ) { double var_12 = var_9 / var_11 ; var_12 += var_3 [ var_7 - 1 ] [ var_10 + 1 ] ; var_3 [ var_7 ] [ var_6 ] = Math . max ( var_3 [ var_7 ] [ var_6 ] , var_12 ) ; } } } } return var_3 [ var_1 - 1 ] [ 0 ] ; } " 961,hashing_StringTransformsIntoAnotherString_1.java,"public boolean canConvert(String str1, String str2) { if (str1.length() != str2.length()) return false; if (str1.equals(str2)) return true; Map mapping = new HashMap<>(); for (int i = 0; i < str1.length(); i++) { char c1 = str1.charAt(i); char c2 = str2.charAt(i); if (mapping.containsKey(c1)) { if (mapping.get(c1) != c2) return false; } else { mapping.put(c1, c2); } } Set set = new HashSet<>(); for (char k : mapping.keySet()) { set.add(mapping.get(k)); } return (set.size() < 26); }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 . length ( ) != var_3 . length ( ) ) return false ; if ( var_2 . equals ( var_3 ) ) return true ; Map < Character , Character > var_9 = new HashMap < > ( ) ; for ( int var_11 = 0 ; var_11 < var_2 . length ( ) ; var_11 ++ ) { char var_13 = var_2 . charAt ( var_11 ) ; char var_14 = var_3 . charAt ( var_11 ) ; if ( var_9 . containsKey ( var_13 ) ) { if ( var_9 . get ( var_13 ) != var_14 ) return false ; } else { var_9 . put ( var_13 , var_14 ) ; } } Set < Character > var_20 = new HashSet < > ( ) ; for ( char var_22 : var_9 . keySet ( ) ) { var_20 . add ( var_9 . get ( var_22 ) ) ; } return ( var_20 . size ( ) < 26 ) ; } " 962,backtracking_Subsets_1.java,"public List> subsets(int[] nums) { List> result = new ArrayList<>(); result.add(new ArrayList<>()); for (int i = 0, l = nums.length; i < l; i++) { for (int j = 0, resLen = result.size(); j < resLen; j++) { List newList = new ArrayList<>(result.get(j)); newList.add(nums[i]); result.add(newList); } } return result; }","public List < List < Integer >> var_2 ( int [ ] var_3 ) { List < List < Integer >> var_5 = new ArrayList < > ( ) ; var_5 . add ( new ArrayList < > ( ) ) ; for ( int var_8 = 0 , var_10 = var_3 . length ; var_8 < var_10 ; var_8 ++ ) { for ( int var_11 = 0 , var_13 = var_5 . size ( ) ; var_11 < var_13 ; var_11 ++ ) { List < Integer > var_15 = new ArrayList < > ( var_5 . get ( var_11 ) ) ; var_15 . add ( var_3 [ var_8 ] ) ; var_5 . add ( var_15 ) ; } } return var_5 ; } " 963,dynamic_programming_LongestPaliandromicSubstring_1.java,"public String longestPalindrome(String s) { int l = s.length(); int startIndex = 0; int maxLen = 1; boolean[][] A = new boolean[l][l]; for (int i = 0, j = 0; i < l; i++, j++) A[i][j] = true; for (int i = 0, j = i + 1; j < l; i++, j++) { if (s.charAt(i) == s.charAt(j)) { A[i][j] = true; startIndex = i; maxLen = 2; } } for (int k = 3; k <= l; k++) { for (int i = 0, j = k - 1; j < l; i++, j++) { if (s.charAt(i) == s.charAt(j)) { A[i][j] = A[i + 1][j - 1]; if (A[i][j]) { if (k > maxLen) { startIndex = i; maxLen = k; } } } } } return s.substring(startIndex, startIndex + maxLen); }","public String var_0 ( String var_2 ) { int var_4 = var_2 . length ( ) ; int var_6 = 0 ; int var_8 = 1 ; boolean [ ] [ ] var_10 = new boolean [ var_4 ] [ var_4 ] ; for ( int var_11 = 0 , var_12 = 0 ; var_11 < var_4 ; var_11 ++ , var_12 ++ ) var_10 [ var_11 ] [ var_12 ] = true ; for ( int var_11 = 0 , var_12 = var_11 + 1 ; var_12 < var_4 ; var_11 ++ , var_12 ++ ) { if ( var_2 . charAt ( var_11 ) == var_2 . charAt ( var_12 ) ) { var_10 [ var_11 ] [ var_12 ] = true ; var_6 = var_11 ; var_8 = 2 ; } } for ( int var_16 = 3 ; var_16 <= var_4 ; var_16 ++ ) { for ( int var_11 = 0 , var_12 = var_16 - 1 ; var_12 < var_4 ; var_11 ++ , var_12 ++ ) { if ( var_2 . charAt ( var_11 ) == var_2 . charAt ( var_12 ) ) { var_10 [ var_11 ] [ var_12 ] = var_10 [ var_11 + 1 ] [ var_12 - 1 ] ; if ( var_10 [ var_11 ] [ var_12 ] ) { if ( var_16 > var_8 ) { var_6 = var_11 ; var_8 = var_16 ; } } } } } return var_2 . substring ( var_6 , var_6 + var_8 ) ; } " 964,dynamic_programming_StoneGameIV_2.java,"private void genSquare(int sq, int limit, Set perfectSquare) { if (!perfectSquare.contains(sq)) { perfectSquare.add(sq); if (((long) sq * sq) <= limit) { genSquare(sq * sq, limit, perfectSquare); } } }","private void sample_funcname ( int sq , int limit , Set < Integer > perfectSquare ) { if ( ! perfectSquare . contains ( sq ) ) { perfectSquare . add ( sq ) ; if ( ( ( long ) sq * sq ) <= limit ) { genSquare ( sq * sq , limit , perfectSquare ) ; } } } " 965,hashing_SubstringConcatenationOfWords_1.java,"public List findSubstring(String s, String[] words) { if (words.length == 0) return new ArrayList<>(); int wLen = words[0].length(); int sLen = wLen * words.length; List result = new ArrayList<>(); if (sLen > s.length()) return result; Map countMap = new HashMap<>(); for (String w : words) { countMap.putIfAbsent(w, 0); countMap.put(w, countMap.get(w) + 1); } for (int k = 0; (s.length() - k) >= sLen; k++) { Map subSMap = new HashMap<>(); int i = k; for (int j = i + wLen; (i - k) < sLen; i = j, j += wLen) { String subS = s.substring(i, j); subSMap.putIfAbsent(subS, 0); subSMap.put(subS, subSMap.get(subS) + 1); if (!countMap.containsKey(subS) || subSMap.get(subS) > countMap.get(subS)) { break; } } if ((i - k) >= sLen) { result.add(k); } } return result; }","public List < Integer > var_1 ( String var_3 , String [ ] var_4 ) { if ( var_4 . length == 0 ) return new ArrayList < > ( ) ; int var_8 = var_4 [ 0 ] . length ( ) ; int var_9 = var_8 * var_4 . length ; List < Integer > var_11 = new ArrayList < > ( ) ; if ( var_9 > var_3 . length ( ) ) return var_11 ; Map < String , Integer > var_14 = new HashMap < > ( ) ; for ( String var_15 : var_4 ) { var_14 . putIfAbsent ( var_15 , 0 ) ; var_14 . put ( var_15 , var_14 . get ( var_15 ) + 1 ) ; } for ( int var_20 = 0 ; ( var_3 . length ( ) - var_20 ) >= var_9 ; var_20 ++ ) { Map < String , Integer > var_21 = new HashMap < > ( ) ; int var_22 = var_20 ; for ( int var_23 = var_22 + var_8 ; ( var_22 - var_20 ) < var_9 ; var_22 = var_23 , var_23 += var_8 ) { String var_25 = var_3 . substring ( var_22 , var_23 ) ; var_21 . putIfAbsent ( var_25 , 0 ) ; var_21 . put ( var_25 , var_21 . get ( var_25 ) + 1 ) ; if ( ! var_14 . containsKey ( var_25 ) || var_21 . get ( var_25 ) > var_14 . get ( var_25 ) ) { break ; } } if ( ( var_22 - var_20 ) >= var_9 ) { var_11 . add ( var_20 ) ; } } return var_11 ; } " 966,greedy_LemonadeChange_1.java,"public boolean lemonadeChange(int[] bills) { int five = 0, ten = 0; for (int b : bills) { if (b == 5) { five++; } else if (b == 10) { ten++; if (five > 0) { five--; } else { return false; } } else { if (ten > 0 && five > 0) { ten--; five--; } else if (five > 2) { five -= 3; } else { return false; } } } return true; }","public boolean var_0 ( int [ ] var_1 ) { int var_3 = 0 , var_4 = 0 ; for ( int var_5 : var_1 ) { if ( var_5 == 5 ) { var_3 ++ ; } else if ( var_5 == 10 ) { var_4 ++ ; if ( var_3 > 0 ) { var_3 -- ; } else { return false ; } } else { if ( var_4 > 0 && var_3 > 0 ) { var_4 -- ; var_3 -- ; } else if ( var_3 > 2 ) { var_3 -= 3 ; } else { return false ; } } } return true ; } " 967,dynamic_programming_ContinuousSubarraySum_1.java,"public boolean checkSubarraySum(int[] nums, int k) { Map map = new HashMap<>(); int sum = 0; map.put(0, -1); for (int i = 0; i < nums.length; i++) { sum += nums[i]; int mod = (k == 0) ? sum : sum % k; if (map.containsKey(mod)) { if (i - map.get(mod) > 1) { return true; } } else { map.put(mod, i); } } return false; }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { Map < Integer , Integer > var_6 = new HashMap < > ( ) ; int var_8 = 0 ; var_6 . put ( 0 , - 1 ) ; for ( int var_11 = 0 ; var_11 < var_1 . length ; var_11 ++ ) { var_8 += var_1 [ var_11 ] ; int var_13 = ( var_2 == 0 ) ? var_8 : var_8 % var_2 ; if ( var_6 . containsKey ( var_13 ) ) { if ( var_11 - var_6 . get ( var_13 ) > 1 ) { return true ; } } else { var_6 . put ( var_13 , var_11 ) ; } } return false ; } " 968,heap_Candy_1.java,"public int candy(int[] ratings) { if (ratings.length == 1) return 1; PriorityQueue pq = new PriorityQueue<>((o1, o2) -> Integer.compare(ratings[o1], ratings[o2])); for (int i = 0; i < ratings.length; i++) { pq.offer(i); } int[] count = new int[ratings.length]; while (!pq.isEmpty()) { int index = pq.poll(); if (index - 1 < 0) { if (ratings[index + 1] == ratings[index]) { count[index] = 1; } else { count[index] = count[index + 1] + 1; } } else if (index + 1 >= ratings.length) { if (ratings[index - 1] == ratings[index]) { count[index] = 1; } else { count[index] = count[index - 1] + 1; } } else { if ((ratings[index - 1] == ratings[index]) && (ratings[index + 1] == ratings[index])) { count[index] = 1; } else { if (((ratings[index - 1] == ratings[index]) && (ratings[index + 1] > ratings[index])) || ((ratings[index + 1] == ratings[index]) && (ratings[index - 1] > ratings[index]))) { count[index] = 1; } else if (((ratings[index - 1] == ratings[index]) && (ratings[index + 1] < ratings[index]))) { count[index] = count[index + 1] + 1; } else if (((ratings[index + 1] == ratings[index]) && (ratings[index - 1] < ratings[index]))) { count[index] = count[index - 1] + 1; } else { if (count[index - 1] > count[index + 1]) { count[index] = count[index - 1] + 1; } else { count[index] = count[index + 1] + 1; } } } } } int result = 0; for (int c : count) { result += c; } return result; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 1 ) return 1 ; PriorityQueue < Integer > var_8 = new PriorityQueue < > ( ( var_5 , var_6 ) -> Integer . compare ( var_0 [ var_5 ] , var_0 [ var_6 ] ) ) ; for ( int var_10 = 0 ; var_10 < var_0 . length ; var_10 ++ ) { var_8 . offer ( var_10 ) ; } int [ ] var_12 = new int [ var_0 . length ] ; while ( ! var_8 . isEmpty ( ) ) { int var_15 = var_8 . poll ( ) ; if ( var_15 - 1 < 0 ) { if ( var_0 [ var_15 + 1 ] == var_0 [ var_15 ] ) { var_12 [ var_15 ] = 1 ; } else { var_12 [ var_15 ] = var_12 [ var_15 + 1 ] + 1 ; } } else if ( var_15 + 1 >= var_0 . length ) { if ( var_0 [ var_15 - 1 ] == var_0 [ var_15 ] ) { var_12 [ var_15 ] = 1 ; } else { var_12 [ var_15 ] = var_12 [ var_15 - 1 ] + 1 ; } } else { if ( ( var_0 [ var_15 - 1 ] == var_0 [ var_15 ] ) && ( var_0 [ var_15 + 1 ] == var_0 [ var_15 ] ) ) { var_12 [ var_15 ] = 1 ; } else { if ( ( ( var_0 [ var_15 - 1 ] == var_0 [ var_15 ] ) && ( var_0 [ var_15 + 1 ] > var_0 [ var_15 ] ) ) || ( ( var_0 [ var_15 + 1 ] == var_0 [ var_15 ] ) && ( var_0 [ var_15 - 1 ] > var_0 [ var_15 ] ) ) ) { var_12 [ var_15 ] = 1 ; } else if ( ( ( var_0 [ var_15 - 1 ] == var_0 [ var_15 ] ) && ( var_0 [ var_15 + 1 ] < var_0 [ var_15 ] ) ) ) { var_12 [ var_15 ] = var_12 [ var_15 + 1 ] + 1 ; } else if ( ( ( var_0 [ var_15 + 1 ] == var_0 [ var_15 ] ) && ( var_0 [ var_15 - 1 ] < var_0 [ var_15 ] ) ) ) { var_12 [ var_15 ] = var_12 [ var_15 - 1 ] + 1 ; } else { if ( var_12 [ var_15 - 1 ] > var_12 [ var_15 + 1 ] ) { var_12 [ var_15 ] = var_12 [ var_15 - 1 ] + 1 ; } else { var_12 [ var_15 ] = var_12 [ var_15 + 1 ] + 1 ; } } } } } int var_16 = 0 ; for ( int var_17 : var_12 ) { var_16 += var_17 ; } return var_16 ; } " 969,string_MultiplyStrings_1.java,"private String add(String s1, String s2) { String result = """"; int carry = 0; int i = s1.length() - 1, j = s2.length() - 1; for (; i >= 0 || j >= 0; i--, j--) { int l = (i >= 0) ? Integer.parseInt(String.valueOf(s1.charAt(i))) : 0; int r = (j >= 0) ? Integer.parseInt(String.valueOf(s2.charAt(j))) : 0; int sum = l + r + carry; carry = sum / 10; result = sum % 10 + result; } if (carry > 0) { result = carry + result; } return result; }","private String var_0 ( String var_2 , String var_3 ) { String var_5 = """" ; int var_7 = 0 ; int var_10 = var_2 . length ( ) - 1 , var_11 = var_3 . length ( ) - 1 ; for ( ; var_10 >= 0 || var_11 >= 0 ; var_10 -- , var_11 -- ) { int var_16 = ( var_10 >= 0 ) ? Integer . parseInt ( String . valueOf ( var_2 . charAt ( var_10 ) ) ) : 0 ; int var_17 = ( var_11 >= 0 ) ? Integer . parseInt ( String . valueOf ( var_3 . charAt ( var_11 ) ) ) : 0 ; int var_18 = var_16 + var_17 + var_7 ; var_7 = var_18 / 10 ; var_5 = var_18 % 10 + var_5 ; } if ( var_7 > 0 ) { var_5 = var_7 + var_5 ; } return var_5 ; } " 970,dynamic_programming_NonNegativeIntegersWithoutConsecutiveOnes_1.java,"public int findIntegers(int num) { int msbIndex = 0; for (int i = 0; i < 31; i++) { if (((1 << i) & num) > 0) { msbIndex = i; } } int[][] DP1 = new int[2][msbIndex + 1]; int[][] DP2 = new int[2][msbIndex + 2]; for (int i = msbIndex; i >= 0; i--) { if (i == msbIndex) { DP1[0][msbIndex] = 1; DP1[1][msbIndex] = 1; } else { DP1[0][i] = DP1[0][i + 1] + DP1[1][i + 1]; DP1[1][i] = DP1[0][i + 1]; } } int[] bits = new int[msbIndex + 1]; boolean bitFlipped = false; for (int i = msbIndex, j = 0; i >= 0; i--, j++) { if (j == 0) { bits[j] = 1; } else { if (bitFlipped) { bits[j] = bits[j - 1] == 0 ? 1 : 0; } else { if (((1 << i) & num) > 0) { if (bits[j - 1] > 0) { bits[j] = 0; bitFlipped = true; } else bits[j] = 1; } } } } DP2[0][msbIndex + 1] = 1; for (int i = bits.length - 1; i >= 0; i--) { if (bits[i] == 0) { DP2[0][i] = DP2[0][i + 1] + DP2[1][i + 1]; if (bits[i - 1] == 0) { DP2[1][i] = (i == bits.length - 1) ? 1 : DP1[0][i + 1]; } } else { DP2[1][i] = DP2[0][i + 1]; } } return (DP1[0][0] + DP1[1][0]) - (DP2[0][0] + DP2[1][0]) + 1; }","public int sample_funcname ( int var_0 ) { int var_2 = 0 ; for ( int var_3 = 0 ; var_3 < 31 ; var_3 ++ ) { if ( ( ( 1 << var_3 ) & var_0 ) > 0 ) { var_2 = var_3 ; } } int [ ] [ ] var_7 = new int [ 2 ] [ var_2 + 1 ] ; int [ ] [ ] var_8 = new int [ 2 ] [ var_2 + 2 ] ; for ( int var_3 = var_2 ; var_3 >= 0 ; var_3 -- ) { if ( var_3 == var_2 ) { var_7 [ 0 ] [ var_2 ] = 1 ; var_7 [ 1 ] [ var_2 ] = 1 ; } else { var_7 [ 0 ] [ var_3 ] = var_7 [ 0 ] [ var_3 + 1 ] + var_7 [ 1 ] [ var_3 + 1 ] ; var_7 [ 1 ] [ var_3 ] = var_7 [ 0 ] [ var_3 + 1 ] ; } } int [ ] var_9 = new int [ var_2 + 1 ] ; boolean var_12 = false ; for ( int var_3 = var_2 , var_11 = 0 ; var_3 >= 0 ; var_3 -- , var_11 ++ ) { if ( var_11 == 0 ) { var_9 [ var_11 ] = 1 ; } else { if ( var_12 ) { var_9 [ var_11 ] = var_9 [ var_11 - 1 ] == 0 ? 1 : 0 ; } else { if ( ( ( 1 << var_3 ) & var_0 ) > 0 ) { if ( var_9 [ var_11 - 1 ] > 0 ) { var_9 [ var_11 ] = 0 ; var_12 = true ; } else var_9 [ var_11 ] = 1 ; } } } } var_8 [ 0 ] [ var_2 + 1 ] = 1 ; for ( int var_3 = var_9 . length - 1 ; var_3 >= 0 ; var_3 -- ) { if ( var_9 [ var_3 ] == 0 ) { var_8 [ 0 ] [ var_3 ] = var_8 [ 0 ] [ var_3 + 1 ] + var_8 [ 1 ] [ var_3 + 1 ] ; if ( var_9 [ var_3 - 1 ] == 0 ) { var_8 [ 1 ] [ var_3 ] = ( var_3 == var_9 . length - 1 ) ? 1 : var_7 [ 0 ] [ var_3 + 1 ] ; } } else { var_8 [ 1 ] [ var_3 ] = var_8 [ 0 ] [ var_3 + 1 ] ; } } return ( var_7 [ 0 ] [ 0 ] + var_7 [ 1 ] [ 0 ] ) - ( var_8 [ 0 ] [ 0 ] + var_8 [ 1 ] [ 0 ] ) + 1 ; } " 971,dynamic_programming_BombEnemy_1.java,"public int maxKilledEnemies(char[][] grid) { int[][] DP1 = new int[grid.length][grid[0].length]; int[][] DP2 = new int[grid.length][grid[0].length]; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[0].length; j++) { if (grid[i][j] == 'E') { DP1[i][j] = 1; } if (grid[i][j] != 'W') { if (j - 1 >= 0) { DP1[i][j] += DP1[i][j - 1]; } if (i - 1 >= 0) { DP1[i][j] += DP1[i - 1][j]; } } } } for (int i = grid.length - 1; i >= 0; i--) { for (int j = grid[0].length - 1; j >= 0; j--) { if (grid[i][j] == 'E') { DP2[i][j] = 1; } if (grid[i][j] != 'W') { if (j + 1 < grid[0].length) { DP2[i][j] += DP2[i][j + 1]; } if (i + 1 < grid.length) { DP2[i][j] += DP2[i + 1][j]; } } } } int max = 0; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[0].length; j++) { if (grid[i][j] == '0') { max = Math.max(max, DP1[i][j] + DP2[i][j]); } } } return max; }","public int sample_funcname ( char [ ] [ ] var_0 ) { int [ ] [ ] var_3 = new int [ var_0 . length ] [ var_0 [ 0 ] . length ] ; int [ ] [ ] var_4 = new int [ var_0 . length ] [ var_0 [ 0 ] . length ] ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { for ( int var_6 = 0 ; var_6 < var_0 [ 0 ] . length ; var_6 ++ ) { if ( var_0 [ var_5 ] [ var_6 ] == 'E' ) { var_3 [ var_5 ] [ var_6 ] = 1 ; } if ( var_0 [ var_5 ] [ var_6 ] != 'W' ) { if ( var_6 - 1 >= 0 ) { var_3 [ var_5 ] [ var_6 ] += var_3 [ var_5 ] [ var_6 - 1 ] ; } if ( var_5 - 1 >= 0 ) { var_3 [ var_5 ] [ var_6 ] += var_3 [ var_5 - 1 ] [ var_6 ] ; } } } } for ( int var_5 = var_0 . length - 1 ; var_5 >= 0 ; var_5 -- ) { for ( int var_6 = var_0 [ 0 ] . length - 1 ; var_6 >= 0 ; var_6 -- ) { if ( var_0 [ var_5 ] [ var_6 ] == 'E' ) { var_4 [ var_5 ] [ var_6 ] = 1 ; } if ( var_0 [ var_5 ] [ var_6 ] != 'W' ) { if ( var_6 + 1 < var_0 [ 0 ] . length ) { var_4 [ var_5 ] [ var_6 ] += var_4 [ var_5 ] [ var_6 + 1 ] ; } if ( var_5 + 1 < var_0 . length ) { var_4 [ var_5 ] [ var_6 ] += var_4 [ var_5 + 1 ] [ var_6 ] ; } } } } int max = 0 ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { for ( int var_6 = 0 ; var_6 < var_0 [ 0 ] . length ; var_6 ++ ) { if ( var_0 [ var_5 ] [ var_6 ] == '0' ) { max = Math . max ( max , var_3 [ var_5 ] [ var_6 ] + var_4 [ var_5 ] [ var_6 ] ) ; } } } return max ; } " 972,hashing_MaximumSizeSubarraySumEqualsk_1.java,"public int maxSubArrayLen(int[] nums, int k) { Map index = new HashMap<>(); int sum = 0; for (int i = 0; i < nums.length; i++) { sum += nums[i]; index.putIfAbsent(sum, i); } sum = 0; int ans = 0; for (int i = 0; i < nums.length; i++) { sum += nums[i]; if (sum == k) { ans = Math.max(ans, i + 1); } else { int exp = sum - k; if (index.containsKey(exp)) { int farLeft = index.get(exp); if (farLeft < i) { ans = Math.max(ans, i - index.get(exp)); } } } } return ans; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { Map < Integer , Integer > var_5 = new HashMap < > ( ) ; int var_7 = 0 ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { var_7 += var_0 [ var_8 ] ; var_5 . putIfAbsent ( var_7 , var_8 ) ; } var_7 = 0 ; int var_11 = 0 ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { var_7 += var_0 [ var_8 ] ; if ( var_7 == var_1 ) { var_11 = Math . max ( var_11 , var_8 + 1 ) ; } else { int var_15 = var_7 - var_1 ; if ( var_5 . containsKey ( var_15 ) ) { int var_18 = var_5 . get ( var_15 ) ; if ( var_18 < var_8 ) { var_11 = Math . max ( var_11 , var_8 - var_5 . get ( var_15 ) ) ; } } } } return var_11 ; } " 973,string_RepeatedSubstringPattern_1.java,"public boolean repeatedSubstringPattern(String s) { boolean found; for (int i = 1, l = s.length(); i < l; i++) { found = true; String subI = s.substring(0, i); int j = i; if (j >= l) return false; while (j < l) { if ((j + i) >= l + 1) return false; String subJ = s.substring(j, j + i); if (!subI.equals(subJ)) { found = false; break; } j += i; } if (found) return true; } return false; }","public boolean var_0 ( String var_2 ) { boolean var_4 ; for ( int var_6 = 1 , var_8 = var_2 . length ( ) ; var_6 < var_8 ; var_6 ++ ) { var_4 = true ; String var_11 = var_2 . substring ( 0 , var_6 ) ; int var_12 = var_6 ; if ( var_12 >= var_8 ) return false ; while ( var_12 < var_8 ) { if ( ( var_12 + var_6 ) >= var_8 + 1 ) return false ; String var_13 = var_2 . substring ( var_12 , var_12 + var_6 ) ; if ( ! var_11 . equals ( var_13 ) ) { var_4 = false ; break ; } var_12 += var_6 ; } if ( var_4 ) return true ; } return false ; } " 974,dynamic_programming_StoneGame_1.java,"private int dp(int[][] A, int[] piles, int i, int j, int sum, int p, int sumA, int sumB) { if (A[p][sum] != -1) return A[p][sum]; else { if (p == 0) { if (i <= j) { int result = dp(A, piles, i + 1, j, sum - piles[i], (p + 1) % 2, sumA + piles[i], sumB); if (result == 0) { A[p][sum] = 1; return 1; } else { result = dp(A, piles, i, j - 1, sum - piles[j], (p + 1) % 2, sumA + piles[j], sumB); A[p][sum] = result; return result; } } else { if (sumA > sumB) return 1; else return 0; } } else { if (i <= j) { int result = dp(A, piles, i + 1, j, sum - piles[i], (p + 1) % 2, sumA, sumB + piles[i]); if (result == 0) { A[p][sum] = 1; return 1; } else { result = dp(A, piles, i, j - 1, sum - piles[j], (p + 1) % 2, sumA, sumB + piles[j]); A[p][sum] = result; return result; } } else { if (sumB > sumA) return 1; else return 0; } } } }","private int sample_funcname ( int [ ] [ ] A , int [ ] piles , int i , int j , int sum , int p , int sumA , int sumB ) { if ( A [ p ] [ sum ] != - 1 ) return A [ p ] [ sum ] ; else { if ( p == 0 ) { if ( i <= j ) { int result = dp ( A , piles , i + 1 , j , sum - piles [ i ] , ( p + 1 ) % 2 , sumA + piles [ i ] , sumB ) ; if ( result == 0 ) { A [ p ] [ sum ] = 1 ; return 1 ; } else { result = dp ( A , piles , i , j - 1 , sum - piles [ j ] , ( p + 1 ) % 2 , sumA + piles [ j ] , sumB ) ; A [ p ] [ sum ] = result ; return result ; } } else { if ( sumA > sumB ) return 1 ; else return 0 ; } } else { if ( i <= j ) { int result = dp ( A , piles , i + 1 , j , sum - piles [ i ] , ( p + 1 ) % 2 , sumA , sumB + piles [ i ] ) ; if ( result == 0 ) { A [ p ] [ sum ] = 1 ; return 1 ; } else { result = dp ( A , piles , i , j - 1 , sum - piles [ j ] , ( p + 1 ) % 2 , sumA , sumB + piles [ j ] ) ; A [ p ] [ sum ] = result ; return result ; } } else { if ( sumB > sumA ) return 1 ; else return 0 ; } } } } " 975,hashing_BrickWall_1.java,"public int leastBricks(List> wall) { for (List row : wall) { int prefix = 0; for (int i = 0, l = row.size(); i < l; i++) { prefix += row.get(i); row.set(i, prefix); } } int result = Integer.MIN_VALUE; Map map = new HashMap<>(); for (List row : wall) { for (int i = 0, l = row.size(); i < l - 1; i++) { int prefix = row.get(i); if (map.containsKey(prefix)) { int plusOne = map.get(prefix) + 1; map.put(prefix, plusOne); result = Math.max(result, plusOne); } else { map.put(prefix, 1); result = Math.max(result, 1); } } } return (result == Integer.MIN_VALUE) ? wall.size() : wall.size() - result; }","public int sample_funcname ( List < List < Integer >> var_2 ) { for ( List < Integer > var_3 : var_2 ) { int var_5 = 0 ; for ( int var_6 = 0 , var_8 = var_3 . size ( ) ; var_6 < var_8 ; var_6 ++ ) { var_5 += var_3 . get ( var_6 ) ; var_3 . set ( var_6 , var_5 ) ; } } int var_12 = Integer . MIN_VALUE ; Map < Integer , Integer > var_15 = new HashMap < > ( ) ; for ( List < Integer > var_3 : var_2 ) { for ( int var_6 = 0 , var_8 = var_3 . size ( ) ; var_6 < var_8 - 1 ; var_6 ++ ) { int var_5 = var_3 . get ( var_6 ) ; if ( var_15 . containsKey ( var_5 ) ) { int var_18 = var_15 . get ( var_5 ) + 1 ; var_15 . put ( var_5 , var_18 ) ; var_12 = Math . max ( var_12 , var_18 ) ; } else { var_15 . put ( var_5 , 1 ) ; var_12 = Math . max ( var_12 , 1 ) ; } } } return ( var_12 == Integer . MIN_VALUE ) ? var_2 . size ( ) : var_2 . size ( ) - var_12 ; } " 976,backtracking_GenerateParentheses_1.java,"private void backTrack(List list, String str, int open, int close, int n) { if (str.length() == n * 2) { list.add(str); } else { if (open < n) backTrack(list, str.concat(""(""), open + 1, close, n); if (close < open) backTrack(list, str.concat("")""), open, close + 1, n); } }","private void sample_funcname ( List < String > list , String str , int open , int close , int n ) { if ( str . length ( ) == n * 2 ) { list . add ( str ) ; } else { if ( open < n ) backTrack ( list , str . concat ( ""("" ) , open + 1 , close , n ) ; if ( close < open ) backTrack ( list , str . concat ( "")"" ) , open , close + 1 , n ) ; } } " 977,dynamic_programming_NumberOfLIS_1.java,"public int findNumberOfLIS(int[] nums) { if (nums.length == 0) return 0; int[] length = new int[nums.length]; length[0] = 1; int maxVal = 1; for (int i = 1; i < nums.length; i++) { int max = 1; for (int j = 0; j < i; j++) { if (nums[i] > nums[j]) { max = Math.max(max, length[j] + 1); maxVal = Math.max(maxVal, max); } } length[i] = max; } int[] count = new int[nums.length]; count[0] = 1; for (int i = 1; i < length.length; i++) { for (int j = 0; j < i; j++) { if ((length[j] + 1 == length[i]) && (nums[j] < nums[i])) { count[i] += count[j]; } } if (count[i] == 0) { count[i] = 1; } } int ans = 0; for (int i = 0; i < length.length; i++) { if (length[i] == maxVal) { ans += count[i]; } } return ans; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int [ ] length = new int [ var_0 . length ] ; length [ 0 ] = 1 ; int var_4 = 1 ; for ( int var_5 = 1 ; var_5 < var_0 . length ; var_5 ++ ) { int max = 1 ; for ( int var_7 = 0 ; var_7 < var_5 ; var_7 ++ ) { if ( var_0 [ var_5 ] > var_0 [ var_7 ] ) { max = Math . max ( max , length [ var_7 ] + 1 ) ; var_4 = Math . max ( var_4 , max ) ; } } length [ var_5 ] = max ; } int [ ] var_9 = new int [ var_0 . length ] ; var_9 [ 0 ] = 1 ; for ( int var_5 = 1 ; var_5 < length . length ; var_5 ++ ) { for ( int var_7 = 0 ; var_7 < var_5 ; var_7 ++ ) { if ( ( length [ var_7 ] + 1 == length [ var_5 ] ) && ( var_0 [ var_7 ] < var_0 [ var_5 ] ) ) { var_9 [ var_5 ] += var_9 [ var_7 ] ; } } if ( var_9 [ var_5 ] == 0 ) { var_9 [ var_5 ] = 1 ; } } int var_10 = 0 ; for ( int var_5 = 0 ; var_5 < length . length ; var_5 ++ ) { if ( length [ var_5 ] == var_4 ) { var_10 += var_9 [ var_5 ] ; } } return var_10 ; } " 978,greedy_JumpGame_1.java,"public boolean canJump(int[] nums) { if (nums.length == 0) return false; int min = nums.length - 1, max = nums.length - 1; for (int i = nums.length - 2; i >= 0; i--) { if ((nums[i] + i) >= min) min = i; } return (min == 0); }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 . length == 0 ) return false ; int var_5 = var_1 . length - 1 , var_6 = var_1 . length - 1 ; for ( int var_8 = var_1 . length - 2 ; var_8 >= 0 ; var_8 -- ) { if ( ( var_1 [ var_8 ] + var_8 ) >= var_5 ) var_5 = var_8 ; } return ( var_5 == 0 ) ; } " 979,dynamic_programming_ConcatenatedWords_1.java,"private boolean concatenatedWordsPossible(String word, Set dictionary) { boolean[] D = new boolean[word.length() + 1]; D[word.length()] = true; dictionary.remove(word); for (int i = word.length() - 1; i >= 0; i--) { for (int j = i, l = word.length(); j < l; j++) { String subStr = word.substring(i, j + 1); if (dictionary.contains(subStr) && D[j + 1]) { D[i] = true; break; } } } dictionary.add(word); return D[0]; }","private boolean var_0 ( String var_2 , Set < String > var_4 ) { boolean [ ] var_8 = new boolean [ var_2 . length ( ) + 1 ] ; var_8 [ var_2 . length ( ) ] = true ; var_4 . remove ( var_2 ) ; for ( int var_10 = var_2 . length ( ) - 1 ; var_10 >= 0 ; var_10 -- ) { for ( int var_12 = var_10 , var_13 = var_2 . length ( ) ; var_12 < var_13 ; var_12 ++ ) { String var_15 = var_2 . substring ( var_10 , var_12 + 1 ) ; if ( var_4 . contains ( var_15 ) && var_8 [ var_12 + 1 ] ) { var_8 [ var_10 ] = true ; break ; } } } var_4 . add ( var_2 ) ; return var_8 [ 0 ] ; } " 980,hashing_GroupsOfSpecialEquivalentStrings_1.java,"public int numSpecialEquivGroups(String[] A) { Set set = new HashSet<>(); for (String s : A) { StringBuilder temp1 = new StringBuilder(); for (int i = 0, l = s.length(); i < l; i += 2) { char c = s.charAt(i); temp1.append(c); } StringBuilder temp2 = new StringBuilder(); if (s.length() > 1) { for (int i = 1, l = s.length(); i < l; i += 2) { char c = s.charAt(i); temp2.append(c); } } char[] temp1Chars = temp1.toString().toCharArray(); char[] temp2Chars = temp2.toString().toCharArray(); Arrays.sort(temp1Chars); Arrays.sort(temp2Chars); set.add(String.valueOf(temp1Chars) + ""+"" + String.valueOf(temp2Chars)); } return set.size(); }","public int sample_funcname ( String [ ] var_1 ) { Set < String > var_4 = new HashSet < > ( ) ; for ( String var_5 : var_1 ) { StringBuilder var_7 = new StringBuilder ( ) ; for ( int var_9 = 0 , var_11 = var_5 . length ( ) ; var_9 < var_11 ; var_9 += 2 ) { char var_14 = var_5 . charAt ( var_9 ) ; var_7 . append ( var_14 ) ; } StringBuilder var_16 = new StringBuilder ( ) ; if ( var_5 . length ( ) > 1 ) { for ( int var_9 = 1 , var_11 = var_5 . length ( ) ; var_9 < var_11 ; var_9 += 2 ) { char var_14 = var_5 . charAt ( var_9 ) ; var_16 . append ( var_14 ) ; } } char [ ] var_20 = var_7 . toString ( ) . toCharArray ( ) ; char [ ] var_21 = var_16 . toString ( ) . toCharArray ( ) ; Arrays . sort ( var_20 ) ; Arrays . sort ( var_21 ) ; var_4 . add ( String . valueOf ( var_20 ) + ""+"" + String . valueOf ( var_21 ) ) ; } return var_4 . size ( ) ; } " 981,string_ShortestPalindrome_1.java,"boolean isPaliandrome(String s, int x, int y) { for (int i = x, j = y; i < j; i++, j--) { if (s.charAt(i) != s.charAt(j)) return false; } return true; }","boolean var_0 ( String var_2 , int var_3 , int var_4 ) { for ( int var_5 = var_3 , var_6 = var_4 ; var_5 < var_6 ; var_5 ++ , var_6 -- ) { if ( var_2 . charAt ( var_5 ) != var_2 . charAt ( var_6 ) ) return false ; } return true ; } " 982,string_SimplifyPath_1.java,"public String simplifyPath(String path) { if (path == null || path.isEmpty()) return ""/""; StringTokenizer st = new StringTokenizer(path, ""/""); Deque dQueue = new ArrayDeque<>(); while (st.hasMoreTokens()) { String token = st.nextToken(); if (token.trim().equals("".."")) { if (!dQueue.isEmpty()) dQueue.pop(); } else if (token.trim().equals(""."")) { } else dQueue.push(token); } if (dQueue.isEmpty()) return ""/""; StringBuilder finalStr = new StringBuilder(); while (!dQueue.isEmpty()) { finalStr.append(""/"").append(dQueue.removeLast()); } return finalStr.toString(); }","public String var_0 ( String var_2 ) { if ( var_2 == null || var_2 . isEmpty ( ) ) return ""/"" ; StringTokenizer var_7 = new StringTokenizer ( var_2 , ""/"" ) ; Deque < String > var_10 = new ArrayDeque < > ( ) ; while ( var_7 . hasMoreTokens ( ) ) { String var_13 = var_7 . nextToken ( ) ; if ( var_13 . trim ( ) . equals ( "".."" ) ) { if ( ! var_10 . isEmpty ( ) ) var_10 . pop ( ) ; } else if ( var_13 . trim ( ) . equals ( ""."" ) ) { } else var_10 . push ( var_13 ) ; } if ( var_10 . isEmpty ( ) ) return ""/"" ; StringBuilder var_21 = new StringBuilder ( ) ; while ( ! var_10 . isEmpty ( ) ) { var_21 . append ( ""/"" ) . append ( var_10 . removeLast ( ) ) ; } return var_21 . toString ( ) ; } " 983,binary_search_ArmstrongNumber_1.java,"private long power(int n, int p) { long res = 1L; for (int i = 0; i < p; i++) { res *= n; } return res; }","private long sample_funcname ( int var_0 , int var_1 ) { long var_3 = 1L ; for ( int var_5 = 0 ; var_5 < var_1 ; var_5 ++ ) { var_3 *= var_0 ; } return var_3 ; } " 984,string_ReverseWordsInAString_1.java,"public String reverseWords(String s) { if (s == null || s.isEmpty()) return """"; StringBuilder sb = new StringBuilder(s.trim()); String reverse = sb.reverse().toString(); StringTokenizer st = new StringTokenizer(reverse, "" ""); List list = new ArrayList<>(); while (st.hasMoreTokens()) { list.add(st.nextToken()); } for (int i = 0, l = list.size(); i < l; i++) { String str = list.get(i); String newStr = new StringBuilder(str).reverse().toString(); list.set(i, newStr); } StringBuilder result = new StringBuilder(); for (String str : list) { result.append(str).append("" ""); } return result.toString().trim(); }","public String var_0 ( String var_2 ) { if ( var_2 == null || var_2 . isEmpty ( ) ) return """" ; StringBuilder var_8 = new StringBuilder ( var_2 . trim ( ) ) ; String reverse = var_8 . reverse ( ) . toString ( ) ; StringTokenizer var_13 = new StringTokenizer ( reverse , "" "" ) ; List < String > var_16 = new ArrayList < > ( ) ; while ( var_13 . hasMoreTokens ( ) ) { var_16 . add ( var_13 . nextToken ( ) ) ; } for ( int var_21 = 0 , var_23 = var_16 . size ( ) ; var_21 < var_23 ; var_21 ++ ) { String var_25 = var_16 . get ( var_21 ) ; String var_26 = new StringBuilder ( var_25 ) . reverse ( ) . toString ( ) ; var_16 . set ( var_21 , var_26 ) ; } StringBuilder var_28 = new StringBuilder ( ) ; for ( String var_25 : var_16 ) { var_28 . append ( var_25 ) . append ( "" "" ) ; } return var_28 . toString ( ) . trim ( ) ; } " 985,math_NthDigit_1.java,"public int findNthDigit(int n) { if (n >= 1 && n <= 9) return n; long sum = 0L; for (int i = 0; ; i++) { long pow = (9 * (new Double(Math.pow(10, i)).longValue())) * (i + 1); sum += pow; if (sum >= n) { long diff = (long) n - (sum - pow); long num = diff / (i + 1); long mod = diff % (i + 1); long result = new Double(Math.pow(10, i)).intValue() + (num - 1) + (mod > 0 ? 1 : 0); String resultStr = String.valueOf(result); return (mod == 0) ? Integer.parseInt(String.valueOf(resultStr.charAt(resultStr.length() - 1))) : Integer.parseInt(String.valueOf(resultStr.charAt((int) mod - 1))); } } }","public int sample_funcname ( int var_0 ) { if ( var_0 >= 1 && var_0 <= 9 ) return var_0 ; long var_4 = 0L ; for ( int var_6 = 0 ; ; var_6 ++ ) { long pow = ( 9 * ( new Double ( Math . pow ( 10 , var_6 ) ) . longValue ( ) ) ) * ( var_6 + 1 ) ; var_4 += pow ; if ( var_4 >= var_0 ) { long var_12 = ( long ) var_0 - ( var_4 - pow ) ; long var_13 = var_12 / ( var_6 + 1 ) ; long var_14 = var_12 % ( var_6 + 1 ) ; long var_16 = new Double ( Math . pow ( 10 , var_6 ) ) . intValue ( ) + ( var_13 - 1 ) + ( var_14 > 0 ? 1 : 0 ) ; String var_19 = String . valueOf ( var_16 ) ; return ( var_14 == 0 ) ? Integer . parseInt ( String . valueOf ( var_19 . charAt ( var_19 . length ( ) - 1 ) ) ) : Integer . parseInt ( String . valueOf ( var_19 . charAt ( ( int ) var_14 - 1 ) ) ) ; } } } " 986,array_SortArrayByParityII_1.java,"public int[] sortArrayByParityII(int[] A) { int[] R = new int[A.length]; int i = 0, j = 1; for (int a : A) { if (a % 2 == 0) { R[i] = a; i += 2; } else { R[j] = a; j += 2; } } return R; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int [ ] var_2 = new int [ var_0 . length ] ; int var_4 = 0 , var_6 = 1 ; for ( int var_7 : var_0 ) { if ( var_7 % 2 == 0 ) { var_2 [ var_4 ] = var_7 ; var_4 += 2 ; } else { var_2 [ var_6 ] = var_7 ; var_6 += 2 ; } } return var_2 ; } " 987,binary_search_FirstBadVersion_1.java,"private boolean isBadVersion(int n) { if (n >= 1702766719) return true; return false; }","private boolean var_0 ( int var_1 ) { if ( var_1 >= 1702766719 ) return true ; return false ; } " 988,greedy_CourseScheduleIII_1.java,"public int scheduleCourse(int[][] courses) { Arrays.sort(courses, (a, b) -> a[1] - b[1]); Queue pq = new PriorityQueue<>((a, b) -> b - a); int time = 0; for (int[] course : courses) { time += course[0]; pq.add(course[0]); if (time > course[1]) time -= pq.poll(); } return pq.size(); }","public int sample_funcname ( int [ ] [ ] var_0 ) { Arrays . sort ( var_0 , ( var_3 , var_4 ) -> var_3 [ 1 ] - var_4 [ 1 ] ) ; Queue < Integer > var_9 = new PriorityQueue < > ( ( var_3 , var_4 ) -> var_4 - var_3 ) ; int var_11 = 0 ; for ( int [ ] var_12 : var_0 ) { var_11 += var_12 [ 0 ] ; var_9 . add ( var_12 [ 0 ] ) ; if ( var_11 > var_12 [ 1 ] ) var_11 -= var_9 . poll ( ) ; } return var_9 . size ( ) ; } " 989,divide_and_conquer_TwentyFourGame_1.java,"private void swap(int i, int j, int[] nums) { int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp; }","private void var_0 ( int var_1 , int var_2 , int [ ] var_3 ) { int var_4 = var_3 [ var_1 ] ; var_3 [ var_1 ] = var_3 [ var_2 ] ; var_3 [ var_2 ] = var_4 ; } " 990,bit_manipulation_GrayCode_1.java,"public List grayCode(int n) { List result = new ArrayList<>(); for (int i = 0; i <= ((1 << n) - 1); i++) result.add(i ^ (i >> 1)); return result; }","public List < Integer > var_1 ( int var_2 ) { List < Integer > var_5 = new ArrayList < > ( ) ; for ( int var_7 = 0 ; var_7 <= ( ( 1 << var_2 ) - 1 ) ; var_7 ++ ) var_5 . add ( var_7 ^ ( var_7 >> 1 ) ) ; return var_5 ; } " 991,binary_search_MinSortedRotatedArray_1.java,"public int findMin(int[] nums) { if (nums.length == 0) return 0; else if (nums.length == 1) return nums[0]; int low = 0, high = nums.length - 1; while (low < high) { int mid = (low + high) / 2; if (mid > 0 && nums[mid] < nums[mid - 1]) return nums[mid]; if (nums[low] > nums[mid]) high = mid - 1; else if (nums[high] < nums[mid]) low = mid + 1; else high = mid - 1; } return nums[low]; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; else if ( var_0 . length == 1 ) return var_0 [ 0 ] ; int var_4 = 0 , var_5 = var_0 . length - 1 ; while ( var_4 < var_5 ) { int var_7 = ( var_4 + var_5 ) / 2 ; if ( var_7 > 0 && var_0 [ var_7 ] < var_0 [ var_7 - 1 ] ) return var_0 [ var_7 ] ; if ( var_0 [ var_4 ] > var_0 [ var_7 ] ) var_5 = var_7 - 1 ; else if ( var_0 [ var_5 ] < var_0 [ var_7 ] ) var_4 = var_7 + 1 ; else var_5 = var_7 - 1 ; } return var_0 [ var_4 ] ; } " 992,string_TextJustification_1.java,"public List fullJustify(String[] words, int L) { int wCount = 0, charCount = 0; List line = new ArrayList<>(); List result = new ArrayList<>(); StringBuilder sb = new StringBuilder(); for (int i = 0, l = words.length; i < l; i++) { String next = words[i]; if ((L - (charCount + wCount)) >= next.length()) { line.add(next); charCount += next.length(); wCount++; } else { sb.append(line.get(0)); StringBuilder space = new StringBuilder(); if (line.size() > 1) { int spaceCount = (L - charCount) / (wCount - 1); int remaining = (L - charCount) % (wCount - 1); for (int j = 0; j < spaceCount; j++) space.append(' '); for (int k = 1, kl = line.size(); k < kl; k++) { sb.append(space); if (remaining > 0) { sb.append(' '); --remaining; } sb.append(line.get(k)); } } else { int balance = L - (charCount + (wCount - 1)); for (int j = 0; j < balance; j++) sb.append(' '); } result.add(sb.toString()); sb = new StringBuilder(); line.clear(); line.add(next); charCount = next.length(); wCount = 1; } } if (!line.isEmpty()) { sb.append(line.get(0)); for (int i = 1, l = line.size(); i < l; i++) { sb.append(' '); sb.append(line.get(i)); } } int balance = L - (charCount + (wCount - 1)); for (int i = 0; i < balance; i++) sb.append(' '); result.add(sb.toString()); return result; }","public List < String > var_1 ( String [ ] var_2 , int var_3 ) { int var_5 = 0 , var_6 = 0 ; List < String > var_9 = new ArrayList < > ( ) ; List < String > var_10 = new ArrayList < > ( ) ; StringBuilder var_12 = new StringBuilder ( ) ; for ( int var_13 = 0 , var_15 = var_2 . length ; var_13 < var_15 ; var_13 ++ ) { String var_16 = var_2 [ var_13 ] ; if ( ( var_3 - ( var_6 + var_5 ) ) >= var_16 . length ( ) ) { var_9 . add ( var_16 ) ; var_6 += var_16 . length ( ) ; var_5 ++ ; } else { var_12 . append ( var_9 . get ( 0 ) ) ; StringBuilder var_20 = new StringBuilder ( ) ; if ( var_9 . size ( ) > 1 ) { int var_23 = ( var_3 - var_6 ) / ( var_5 - 1 ) ; int var_24 = ( var_3 - var_6 ) % ( var_5 - 1 ) ; for ( int var_25 = 0 ; var_25 < var_23 ; var_25 ++ ) var_20 . append ( ' ' ) ; for ( int var_27 = 1 , var_28 = var_9 . size ( ) ; var_27 < var_28 ; var_27 ++ ) { var_12 . append ( var_20 ) ; if ( var_24 > 0 ) { var_12 . append ( ' ' ) ; -- var_24 ; } var_12 . append ( var_9 . get ( var_27 ) ) ; } } else { int var_29 = var_3 - ( var_6 + ( var_5 - 1 ) ) ; for ( int var_25 = 0 ; var_25 < var_29 ; var_25 ++ ) var_12 . append ( ' ' ) ; } var_10 . add ( var_12 . toString ( ) ) ; var_12 = new StringBuilder ( ) ; var_9 . clear ( ) ; var_9 . add ( var_16 ) ; var_6 = var_16 . length ( ) ; var_5 = 1 ; } } if ( ! var_9 . isEmpty ( ) ) { var_12 . append ( var_9 . get ( 0 ) ) ; for ( int var_13 = 1 , var_15 = var_9 . size ( ) ; var_13 < var_15 ; var_13 ++ ) { var_12 . append ( ' ' ) ; var_12 . append ( var_9 . get ( var_13 ) ) ; } } int var_29 = var_3 - ( var_6 + ( var_5 - 1 ) ) ; for ( int var_13 = 0 ; var_13 < var_29 ; var_13 ++ ) var_12 . append ( ' ' ) ; var_10 . add ( var_12 . toString ( ) ) ; return var_10 ; } " 993,binary_search_KokoEatingBananas_1.java,"private boolean check(int[] piles, int H, int k) { for (int p : piles) { if (p <= k) { H--; } else { int q = p / k; if ((p % k) > 0) { q++; } H -= q; } if (H < 0) { return false; } } return true; }","private boolean var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { for ( int var_4 : var_1 ) { if ( var_4 <= var_3 ) { var_2 -- ; } else { int var_5 = var_4 / var_3 ; if ( ( var_4 % var_3 ) > 0 ) { var_5 ++ ; } var_2 -= var_5 ; } if ( var_2 < 0 ) { return false ; } } return true ; } " 994,string_FindWordsThatCanBeFormedbyCharacters_1.java,"public int countCharacters(String[] words, String chars) { Map countMap = new HashMap<>(); for (char c : chars.toCharArray()) { countMap.putIfAbsent(c, 0); countMap.put(c, countMap.get(c) + 1); } int ans = 0; for (String s : words) { Map subMap = new HashMap<>(); for (char c : s.toCharArray()) { subMap.putIfAbsent(c, 0); subMap.put(c, subMap.get(c) + 1); } boolean possible = true; for (char k : subMap.keySet()) { if (!countMap.containsKey(k) || subMap.get(k) > countMap.get(k)) { possible = false; break; } } if (possible) { ans += s.length(); } } return ans; }","public int sample_funcname ( String [ ] var_1 , String var_2 ) { Map < Character , Integer > var_7 = new HashMap < > ( ) ; for ( char var_9 : var_2 . toCharArray ( ) ) { var_7 . putIfAbsent ( var_9 , 0 ) ; var_7 . put ( var_9 , var_7 . get ( var_9 ) + 1 ) ; } int var_15 = 0 ; for ( String var_16 : var_1 ) { Map < Character , Integer > var_17 = new HashMap < > ( ) ; for ( char var_9 : var_16 . toCharArray ( ) ) { var_17 . putIfAbsent ( var_9 , 0 ) ; var_17 . put ( var_9 , var_17 . get ( var_9 ) + 1 ) ; } boolean var_22 = true ; for ( char var_20 : var_17 . keySet ( ) ) { if ( ! var_7 . containsKey ( var_20 ) || var_17 . get ( var_20 ) > var_7 . get ( var_20 ) ) { var_22 = false ; break ; } } if ( var_22 ) { var_15 += var_16 . length ( ) ; } } return var_15 ; } " 995,string_ReverseStringII_1.java,"public String reverseStr(String s, int k) { StringBuilder sb = new StringBuilder(); for (int i = 0, l = s.length(); i < l; i++) { if (i % (2 * k) == 0) { int count = 0; StringBuilder temp = new StringBuilder(); while (count < k && i < l) { temp.append(s.charAt(i)); count++; i++; } sb.append(temp.reverse()); } if (i < l) { sb.append(s.charAt(i)); } } return sb.toString(); }","public String var_0 ( String var_2 , int var_3 ) { StringBuilder var_5 = new StringBuilder ( ) ; for ( int var_7 = 0 , var_9 = var_2 . length ( ) ; var_7 < var_9 ; var_7 ++ ) { if ( var_7 % ( 2 * var_3 ) == 0 ) { int var_11 = 0 ; StringBuilder var_12 = new StringBuilder ( ) ; while ( var_11 < var_3 && var_7 < var_9 ) { var_12 . append ( var_2 . charAt ( var_7 ) ) ; var_11 ++ ; var_7 ++ ; } var_5 . append ( var_12 . reverse ( ) ) ; } if ( var_7 < var_9 ) { var_5 . append ( var_2 . charAt ( var_7 ) ) ; } } return var_5 . toString ( ) ; } " 996,depth_first_search_CrackingTheSafe_2.java,"private String dfs( String num, StringBuilder result, Set done, int k, int states, int count) { done.add(num); if (states == count) { return result.toString(); } else { for (int i = 0; i < k; i++) { String newNum = (num + String.valueOf(i)); String newState = newNum.substring(1); if (!done.contains(newState)) { String retValue = dfs(newState, result.append(String.valueOf(i)), done, k, states, count + 1); if (!retValue.isEmpty()) { return retValue; } else { result.deleteCharAt(result.length() - 1); } } } } done.remove(num); return """"; }","private String sample_funcname ( String num , StringBuilder result , Set < String > done , int k , int states , int count ) { done . add ( num ) ; if ( states == count ) { return result . toString ( ) ; } else { for ( int i = 0 ; i < k ; i ++ ) { String newNum = ( num + String . valueOf ( i ) ) ; String newState = newNum . substring ( 1 ) ; if ( ! done . contains ( newState ) ) { String retValue = dfs ( newState , result . append ( String . valueOf ( i ) ) , done , k , states , count + 1 ) ; if ( ! retValue . isEmpty ( ) ) { return retValue ; } else { result . deleteCharAt ( result . length ( ) - 1 ) ; } } } } done . remove ( num ) ; return """" ; } " 997,heap_TheSkylineProblem_1.java,"private int[] makeNewPoint(int x, int y) { int[] point = new int[2]; point[0] = x; point[1] = y; return point; }","private int [ ] sample_funcname ( int var_0 , int var_1 ) { int [ ] var_3 = new int [ 2 ] ; var_3 [ 0 ] = var_0 ; var_3 [ 1 ] = var_1 ; return var_3 ; } " 998,array_SubarraySumEqualsK_1.java,"public int subarraySum(int[] nums, int k) { Map map = new HashMap<>(); int sum = 0; for (int i : nums) { sum += i; Integer count = map.get(sum); if (count == null) { map.put(sum, 1); } else { map.put(sum, count + 1); } } sum = 0; int result = 0; for (int i : nums) { int key = sum + k; if (map.containsKey(key)) { int count = map.get(key); result += count; } sum += i; if (map.containsKey(sum)) { int count = map.get(sum); if (count - 1 > 0) { map.put(sum, count - 1); } else { map.remove(sum); } } } return result; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { Map < Integer , Integer > var_5 = new HashMap < > ( ) ; int var_7 = 0 ; for ( int var_8 : var_0 ) { var_7 += var_8 ; Integer var_10 = var_5 . get ( var_7 ) ; if ( var_10 == null ) { var_5 . put ( var_7 , 1 ) ; } else { var_5 . put ( var_7 , var_10 + 1 ) ; } } var_7 = 0 ; int var_14 = 0 ; for ( int var_8 : var_0 ) { int var_15 = var_7 + var_1 ; if ( var_5 . containsKey ( var_15 ) ) { int var_10 = var_5 . get ( var_15 ) ; var_14 += var_10 ; } var_7 += var_8 ; if ( var_5 . containsKey ( var_7 ) ) { int var_10 = var_5 . get ( var_7 ) ; if ( var_10 - 1 > 0 ) { var_5 . put ( var_7 , var_10 - 1 ) ; } else { var_5 . remove ( var_7 ) ; } } } return var_14 ; } " 999,array_ArrayPartitionI_1.java,"public int arrayPairSum(int[] nums) { Arrays.sort(nums); int sum = 0; for (int i = 1; i < nums.length; i += 2) { sum += Math.min(nums[i - 1], nums[i]); } return sum; }","public int sample_funcname ( int [ ] var_0 ) { Arrays . sort ( var_0 ) ; int var_4 = 0 ; for ( int var_6 = 1 ; var_6 < var_0 . length ; var_6 += 2 ) { var_4 += Math . min ( var_0 [ var_6 - 1 ] , var_0 [ var_6 ] ) ; } return var_4 ; } " 1000,array_SortColors_1.java,"public void sortColors(int[] nums) { int s = nums[0]; nums[0] = 1; int l = 0, r = 0; for (int i = 1; i < nums.length; i++) { switch (nums[i]) { case 0: nums[l] = 0; nums[r + 1] = 1; if (r + 1 != i) { nums[i] = 2; } l++; r++; break; case 1: nums[r + 1] = 1; if (r + 1 != i) { nums[i] = 2; } r++; break; } } if (s == 0) nums[l] = 0; else if (s == 2) nums[r] = 2; }","public void var_0 ( int [ ] var_1 ) { int var_3 = var_1 [ 0 ] ; var_1 [ 0 ] = 1 ; int var_5 = 0 , var_6 = 0 ; for ( int var_7 = 1 ; var_7 < var_1 . length ; var_7 ++ ) { switch ( var_1 [ var_7 ] ) { case 0 : var_1 [ var_5 ] = 0 ; var_1 [ var_6 + 1 ] = 1 ; if ( var_6 + 1 != var_7 ) { var_1 [ var_7 ] = 2 ; } var_5 ++ ; var_6 ++ ; break ; case 1 : var_1 [ var_6 + 1 ] = 1 ; if ( var_6 + 1 != var_7 ) { var_1 [ var_7 ] = 2 ; } var_6 ++ ; break ; } } if ( var_3 == 0 ) var_1 [ var_5 ] = 0 ; else if ( var_3 == 2 ) var_1 [ var_6 ] = 2 ; } " 1001,bit_manipulation_HammingDistance_1.java,"public int hammingDistance(int x, int y) { int z = (x ^ y); int count = 0; for (int i = 0; i < 31; i++) { if ((z & (1 << i)) > 0) { count++; } } return count; }","public int sample_funcname ( int var_0 , int var_1 ) { int var_2 = ( var_0 ^ var_1 ) ; int var_4 = 0 ; for ( int var_5 = 0 ; var_5 < 31 ; var_5 ++ ) { if ( ( var_2 & ( 1 << var_5 ) ) > 0 ) { var_4 ++ ; } } return var_4 ; } " 1002,math_GlobalAndLocalInversions_1.java,"public boolean isIdealPermutation(int[] A) { if (A.length == 0 || A.length == 1) return true; int max = Integer.MIN_VALUE; for (int i = 1; i < A.length; i++) { if (A[i] < max) { return false; } else { max = Math.max(max, A[i - 1]); } } return true; }","public boolean var_0 ( int [ ] var_1 ) { if ( var_1 . length == 0 || var_1 . length == 1 ) return true ; int max = Integer . MIN_VALUE ; for ( int var_8 = 1 ; var_8 < var_1 . length ; var_8 ++ ) { if ( var_1 [ var_8 ] < max ) { return false ; } else { max = Math . max ( max , var_1 [ var_8 - 1 ] ) ; } } return true ; } " 1003,backtracking_PermutationsII_1.java,"private void swap(int[] a, int i, int j) { int tmp = a[i]; a[i] = a[j]; a[j] = tmp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 1004,two_pointers_LongestSubstringWitoutRepeats_1.java,"private int lengthOfLongestSubstring(String s) { if (s == null || s.isEmpty()) return 0; Map map = new HashMap<>(); int i = 0, max = Integer.MIN_VALUE; for (int j = 0, l = s.length(); j < l; j++) { if (map.keySet().contains(s.charAt(j))) { i = Math.max(map.get(s.charAt(j)) + 1, i); } map.put(s.charAt(j), j); max = Math.max(max, (j - i) + 1); } return max; }","private int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . isEmpty ( ) ) return 0 ; Map < Character , Integer > var_9 = new HashMap < > ( ) ; int var_10 = 0 , max = Integer . MIN_VALUE ; for ( int var_13 = 0 , var_15 = var_1 . length ( ) ; var_13 < var_15 ; var_13 ++ ) { if ( var_9 . keySet ( ) . contains ( var_1 . charAt ( var_13 ) ) ) { var_10 = Math . max ( var_9 . get ( var_1 . charAt ( var_13 ) ) + 1 , var_10 ) ; } var_9 . put ( var_1 . charAt ( var_13 ) , var_13 ) ; max = Math . max ( max , ( var_13 - var_10 ) + 1 ) ; } return max ; } " 1005,string_FindTheClosestPalindrome_2.java,"private String getHigh(String s) { int n = s.length() - 1; StringBuilder sb = new StringBuilder(); sb.append(""1""); for (int i = 0; i < n; i++) { sb.append(""0""); } sb.append(""1""); return sb.toString(); }","private String var_0 ( String var_2 ) { int var_5 = var_2 . length ( ) - 1 ; StringBuilder var_7 = new StringBuilder ( ) ; var_7 . append ( ""1"" ) ; for ( int var_11 = 0 ; var_11 < var_5 ; var_11 ++ ) { var_7 . append ( ""0"" ) ; } var_7 . append ( ""1"" ) ; return var_7 . toString ( ) ; } " 1006,array_ChampagneTower_1.java,"public double champagneTower(int poured, int query_row, int query_glass) { double[][] A = new double[query_row + 1][query_row + 1]; A[0][0] = poured; for (int i = 1; i <= query_row; i++) { for (int j = 0; j <= query_row; j++) { if (A[i - 1][j] > 1.0) { A[i][j] += (A[i - 1][j] - 1.0) / 2; } if (j == 0) continue; if (A[i - 1][j - 1] > 1.0) { A[i][j] += (A[i - 1][j - 1] - 1.0) / 2; } } } if (A[query_row][query_glass] > 1.0) return 1; else return A[query_row][query_glass]; }","public double sample_funcname ( int var_0 , int var_1 , int var_2 ) { double [ ] [ ] var_4 = new double [ var_1 + 1 ] [ var_1 + 1 ] ; var_4 [ 0 ] [ 0 ] = var_0 ; for ( int var_6 = 1 ; var_6 <= var_1 ; var_6 ++ ) { for ( int var_7 = 0 ; var_7 <= var_1 ; var_7 ++ ) { if ( var_4 [ var_6 - 1 ] [ var_7 ] > 1.0 ) { var_4 [ var_6 ] [ var_7 ] += ( var_4 [ var_6 - 1 ] [ var_7 ] - 1.0 ) / 2 ; } if ( var_7 == 0 ) continue ; if ( var_4 [ var_6 - 1 ] [ var_7 - 1 ] > 1.0 ) { var_4 [ var_6 ] [ var_7 ] += ( var_4 [ var_6 - 1 ] [ var_7 - 1 ] - 1.0 ) / 2 ; } } } if ( var_4 [ var_1 ] [ var_2 ] > 1.0 ) return 1 ; else return var_4 [ var_1 ] [ var_2 ] ; } " 1007,dynamic_programming_CoinChange2_1.java,"private int dp(int[][] dp, int i, int[] coins, int l, int n) { if (n == 0) return 1; else if (i >= l) return 0; if (n < 0) return 0; if (dp[i][n] != -1) return dp[i][n]; dp[i][n] = dp(dp, i + 1, coins, l, n) + dp(dp, i, coins, l, n - coins[i]); return dp[i][n]; }","private int sample_funcname ( int [ ] [ ] dp , int i , int [ ] coins , int l , int n ) { if ( n == 0 ) return 1 ; else if ( i >= l ) return 0 ; if ( n < 0 ) return 0 ; if ( dp [ i ] [ n ] != - 1 ) return dp [ i ] [ n ] ; dp [ i ] [ n ] = dp ( dp , i + 1 , coins , l , n ) + dp ( dp , i , coins , l , n - coins [ i ] ) ; return dp [ i ] [ n ] ; } " 1008,two_pointers_LastSubstringInLexicographicalOrder_1.java,"public String lastSubstring(String s) { int currAns = 0; int candidate = -1; int prevIndex = 1; for (int i = 1, l = s.length(); i < l; i++) { if (candidate != -1) { if (s.charAt(i) == s.charAt(prevIndex)) { prevIndex++; } else if (s.charAt(i) > s.charAt(prevIndex)) { if (s.charAt(i) > s.charAt(candidate)) { currAns = i; candidate = -1; prevIndex = currAns + 1; } else if (s.charAt(i) == s.charAt(candidate)) { currAns = candidate; candidate = i; prevIndex = currAns + 1; } else { currAns = candidate; candidate = -1; prevIndex = currAns + 1; } } else { candidate = -1; prevIndex = currAns + 1; } } else { if (s.charAt(i) > s.charAt(currAns)) { currAns = i; candidate = -1; prevIndex = currAns + 1; } else if (s.charAt(i) == s.charAt(currAns)) { candidate = i; } } } return s.substring(currAns); }","public String var_0 ( String var_2 ) { int var_4 = 0 ; int var_6 = - 1 ; int var_7 = 1 ; for ( int var_8 = 1 , var_10 = var_2 . length ( ) ; var_8 < var_10 ; var_8 ++ ) { if ( var_6 != - 1 ) { if ( var_2 . charAt ( var_8 ) == var_2 . charAt ( var_7 ) ) { var_7 ++ ; } else if ( var_2 . charAt ( var_8 ) > var_2 . charAt ( var_7 ) ) { if ( var_2 . charAt ( var_8 ) > var_2 . charAt ( var_6 ) ) { var_4 = var_8 ; var_6 = - 1 ; var_7 = var_4 + 1 ; } else if ( var_2 . charAt ( var_8 ) == var_2 . charAt ( var_6 ) ) { var_4 = var_6 ; var_6 = var_8 ; var_7 = var_4 + 1 ; } else { var_4 = var_6 ; var_6 = - 1 ; var_7 = var_4 + 1 ; } } else { var_6 = - 1 ; var_7 = var_4 + 1 ; } } else { if ( var_2 . charAt ( var_8 ) > var_2 . charAt ( var_4 ) ) { var_4 = var_8 ; var_6 = - 1 ; var_7 = var_4 + 1 ; } else if ( var_2 . charAt ( var_8 ) == var_2 . charAt ( var_4 ) ) { var_6 = var_8 ; } } } return var_2 . substring ( var_4 ) ; } " 1009,binary_search_MinimumWindowSubsequence_1.java,"public String minWindow(String S, String T) { if (T.isEmpty() || S.isEmpty()) return """"; Map> charMap = new HashMap<>(); for (int i = 0, l = S.length(); i < l; i++) { char c = S.charAt(i); charMap.putIfAbsent(c, new TreeSet<>()); charMap.get(c).add(i); } int min = Integer.MAX_VALUE; int start = -1, end; int ansStart = -1, ansEnd = -1; boolean finished = false; while (true) { int index = start; end = -1; for (int i = 0, l = T.length(); i < l; i++) { char c = T.charAt(i); if (!charMap.containsKey(c)) { return """"; } else { TreeSet indicies = charMap.get(c); Integer found = indicies.higher(index); if (found == null) { finished = true; break; } else { index = found; if (i == 0) { start = index; } if (i == l - 1) { end = index; } } } } if (start != -1 && end != -1) { if ((end - start) < min) { min = end - start; ansStart = start; ansEnd = end; } } if (finished) return ansStart == -1 ? """" : S.substring(ansStart, ansEnd + 1); } }","public String var_0 ( String var_2 , String var_3 ) { if ( var_3 . isEmpty ( ) || var_2 . isEmpty ( ) ) return """" ; Map < Character , TreeSet < Integer >> var_11 = new HashMap < > ( ) ; for ( int var_13 = 0 , var_15 = var_2 . length ( ) ; var_13 < var_15 ; var_13 ++ ) { char var_17 = var_2 . charAt ( var_13 ) ; var_11 . putIfAbsent ( var_17 , new TreeSet < > ( ) ) ; var_11 . get ( var_17 ) . add ( var_13 ) ; } int var_22 = Integer . MAX_VALUE ; int var_24 = - 1 , var_25 ; int var_26 = - 1 , var_27 = - 1 ; boolean var_35 = false ; while ( true ) { int var_29 = var_24 ; var_25 = - 1 ; for ( int var_13 = 0 , var_15 = var_3 . length ( ) ; var_13 < var_15 ; var_13 ++ ) { char var_17 = var_3 . charAt ( var_13 ) ; if ( ! var_11 . containsKey ( var_17 ) ) { return """" ; } else { TreeSet < Integer > var_31 = var_11 . get ( var_17 ) ; Integer var_33 = var_31 . higher ( var_29 ) ; if ( var_33 == null ) { var_35 = true ; break ; } else { var_29 = var_33 ; if ( var_13 == 0 ) { var_24 = var_29 ; } if ( var_13 == var_15 - 1 ) { var_25 = var_29 ; } } } } if ( var_24 != - 1 && var_25 != - 1 ) { if ( ( var_25 - var_24 ) < var_22 ) { var_22 = var_25 - var_24 ; var_26 = var_24 ; var_27 = var_25 ; } } if ( var_35 ) return var_26 == - 1 ? """" : var_2 . substring ( var_26 , var_27 + 1 ) ; } } " 1010,dynamic_programming_TwoKeysKeyboard_1.java,"public int minSteps(int n) { int[] DP = new int[n + 1]; for (int i = 2; i <= n; i++) { DP[i] = i; for (int j = 2; j < i; j++) { if ((i % j) == 0) { DP[i] = Math.min(DP[i], DP[j] + (i / j)); } } } return DP[n]; }","public int sample_funcname ( int var_0 ) { int [ ] var_2 = new int [ var_0 + 1 ] ; for ( int var_4 = 2 ; var_4 <= var_0 ; var_4 ++ ) { var_2 [ var_4 ] = var_4 ; for ( int var_5 = 2 ; var_5 < var_4 ; var_5 ++ ) { if ( ( var_4 % var_5 ) == 0 ) { var_2 [ var_4 ] = Math . min ( var_2 [ var_4 ] , var_2 [ var_5 ] + ( var_4 / var_5 ) ) ; } } } return var_2 [ var_0 ] ; } " 1011,greedy_BoatsToSavePeople_1.java,"public int numRescueBoats(int[] people, int limit) { TreeMap treeMap = new TreeMap<>(); int boats = 0; for (int p : people) { treeMap.putIfAbsent(p, 0); treeMap.put(p, treeMap.get(p) + 1); } Arrays.sort(people); for (int p : people) { if (treeMap.containsKey(p)) { int count = treeMap.remove(p); --count; if (count != 0) { treeMap.put(p, count); } int balance = limit - p; Map.Entry floor = treeMap.floorEntry(balance); if (floor != null) { int c = floor.getValue(); --c; treeMap.remove(floor.getKey()); if (c != 0) { treeMap.put(floor.getKey(), c); } } boats++; } } return boats; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { TreeMap < Integer , Integer > var_4 = new TreeMap < > ( ) ; int var_6 = 0 ; for ( int var_7 : var_0 ) { var_4 . putIfAbsent ( var_7 , 0 ) ; var_4 . put ( var_7 , var_4 . get ( var_7 ) + 1 ) ; } Arrays . sort ( var_0 ) ; for ( int var_7 : var_0 ) { if ( var_4 . containsKey ( var_7 ) ) { int var_16 = var_4 . remove ( var_7 ) ; -- var_16 ; if ( var_16 != 0 ) { var_4 . put ( var_7 , var_16 ) ; } int var_17 = var_1 - var_7 ; Map . Entry < Integer , Integer > var_21 = var_4 . floorEntry ( var_17 ) ; if ( var_21 != null ) { int var_24 = var_21 . getValue ( ) ; -- var_24 ; var_4 . remove ( var_21 . getKey ( ) ) ; if ( var_24 != 0 ) { var_4 . put ( var_21 . getKey ( ) , var_24 ) ; } } var_6 ++ ; } } return var_6 ; } " 1012,math_DecodedStringAtIndex_1.java,"public String decodeAtIndex(String S, int K) { long product = 0; char lastC = S.charAt(0); for (int i = 0, l = S.length(); i < l; ) { char c = S.charAt(i); if (Character.isLetter(c)) { lastC = c; product++; i++; if (K == product) break; } else { long temp = (product * Integer.parseInt(String.valueOf(c))); if (temp == K) break; else { if (temp > K) { long x = (K / product); if ((product * x) == K) break; K -= (product * x); i = 0; product = 0; } else { product = temp; i++; } } } } return String.valueOf(lastC); }","public String var_0 ( String var_2 , int var_3 ) { long var_5 = 0 ; char var_7 = var_2 . charAt ( 0 ) ; for ( int var_8 = 0 , var_10 = var_2 . length ( ) ; var_8 < var_10 ; ) { char var_11 = var_2 . charAt ( var_8 ) ; if ( Character . isLetter ( var_11 ) ) { var_7 = var_11 ; var_5 ++ ; var_8 ++ ; if ( var_3 == var_5 ) break ; } else { long var_17 = ( var_5 * Integer . parseInt ( String . valueOf ( var_11 ) ) ) ; if ( var_17 == var_3 ) break ; else { if ( var_17 > var_3 ) { long var_18 = ( var_3 / var_5 ) ; if ( ( var_5 * var_18 ) == var_3 ) break ; var_3 -= ( var_5 * var_18 ) ; var_8 = 0 ; var_5 = 0 ; } else { var_5 = var_17 ; var_8 ++ ; } } } } return String . valueOf ( var_7 ) ; } " 1013,array_RotateArray_1.java,"private void reverse(int[] nums, int s, int e) { for (int i = s, j = e; i < j; i++, j--) { int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp; } }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { for ( int var_4 = var_2 , var_5 = var_3 ; var_4 < var_5 ; var_4 ++ , var_5 -- ) { int var_6 = var_1 [ var_4 ] ; var_1 [ var_4 ] = var_1 [ var_5 ] ; var_1 [ var_5 ] = var_6 ; } } " 1014,dynamic_programming_TallestBillboard_1.java,"private void update(Map map, int diff, int rod1, int rod2) { if (map.getOrDefault(diff, 0) < Math.max(rod1, rod2)) { map.put(diff, Math.max(rod1, rod2)); } }","private void var_0 ( Map < Integer , Integer > var_3 , int var_4 , int var_5 , int var_6 ) { if ( var_3 . getOrDefault ( var_4 , 0 ) < Math . max ( var_5 , var_6 ) ) { var_3 . put ( var_4 , Math . max ( var_5 , var_6 ) ) ; } } " 1015,string_KeyboardRow_1.java,"public String[] findWords(String[] words) { String R1 = ""qwertyuiop""; String R2 = ""asdfghjkl""; String R3 = ""zxcvbnm""; List answer = new ArrayList<>(); for (String s : words) { Set set = new HashSet<>(); for (char c : s.toCharArray()) { if (R1.indexOf(c) != -1) { set.add('1'); } else if (R2.indexOf(c) != -1) { set.add('2'); } else if (R3.indexOf(c) != -1) { set.add('3'); } } if (set.size() == 1) { answer.add(s); } } String[] ans = new String[answer.size()]; int i = 0; for (String s : answer) { ans[i++] = s; } return ans; }","public String [ ] var_0 ( String [ ] var_2 ) { String var_4 = ""qwertyuiop"" ; String var_6 = ""asdfghjkl"" ; String var_8 = ""zxcvbnm"" ; List < String > var_11 = new ArrayList < > ( ) ; for ( String var_12 : var_2 ) { Set < Character > var_16 = new HashSet < > ( ) ; for ( char var_18 : var_12 . toCharArray ( ) ) { if ( var_4 . indexOf ( var_18 ) != - 1 ) { var_16 . add ( '1' ) ; } else if ( var_6 . indexOf ( var_18 ) != - 1 ) { var_16 . add ( '2' ) ; } else if ( var_8 . indexOf ( var_18 ) != - 1 ) { var_16 . add ( '3' ) ; } } if ( var_16 . size ( ) == 1 ) { var_11 . add ( var_12 ) ; } } String [ ] var_26 = new String [ var_11 . size ( ) ] ; int var_28 = 0 ; for ( String var_12 : var_11 ) { var_26 [ var_28 ++ ] = var_12 ; } return var_26 ; } " 1016,binary_search_SearchRotatedSortedArray_1.java,"public int search(int[] nums, int target) { if (nums.length == 0) return -1; if (nums.length == 1) { return (nums[0] == target) ? 0 : -1; } int low = 0, high = nums.length - 1; while (low < high) { int mid = (low + high) >>> 1; if (nums[mid] == target) return mid; if ((nums[mid] <= nums[low]) && (target > nums[mid] && target <= nums[high]) || (nums[low] <= nums[mid] && (target < nums[low] || target > nums[mid]))) low = mid + 1; else high = mid - 1; } return (nums[low] == target) ? low : -1; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { if ( var_0 . length == 0 ) return - 1 ; if ( var_0 . length == 1 ) { return ( var_0 [ 0 ] == var_1 ) ? 0 : - 1 ; } int var_5 = 0 , var_6 = var_0 . length - 1 ; while ( var_5 < var_6 ) { int var_7 = ( var_5 + var_6 ) >>> 1 ; if ( var_0 [ var_7 ] == var_1 ) return var_7 ; if ( ( var_0 [ var_7 ] <= var_0 [ var_5 ] ) && ( var_1 > var_0 [ var_7 ] && var_1 <= var_0 [ var_6 ] ) || ( var_0 [ var_5 ] <= var_0 [ var_7 ] && ( var_1 < var_0 [ var_5 ] || var_1 > var_0 [ var_7 ] ) ) ) var_5 = var_7 + 1 ; else var_6 = var_7 - 1 ; } return ( var_0 [ var_5 ] == var_1 ) ? var_5 : - 1 ; } " 1017,math_SolveTheEquation_1.java,"private int[] calculate(String num, boolean isNeg, int xSum, int rest) { int[] A = new int[2]; if (num.contains(""x"")) { num = num.substring(0, num.length() - 1); if (isNeg) { xSum -= num.isEmpty() ? 1 : Integer.parseInt(num); } else { xSum += num.isEmpty() ? 1 : Integer.parseInt(num); } } else { if (isNeg) { rest -= Integer.parseInt(num); } else { rest += Integer.parseInt(num); } } A[0] = xSum; A[1] = rest; return A; }","private int [ ] sample_funcname ( String var_1 , boolean var_3 , int var_4 , int var_5 ) { int [ ] var_7 = new int [ 2 ] ; if ( var_1 . contains ( ""x"" ) ) { var_1 = var_1 . substring ( 0 , var_1 . length ( ) - 1 ) ; if ( var_3 ) { var_4 -= var_1 . isEmpty ( ) ? 1 : Integer . parseInt ( var_1 ) ; } else { var_4 += var_1 . isEmpty ( ) ? 1 : Integer . parseInt ( var_1 ) ; } } else { if ( var_3 ) { var_5 -= Integer . parseInt ( var_1 ) ; } else { var_5 += Integer . parseInt ( var_1 ) ; } } var_7 [ 0 ] = var_4 ; var_7 [ 1 ] = var_5 ; return var_7 ; } " 1018,dynamic_programming_LongestPalindromicSubsequence_1.java,"public int longestPalindromeSubseq(String s) { int[][] dp = new int[s.length() + 1][s.length() + 1]; String sI = new StringBuilder(s).reverse().toString(); for (int i = 1, l = s.length(); i <= l; i++) for (int j = 1; j <= l; j++) { dp[i][j] = (s.charAt(i - 1) == sI.charAt(j - 1)) ? dp[i - 1][j - 1] + 1 : Math.max(dp[i - 1][j], dp[i][j - 1]); } return dp[s.length()][s.length()]; }","public int sample_funcname ( String var_1 ) { int [ ] [ ] var_4 = new int [ var_1 . length ( ) + 1 ] [ var_1 . length ( ) + 1 ] ; String var_8 = new StringBuilder ( var_1 ) . reverse ( ) . toString ( ) ; for ( int var_9 = 1 , var_10 = var_1 . length ( ) ; var_9 <= var_10 ; var_9 ++ ) for ( int var_11 = 1 ; var_11 <= var_10 ; var_11 ++ ) { var_4 [ var_9 ] [ var_11 ] = ( var_1 . charAt ( var_9 - 1 ) == var_8 . charAt ( var_11 - 1 ) ) ? var_4 [ var_9 - 1 ] [ var_11 - 1 ] + 1 : Math . max ( var_4 [ var_9 - 1 ] [ var_11 ] , var_4 [ var_9 ] [ var_11 - 1 ] ) ; } return var_4 [ var_1 . length ( ) ] [ var_1 . length ( ) ] ; } " 1019,math_AddDigits_1.java,"public int addDigits(int num) { if (num == 0) return 0; return num % 9 == 0 ? 9 : num % 9; }","public int sample_funcname ( int var_0 ) { if ( var_0 == 0 ) return 0 ; return var_0 % 9 == 0 ? 9 : var_0 % 9 ; } " 1020,array_LargestNumberAtLeastTwice_1.java,"public int dominantIndex(int[] nums) { int index = 0, max = Integer.MIN_VALUE; for (int i = 0; i < nums.length; i++) { if (nums[i] > max) { max = nums[i]; index = i; } } for (int i = 0; i < nums.length; i++) { if (i == index) continue; if (((long) nums[i] * 2) > max) { return -1; } } return index; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 , var_5 = Integer . MIN_VALUE ; for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { if ( var_0 [ var_6 ] > var_5 ) { var_5 = var_0 [ var_6 ] ; var_2 = var_6 ; } } for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { if ( var_6 == var_2 ) continue ; if ( ( ( long ) var_0 [ var_6 ] * 2 ) > var_5 ) { return - 1 ; } } return var_2 ; } " 1021,array_PascalsTriangle_1.java,"public List getRow(int rowIndex) { int k = rowIndex; if (k == 0) return Arrays.asList(1); else if (k == 1) return Arrays.asList(1, 1); else if (k == 2) return Arrays.asList(1, 2, 1); List result = new ArrayList<>(); result.add(2); k = k - 2; int p, c; while (k-- > 0) { p = 1; int i = 0; for (int l = result.size(); i < l; i++) { c = result.get(i); result.set(i, p + c); p = c; } result.add(p + 1); } result.add(0, 1); result.add(1); return result; }","public List < Integer > var_1 ( int var_2 ) { int var_3 = var_2 ; if ( var_3 == 0 ) return Arrays . asList ( 1 ) ; else if ( var_3 == 1 ) return Arrays . asList ( 1 , 1 ) ; else if ( var_3 == 2 ) return Arrays . asList ( 1 , 2 , 1 ) ; List < Integer > var_11 = new ArrayList < > ( ) ; var_11 . add ( 2 ) ; var_3 = var_3 - 2 ; int var_13 , var_14 ; while ( var_3 -- > 0 ) { var_13 = 1 ; int var_15 = 0 ; for ( int var_17 = var_11 . size ( ) ; var_15 < var_17 ; var_15 ++ ) { var_14 = var_11 . get ( var_15 ) ; var_11 . set ( var_15 , var_13 + var_14 ) ; var_13 = var_14 ; } var_11 . add ( var_13 + 1 ) ; } var_11 . add ( 0 , 1 ) ; var_11 . add ( 1 ) ; return var_11 ; } " 1022,math_CouplesHoldingHands_2.java,"private void swap(int[] A, int i, int j) { int temp = A[i]; A[i] = A[j]; A[j] = temp; }","private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; } " 1023,array_MinimumMovesToEqualArray_1.java,"public int minMoves2(int[] nums) { if (nums.length == 1) return 0; else if (nums.length == 2) return Math.abs(nums[0] - nums[1]); Arrays.sort(nums); int median; if ((nums.length % 2) == 1) { median = (nums.length / 2); int sum = 0; for (int i = 0; i < nums.length; i++) { sum += Math.abs(nums[i] - nums[median]); } return sum; } else { median = (nums.length / 2) - 1; int sum = 0; int min; for (int i = 0; i < nums.length; i++) { sum += Math.abs(nums[i] - nums[median]); } min = sum; sum = 0; median = (nums.length / 2); for (int i = 0; i < nums.length; i++) { sum += Math.abs(nums[i] - nums[median]); } min = Math.min(min, sum); return min; } }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 1 ) return 0 ; else if ( var_0 . length == 2 ) return Math . abs ( var_0 [ 0 ] - var_0 [ 1 ] ) ; Arrays . sort ( var_0 ) ; int var_9 ; if ( ( var_0 . length % 2 ) == 1 ) { var_9 = ( var_0 . length / 2 ) ; int var_10 = 0 ; for ( int var_11 = 0 ; var_11 < var_0 . length ; var_11 ++ ) { var_10 += Math . abs ( var_0 [ var_11 ] - var_0 [ var_9 ] ) ; } return var_10 ; } else { var_9 = ( var_0 . length / 2 ) - 1 ; int var_10 = 0 ; int min ; for ( int var_11 = 0 ; var_11 < var_0 . length ; var_11 ++ ) { var_10 += Math . abs ( var_0 [ var_11 ] - var_0 [ var_9 ] ) ; } min = var_10 ; var_10 = 0 ; var_9 = ( var_0 . length / 2 ) ; for ( int var_11 = 0 ; var_11 < var_0 . length ; var_11 ++ ) { var_10 += Math . abs ( var_0 [ var_11 ] - var_0 [ var_9 ] ) ; } min = Math . min ( min , var_10 ) ; return min ; } } " 1024,array_MissingNumber_1.java,"public int missingNumber(int[] nums) { int sum = 0; int n = nums.length; for (int num : nums) { sum += num; } int arrSum = (((n + 1)) * n) / 2; if (arrSum == sum) return 0; else return arrSum - sum; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 ; int var_4 = var_0 . length ; for ( int var_5 : var_0 ) { var_2 += var_5 ; } int var_8 = ( ( ( var_4 + 1 ) ) * var_4 ) / 2 ; if ( var_8 == var_2 ) return 0 ; else return var_8 - var_2 ; } " 1025,math_RotateFunction_1.java,"public int maxRotateFunction(int[] A) { if (A.length == 0 || A.length == 1) return 0; int max = Integer.MIN_VALUE; int l = A.length; int sum = 0, prodSum = 0; for (int i = 0; i < l; i++) { prodSum += (A[i] * i); sum += A[i]; } max = Math.max(max, prodSum); for (int i = 0; i < l - 1; i++) { prodSum = (prodSum - sum + A[i] + ((l - 1) * A[i])); max = Math.max(max, prodSum); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 || var_0 . length == 1 ) return 0 ; int max = Integer . MIN_VALUE ; int var_7 = var_0 . length ; int var_8 = 0 , var_9 = 0 ; for ( int var_10 = 0 ; var_10 < var_7 ; var_10 ++ ) { var_9 += ( var_0 [ var_10 ] * var_10 ) ; var_8 += var_0 [ var_10 ] ; } max = Math . max ( max , var_9 ) ; for ( int var_10 = 0 ; var_10 < var_7 - 1 ; var_10 ++ ) { var_9 = ( var_9 - var_8 + var_0 [ var_10 ] + ( ( var_7 - 1 ) * var_0 [ var_10 ] ) ) ; max = Math . max ( max , var_9 ) ; } return max ; } " 1026,backtracking_Combinations_1.java,"private void getNext(int i, int count, int n, int k, int[] subArr, List> result) { if (k == 0) { List subList = new ArrayList<>(); for (int a : subArr) subList.add(a); result.add(subList); } else { for (int j = i + 1; j <= n; j++) { subArr[count] = j; getNext(j, count + 1, n, k - 1, subArr, result); } } }","private void sample_funcname ( int i , int count , int n , int k , int [ ] subArr , List < List < Integer >> result ) { if ( k == 0 ) { List < Integer > subList = new ArrayList < > ( ) ; for ( int a : subArr ) subList . add ( a ) ; result . add ( subList ) ; } else { for ( int j = i + 1 ; j <= n ; j ++ ) { subArr [ count ] = j ; getNext ( j , count + 1 , n , k - 1 , subArr , result ) ; } } } " 1027,depth_first_search_AllPathsFromSourceToTarget_1.java,"private void dfs( List> result, Set done, int i, Stack stack, int[][] graph) { done.add(i); stack.push(i); int[] children = graph[i]; if (children.length == 0) { List childList = new ArrayList<>(stack); result.add(childList); } else { for (int c : children) { dfs(result, done, c, stack, graph); } } stack.pop(); done.remove(i); }","private void sample_funcname ( List < List < Integer >> result , Set < Integer > done , int i , Stack < Integer > stack , int [ ] [ ] graph ) { done . add ( i ) ; stack . push ( i ) ; int [ ] children = graph [ i ] ; if ( children . length == 0 ) { List < Integer > childList = new ArrayList < > ( stack ) ; result . add ( childList ) ; } else { for ( int c : children ) { dfs ( result , done , c , stack , graph ) ; } } stack . pop ( ) ; done . remove ( i ) ; } " 1028,stack_BasicCalculator_1.java,"public int calculate(String s) { Stack stack = new Stack<>(); String num = """"; s = ""("" + s + "")""; for (char c : s.toCharArray()) { switch (c) { case ' ': case '(': case '+': case '-': if (!num.equals("""")) { stack.push(String.valueOf(num)); num = """"; } if (c != ' ') { stack.push(String.valueOf(c)); } break; case ')': if (!num.equals("""")) { stack.push(String.valueOf(num)); num = """"; } int sum = 0; int prev = 0; while (!stack.isEmpty()) { String top = stack.pop(); if (top.equals(""-"")) { sum -= (prev * 2); prev = 0; } else if (top.equals(""+"")) { } else if (top.equals(""("")) { stack.push(String.valueOf(sum)); break; } else { sum += Integer.parseInt(top); prev = Integer.parseInt(top); } } break; default: num += String.valueOf(c); break; } } return Integer.parseInt(stack.peek()); }","public int sample_funcname ( String var_1 ) { Stack < String > var_3 = new Stack < > ( ) ; String var_5 = """" ; var_1 = ""("" + var_1 + "")"" ; for ( char var_9 : var_1 . toCharArray ( ) ) { switch ( var_9 ) { case ' ' : case '(' : case '+' : case '-' : if ( ! var_5 . equals ( """" ) ) { var_3 . push ( String . valueOf ( var_5 ) ) ; var_5 = """" ; } if ( var_9 != ' ' ) { var_3 . push ( String . valueOf ( var_9 ) ) ; } break ; case ')' : if ( ! var_5 . equals ( """" ) ) { var_3 . push ( String . valueOf ( var_5 ) ) ; var_5 = """" ; } int var_19 = 0 ; int var_20 = 0 ; while ( ! var_3 . isEmpty ( ) ) { String var_23 = var_3 . pop ( ) ; if ( var_23 . equals ( ""-"" ) ) { var_19 -= ( var_20 * 2 ) ; var_20 = 0 ; } else if ( var_23 . equals ( ""+"" ) ) { } else if ( var_23 . equals ( ""("" ) ) { var_3 . push ( String . valueOf ( var_19 ) ) ; break ; } else { var_19 += Integer . parseInt ( var_23 ) ; var_20 = Integer . parseInt ( var_23 ) ; } } break ; default : var_5 += String . valueOf ( var_9 ) ; break ; } } return Integer . parseInt ( var_3 . peek ( ) ) ; } " 1029,array_MaxProductOfThreeNumbers_1.java,"public int maximumProduct(int[] nums) { Arrays.sort(nums); int prod1 = nums[nums.length - 1] * nums[nums.length - 2] * nums[nums.length - 3]; int prod2 = nums[nums.length - 1] * nums[0] * nums[1]; return prod1 > prod2 ? prod1 : prod2; }","public int sample_funcname ( int [ ] var_0 ) { Arrays . sort ( var_0 ) ; int var_7 = var_0 [ var_0 . length - 1 ] * var_0 [ var_0 . length - 2 ] * var_0 [ var_0 . length - 3 ] ; int var_9 = var_0 [ var_0 . length - 1 ] * var_0 [ 0 ] * var_0 [ 1 ] ; return var_7 > var_9 ? var_7 : var_9 ; } " 1030,two_pointers_ThreeSumClosest_1.java,"public int threeSumClosest(int[] a, int target) { Arrays.sort(a); int min = Integer.MAX_VALUE, ans = -1; for (int i = 0, l = a.length; i < l - 2; i++) { if (i == 0 || !(a[i] == a[i - 1])) { int j = i + 1, k = l - 1; while (k > j) { if (j != i + 1 && (a[j] == a[j - 1])) { j++; continue; } int sum = a[i] + a[j] + a[k]; if (sum < target) { int diff = Math.abs(sum - target); if (diff < min) { min = diff; ans = sum; } j++; } else if (sum > target) { int diff = Math.abs(sum - target); if (diff < min) { min = diff; ans = sum; } k--; } else { return sum; } } } } return ans; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { Arrays . sort ( var_0 ) ; int var_6 = Integer . MAX_VALUE , var_8 = - 1 ; for ( int var_10 = 0 , var_12 = var_0 . length ; var_10 < var_12 - 2 ; var_10 ++ ) { if ( var_10 == 0 || ! ( var_0 [ var_10 ] == var_0 [ var_10 - 1 ] ) ) { int var_14 = var_10 + 1 , var_15 = var_12 - 1 ; while ( var_15 > var_14 ) { if ( var_14 != var_10 + 1 && ( var_0 [ var_14 ] == var_0 [ var_14 - 1 ] ) ) { var_14 ++ ; continue ; } int var_16 = var_0 [ var_10 ] + var_0 [ var_14 ] + var_0 [ var_15 ] ; if ( var_16 < var_1 ) { int var_19 = Math . abs ( var_16 - var_1 ) ; if ( var_19 < var_6 ) { var_6 = var_19 ; var_8 = var_16 ; } var_14 ++ ; } else if ( var_16 > var_1 ) { int var_19 = Math . abs ( var_16 - var_1 ) ; if ( var_19 < var_6 ) { var_6 = var_19 ; var_8 = var_16 ; } var_15 -- ; } else { return var_16 ; } } } } return var_8 ; } " 1031,string_StringToInteger_1.java,"public int myAtoi(String str) { boolean isPositive = true; if (str == null || str.trim().isEmpty()) return 0; str = str.trim(); if (str.charAt(0) == '+') { isPositive = true; str = str.substring(1, str.length()); } else if (str.charAt(0) == '-') { isPositive = false; str = str.substring(1, str.length()); } else if (str.charAt(0) > '9' || str.charAt(0) < '0') return 0; int i = 0; for (int l = str.length(); i < l; i++) { if (str.charAt(i) > '9' || str.charAt(i) < '0') break; } str = str.substring(0, i); long num = 0; for (int j = 0, l = str.length(); j < l; j++) { int n = (str.charAt(j) - '0'); num *= 10; num += n; if (isPositive) { if (num > Integer.MAX_VALUE) return Integer.MAX_VALUE; } else { if ((num * -1) < Integer.MIN_VALUE) return Integer.MIN_VALUE; } } if (isPositive) return (int) num; else return (int) (num * -1); }","public int sample_funcname ( String var_1 ) { boolean var_21 = true ; if ( var_1 == null || var_1 . trim ( ) . isEmpty ( ) ) return 0 ; var_1 = var_1 . trim ( ) ; if ( var_1 . charAt ( 0 ) == '+' ) { var_21 = true ; var_1 = var_1 . substring ( 1 , var_1 . length ( ) ) ; } else if ( var_1 . charAt ( 0 ) == '-' ) { var_21 = false ; var_1 = var_1 . substring ( 1 , var_1 . length ( ) ) ; } else if ( var_1 . charAt ( 0 ) > '9' || var_1 . charAt ( 0 ) < '0' ) return 0 ; int var_15 = 0 ; for ( int var_16 = var_1 . length ( ) ; var_15 < var_16 ; var_15 ++ ) { if ( var_1 . charAt ( var_15 ) > '9' || var_1 . charAt ( var_15 ) < '0' ) break ; } var_1 = var_1 . substring ( 0 , var_15 ) ; long var_17 = 0 ; for ( int var_18 = 0 , var_16 = var_1 . length ( ) ; var_18 < var_16 ; var_18 ++ ) { int var_19 = ( var_1 . charAt ( var_18 ) - '0' ) ; var_17 *= 10 ; var_17 += var_19 ; if ( var_21 ) { if ( var_17 > Integer . MAX_VALUE ) return Integer . MAX_VALUE ; } else { if ( ( var_17 * - 1 ) < Integer . MIN_VALUE ) return Integer . MIN_VALUE ; } } if ( var_21 ) return ( int ) var_17 ; else return ( int ) ( var_17 * - 1 ) ; } " 1032,string_ValidWordAbbreviation_1.java,"public boolean validWordAbbreviation(String word, String abbr) { if (abbr.length() > word.length()) return false; StringBuilder num = new StringBuilder(); int j = 0; for (int i = 0; i < abbr.length() && j < word.length(); i++) { char curr = abbr.charAt(i); if (curr == '0' && num.toString().isEmpty()) return false; if (curr >= '0' && curr <= '9') { num.append(curr); } else { if (num.toString().isEmpty()) { if (word.charAt(j) != abbr.charAt(i)) { return false; } j++; } else { int next = Integer.parseInt(num.toString()); j += next; if (word.length() <= j) { return false; } if (word.charAt(j) != abbr.charAt(i)) { return false; } num = new StringBuilder(); j++; } } } if (!num.toString().isEmpty()) { int next = Integer.parseInt(num.toString()); j += next; if (j > word.length() || j < word.length()) { return false; } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_3 . length ( ) > var_2 . length ( ) ) return false ; StringBuilder var_6 = new StringBuilder ( ) ; int var_8 = 0 ; for ( int var_9 = 0 ; var_9 < var_3 . length ( ) && var_8 < var_2 . length ( ) ; var_9 ++ ) { char var_11 = var_3 . charAt ( var_9 ) ; if ( var_11 == '0' && var_6 . toString ( ) . isEmpty ( ) ) return false ; if ( var_11 >= '0' && var_11 <= '9' ) { var_6 . append ( var_11 ) ; } else { if ( var_6 . toString ( ) . isEmpty ( ) ) { if ( var_2 . charAt ( var_8 ) != var_3 . charAt ( var_9 ) ) { return false ; } var_8 ++ ; } else { int var_19 = Integer . parseInt ( var_6 . toString ( ) ) ; var_8 += var_19 ; if ( var_2 . length ( ) <= var_8 ) { return false ; } if ( var_2 . charAt ( var_8 ) != var_3 . charAt ( var_9 ) ) { return false ; } var_6 = new StringBuilder ( ) ; var_8 ++ ; } } } if ( ! var_6 . toString ( ) . isEmpty ( ) ) { int var_19 = Integer . parseInt ( var_6 . toString ( ) ) ; var_8 += var_19 ; if ( var_8 > var_2 . length ( ) || var_8 < var_2 . length ( ) ) { return false ; } } return true ; } " 1033,greedy_GasStation_1.java,"public int canCompleteCircuit(int[] gas, int[] cost) { int debt = 0, sum = 0, start = 0; for (int i = 0; i < gas.length; i++) { sum += gas[i] - cost[i]; if (sum < 0) { debt += sum; sum = 0; start = i + 1; } } debt += sum; return debt >= 0 ? start : -1; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { int var_3 = 0 , var_4 = 0 , var_5 = 0 ; for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { var_4 += var_0 [ var_6 ] - var_1 [ var_6 ] ; if ( var_4 < 0 ) { var_3 += var_4 ; var_4 = 0 ; var_5 = var_6 + 1 ; } } var_3 += var_4 ; return var_3 >= 0 ? var_5 : - 1 ; } " 1034,dynamic_programming_HouseRobberII_1.java,"public int rob(int[] nums) { if (nums.length == 0) return 0; if (nums.length == 1) return nums[0]; else if (nums.length == 2) { if (nums[0] > nums[1]) return nums[0]; return nums[1]; } else if (nums.length == 3) return Math.max(Math.max(nums[0], nums[1]), nums[2]); int[] DP = new int[nums.length]; for (int i = nums.length - 1; i > 0; i--) { if (i + 3 < nums.length) DP[i] = Math.max(nums[i] + DP[i + 2], nums[i] + DP[i + 3]); else if (i + 2 < nums.length) DP[i] = nums[i] + DP[i + 2]; else DP[i] = nums[i]; } int max = Math.max(DP[1], DP[2]); Arrays.fill(DP, 0); for (int i = nums.length - 2; i >= 0; i--) { if (i + 3 < nums.length) DP[i] = Math.max(nums[i] + DP[i + 2], nums[i] + DP[i + 3]); else if (i + 2 < nums.length) DP[i] = nums[i] + DP[i + 2]; else DP[i] = nums[i]; } max = Math.max(max, Math.max(DP[0], DP[1])); return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; if ( var_0 . length == 1 ) return var_0 [ 0 ] ; else if ( var_0 . length == 2 ) { if ( var_0 [ 0 ] > var_0 [ 1 ] ) return var_0 [ 0 ] ; return var_0 [ 1 ] ; } else if ( var_0 . length == 3 ) return Math . max ( Math . max ( var_0 [ 0 ] , var_0 [ 1 ] ) , var_0 [ 2 ] ) ; int [ ] var_8 = new int [ var_0 . length ] ; for ( int var_9 = var_0 . length - 1 ; var_9 > 0 ; var_9 -- ) { if ( var_9 + 3 < var_0 . length ) var_8 [ var_9 ] = Math . max ( var_0 [ var_9 ] + var_8 [ var_9 + 2 ] , var_0 [ var_9 ] + var_8 [ var_9 + 3 ] ) ; else if ( var_9 + 2 < var_0 . length ) var_8 [ var_9 ] = var_0 [ var_9 ] + var_8 [ var_9 + 2 ] ; else var_8 [ var_9 ] = var_0 [ var_9 ] ; } int max = Math . max ( var_8 [ 1 ] , var_8 [ 2 ] ) ; Arrays . fill ( var_8 , 0 ) ; for ( int var_9 = var_0 . length - 2 ; var_9 >= 0 ; var_9 -- ) { if ( var_9 + 3 < var_0 . length ) var_8 [ var_9 ] = Math . max ( var_0 [ var_9 ] + var_8 [ var_9 + 2 ] , var_0 [ var_9 ] + var_8 [ var_9 + 3 ] ) ; else if ( var_9 + 2 < var_0 . length ) var_8 [ var_9 ] = var_0 [ var_9 ] + var_8 [ var_9 + 2 ] ; else var_8 [ var_9 ] = var_0 [ var_9 ] ; } max = Math . max ( max , Math . max ( var_8 [ 0 ] , var_8 [ 1 ] ) ) ; return max ; } " 1035,array_LongestIncreasingSubsequence_1.java,"public int findLengthOfLCIS(int[] nums) { int max = 1, count = 1; if (nums.length == 1) return max; if (nums.length == 0) return 0; for (int i = 0, j = i + 1; j < nums.length; ) { if (nums[j] > nums[i]) { count++; i++; j++; } else { max = Math.max(max, count); count = 0; i = j; j = i + 1; } } return max; }","public int sample_funcname ( int [ ] var_0 ) { int max = 1 , var_3 = 1 ; if ( var_0 . length == 1 ) return max ; if ( var_0 . length == 0 ) return 0 ; for ( int var_6 = 0 , var_7 = var_6 + 1 ; var_7 < var_0 . length ; ) { if ( var_0 [ var_7 ] > var_0 [ var_6 ] ) { var_3 ++ ; var_6 ++ ; var_7 ++ ; } else { max = Math . max ( max , var_3 ) ; var_3 = 0 ; var_6 = var_7 ; var_7 = var_6 + 1 ; } } return max ; } " 1036,greedy_JumpGameII_1.java,"public int jump(int[] nums) { int step = 0; int e = 0, max = 0; for (int i = 0; i < nums.length - 1; i++) { max = Math.max(max, i + nums[i]); if (i == e) { step++; e = max; } } return step; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 ; int var_3 = 0 , max = 0 ; for ( int var_5 = 0 ; var_5 < var_0 . length - 1 ; var_5 ++ ) { max = Math . max ( max , var_5 + var_0 [ var_5 ] ) ; if ( var_5 == var_3 ) { var_2 ++ ; var_3 = max ; } } return var_2 ; } " 1037,dynamic_programming_ClimbingStairs_1.java,"public int climbStairs(int n) { if (n == 0 || n == 1) return 1; int[] A = new int[n + 1]; A[n] = 1; A[n - 1] = 1; for (int i = n - 2; i >= 0; i--) A[i] = A[i + 1] + A[i + 2]; return A[0]; }","public int sample_funcname ( int var_0 ) { if ( var_0 == 0 || var_0 == 1 ) return 1 ; int [ ] var_3 = new int [ var_0 + 1 ] ; var_3 [ var_0 ] = 1 ; var_3 [ var_0 - 1 ] = 1 ; for ( int var_5 = var_0 - 2 ; var_5 >= 0 ; var_5 -- ) var_3 [ var_5 ] = var_3 [ var_5 + 1 ] + var_3 [ var_5 + 2 ] ; return var_3 [ 0 ] ; } " 1038,array_MaximumSwap_1.java,"public int maximumSwap(int num) { int[] D = new int[10]; char[] A = String.valueOf(num).toCharArray(); for (int i = 0; i < A.length; i++) { D[A[i] - '0'] = i; } boolean found = false; for (int i = 0; i < A.length; i++) { int digit = A[i] - '0'; for (int j = 9; j > digit; j--) { if (D[j] > i) { char temp = A[i]; A[i] = (char) (j + '0'); A[D[j]] = temp; found = true; break; } } if (found) break; } return Integer.parseInt(String.valueOf(A)); }","public int sample_funcname ( int var_0 ) { int [ ] var_2 = new int [ 10 ] ; char [ ] var_6 = String . valueOf ( var_0 ) . toCharArray ( ) ; for ( int var_8 = 0 ; var_8 < var_6 . length ; var_8 ++ ) { var_2 [ var_6 [ var_8 ] - '0' ] = var_8 ; } boolean var_16 = false ; for ( int var_8 = 0 ; var_8 < var_6 . length ; var_8 ++ ) { int var_12 = var_6 [ var_8 ] - '0' ; for ( int var_14 = 9 ; var_14 > var_12 ; var_14 -- ) { if ( var_2 [ var_14 ] > var_8 ) { char var_15 = var_6 [ var_8 ] ; var_6 [ var_8 ] = ( char ) ( var_14 + '0' ) ; var_6 [ var_2 [ var_14 ] ] = var_15 ; var_16 = true ; break ; } } if ( var_16 ) break ; } return Integer . parseInt ( String . valueOf ( var_6 ) ) ; } " 1039,backtracking_CombinationSumII_1.java,"private void combination( int i, int target, int[] candidates, List row, List> result) { if (target == 0) { result.add(new ArrayList<>(row)); } else if (target > 0) { for (int j = i, l = candidates.length; j < l; j++) { if (j > i && candidates[j] == candidates[j - 1]) continue; row.add(candidates[j]); combination(j + 1, target - candidates[j], candidates, row, result); row.remove(row.size() - 1); } } }","private void sample_funcname ( int i , int target , int [ ] candidates , List < Integer > row , List < List < Integer >> result ) { if ( target == 0 ) { result . add ( new ArrayList < > ( row ) ) ; } else if ( target > 0 ) { for ( int j = i , l = candidates . length ; j < l ; j ++ ) { if ( j > i && candidates [ j ] == candidates [ j - 1 ] ) continue ; row . add ( candidates [ j ] ) ; combination ( j + 1 , target - candidates [ j ] , candidates , row , result ) ; row . remove ( row . size ( ) - 1 ) ; } } } " 1040,greedy_ScoreAfterFlippingMatrix_2.java,"private void flip(int[] A) { for (int i = 0; i < A.length; i++) { if (A[i] == 1) { A[i] = 0; } else { A[i] = 1; } } }","private void var_0 ( int [ ] var_1 ) { for ( int var_3 = 0 ; var_3 < var_1 . length ; var_3 ++ ) { if ( var_1 [ var_3 ] == 1 ) { var_1 [ var_3 ] = 0 ; } else { var_1 [ var_3 ] = 1 ; } } } " 1041,string_ImplementStrStr_1.java,"private boolean isEqual(String haystack, String needle, int i) { int hL = haystack.length(); int nL = needle.length(); int j = 0; while (i < hL && j < nL) { if (haystack.charAt(i) != needle.charAt(j)) return false; i++; j++; } return j >= nL; }","private boolean var_0 ( String var_2 , String var_3 , int var_4 ) { int var_6 = var_2 . length ( ) ; int var_7 = var_3 . length ( ) ; int var_9 = 0 ; while ( var_4 < var_6 && var_9 < var_7 ) { if ( var_2 . charAt ( var_4 ) != var_3 . charAt ( var_9 ) ) return false ; var_4 ++ ; var_9 ++ ; } return var_9 >= var_7 ; } " 1042,array_RelativeSortArray_1.java,"public int[] relativeSortArray(int[] arr1, int[] arr2) { List notPresent = new ArrayList<>(); Map map = new HashMap<>(); Set set = new HashSet<>(); for (int i : arr2) { set.add(i); } for (int i : arr1) { map.putIfAbsent(i, 0); map.put(i, map.get(i) + 1); } List result = new ArrayList<>(); for (int i : arr2) { int count = map.get(i); for (int j = 0; j < count; j++) { result.add(i); } } for (int k : map.keySet()) { if (!set.contains(k)) { int count = map.get(k); for (int i = 0; i < count; i++) { notPresent.add(k); } } } notPresent.sort(Comparator.comparingInt(o -> o)); result.addAll(notPresent); int[] resA = new int[result.size()]; for (int i = 0; i < result.size(); i++) { resA[i] = result.get(i); } return resA; }","public int [ ] sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { List < Integer > var_5 = new ArrayList < > ( ) ; Map < Integer , Integer > var_8 = new HashMap < > ( ) ; Set < Integer > var_11 = new HashSet < > ( ) ; for ( int var_12 : var_1 ) { var_11 . add ( var_12 ) ; } for ( int var_12 : var_0 ) { var_8 . putIfAbsent ( var_12 , 0 ) ; var_8 . put ( var_12 , var_8 . get ( var_12 ) + 1 ) ; } List < Integer > var_19 = new ArrayList < > ( ) ; for ( int var_12 : var_1 ) { int var_20 = var_8 . get ( var_12 ) ; for ( int var_21 = 0 ; var_21 < var_20 ; var_21 ++ ) { var_19 . add ( var_12 ) ; } } for ( int var_23 : var_8 . keySet ( ) ) { if ( ! var_11 . contains ( var_23 ) ) { int var_20 = var_8 . get ( var_23 ) ; for ( int var_12 = 0 ; var_12 < var_20 ; var_12 ++ ) { var_5 . add ( var_23 ) ; } } } var_5 . sort ( Comparator . comparingInt ( var_28 -> var_28 ) ) ; var_19 . addAll ( var_5 ) ; int [ ] var_31 = new int [ var_19 . size ( ) ] ; for ( int var_12 = 0 ; var_12 < var_19 . size ( ) ; var_12 ++ ) { var_31 [ var_12 ] = var_19 . get ( var_12 ) ; } return var_31 ; } " 1043,binary_search_SqrtX_1.java,"public int mySqrt(int x) { int s = 0, e = x; long ans = 0L; while (s <= e) { long m = s + (e - s) / 2; long prod = m * m; if (prod <= x) { s = (int) (m + 1); ans = m; } else e = (int) m - 1; } return (int) ans; }","public int sample_funcname ( int var_0 ) { int var_2 = 0 , var_3 = var_0 ; long var_5 = 0L ; while ( var_2 <= var_3 ) { long var_7 = var_2 + ( var_3 - var_2 ) / 2 ; long var_8 = var_7 * var_7 ; if ( var_8 <= var_0 ) { var_2 = ( int ) ( var_7 + 1 ) ; var_5 = var_7 ; } else var_3 = ( int ) var_7 - 1 ; } return ( int ) var_5 ; } " 1044,breadth_first_search_SlidingPuzzle_1.java,"private int[][] clone(int[][] original) { int[][] cloned = new int[2][3]; for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { cloned[i][j] = original[i][j]; } } return cloned; }","private int [ ] [ ] sample_funcname ( int [ ] [ ] var_0 ) { int [ ] [ ] var_3 = new int [ 2 ] [ 3 ] ; for ( int var_5 = 0 ; var_5 < 2 ; var_5 ++ ) { for ( int var_6 = 0 ; var_6 < 3 ; var_6 ++ ) { var_3 [ var_5 ] [ var_6 ] = var_0 [ var_5 ] [ var_6 ] ; } } return var_3 ; } " 1045,array_SubArraysWithBoundedMaximum_1.java,"public int numSubarrayBoundedMax(int[] A, int L, int R) { int[] DP = new int[A.length]; int v = -1; for (int i = A.length - 1; i >= 0; i--) { if (A[i] >= L && A[i] <= R) { if (v != -1) { DP[i] = v - i + 1; } else { DP[i] = 1; v = i; } } else if (A[i] < L) { if (v == -1) { v = i; } if (i + 1 < A.length) { if (A[i + 1] < L || (A[i + 1] >= L && A[i + 1] <= R)) { DP[i] = DP[i + 1]; } else { DP[i] = 0; } } } else { v = -1; } } int sum = 0; for (int i = 0; i < DP.length; i++) { sum += DP[i]; } return sum; }","public int sample_funcname ( int [ ] var_0 , int var_1 , int var_2 ) { int [ ] var_4 = new int [ var_0 . length ] ; int var_6 = - 1 ; for ( int var_7 = var_0 . length - 1 ; var_7 >= 0 ; var_7 -- ) { if ( var_0 [ var_7 ] >= var_1 && var_0 [ var_7 ] <= var_2 ) { if ( var_6 != - 1 ) { var_4 [ var_7 ] = var_6 - var_7 + 1 ; } else { var_4 [ var_7 ] = 1 ; var_6 = var_7 ; } } else if ( var_0 [ var_7 ] < var_1 ) { if ( var_6 == - 1 ) { var_6 = var_7 ; } if ( var_7 + 1 < var_0 . length ) { if ( var_0 [ var_7 + 1 ] < var_1 || ( var_0 [ var_7 + 1 ] >= var_1 && var_0 [ var_7 + 1 ] <= var_2 ) ) { var_4 [ var_7 ] = var_4 [ var_7 + 1 ] ; } else { var_4 [ var_7 ] = 0 ; } } } else { var_6 = - 1 ; } } int var_9 = 0 ; for ( int var_7 = 0 ; var_7 < var_4 . length ; var_7 ++ ) { var_9 += var_4 [ var_7 ] ; } return var_9 ; } " 1046,two_pointers_MinimumSizeSubarraySum_1.java,"public int minSubArrayLen(int s, int[] nums) { int sum = 0, count = 0, min = Integer.MAX_VALUE; for (int i = 0, j = 0; j < nums.length; ) { if (nums[j] >= s) { return 1; } else { sum += nums[j]; count++; if (sum >= s) { min = Math.min(min, count); while (j > i) { sum -= nums[i]; count--; i++; if (sum < s) break; min = Math.min(min, count); } } } j++; } if (min == Integer.MAX_VALUE) { return 0; } return min; }","public int sample_funcname ( int var_0 , int [ ] var_1 ) { int var_3 = 0 , var_4 = 0 , min = Integer . MAX_VALUE ; for ( int var_8 = 0 , var_9 = 0 ; var_9 < var_1 . length ; ) { if ( var_1 [ var_9 ] >= var_0 ) { return 1 ; } else { var_3 += var_1 [ var_9 ] ; var_4 ++ ; if ( var_3 >= var_0 ) { min = Math . min ( min , var_4 ) ; while ( var_9 > var_8 ) { var_3 -= var_1 [ var_8 ] ; var_4 -- ; var_8 ++ ; if ( var_3 < var_0 ) break ; min = Math . min ( min , var_4 ) ; } } } var_9 ++ ; } if ( min == Integer . MAX_VALUE ) { return 0 ; } return min ; } " 1047,string_MinimumAddtoMakeParenthesesValid_1.java,"public int minAddToMakeValid(String S) { int result = 0; int open = 0; for (char c : S.toCharArray()) { if (c == '(') { open++; } else if (c == ')') { if (open > 0) { open--; } else result++; } } return result + open; }","public int sample_funcname ( String var_1 ) { int var_3 = 0 ; int var_4 = 0 ; for ( char var_6 : var_1 . toCharArray ( ) ) { if ( var_6 == '(' ) { var_4 ++ ; } else if ( var_6 == ')' ) { if ( var_4 > 0 ) { var_4 -- ; } else var_3 ++ ; } } return var_3 + var_4 ; } " 1048,two_pointers_RemoveDuplicates_1.java,"public int removeDuplicates(int[] nums) { if (nums.length == 1) return 1; int size = 1; for (int j = 0, i = 1; i < nums.length; i++) { if (nums[i] != nums[i - 1]) { size++; j++; nums[j] = nums[i]; } } return size; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 1 ) return 1 ; int var_3 = 1 ; for ( int var_5 = 0 , var_6 = 1 ; var_6 < var_0 . length ; var_6 ++ ) { if ( var_0 [ var_6 ] != var_0 [ var_6 - 1 ] ) { var_3 ++ ; var_5 ++ ; var_0 [ var_5 ] = var_0 [ var_6 ] ; } } return var_3 ; } " 1049,math_LargestComponentSizebyCommonFactor_1.java,"private List primes(int N, int[] A) { boolean[] P = new boolean[N + 1]; int[] pF = new int[N + 1]; int sqRt = (int) Math.sqrt(N); for (int i = 2; i <= sqRt; i++) { if (!P[i]) { for (int j = 2; ; j++) { if (i * j > N) break; P[i * j] = true; if (pF[i * j] == 0) { pF[i * j] = i; } } } } Map result = new HashMap<>(); for (int a : A) { if (a == 1) continue; int n = pF[a]; while (n != 0) { result.putIfAbsent(n, 0); result.put(n, result.get(n) + 1); a /= n; n = pF[a]; } result.putIfAbsent(a, 0); result.put(a, result.get(a) + 1); } return result.keySet().stream().filter(x -> result.get(x) > 1).collect(Collectors.toList()); }","private List < Integer > var_1 ( int var_2 , int [ ] var_3 ) { boolean [ ] var_6 = new boolean [ var_2 + 1 ] ; int [ ] var_7 = new int [ var_2 + 1 ] ; int var_10 = ( int ) Math . sqrt ( var_2 ) ; for ( int var_12 = 2 ; var_12 <= var_10 ; var_12 ++ ) { if ( ! var_6 [ var_12 ] ) { for ( int var_13 = 2 ; ; var_13 ++ ) { if ( var_12 * var_13 > var_2 ) break ; var_6 [ var_12 * var_13 ] = true ; if ( var_7 [ var_12 * var_13 ] == 0 ) { var_7 [ var_12 * var_13 ] = var_12 ; } } } } Map < Integer , Integer > var_17 = new HashMap < > ( ) ; for ( int var_18 : var_3 ) { if ( var_18 == 1 ) continue ; int var_19 = var_7 [ var_18 ] ; while ( var_19 != 0 ) { var_17 . putIfAbsent ( var_19 , 0 ) ; var_17 . put ( var_19 , var_17 . get ( var_19 ) + 1 ) ; var_18 /= var_19 ; var_19 = var_7 [ var_18 ] ; } var_17 . putIfAbsent ( var_18 , 0 ) ; var_17 . put ( var_18 , var_17 . get ( var_18 ) + 1 ) ; } return var_17 . keySet ( ) . stream ( ) . filter ( var_26 -> var_17 . get ( var_26 ) > 1 ) . collect ( Collectors . toList ( ) ) ; } " 1050,string_StringCompression_1.java,"public int compress(char[] chars) { int count = 0; int i = 0; int p = 0; for (int j = 0; j < chars.length; j++) { if (chars[i] == chars[j]) { count++; } else { chars[p] = chars[i]; p++; if (count > 1) { String countStr = String.valueOf(count); for (int l = 0; l < countStr.length(); l++) { chars[p++] = countStr.charAt(l); } } i = j; count = 1; } } chars[p] = chars[i]; p++; if (count > 1) { String countStr = String.valueOf(count); for (int l = 0; l < countStr.length(); l++) { chars[p++] = countStr.charAt(l); } } return p; }","public int sample_funcname ( char [ ] var_0 ) { int var_2 = 0 ; int var_3 = 0 ; int var_4 = 0 ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { if ( var_0 [ var_3 ] == var_0 [ var_5 ] ) { var_2 ++ ; } else { var_0 [ var_4 ] = var_0 [ var_3 ] ; var_4 ++ ; if ( var_2 > 1 ) { String var_10 = String . valueOf ( var_2 ) ; for ( int var_11 = 0 ; var_11 < var_10 . length ( ) ; var_11 ++ ) { var_0 [ var_4 ++ ] = var_10 . charAt ( var_11 ) ; } } var_3 = var_5 ; var_2 = 1 ; } } var_0 [ var_4 ] = var_0 [ var_3 ] ; var_4 ++ ; if ( var_2 > 1 ) { String var_10 = String . valueOf ( var_2 ) ; for ( int var_11 = 0 ; var_11 < var_10 . length ( ) ; var_11 ++ ) { var_0 [ var_4 ++ ] = var_10 . charAt ( var_11 ) ; } } return var_4 ; } " 1051,string_FindTheClosestPalindrome_3.java,"private boolean isPaliandrome(String s) { for (int i = 0, j = s.length() - 1; i < j; i++, j--) { if (s.charAt(i) != s.charAt(j)) { return false; } } return true; }","private boolean var_0 ( String var_2 ) { for ( int var_4 = 0 , var_7 = var_2 . length ( ) - 1 ; var_4 < var_7 ; var_4 ++ , var_7 -- ) { if ( var_2 . charAt ( var_4 ) != var_2 . charAt ( var_7 ) ) { return false ; } } return true ; } " 1052,array_CanPlaceFlowers_1.java,"public boolean canPlaceFlowers(int[] flowerbed, int n) { int[] T = new int[flowerbed.length + 4]; for (int i = 0, j = 2; i < flowerbed.length; i++) T[j++] = flowerbed[i]; T[0] = 1; T[T.length - 1] = 1; int total = 0, count = 0; for (int i = 1; i < T.length; i++) { if (T[i] == 0) count++; else { if ((count % 2) == 0) total += ((count / 2) - 1); else total += (count / 2); count = 0; } } return (total >= n); }","public boolean var_0 ( int [ ] var_1 , int var_2 ) { int [ ] var_5 = new int [ var_1 . length + 4 ] ; for ( int var_7 = 0 , var_9 = 2 ; var_7 < var_1 . length ; var_7 ++ ) var_5 [ var_9 ++ ] = var_1 [ var_7 ] ; var_5 [ 0 ] = 1 ; var_5 [ var_5 . length - 1 ] = 1 ; int var_11 = 0 , var_12 = 0 ; for ( int var_7 = 1 ; var_7 < var_5 . length ; var_7 ++ ) { if ( var_5 [ var_7 ] == 0 ) var_12 ++ ; else { if ( ( var_12 % 2 ) == 0 ) var_11 += ( ( var_12 / 2 ) - 1 ) ; else var_11 += ( var_12 / 2 ) ; var_12 = 0 ; } } return ( var_11 >= var_2 ) ; } " 1053,dynamic_programming_BestTimeToBuyAndSellStocksWithFee_1.java,"public int maxProfit(int[] prices, int fee) { int cash = 0, stock = -prices[0]; for (int i = 1; i < prices.length; i++) { cash = Math.max(cash, prices[i] + stock - fee); stock = Math.max(stock, cash - prices[i]); } return cash; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = 0 , var_4 = - var_0 [ 0 ] ; for ( int var_6 = 1 ; var_6 < var_0 . length ; var_6 ++ ) { var_3 = Math . max ( var_3 , var_0 [ var_6 ] + var_4 - var_1 ) ; var_4 = Math . max ( var_4 , var_3 - var_0 [ var_6 ] ) ; } return var_3 ; } " 1054,array_LargestTimeForGivenDigits_1.java,"public String largestTimeFromDigits(int[] A) { int max = -1; String result = """"; for (int i = 0; i < A.length; i++) { if (A[i] > 2) continue; for (int j = 0; j < A.length; j++) { if (j == i) continue; if (A[i] == 2 && A[j] > 3) continue; for (int k = 0; k < A.length; k++) { if (k == i || k == j) continue; if (A[k] > 5) continue; for (int l = 0; l < A.length; l++) { if (l == i || l == j || l == k) continue; int value = ((A[i] * 10 + A[j]) * 60) + A[k] * 10 + A[l]; if (value > max) { max = value; result = A[i] + """" + A[j] + "":"" + A[k] + """" + A[l]; } } } } } return result; }","public String var_0 ( int [ ] var_1 ) { int var_3 = - 1 ; String var_6 = """" ; for ( int var_8 = 0 ; var_8 < var_1 . length ; var_8 ++ ) { if ( var_1 [ var_8 ] > 2 ) continue ; for ( int var_11 = 0 ; var_11 < var_1 . length ; var_11 ++ ) { if ( var_11 == var_8 ) continue ; if ( var_1 [ var_8 ] == 2 && var_1 [ var_11 ] > 3 ) continue ; for ( int var_13 = 0 ; var_13 < var_1 . length ; var_13 ++ ) { if ( var_13 == var_8 || var_13 == var_11 ) continue ; if ( var_1 [ var_13 ] > 5 ) continue ; for ( int var_15 = 0 ; var_15 < var_1 . length ; var_15 ++ ) { if ( var_15 == var_8 || var_15 == var_11 || var_15 == var_13 ) continue ; int var_18 = ( ( var_1 [ var_8 ] * 10 + var_1 [ var_11 ] ) * 60 ) + var_1 [ var_13 ] * 10 + var_1 [ var_15 ] ; if ( var_18 > var_3 ) { var_3 = var_18 ; var_6 = var_1 [ var_8 ] + """" + var_1 [ var_11 ] + "":"" + var_1 [ var_13 ] + """" + var_1 [ var_15 ] ; } } } } } return var_6 ; } " 1055,greedy_ScoreAfterFlippingMatrix_1.java,"private int makeNum(int[] a) { int n = 0; for (int i = 0; i < a.length; i++) { if (a[i] == 1) { n |= (1 << (a.length - i - 1)); } } return n; }","private int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { if ( var_0 [ var_3 ] == 1 ) { var_2 |= ( 1 << ( var_0 . length - var_3 - 1 ) ) ; } } return var_2 ; } " 1056,math_SmallestRangeI_1.java,"public int smallestRangeI(int[] A, int K) { Arrays.sort(A); if (A.length == 0 || A.length == 1) return 0; else { int low = A[0]; int high = A[A.length - 1]; int l = low + (K); int r = high - (K); if (r > l) return r - l; else return 0; } }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { Arrays . sort ( var_0 ) ; if ( var_0 . length == 0 || var_0 . length == 1 ) return 0 ; else { int var_7 = var_0 [ 0 ] ; int var_8 = var_0 [ var_0 . length - 1 ] ; int var_9 = var_7 + ( var_1 ) ; int var_10 = var_8 - ( var_1 ) ; if ( var_10 > var_9 ) return var_10 - var_9 ; else return 0 ; } } " 1057,array_ReadNCharacters_1.java,"private int read4(char[] buf) { return 1; }","private int sample_funcname ( char [ ] var_0 ) { return 1 ; } " 1058,dynamic_programming_MinimumNumberOfRefuelingStops_1.java,"public int minRefuelStops(int target, int startFuel, int[][] stations) { long[] dp = new long[stations.length + 1]; dp[0] = startFuel; for (int i = 0; i < stations.length; i++) { int d = stations[i][0]; int f = stations[i][1]; for (int j = i; j >= 0; j--) { if (dp[j] >= d) { dp[j + 1] = Math.max(dp[j + 1], dp[j] + f); } } } for (int i = 0; i < dp.length; i++) { if (dp[i] >= target) { return i; } } return -1; }","public int sample_funcname ( int var_0 , int var_1 , int [ ] [ ] var_2 ) { long [ ] var_5 = new long [ var_2 . length + 1 ] ; var_5 [ 0 ] = var_1 ; for ( int var_7 = 0 ; var_7 < var_2 . length ; var_7 ++ ) { int var_8 = var_2 [ var_7 ] [ 0 ] ; int var_9 = var_2 [ var_7 ] [ 1 ] ; for ( int var_10 = var_7 ; var_10 >= 0 ; var_10 -- ) { if ( var_5 [ var_10 ] >= var_8 ) { var_5 [ var_10 + 1 ] = Math . max ( var_5 [ var_10 + 1 ] , var_5 [ var_10 ] + var_9 ) ; } } } for ( int var_7 = 0 ; var_7 < var_5 . length ; var_7 ++ ) { if ( var_5 [ var_7 ] >= var_0 ) { return var_7 ; } } return - 1 ; } " 1059,array_MaxConsecutiveOnesII_1.java,"public int findMaxConsecutiveOnes(int[] nums) { int[] L = new int[nums.length]; int[] R = new int[nums.length]; boolean flag = false; int count = 0; int max = 0; for (int j = 0; j < nums.length; j++) { if (nums[j] == 1) { if (!flag) { flag = true; } count++; L[j] = count; } else { count = 0; flag = false; L[j] = count; } max = Math.max(max, count); } flag = false; count = 0; for (int j = nums.length - 1; j >= 0; j--) { if (nums[j] == 1) { if (!flag) { flag = true; } count++; R[j] = count; } else { count = 0; flag = false; R[j] = count; } } for (int i = 0; i < nums.length; i++) { if (nums[i] == 0) { int l = i == 0 ? 0 : L[i - 1]; int r = i == nums.length - 1 ? 0 : R[i + 1]; max = Math.max(max, l + r + 1); } } return max; }","public int sample_funcname ( int [ ] var_0 ) { int [ ] var_2 = new int [ var_0 . length ] ; int [ ] var_3 = new int [ var_0 . length ] ; boolean var_10 = false ; int var_6 = 0 ; int max = 0 ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { if ( var_0 [ var_8 ] == 1 ) { if ( ! var_10 ) { var_10 = true ; } var_6 ++ ; var_2 [ var_8 ] = var_6 ; } else { var_6 = 0 ; var_10 = false ; var_2 [ var_8 ] = var_6 ; } max = Math . max ( max , var_6 ) ; } var_10 = false ; var_6 = 0 ; for ( int var_8 = var_0 . length - 1 ; var_8 >= 0 ; var_8 -- ) { if ( var_0 [ var_8 ] == 1 ) { if ( ! var_10 ) { var_10 = true ; } var_6 ++ ; var_3 [ var_8 ] = var_6 ; } else { var_6 = 0 ; var_10 = false ; var_3 [ var_8 ] = var_6 ; } } for ( int var_12 = 0 ; var_12 < var_0 . length ; var_12 ++ ) { if ( var_0 [ var_12 ] == 0 ) { int var_13 = var_12 == 0 ? 0 : var_2 [ var_12 - 1 ] ; int var_14 = var_12 == var_0 . length - 1 ? 0 : var_3 [ var_12 + 1 ] ; max = Math . max ( max , var_13 + var_14 + 1 ) ; } } return max ; } " 1060,dynamic_programming_MinCostClimbingStairs_1.java,"public int minCostClimbingStairs(int[] cost) { for (int i = cost.length - 1; i >= 0; i--) { if (i + 1 < cost.length && i + 2 < cost.length) { cost[i] = Math.min(cost[i] + cost[i + 1], cost[i] + cost[i + 2]); } } return Math.min(cost[0], cost[1]); }","public int sample_funcname ( int [ ] var_0 ) { for ( int var_3 = var_0 . length - 1 ; var_3 >= 0 ; var_3 -- ) { if ( var_3 + 1 < var_0 . length && var_3 + 2 < var_0 . length ) { var_0 [ var_3 ] = Math . min ( var_0 [ var_3 ] + var_0 [ var_3 + 1 ] , var_0 [ var_3 ] + var_0 [ var_3 + 2 ] ) ; } } return Math . min ( var_0 [ 0 ] , var_0 [ 1 ] ) ; } " 1061,math_ProjectionAreaOf3DShapes_1.java,"public int projectionArea(int[][] grid) { int area = 0; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid.length; j++) { area += (grid[i][j] > 0 ? 1 : 0); } } for (int i = 0; i < grid.length; i++) { int max = 0; for (int j = 0; j < grid[0].length; j++) { max = Math.max(max, grid[i][j]); } area += max; } for (int i = 0; i < grid[0].length; i++) { int max = 0; for (int j = 0; j < grid.length; j++) { max = Math.max(max, grid[j][i]); } area += max; } return area; }","public int sample_funcname ( int [ ] [ ] var_0 ) { int var_2 = 0 ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { var_2 += ( var_0 [ var_3 ] [ var_5 ] > 0 ? 1 : 0 ) ; } } for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { int max = 0 ; for ( int var_5 = 0 ; var_5 < var_0 [ 0 ] . length ; var_5 ++ ) { max = Math . max ( max , var_0 [ var_3 ] [ var_5 ] ) ; } var_2 += max ; } for ( int var_3 = 0 ; var_3 < var_0 [ 0 ] . length ; var_3 ++ ) { int max = 0 ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { max = Math . max ( max , var_0 [ var_5 ] [ var_3 ] ) ; } var_2 += max ; } return var_2 ; } " 1062,two_pointers_SubarrayProductLessThanK_1.java,"public int numSubarrayProductLessThanK(int[] nums, int k) { long prod = 1; int count = 0; Queue queue = new ArrayDeque<>(); for (int i = 0; i < nums.length; i++) { if (nums[i] < k) { count++; if ((prod * nums[i]) < k) { prod *= nums[i]; if (!queue.isEmpty()) { count += (i - queue.peek()); } } else { while (!queue.isEmpty()) { int last = queue.poll(); prod /= nums[last]; if ((prod * nums[i]) < k) { prod = prod * nums[i]; if (!queue.isEmpty()) { count += (i - queue.peek()); } break; } } } if (queue.isEmpty()) { prod = nums[i]; } queue.offer(i); } else { queue.clear(); } } return count; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { long var_3 = 1 ; int var_5 = 0 ; Queue < Integer > var_9 = new ArrayDeque < > ( ) ; for ( int var_10 = 0 ; var_10 < var_0 . length ; var_10 ++ ) { if ( var_0 [ var_10 ] < var_1 ) { var_5 ++ ; if ( ( var_3 * var_0 [ var_10 ] ) < var_1 ) { var_3 *= var_0 [ var_10 ] ; if ( ! var_9 . isEmpty ( ) ) { var_5 += ( var_10 - var_9 . peek ( ) ) ; } } else { while ( ! var_9 . isEmpty ( ) ) { int var_15 = var_9 . poll ( ) ; var_3 /= var_0 [ var_15 ] ; if ( ( var_3 * var_0 [ var_10 ] ) < var_1 ) { var_3 = var_3 * var_0 [ var_10 ] ; if ( ! var_9 . isEmpty ( ) ) { var_5 += ( var_10 - var_9 . peek ( ) ) ; } break ; } } } if ( var_9 . isEmpty ( ) ) { var_3 = var_0 [ var_10 ] ; } var_9 . offer ( var_10 ) ; } else { var_9 . clear ( ) ; } } return var_5 ; } " 1063,backtracking_RegularExpressionMatching_1.java,"private boolean backTrack(int si, int pi, String s, String p) { if (si >= s.length() && pi >= p.length()) return true; else { if (pi >= p.length()) return false; else if (si >= s.length()) { if (pi + 1 < p.length() && p.charAt(pi + 1) == '*') { return backTrack(si, pi + 2, s, p); } else return false; } else if (s.charAt(si) == p.charAt(pi) || p.charAt(pi) == '.') { if (pi + 1 < p.length() && p.charAt(pi + 1) == '*') { if (backTrack(si, pi + 2, s, p)) return true; for (int i = si, l = s.length(); i < l; i++) { if (s.charAt(i) == p.charAt(pi) || p.charAt(pi) == '.') { if (backTrack(i + 1, pi + 2, s, p)) return true; } else { return false; } } return backTrack(s.length(), pi, s, p); } else { return backTrack(si + 1, pi + 1, s, p); } } else { if (pi + 1 < p.length() && p.charAt(pi + 1) == '*') { return backTrack(si, pi + 2, s, p); } else return false; } } }","private boolean sample_funcname ( int si , int pi , String s , String p ) { if ( si >= s . length ( ) && pi >= p . length ( ) ) return true ; else { if ( pi >= p . length ( ) ) return false ; else if ( si >= s . length ( ) ) { if ( pi + 1 < p . length ( ) && p . charAt ( pi + 1 ) == '*' ) { return backTrack ( si , pi + 2 , s , p ) ; } else return false ; } else if ( s . charAt ( si ) == p . charAt ( pi ) || p . charAt ( pi ) == '.' ) { if ( pi + 1 < p . length ( ) && p . charAt ( pi + 1 ) == '*' ) { if ( backTrack ( si , pi + 2 , s , p ) ) return true ; for ( int i = si , l = s . length ( ) ; i < l ; i ++ ) { if ( s . charAt ( i ) == p . charAt ( pi ) || p . charAt ( pi ) == '.' ) { if ( backTrack ( i + 1 , pi + 2 , s , p ) ) return true ; } else { return false ; } } return backTrack ( s . length ( ) , pi , s , p ) ; } else { return backTrack ( si + 1 , pi + 1 , s , p ) ; } } else { if ( pi + 1 < p . length ( ) && p . charAt ( pi + 1 ) == '*' ) { return backTrack ( si , pi + 2 , s , p ) ; } else return false ; } } } " 1064,array_BestMeetingPoint_1.java,"public int minTotalDistance(int[][] grid) { int[] countR = new int[grid.length]; int[] countC = new int[grid[0].length]; int[] distR = new int[grid.length]; int[] distC = new int[grid[0].length]; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[0].length; j++) { if (grid[i][j] == 1) { countR[i]++; countC[j]++; } } } for (int i = 0; i < distR.length; i++) { for (int j = 0; j < distR.length; j++) { if (countR[j] != 0) { distR[i] += Math.abs(j - i) * countR[j]; } } } for (int i = 0; i < distC.length; i++) { for (int j = 0; j < distC.length; j++) { if (countC[j] != 0) { distC[i] += Math.abs(j - i) * countC[j]; } } } int min = Integer.MAX_VALUE; for (int i = 0; i < distR.length; i++) { for (int j = 0; j < distC.length; j++) { min = Math.min(min, distR[i] + distC[j]); } } return min; }","public int sample_funcname ( int [ ] [ ] var_0 ) { int [ ] var_2 = new int [ var_0 . length ] ; int [ ] var_4 = new int [ var_0 [ 0 ] . length ] ; int [ ] var_5 = new int [ var_0 . length ] ; int [ ] var_6 = new int [ var_0 [ 0 ] . length ] ; for ( int var_7 = 0 ; var_7 < var_0 . length ; var_7 ++ ) { for ( int var_8 = 0 ; var_8 < var_0 [ 0 ] . length ; var_8 ++ ) { if ( var_0 [ var_7 ] [ var_8 ] == 1 ) { var_2 [ var_7 ] ++ ; var_4 [ var_8 ] ++ ; } } } for ( int var_7 = 0 ; var_7 < var_5 . length ; var_7 ++ ) { for ( int var_8 = 0 ; var_8 < var_5 . length ; var_8 ++ ) { if ( var_2 [ var_8 ] != 0 ) { var_5 [ var_7 ] += Math . abs ( var_8 - var_7 ) * var_2 [ var_8 ] ; } } } for ( int var_7 = 0 ; var_7 < var_6 . length ; var_7 ++ ) { for ( int var_8 = 0 ; var_8 < var_6 . length ; var_8 ++ ) { if ( var_4 [ var_8 ] != 0 ) { var_6 [ var_7 ] += Math . abs ( var_8 - var_7 ) * var_4 [ var_8 ] ; } } } int min = Integer . MAX_VALUE ; for ( int var_7 = 0 ; var_7 < var_5 . length ; var_7 ++ ) { for ( int var_8 = 0 ; var_8 < var_6 . length ; var_8 ++ ) { min = Math . min ( min , var_5 [ var_7 ] + var_6 [ var_8 ] ) ; } } return min ; } " 1065,two_pointers_MoveZeroes_1.java,"public void moveZeroes(int[] nums) { int i = 0; for (int j = 0, l = nums.length; j < l; ) { if (nums[j] == 0) j++; else { int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp; i++; j++; } } while (i < nums.length) nums[i++] = 0; }","public void var_0 ( int [ ] var_1 ) { int var_3 = 0 ; for ( int var_4 = 0 , var_6 = var_1 . length ; var_4 < var_6 ; ) { if ( var_1 [ var_4 ] == 0 ) var_4 ++ ; else { int var_7 = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_1 [ var_4 ] ; var_1 [ var_4 ] = var_7 ; var_3 ++ ; var_4 ++ ; } } while ( var_3 < var_1 . length ) var_1 [ var_3 ++ ] = 0 ; } " 1066,breadth_first_search_BusRoutes_1.java,"private boolean intersect(int[] A, int[] B) { for (int i = 0, j = 0; i < A.length && j < B.length; ) { if (A[i] == B[j]) return true; else if (A[i] < B[j]) i++; else j++; } return false; }","private boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { for ( int var_4 = 0 , var_5 = 0 ; var_4 < var_1 . length && var_5 < var_2 . length ; ) { if ( var_1 [ var_4 ] == var_2 [ var_5 ] ) return true ; else if ( var_1 [ var_4 ] < var_2 [ var_5 ] ) var_4 ++ ; else var_5 ++ ; } return false ; } " 1067,backtracking_PalindromePartitioning_1.java,"private boolean isPalindrome(String s) { int i = 0, j = s.length() - 1; while (i <= j) { if (s.charAt(i) != s.charAt(j)) return false; i++; j--; } return true; }","private boolean var_0 ( String var_2 ) { int var_4 = 0 , var_7 = var_2 . length ( ) - 1 ; while ( var_4 <= var_7 ) { if ( var_2 . charAt ( var_4 ) != var_2 . charAt ( var_7 ) ) return false ; var_4 ++ ; var_7 -- ; } return true ; } " 1068,bit_manipulation_DivideTwoIntegers_1.java,"public int divide(int dividend, int divisor) { if (divisor == 0) return Integer.MAX_VALUE; else if (dividend == Integer.MIN_VALUE && divisor == -1) return Integer.MAX_VALUE; else if (divisor == 1) return dividend; boolean isNegative = ((dividend < 0 && divisor > 0) || (dividend > 0 && divisor < 0)); dividend = (dividend < 0) ? -dividend : dividend; divisor = (divisor < 0) ? -divisor : divisor; int sum, result = 0; while (true) { int d1 = divisor; sum = 0; if (dividend - d1 == 0) { sum += 1; result += sum; break; } if (dividend - d1 < 0) break; while (dividend - (d1 << 1) > 0) { d1 <<= 1; sum += 1; } result += (1 << sum); dividend = dividend - d1; } return isNegative ? -result : result; }","public int sample_funcname ( int var_0 , int var_1 ) { if ( var_1 == 0 ) return Integer . MAX_VALUE ; else if ( var_0 == Integer . MIN_VALUE && var_1 == - 1 ) return Integer . MAX_VALUE ; else if ( var_1 == 1 ) return var_0 ; boolean var_8 = ( ( var_0 < 0 && var_1 > 0 ) || ( var_0 > 0 && var_1 < 0 ) ) ; var_0 = ( var_0 < 0 ) ? - var_0 : var_0 ; var_1 = ( var_1 < 0 ) ? - var_1 : var_1 ; int var_9 , var_10 = 0 ; while ( true ) { int var_11 = var_1 ; var_9 = 0 ; if ( var_0 - var_11 == 0 ) { var_9 += 1 ; var_10 += var_9 ; break ; } if ( var_0 - var_11 < 0 ) break ; while ( var_0 - ( var_11 << 1 ) > 0 ) { var_11 <<= 1 ; var_9 += 1 ; } var_10 += ( 1 << var_9 ) ; var_0 = var_0 - var_11 ; } return var_8 ? - var_10 : var_10 ; } " 1069,dynamic_programming_SplitArrayLargestSum_1.java,"public int splitArray(int[] nums, int m) { int[][] dp = new int[m][nums.length]; for (int i = nums.length - 1; i >= 0; i--) { int sum = 0; for (int j = i; j < nums.length; j++) { sum += nums[j]; if (j + 1 >= nums.length) break; for (int k = 0; k < m - 1; k++) { dp[k + 1][i] = (dp[k + 1][i] == 0) ? Integer.MAX_VALUE : dp[k + 1][i]; int temp = Math.max(sum, dp[k][j + 1]); dp[k + 1][i] = Math.min(dp[k + 1][i], temp); } } dp[0][i] = sum; } return dp[m - 1][0]; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { int [ ] [ ] var_3 = new int [ var_1 ] [ var_0 . length ] ; for ( int var_5 = var_0 . length - 1 ; var_5 >= 0 ; var_5 -- ) { int var_7 = 0 ; for ( int var_8 = var_5 ; var_8 < var_0 . length ; var_8 ++ ) { var_7 += var_0 [ var_8 ] ; if ( var_8 + 1 >= var_0 . length ) break ; for ( int var_9 = 0 ; var_9 < var_1 - 1 ; var_9 ++ ) { var_3 [ var_9 + 1 ] [ var_5 ] = ( var_3 [ var_9 + 1 ] [ var_5 ] == 0 ) ? Integer . MAX_VALUE : var_3 [ var_9 + 1 ] [ var_5 ] ; int var_14 = Math . max ( var_7 , var_3 [ var_9 ] [ var_8 + 1 ] ) ; var_3 [ var_9 + 1 ] [ var_5 ] = Math . min ( var_3 [ var_9 + 1 ] [ var_5 ] , var_14 ) ; } } var_3 [ 0 ] [ var_5 ] = var_7 ; } return var_3 [ var_1 - 1 ] [ 0 ] ; } " 1070,backtracking_Permutations_1.java,"private void nextPermutation(int i, int[] nums, List> result) { if (i == nums.length - 1) { List list = new ArrayList<>(); for (int n : nums) list.add(n); result.add(list); } else { for (int j = i, l = nums.length; j < l; j++) { int temp = nums[j]; nums[j] = nums[i]; nums[i] = temp; nextPermutation(i + 1, nums, result); temp = nums[j]; nums[j] = nums[i]; nums[i] = temp; } } }","private void sample_funcname ( int i , int [ ] nums , List < List < Integer >> result ) { if ( i == nums . length - 1 ) { List < Integer > list = new ArrayList < > ( ) ; for ( int n : nums ) list . add ( n ) ; result . add ( list ) ; } else { for ( int j = i , l = nums . length ; j < l ; j ++ ) { int temp = nums [ j ] ; nums [ j ] = nums [ i ] ; nums [ i ] = temp ; nextPermutation ( i + 1 , nums , result ) ; temp = nums [ j ] ; nums [ j ] = nums [ i ] ; nums [ i ] = temp ; } } } " 1071,string_NumberOfMatchingSubsequences_1.java,"private boolean isSubsequence(String S, String P) { int i = 0, j = 0; if (P.length() > S.length()) return false; for (; ; ) { if (j >= P.length()) return true; else if (i >= S.length()) return false; else { if (S.charAt(i) == P.charAt(j)) { i++; j++; } else { i++; } } } }","private boolean var_0 ( String var_2 , String var_3 ) { int var_5 = 0 , var_6 = 0 ; if ( var_3 . length ( ) > var_2 . length ( ) ) return false ; for ( ; ; ) { if ( var_6 >= var_3 . length ( ) ) return true ; else if ( var_5 >= var_2 . length ( ) ) return false ; else { if ( var_2 . charAt ( var_5 ) == var_3 . charAt ( var_6 ) ) { var_5 ++ ; var_6 ++ ; } else { var_5 ++ ; } } } } " 1072,math_RangeAdditionII_1.java,"public int maxCount(int m, int n, int[][] ops) { int minR = m; int minC = n; for (int[] v : ops) { minR = Math.min(minR, v[0]); minC = Math.min(minC, v[1]); } return minR * minC; }","public int sample_funcname ( int var_0 , int var_1 , int [ ] [ ] var_2 ) { int var_3 = var_0 ; int var_4 = var_1 ; for ( int [ ] var_5 : var_2 ) { var_3 = Math . min ( var_3 , var_5 [ 0 ] ) ; var_4 = Math . min ( var_4 , var_5 [ 1 ] ) ; } return var_3 * var_4 ; } " 1073,math_SuperWashingMachines_1.java,"public int findMinMoves(int[] machines) { long sum = Arrays.stream(machines).asLongStream().sum(); if (((sum / machines.length) < 0) || ((sum % machines.length) != 0)) return -1; int n = (int) (sum / machines.length); int count = 0, moves = Integer.MIN_VALUE; for (int i = 0; i < machines.length; i++) { count += (machines[i] - n); moves = Math.max(moves, Math.max(Math.abs(count), (machines[i] - n))); } return moves; }","public int sample_funcname ( int [ ] var_0 ) { long sum = Arrays . stream ( var_0 ) . asLongStream ( ) . sum ( ) ; if ( ( ( sum / var_0 . length ) < 0 ) || ( ( sum % var_0 . length ) != 0 ) ) return - 1 ; int var_8 = ( int ) ( sum / var_0 . length ) ; int var_9 = 0 , var_12 = Integer . MIN_VALUE ; for ( int var_13 = 0 ; var_13 < var_0 . length ; var_13 ++ ) { var_9 += ( var_0 [ var_13 ] - var_8 ) ; var_12 = Math . max ( var_12 , Math . max ( Math . abs ( var_9 ) , ( var_0 [ var_13 ] - var_8 ) ) ) ; } return var_12 ; } " 1074,dynamic_programming_CherryPickup_1.java,"private int dp(int N, int r1, int c1, int c2, int[][][] DP, int[][] grid) { int r2 = r1 + (c1 - c2); if (r1 >= N || c1 >= N || c2 >= N || r2 >= N || grid[r1][c1] == -1 || grid[r2][c2] == -1) return Integer.MIN_VALUE; else if (DP[r1][c1][c2] != -1) return DP[r1][c1][c2]; else if (r1 == N - 1 && c1 == N - 1) return grid[N - 1][N - 1]; else { int max = (c1 == c2) ? grid[r1][c1] : (grid[r1][c1] + grid[r2][c2]); max += Math.max( Math.max( Math.max(dp(N, r1 + 1, c1, c2, DP, grid), dp(N, r1 + 1, c1, c2 + 1, DP, grid)), dp(N, r1, c1 + 1, c2, DP, grid)), dp(N, r1, c1 + 1, c2 + 1, DP, grid)); DP[r1][c1][c2] = max; return max; } }","private int sample_funcname ( int N , int r1 , int c1 , int c2 , int [ ] [ ] [ ] DP , int [ ] [ ] grid ) { int r2 = r1 + ( c1 - c2 ) ; if ( r1 >= N || c1 >= N || c2 >= N || r2 >= N || grid [ r1 ] [ c1 ] == - 1 || grid [ r2 ] [ c2 ] == - 1 ) return Integer . MIN_VALUE ; else if ( DP [ r1 ] [ c1 ] [ c2 ] != - 1 ) return DP [ r1 ] [ c1 ] [ c2 ] ; else if ( r1 == N - 1 && c1 == N - 1 ) return grid [ N - 1 ] [ N - 1 ] ; else { int max = ( c1 == c2 ) ? grid [ r1 ] [ c1 ] : ( grid [ r1 ] [ c1 ] + grid [ r2 ] [ c2 ] ) ; max += Math . max ( Math . max ( Math . max ( dp ( N , r1 + 1 , c1 , c2 , DP , grid ) , dp ( N , r1 + 1 , c1 , c2 + 1 , DP , grid ) ) , dp ( N , r1 , c1 + 1 , c2 , DP , grid ) ) , dp ( N , r1 , c1 + 1 , c2 + 1 , DP , grid ) ) ; DP [ r1 ] [ c1 ] [ c2 ] = max ; return max ; } } " 1075,backtracking_WildcardMatching_1.java,"public boolean isMatch(String s, String p) { int starIdx = -1; int starPosAtStr = -1; int j = 0; for (int i = 0, l = s.length(); i < l; ) { if (j < p.length()) { if (s.charAt(i) == p.charAt(j) || p.charAt(j) == '?') { i++; j++; } else if (p.charAt(j) == '*') { starIdx = j; starPosAtStr = i; j++; } else if (starIdx != -1) { i = ++starPosAtStr; j = starIdx + 1; } else return false; } else if (starIdx != -1) { i = ++starPosAtStr; j = starIdx + 1; } else return false; } while (j < p.length()) { if (p.charAt(j) == '*') { j++; } else break; } return j == p.length(); }","public boolean var_0 ( String var_2 , String var_3 ) { int var_5 = - 1 ; int var_6 = - 1 ; int var_8 = 0 ; for ( int var_9 = 0 , var_11 = var_2 . length ( ) ; var_9 < var_11 ; ) { if ( var_8 < var_3 . length ( ) ) { if ( var_2 . charAt ( var_9 ) == var_3 . charAt ( var_8 ) || var_3 . charAt ( var_8 ) == '?' ) { var_9 ++ ; var_8 ++ ; } else if ( var_3 . charAt ( var_8 ) == '*' ) { var_5 = var_8 ; var_6 = var_9 ; var_8 ++ ; } else if ( var_5 != - 1 ) { var_9 = ++ var_6 ; var_8 = var_5 + 1 ; } else return false ; } else if ( var_5 != - 1 ) { var_9 = ++ var_6 ; var_8 = var_5 + 1 ; } else return false ; } while ( var_8 < var_3 . length ( ) ) { if ( var_3 . charAt ( var_8 ) == '*' ) { var_8 ++ ; } else break ; } return var_8 == var_3 . length ( ) ; } " 1076,string_PushDominoes_1.java,"public String pushDominoes(String dominoes) { int R = -1, L = -1; char[] A = dominoes.toCharArray(); for (int i = 0; i < A.length; i++) { if (A[i] == 'L') { if (R > L) { int d = (i - R); int st; st = R + d / 2; if ((d % 2) == 0) { A[st] = '.'; } for (int j = st + 1; j < i; j++) { A[j] = 'L'; } } else { for (int j = (L == -1 ? 0 : L); j < i; j++) { A[j] = 'L'; } } L = i; } else { if (A[i] == 'R') { R = i; } else { if (R > L) { A[i] = 'R'; } } } } return String.valueOf(A); }","public String var_0 ( String var_2 ) { int var_4 = - 1 , var_5 = - 1 ; char [ ] var_7 = var_2 . toCharArray ( ) ; for ( int var_9 = 0 ; var_9 < var_7 . length ; var_9 ++ ) { if ( var_7 [ var_9 ] == 'L' ) { if ( var_4 > var_5 ) { int var_12 = ( var_9 - var_4 ) ; int var_13 ; var_13 = var_4 + var_12 / 2 ; if ( ( var_12 % 2 ) == 0 ) { var_7 [ var_13 ] = '.' ; } for ( int var_16 = var_13 + 1 ; var_16 < var_9 ; var_16 ++ ) { var_7 [ var_16 ] = 'L' ; } } else { for ( int var_16 = ( var_5 == - 1 ? 0 : var_5 ) ; var_16 < var_9 ; var_16 ++ ) { var_7 [ var_16 ] = 'L' ; } } var_5 = var_9 ; } else { if ( var_7 [ var_9 ] == 'R' ) { var_4 = var_9 ; } else { if ( var_4 > var_5 ) { var_7 [ var_9 ] = 'R' ; } } } } return String . valueOf ( var_7 ) ; } " 1077,array_NextGreaterElementI_1.java,"public int[] nextGreaterElement(int[] nums1, int[] nums2) { int[] result = new int[nums1.length]; for (int i = 0; i < nums1.length; i++) { int n = nums1[i]; boolean found = false; int nF = 0; for (int j = 0; j < nums2.length; j++) { if (nums2[j] == n) { found = true; } if (found) { if (nums2[j] > n) { nF = nums2[j]; break; } } } if (found) { result[i] = nF; } else { result[i] = -1; } } return result; }","public int [ ] sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { int [ ] var_3 = new int [ var_0 . length ] ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { int var_6 = var_0 [ var_5 ] ; boolean var_10 = false ; int var_8 = 0 ; for ( int var_9 = 0 ; var_9 < var_1 . length ; var_9 ++ ) { if ( var_1 [ var_9 ] == var_6 ) { var_10 = true ; } if ( var_10 ) { if ( var_1 [ var_9 ] > var_6 ) { var_8 = var_1 [ var_9 ] ; break ; } } } if ( var_10 ) { var_3 [ var_5 ] = var_8 ; } else { var_3 [ var_5 ] = - 1 ; } } return var_3 ; } " 1078,hashing_NumberOfAtoms_1.java,"private Map merge(Map left, Map right) { for (String k : left.keySet()) { if (right.containsKey(k)) { right.put(k, right.get(k) + left.get(k)); } else right.put(k, left.get(k)); } return right; }","private Map < String , Integer > var_2 ( Map < String , Integer > var_4 , Map < String , Integer > var_5 ) { for ( String var_7 : var_4 . keySet ( ) ) { if ( var_5 . containsKey ( var_7 ) ) { var_5 . put ( var_7 , var_5 . get ( var_7 ) + var_4 . get ( var_7 ) ) ; } else var_5 . put ( var_7 , var_4 . get ( var_7 ) ) ; } return var_5 ; } " 1079,array_MaxConsecutiveOnes_1.java,"public int findMaxConsecutiveOnes(int[] nums) { int max = 0; boolean flag = false; int count = 0; for (int i = 0; i < nums.length; i++) { if (nums[i] == 1) { if (!flag) { flag = true; } count++; max = Math.max(max, count); } else { count = 0; flag = false; } } return max; }","public int sample_funcname ( int [ ] var_0 ) { int max = 0 ; boolean var_8 = false ; int var_4 = 0 ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { if ( var_0 [ var_5 ] == 1 ) { if ( ! var_8 ) { var_8 = true ; } var_4 ++ ; max = Math . max ( max , var_4 ) ; } else { var_4 = 0 ; var_8 = false ; } } return max ; } " 1080,binary_search_SearchInsertPosition_1.java,"public int searchInsert(int[] nums, int target) { int pos = nums.length; int s = 0, e = nums.length - 1; while (s <= e) { int m = s + (e - s) / 2; if (nums[m] >= target) { pos = m; e = m - 1; } else s = m + 1; } return pos; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = var_0 . length ; int var_5 = 0 , var_7 = var_0 . length - 1 ; while ( var_5 <= var_7 ) { int var_9 = var_5 + ( var_7 - var_5 ) / 2 ; if ( var_0 [ var_9 ] >= var_1 ) { var_3 = var_9 ; var_7 = var_9 - 1 ; } else var_5 = var_9 + 1 ; } return var_3 ; } " 1081,math_SquirrelSimulation_1.java,"public int minDistance(int height, int width, int[] tree, int[] squirrel, int[][] nuts) { int dist = 0; for (int[] n : nuts) { dist += Math.abs(n[0] - tree[0]) + Math.abs(n[1] - tree[1]); } dist *= 2; int ans = Integer.MAX_VALUE; for (int[] n : nuts) { int nutDist = Math.abs(n[0] - squirrel[0]) + Math.abs(n[1] - squirrel[1]); ans = Math.min(ans, dist - (Math.abs(n[0] - tree[0]) + Math.abs(n[1] - tree[1])) + nutDist); } return ans; }","public int sample_funcname ( int var_0 , int var_1 , int [ ] var_2 , int [ ] var_3 , int [ ] [ ] var_4 ) { int var_6 = 0 ; for ( int [ ] var_7 : var_4 ) { var_6 += Math . abs ( var_7 [ 0 ] - var_2 [ 0 ] ) + Math . abs ( var_7 [ 1 ] - var_2 [ 1 ] ) ; } var_6 *= 2 ; int var_14 = Integer . MAX_VALUE ; for ( int [ ] var_7 : var_4 ) { int var_15 = Math . abs ( var_7 [ 0 ] - var_3 [ 0 ] ) + Math . abs ( var_7 [ 1 ] - var_3 [ 1 ] ) ; var_14 = Math . min ( var_14 , var_6 - ( Math . abs ( var_7 [ 0 ] - var_2 [ 0 ] ) + Math . abs ( var_7 [ 1 ] - var_2 [ 1 ] ) ) + var_15 ) ; } return var_14 ; } " 1082,string_ReconstructOriginalDigitsFromEnglish_1.java,"private void update( Map map, Map intMap, int num, char id, List list) { if (map.containsKey(id)) { int count = map.get(id); intMap.put(num, count); while (count-- > 0) { for (char c : list) { map.put(c, map.get(c) - 1); } } } }","private void var_0 ( Map < Character , Integer > var_4 , Map < Integer , Integer > var_5 , int var_6 , char var_7 , List < Character > var_9 ) { if ( var_4 . containsKey ( var_7 ) ) { int var_12 = var_4 . get ( var_7 ) ; var_5 . put ( var_6 , var_12 ) ; while ( var_12 -- > 0 ) { for ( char var_15 : var_9 ) { var_4 . put ( var_15 , var_4 . get ( var_15 ) - 1 ) ; } } } } " 1083,math_CouplesHoldingHands_1.java,"private int find(int[] A, int n) { for (int i = 0; i < A.length; i++) { if (A[i] == n) { return i; } } return -1; }","private int sample_funcname ( int [ ] var_0 , int var_1 ) { for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { if ( var_0 [ var_3 ] == var_1 ) { return var_3 ; } } return - 1 ; } " 1084,string_LongestCommonPrefix_1.java,"public String longestCommonPrefix(String[] strs) { if (strs.length == 0) return """"; String result = strs[0]; for (int i = 1; i < strs.length; i++) { String s = strs[i]; for (int j = 0; j < result.length(); j++) { if (j >= s.length() || result.charAt(j) != s.charAt(j)) { result = result.substring(0, j); break; } } } return result; }","public String var_0 ( String [ ] var_2 ) { if ( var_2 . length == 0 ) return """" ; String var_6 = var_2 [ 0 ] ; for ( int var_8 = 1 ; var_8 < var_2 . length ; var_8 ++ ) { String var_9 = var_2 [ var_8 ] ; for ( int var_10 = 0 ; var_10 < var_6 . length ( ) ; var_10 ++ ) { if ( var_10 >= var_9 . length ( ) || var_6 . charAt ( var_10 ) != var_9 . charAt ( var_10 ) ) { var_6 = var_6 . substring ( 0 , var_10 ) ; break ; } } } return var_6 ; } " 1085,binary_search_SingleElementInASortedArray_1.java,"public int singleNonDuplicate(int[] nums) { if (nums.length == 1) return nums[0]; int l = 0, h = nums.length - 1; while (l <= h) { int m = l + ((h - l) / 2); int N = nums[m]; if (m + 1 >= nums.length) { if (nums[m - 1] != N) { return N; } h = m - 1; } else if (m - 1 < 0) { if (nums[m + 1] != N) { return N; } l = m + 1; } else { if (m % 2 == 0) { if (nums[m + 1] != N && nums[m - 1] != N) { return N; } else if (nums[m + 1] != N) { h = m - 1; } else l = m + 1; } else { if (nums[m + 1] != N && nums[m - 1] != N) { return N; } else if (nums[m - 1] != N) { h = m - 1; } else l = m + 1; } } } return -1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 1 ) return var_0 [ 0 ] ; int var_4 = 0 , var_5 = var_0 . length - 1 ; while ( var_4 <= var_5 ) { int var_7 = var_4 + ( ( var_5 - var_4 ) / 2 ) ; int var_8 = var_0 [ var_7 ] ; if ( var_7 + 1 >= var_0 . length ) { if ( var_0 [ var_7 - 1 ] != var_8 ) { return var_8 ; } var_5 = var_7 - 1 ; } else if ( var_7 - 1 < 0 ) { if ( var_0 [ var_7 + 1 ] != var_8 ) { return var_8 ; } var_4 = var_7 + 1 ; } else { if ( var_7 % 2 == 0 ) { if ( var_0 [ var_7 + 1 ] != var_8 && var_0 [ var_7 - 1 ] != var_8 ) { return var_8 ; } else if ( var_0 [ var_7 + 1 ] != var_8 ) { var_5 = var_7 - 1 ; } else var_4 = var_7 + 1 ; } else { if ( var_0 [ var_7 + 1 ] != var_8 && var_0 [ var_7 - 1 ] != var_8 ) { return var_8 ; } else if ( var_0 [ var_7 - 1 ] != var_8 ) { var_5 = var_7 - 1 ; } else var_4 = var_7 + 1 ; } } } return - 1 ; } " 1086,array_ValidTicTacToeState_1.java,"private boolean hasWon(String[] board, char c) { boolean diagnol = ((board[0].charAt(0) == c && board[1].charAt(1) == c && board[2].charAt(2) == c) || (board[0].charAt(2) == c && board[1].charAt(1) == c && board[2].charAt(0) == c)); if (diagnol) return true; for (int i = 0; i < 3; i++) { if (board[i].charAt(0) == c && board[i].charAt(1) == c && board[i].charAt(2) == c) return true; } for (int i = 0; i < 3; i++) { if (board[0].charAt(i) == c && board[1].charAt(i) == c && board[2].charAt(i) == c) return true; } return false; }","private boolean var_0 ( String [ ] var_2 , char var_3 ) { boolean var_9 = ( ( var_2 [ 0 ] . charAt ( 0 ) == var_3 && var_2 [ 1 ] . charAt ( 1 ) == var_3 && var_2 [ 2 ] . charAt ( 2 ) == var_3 ) || ( var_2 [ 0 ] . charAt ( 2 ) == var_3 && var_2 [ 1 ] . charAt ( 1 ) == var_3 && var_2 [ 2 ] . charAt ( 0 ) == var_3 ) ) ; if ( var_9 ) return true ; for ( int var_10 = 0 ; var_10 < 3 ; var_10 ++ ) { if ( var_2 [ var_10 ] . charAt ( 0 ) == var_3 && var_2 [ var_10 ] . charAt ( 1 ) == var_3 && var_2 [ var_10 ] . charAt ( 2 ) == var_3 ) return true ; } for ( int var_10 = 0 ; var_10 < 3 ; var_10 ++ ) { if ( var_2 [ 0 ] . charAt ( var_10 ) == var_3 && var_2 [ 1 ] . charAt ( var_10 ) == var_3 && var_2 [ 2 ] . charAt ( var_10 ) == var_3 ) return true ; } return false ; } " 1087,greedy_ReducingDishes_1.java,"public int maxSatisfaction(int[] satisfaction) { Queue pq = new PriorityQueue<>(((o1, o2) -> o2 - o1)); Arrays.stream(satisfaction).forEach(pq::offer); int max = 0, sum = 0; while (!pq.isEmpty()) { if ((max + sum) >= max) { max += sum; sum += pq.poll(); } else break; } return max; }","public int sample_funcname ( int [ ] var_0 ) { Queue < Integer > var_6 = new PriorityQueue < > ( ( ( var_3 , var_4 ) -> var_4 - var_3 ) ) ; Arrays . stream ( var_0 ) . forEach ( var_6 :: offer ) ; int var_12 = 0 , var_13 = 0 ; while ( ! var_6 . isEmpty ( ) ) { if ( ( var_12 + var_13 ) >= var_12 ) { var_12 += var_13 ; var_13 += var_6 . poll ( ) ; } else break ; } return var_12 ; } " 1088,string_ValidPalindromeII_1.java,"private boolean isPaliandrome(String s) { for (int i = 0, j = s.length() - 1; i < j; ) { if (s.charAt(i) == s.charAt(j)) { i++; j--; } else return false; } return true; }","private boolean var_0 ( String var_2 ) { for ( int var_4 = 0 , var_7 = var_2 . length ( ) - 1 ; var_4 < var_7 ; ) { if ( var_2 . charAt ( var_4 ) == var_2 . charAt ( var_7 ) ) { var_4 ++ ; var_7 -- ; } else return false ; } return true ; } " 1089,two_pointers_ThreeSum_1.java,"public List> threeSum(int[] nums) { List> result = new ArrayList<>(); if (nums.length < 3) return result; Arrays.sort(nums); for (int i = 0, l = nums.length; i < l - 2; i++) { if (i == 0 || nums[i] != nums[i - 1]) { int j = i + 1, k = l - 1; while (k > j) { if (j != i + 1 && nums[j] == nums[j - 1]) { j++; continue; } int sum = nums[i] + nums[j] + nums[k]; if (sum == 0) { result.add(Arrays.asList(nums[i], nums[j], nums[k])); k--; j++; } else if (sum > 0) k--; else j++; } } } return result; }","public List < List < Integer >> var_2 ( int [ ] var_3 ) { List < List < Integer >> var_5 = new ArrayList < > ( ) ; if ( var_3 . length < 3 ) return var_5 ; Arrays . sort ( var_3 ) ; for ( int var_11 = 0 , var_12 = var_3 . length ; var_11 < var_12 - 2 ; var_11 ++ ) { if ( var_11 == 0 || var_3 [ var_11 ] != var_3 [ var_11 - 1 ] ) { int var_15 = var_11 + 1 , var_16 = var_12 - 1 ; while ( var_16 > var_15 ) { if ( var_15 != var_11 + 1 && var_3 [ var_15 ] == var_3 [ var_15 - 1 ] ) { var_15 ++ ; continue ; } int var_17 = var_3 [ var_11 ] + var_3 [ var_15 ] + var_3 [ var_16 ] ; if ( var_17 == 0 ) { var_5 . add ( Arrays . asList ( var_3 [ var_11 ] , var_3 [ var_15 ] , var_3 [ var_16 ] ) ) ; var_16 -- ; var_15 ++ ; } else if ( var_17 > 0 ) var_16 -- ; else var_15 ++ ; } } } return var_5 ; } " 1090,string_LongestPalindrome_1.java,"public int longestPalindrome(String s) { Map map = new HashMap<>(); for (char c : s.toCharArray()) { map.putIfAbsent(c, 0); int count = map.get(c); map.put(c, count + 1); } int max = 0; boolean odd = false; for (char c : map.keySet()) { int count = map.get(c); max += count; if ((count % 2) != 0) { max--; odd = true; } } if (odd) max++; return max; }","public int sample_funcname ( String var_1 ) { Map < Character , Integer > var_6 = new HashMap < > ( ) ; for ( char var_8 : var_1 . toCharArray ( ) ) { var_6 . putIfAbsent ( var_8 , 0 ) ; int var_12 = var_6 . get ( var_8 ) ; var_6 . put ( var_8 , var_12 + 1 ) ; } int var_15 = 0 ; boolean var_19 = false ; for ( char var_8 : var_6 . keySet ( ) ) { int var_12 = var_6 . get ( var_8 ) ; var_15 += var_12 ; if ( ( var_12 % 2 ) != 0 ) { var_15 -- ; var_19 = true ; } } if ( var_19 ) var_15 ++ ; return var_15 ; } " 1091,binary_search_PowXN_1.java,"public double solve(double x, long n) { if (n == 1) return x; double val = solve(x, n / 2); return val * val * ((n % 2) == 0 ? 1 : x); }","public double sample_funcname ( double x , long n ) { if ( n == 1 ) return x ; double val = solve ( x , n / 2 ) ; return val * val * ( ( n % 2 ) == 0 ? 1 : x ) ; } " 1092,array_MinimumTimeDifference_1.java,"public int findMinDifference(List timePoints) { List timeInMinutes = timePoints .stream() .map( t -> { String[] strings = t.split("":""); return Integer.parseInt(strings[0]) * 60 + Integer.parseInt(strings[1]); }) .sorted(Integer::compareTo) .collect(Collectors.toList()); int min = Integer.MAX_VALUE; for (int i = 1, l = timeInMinutes.size(); i < l; i++) { int prev = timeInMinutes.get(i - 1); int curr = timeInMinutes.get(i); min = Math.min(min, curr - prev); min = Math.min(min, ((24 * 60) - curr) + prev); } int prev = timeInMinutes.get(0); int curr = timeInMinutes.get(timeInMinutes.size() - 1); min = Math.min(min, curr - prev); min = Math.min(min, ((24 * 60) - curr) + prev); return min; }","public int sample_funcname ( List < String > var_2 ) { List < Integer > var_19 = var_2 . stream ( ) . map ( var_10 -> { String [ ] var_14 = var_10 . split ( "":"" ) ; return Integer . parseInt ( var_14 [ 0 ] ) * 60 + Integer . parseInt ( var_14 [ 1 ] ) ; } ) . sorted ( Integer :: compareTo ) . collect ( Collectors . toList ( ) ) ; int min = Integer . MAX_VALUE ; for ( int var_22 = 1 , var_24 = var_19 . size ( ) ; var_22 < var_24 ; var_22 ++ ) { int var_26 = var_19 . get ( var_22 - 1 ) ; int var_27 = var_19 . get ( var_22 ) ; min = Math . min ( min , var_27 - var_26 ) ; min = Math . min ( min , ( ( 24 * 60 ) - var_27 ) + var_26 ) ; } int var_26 = var_19 . get ( 0 ) ; int var_27 = var_19 . get ( var_19 . size ( ) - 1 ) ; min = Math . min ( min , var_27 - var_26 ) ; min = Math . min ( min , ( ( 24 * 60 ) - var_27 ) + var_26 ) ; return min ; } " 1093,hashing_ContiguousArray_1.java,"public int findMaxLength(int[] nums) { Map map = new HashMap<>(); int count = 0; int max = 0; for (int i = 0; i < nums.length; i++) { if (nums[i] == 0) { count--; } else count++; if (count == 0) { max = Math.max(max, i + 1); } else { if (map.containsKey(count)) { int index = map.get(count); max = Math.max(max, i - index); } else { map.put(count, i); } } } return max; }","public int sample_funcname ( int [ ] var_0 ) { Map < Integer , Integer > var_4 = new HashMap < > ( ) ; int var_6 = 0 ; int max = 0 ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { if ( var_0 [ var_8 ] == 0 ) { var_6 -- ; } else var_6 ++ ; if ( var_6 == 0 ) { max = Math . max ( max , var_8 + 1 ) ; } else { if ( var_4 . containsKey ( var_6 ) ) { int var_14 = var_4 . get ( var_6 ) ; max = Math . max ( max , var_8 - var_14 ) ; } else { var_4 . put ( var_6 , var_8 ) ; } } } return max ; } " 1094,heap_SlidingWindowMaximum_1.java,"public int[] maxSlidingWindow(int[] nums, int k) { int[] result = new int[nums.length - (k - 1)]; if (nums.length == 0) return new int[0]; Deque queue = new ArrayDeque<>(); for (int i = 0, j = 0, l = nums.length; i < l; i++) { int head = i - (k - 1); if (head >= 0) { if (queue.peek() != null && queue.peek() < head) queue.poll(); } while (queue.peekLast() != null && nums[queue.peekLast()] <= nums[i]) { queue.pollLast(); } queue.offer(i); if (i >= k - 1) result[j++] = nums[queue.peek()]; } return result; }","public int [ ] sample_funcname ( int [ ] var_0 , int var_1 ) { int [ ] var_4 = new int [ var_0 . length - ( var_1 - 1 ) ] ; if ( var_0 . length == 0 ) return new int [ 0 ] ; Deque < Integer > var_9 = new ArrayDeque < > ( ) ; for ( int var_10 = 0 , var_11 = 0 , var_12 = var_0 . length ; var_10 < var_12 ; var_10 ++ ) { int var_13 = var_10 - ( var_1 - 1 ) ; if ( var_13 >= 0 ) { if ( var_9 . peek ( ) != null && var_9 . peek ( ) < var_13 ) var_9 . poll ( ) ; } while ( var_9 . peekLast ( ) != null && var_0 [ var_9 . peekLast ( ) ] <= var_0 [ var_10 ] ) { var_9 . pollLast ( ) ; } var_9 . offer ( var_10 ) ; if ( var_10 >= var_1 - 1 ) var_4 [ var_11 ++ ] = var_0 [ var_9 . peek ( ) ] ; } return var_4 ; } " 1095,greedy_BrokenCalculator_1.java,"public int brokenCalc(int X, int Y) { if (X == Y) return 0; else if (Y < X) return X - Y; else { int count = 0; while (Y > X) { if (Y % 2 == 0) { Y /= 2; count++; } else { Y += 1; Y /= 2; count += 2; } } if (X == Y) return count; else return count + (X - Y); } }","public int sample_funcname ( int var_0 , int var_1 ) { if ( var_0 == var_1 ) return 0 ; else if ( var_1 < var_0 ) return var_0 - var_1 ; else { int var_3 = 0 ; while ( var_1 > var_0 ) { if ( var_1 % 2 == 0 ) { var_1 /= 2 ; var_3 ++ ; } else { var_1 += 1 ; var_1 /= 2 ; var_3 += 2 ; } } if ( var_0 == var_1 ) return var_3 ; else return var_3 + ( var_0 - var_1 ) ; } } " 1096,binary_search_FindPeakElement_1.java,"public int findPeakElement(int[] nums) { if (nums.length == 1) return 0; if (nums[0] > nums[1]) return 0; else if (nums[nums.length - 1] > nums[nums.length - 2]) return nums.length - 1; int l = 0, h = nums.length - 1; int ans = 0; while (l <= h) { int m = l + (h - l) / 2; if (m - 1 >= 0 && m + 1 < nums.length) { if (nums[m] > nums[m - 1] && nums[m] > nums[m + 1]) { return m; } } if (m - 1 >= 0 && nums[m - 1] > nums[m]) { h = m - 1; } else { ans = l; l = m + 1; } } return ans; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 1 ) return 0 ; if ( var_0 [ 0 ] > var_0 [ 1 ] ) return 0 ; else if ( var_0 [ var_0 . length - 1 ] > var_0 [ var_0 . length - 2 ] ) return var_0 . length - 1 ; int var_5 = 0 , var_6 = var_0 . length - 1 ; int var_7 = 0 ; while ( var_5 <= var_6 ) { int var_8 = var_5 + ( var_6 - var_5 ) / 2 ; if ( var_8 - 1 >= 0 && var_8 + 1 < var_0 . length ) { if ( var_0 [ var_8 ] > var_0 [ var_8 - 1 ] && var_0 [ var_8 ] > var_0 [ var_8 + 1 ] ) { return var_8 ; } } if ( var_8 - 1 >= 0 && var_0 [ var_8 - 1 ] > var_0 [ var_8 ] ) { var_6 = var_8 - 1 ; } else { var_7 = var_5 ; var_5 = var_8 + 1 ; } } return var_7 ; } " 1097,string_IsomorphicStrings_1.java,"public boolean isIsomorphic(String s, String t) { if (s.length() != t.length()) return false; Map first = new HashMap<>(); Map second = new HashMap<>(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (first.containsKey(c)) { char secondC = first.get(c); if (t.charAt(i) != secondC) return false; } else { first.put(c, t.charAt(i)); if (second.containsKey(t.charAt(i))) return false; second.put(t.charAt(i), c); } } return true; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 . length ( ) != var_3 . length ( ) ) return false ; Map < Character , Character > var_8 = new HashMap < > ( ) ; Map < Character , Character > var_9 = new HashMap < > ( ) ; for ( int var_11 = 0 ; var_11 < var_2 . length ( ) ; var_11 ++ ) { char var_13 = var_2 . charAt ( var_11 ) ; if ( var_8 . containsKey ( var_13 ) ) { char var_16 = var_8 . get ( var_13 ) ; if ( var_3 . charAt ( var_11 ) != var_16 ) return false ; } else { var_8 . put ( var_13 , var_3 . charAt ( var_11 ) ) ; if ( var_9 . containsKey ( var_3 . charAt ( var_11 ) ) ) return false ; var_9 . put ( var_3 . charAt ( var_11 ) , var_13 ) ; } } return true ; } " 1098,two_pointers_FourSum_1.java,"public List> fourSum(int[] nums, int target) { List> result = new ArrayList<>(); if (nums.length < 4) return result; Arrays.sort(nums); for (int i = 0; i < nums.length - 3; i++) { if (i == 0 || nums[i] != nums[i - 1]) { for (int j = i + 1; j < nums.length - 2; j++) { if (j == i + 1 || nums[j] != nums[j - 1]) { int k = j + 1, l = nums.length - 1; while (k < l) { if (k != j + 1 && nums[k] == nums[k + 1]) { k++; continue; } int sum = nums[i] + nums[j] + nums[k] + nums[l]; if (sum == target) { result.add(Arrays.asList(nums[i], nums[j], nums[k], nums[l])); k++; l--; } else if (sum < target) { k++; } else { l--; } } } } } } return result; }","public List < List < Integer >> var_2 ( int [ ] var_3 , int var_4 ) { List < List < Integer >> var_6 = new ArrayList < > ( ) ; if ( var_3 . length < 4 ) return var_6 ; Arrays . sort ( var_3 ) ; for ( int var_12 = 0 ; var_12 < var_3 . length - 3 ; var_12 ++ ) { if ( var_12 == 0 || var_3 [ var_12 ] != var_3 [ var_12 - 1 ] ) { for ( int var_15 = var_12 + 1 ; var_15 < var_3 . length - 2 ; var_15 ++ ) { if ( var_15 == var_12 + 1 || var_3 [ var_15 ] != var_3 [ var_15 - 1 ] ) { int var_17 = var_15 + 1 , var_18 = var_3 . length - 1 ; while ( var_17 < var_18 ) { if ( var_17 != var_15 + 1 && var_3 [ var_17 ] == var_3 [ var_17 + 1 ] ) { var_17 ++ ; continue ; } int var_19 = var_3 [ var_12 ] + var_3 [ var_15 ] + var_3 [ var_17 ] + var_3 [ var_18 ] ; if ( var_19 == var_4 ) { var_6 . add ( Arrays . asList ( var_3 [ var_12 ] , var_3 [ var_15 ] , var_3 [ var_17 ] , var_3 [ var_18 ] ) ) ; var_17 ++ ; var_18 -- ; } else if ( var_19 < var_4 ) { var_17 ++ ; } else { var_18 -- ; } } } } } } return var_6 ; } " 1099,dynamic_programming_MinimumCostForTickets_1.java,"public int mincostTickets(int[] days, int[] costs) { int[] min = new int[days.length]; Arrays.fill(min, Integer.MAX_VALUE); for (int i = days.length - 1; i >= 0; i--) { for (int j = 0; j < costs.length; j++) { if (j == 0) { min[i] = Math.min(min[i], costs[j] + ((i + 1 >= min.length) ? 0 : min[i + 1])); } else if (j == 1) { int c = 0; for (int k = i + 1; k < days.length; k++) { if (days[k] >= (days[i] + 7)) { c = min[k]; break; } } min[i] = Math.min(min[i], costs[j] + c); } else { int c = 0; for (int k = i + 1; k < days.length; k++) { if (days[k] >= (days[i] + 30)) { c = min[k]; break; } } min[i] = Math.min(min[i], costs[j] + c); } } } return min[0]; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { int [ ] min = new int [ var_0 . length ] ; Arrays . fill ( min , Integer . MAX_VALUE ) ; for ( int var_9 = var_0 . length - 1 ; var_9 >= 0 ; var_9 -- ) { for ( int var_11 = 0 ; var_11 < var_1 . length ; var_11 ++ ) { if ( var_11 == 0 ) { min [ var_9 ] = Math . min ( min [ var_9 ] , var_1 [ var_11 ] + ( ( var_9 + 1 >= min . length ) ? 0 : min [ var_9 + 1 ] ) ) ; } else if ( var_11 == 1 ) { int var_13 = 0 ; for ( int var_14 = var_9 + 1 ; var_14 < var_0 . length ; var_14 ++ ) { if ( var_0 [ var_14 ] >= ( var_0 [ var_9 ] + 7 ) ) { var_13 = min [ var_14 ] ; break ; } } min [ var_9 ] = Math . min ( min [ var_9 ] , var_1 [ var_11 ] + var_13 ) ; } else { int var_13 = 0 ; for ( int var_14 = var_9 + 1 ; var_14 < var_0 . length ; var_14 ++ ) { if ( var_0 [ var_14 ] >= ( var_0 [ var_9 ] + 30 ) ) { var_13 = min [ var_14 ] ; break ; } } min [ var_9 ] = Math . min ( min [ var_9 ] , var_1 [ var_11 ] + var_13 ) ; } } } return min [ 0 ] ; } " 1100,string_FindTheClosestPalindrome_1.java,"private String getLow(String s) { int n = s.length() - 1; StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { sb.append(""9""); } return sb.toString(); }","private String var_0 ( String var_2 ) { int var_5 = var_2 . length ( ) - 1 ; StringBuilder var_7 = new StringBuilder ( ) ; for ( int var_9 = 0 ; var_9 < var_5 ; var_9 ++ ) { var_7 . append ( ""9"" ) ; } return var_7 . toString ( ) ; } " 1101,dynamic_programming_LengthofLongestFibonacciSubsequence_1.java,"public int lenLongestFibSubseq(int[] A) { if (A.length < 3) return 0; Map> indexMap = new HashMap<>(); int max = 0; for (int i = A.length - 1; i >= 0; i--) { Map subHashMap = new HashMap<>(); for (int j = 0; j < i; j++) { int sum = A[i] + A[j]; if (indexMap.containsKey(sum)) { if (indexMap.get(sum).containsKey(A[i])) { int value = 1 + indexMap.get(sum).get(A[i]); subHashMap.put(A[j], value); max = Math.max(max, value); } else { subHashMap.put(A[j], 1); max = Math.max(max, 1); } } } indexMap.put(A[i], subHashMap); } return max == 0 ? 0 : max + 2; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length < 3 ) return 0 ; Map < Integer , Map < Integer , Integer >> var_7 = new HashMap < > ( ) ; int max = 0 ; for ( int var_10 = var_0 . length - 1 ; var_10 >= 0 ; var_10 -- ) { Map < Integer , Integer > var_11 = new HashMap < > ( ) ; for ( int var_12 = 0 ; var_12 < var_10 ; var_12 ++ ) { int var_13 = var_0 [ var_10 ] + var_0 [ var_12 ] ; if ( var_7 . containsKey ( var_13 ) ) { if ( var_7 . get ( var_13 ) . containsKey ( var_0 [ var_10 ] ) ) { int var_16 = 1 + var_7 . get ( var_13 ) . get ( var_0 [ var_10 ] ) ; var_11 . put ( var_0 [ var_12 ] , var_16 ) ; max = Math . max ( max , var_16 ) ; } else { var_11 . put ( var_0 [ var_12 ] , 1 ) ; max = Math . max ( max , 1 ) ; } } } var_7 . put ( var_0 [ var_10 ] , var_11 ) ; } return max == 0 ? 0 : max + 2 ; } " 1102,dynamic_programming_PalindromicSubstrings_1.java,"public int countSubstrings(String s) { boolean[][] T = new boolean[s.length()][s.length()]; int count = s.length(); for (int i = 0, j = 0; i < T.length; i++, j++) { T[i][j] = true; } for (int k = 1, col = s.length(); k < col; k++) { for (int i = 0, j = k; i < col && j < col; i++, j++) { if (k == 1) { if (s.charAt(i) == s.charAt(j)) { T[i][j] = true; count++; } } else { if (s.charAt(i) == s.charAt(j) && T[i + 1][j - 1]) { T[i][j] = true; count++; } } } } return count; }","public int sample_funcname ( String var_1 ) { boolean [ ] [ ] var_4 = new boolean [ var_1 . length ( ) ] [ var_1 . length ( ) ] ; int var_5 = var_1 . length ( ) ; for ( int var_7 = 0 , var_8 = 0 ; var_7 < var_4 . length ; var_7 ++ , var_8 ++ ) { var_4 [ var_7 ] [ var_8 ] = true ; } for ( int var_10 = 1 , var_11 = var_1 . length ( ) ; var_10 < var_11 ; var_10 ++ ) { for ( int var_7 = 0 , var_8 = var_10 ; var_7 < var_11 && var_8 < var_11 ; var_7 ++ , var_8 ++ ) { if ( var_10 == 1 ) { if ( var_1 . charAt ( var_7 ) == var_1 . charAt ( var_8 ) ) { var_4 [ var_7 ] [ var_8 ] = true ; var_5 ++ ; } } else { if ( var_1 . charAt ( var_7 ) == var_1 . charAt ( var_8 ) && var_4 [ var_7 + 1 ] [ var_8 - 1 ] ) { var_4 [ var_7 ] [ var_8 ] = true ; var_5 ++ ; } } } } return var_5 ; } " 1103,array_KEmptySlots_1.java,"public int kEmptySlots(int[] flowers, int k) { TreeSet set = new TreeSet<>(); for (int i = 0; i < flowers.length; i++) { Integer lowerBound = set.floor(flowers[i]); Integer upperBound = set.ceiling(flowers[i]); if (lowerBound != null) { if ((Math.abs(flowers[i] - lowerBound) + 1) == k) { return i + 1; } } if (upperBound != null) { if ((Math.abs(flowers[i] - upperBound) + 1) == k) { return i + 1; } } set.add(flowers[i]); } return -1; }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { TreeSet < Integer > var_4 = new TreeSet < > ( ) ; for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { Integer var_9 = var_4 . floor ( var_0 [ var_6 ] ) ; Integer var_11 = var_4 . ceiling ( var_0 [ var_6 ] ) ; if ( var_9 != null ) { if ( ( Math . abs ( var_0 [ var_6 ] - var_9 ) + 1 ) == var_1 ) { return var_6 + 1 ; } } if ( var_11 != null ) { if ( ( Math . abs ( var_0 [ var_6 ] - var_11 ) + 1 ) == var_1 ) { return var_6 + 1 ; } } var_4 . add ( var_0 [ var_6 ] ) ; } return - 1 ; } " 1104,array_RevealCardsInIncreasingOrder_1.java,"public int[] deckRevealedIncreasing(int[] deck) { Arrays.sort(deck); ArrayDeque queue = new ArrayDeque<>(); for (int i = deck.length - 1; i >= 0; i--) { queue.offer(deck[i]); if (i == 0) break; int temp = queue.pollFirst(); queue.offer(temp); } int[] answer = new int[deck.length]; int i = 0; while (!queue.isEmpty()) { answer[i++] = queue.pollLast(); } return answer; }","public int [ ] sample_funcname ( int [ ] var_0 ) { Arrays . sort ( var_0 ) ; ArrayDeque < Integer > var_5 = new ArrayDeque < > ( ) ; for ( int var_8 = var_0 . length - 1 ; var_8 >= 0 ; var_8 -- ) { var_5 . offer ( var_0 [ var_8 ] ) ; if ( var_8 == 0 ) break ; int var_12 = var_5 . pollFirst ( ) ; var_5 . offer ( var_12 ) ; } int [ ] var_13 = new int [ var_0 . length ] ; int var_8 = 0 ; while ( ! var_5 . isEmpty ( ) ) { var_13 [ var_8 ++ ] = var_5 . pollLast ( ) ; } return var_13 ; } " 1105,two_pointers_TrappingRainWater_1.java,"private int trap(int[] height) { if (height.length == 0) return 0; int[] left = new int[height.length]; int[] right = new int[height.length]; int max = 0; left[0] = 0; right[height.length - 1] = 0; int total = 0; for (int i = 1, l = height.length; i < l; i++) { left[i] = Math.max(max, height[i - 1]); max = left[i]; } max = 0; for (int i = height.length - 2; i >= 0; i--) { right[i] = Math.max(max, height[i + 1]); max = right[i]; } for (int i = 0, l = height.length; i < l; i++) { int min = Math.min(left[i], right[i]); if (min > height[i]) { total += (min - height[i]); } } return total; }","private int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int [ ] var_3 = new int [ var_0 . length ] ; int [ ] var_4 = new int [ var_0 . length ] ; int max = 0 ; var_3 [ 0 ] = 0 ; var_4 [ var_0 . length - 1 ] = 0 ; int var_7 = 0 ; for ( int var_8 = 1 , var_9 = var_0 . length ; var_8 < var_9 ; var_8 ++ ) { var_3 [ var_8 ] = Math . max ( max , var_0 [ var_8 - 1 ] ) ; max = var_3 [ var_8 ] ; } max = 0 ; for ( int var_8 = var_0 . length - 2 ; var_8 >= 0 ; var_8 -- ) { var_4 [ var_8 ] = Math . max ( max , var_0 [ var_8 + 1 ] ) ; max = var_4 [ var_8 ] ; } for ( int var_8 = 0 , var_9 = var_0 . length ; var_8 < var_9 ; var_8 ++ ) { int min = Math . min ( var_3 [ var_8 ] , var_4 [ var_8 ] ) ; if ( min > var_0 [ var_8 ] ) { var_7 += ( min - var_0 [ var_8 ] ) ; } } return var_7 ; } " 1106,greedy_BurstBalloons_1.java,"public int findMinArrowShots(int[][] points) { if (points.length == 0) return 0; Arrays.sort(points, ((o1, o2) -> o1[1] - o2[1])); int count = 0; int leftMost = points[0][1]; for (int i = 1; i < points.length; i++) { if (leftMost < points[i][0]) { count++; leftMost = points[i][1]; } } return count + 1; }","public int sample_funcname ( int [ ] [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; Arrays . sort ( var_0 , ( ( var_5 , var_6 ) -> var_5 [ 1 ] - var_6 [ 1 ] ) ) ; int var_8 = 0 ; int var_9 = var_0 [ 0 ] [ 1 ] ; for ( int var_10 = 1 ; var_10 < var_0 . length ; var_10 ++ ) { if ( var_9 < var_0 [ var_10 ] [ 0 ] ) { var_8 ++ ; var_9 = var_0 [ var_10 ] [ 1 ] ; } } return var_8 + 1 ; } " 1107,array_MergeSortedArray_1.java,"public void merge(int[] nums1, int m, int[] nums2, int n) { int i = m + n - 1, j = m - 1, k = n - 1; while (j >= 0 && k >= 0) nums1[i--] = (nums1[j] > nums2[k]) ? nums1[j--] : nums2[k--]; while (k >= 0) nums1[i--] = nums2[k--]; }","public void var_0 ( int [ ] var_1 , int var_2 , int [ ] var_3 , int var_4 ) { int var_6 = var_2 + var_4 - 1 , var_7 = var_2 - 1 , var_8 = var_4 - 1 ; while ( var_7 >= 0 && var_8 >= 0 ) var_1 [ var_6 -- ] = ( var_1 [ var_7 ] > var_3 [ var_8 ] ) ? var_1 [ var_7 -- ] : var_3 [ var_8 -- ] ; while ( var_8 >= 0 ) var_1 [ var_6 -- ] = var_3 [ var_8 -- ] ; } " 1108,binary_search_SearchForARange_1.java,"private int findIndex(int[] nums, int target, boolean isLowerIndex) { int result = -1; int s = 0, e = nums.length - 1; while (s <= e) { int m = s + (e - s) / 2; if (nums[m] == target) { result = m; if (isLowerIndex) e = m - 1; else s = m + 1; } else if (nums[m] < target) { s = m + 1; } else e = m - 1; } return result; }","private int sample_funcname ( int [ ] var_0 , int var_1 , boolean var_3 ) { int var_5 = - 1 ; int var_7 = 0 , var_9 = var_0 . length - 1 ; while ( var_7 <= var_9 ) { int var_11 = var_7 + ( var_9 - var_7 ) / 2 ; if ( var_0 [ var_11 ] == var_1 ) { var_5 = var_11 ; if ( var_3 ) var_9 = var_11 - 1 ; else var_7 = var_11 + 1 ; } else if ( var_0 [ var_11 ] < var_1 ) { var_7 = var_11 + 1 ; } else var_9 = var_11 - 1 ; } return var_5 ; } " 1109,string_CountAndSay_1.java,"public String countAndSay(int n) { String result = ""1""; for (int i = 1; i < n; i++) { int count = 1; char num = result.charAt(0); StringBuilder temp = new StringBuilder(); for (int j = 1, l = result.length(); j < l; j++) { if (result.charAt(j) == num) { count++; } else { temp = temp.append(String.valueOf(count)).append(String.valueOf(num)); num = result.charAt(j); count = 1; } } temp = temp.append(String.valueOf(count)).append(String.valueOf(num)); result = temp.toString(); } return result; }","public String var_0 ( int var_1 ) { String var_4 = ""1"" ; for ( int var_6 = 1 ; var_6 < var_1 ; var_6 ++ ) { int var_7 = 1 ; char var_10 = var_4 . charAt ( 0 ) ; StringBuilder var_12 = new StringBuilder ( ) ; for ( int var_13 = 1 , var_15 = var_4 . length ( ) ; var_13 < var_15 ; var_13 ++ ) { if ( var_4 . charAt ( var_13 ) == var_10 ) { var_7 ++ ; } else { var_12 = var_12 . append ( String . valueOf ( var_7 ) ) . append ( String . valueOf ( var_10 ) ) ; var_10 = var_4 . charAt ( var_13 ) ; var_7 = 1 ; } } var_12 = var_12 . append ( String . valueOf ( var_7 ) ) . append ( String . valueOf ( var_10 ) ) ; var_4 = var_12 . toString ( ) ; } return var_4 ; } " 1110,hashing_PartitionLabels_1.java,"public List partitionLabels(String S) { if (S == null || S.trim().isEmpty()) return new ArrayList<>(); Map map = new HashMap<>(); for (int i = S.length() - 1; i >= 0; i--) { char c = S.charAt(i); map.putIfAbsent(c, i); } List result = new ArrayList<>(); int start = 0; int max = map.get(S.charAt(0)); for (int i = 0; i < S.length(); i++) { char c = S.charAt(i); if (map.get(c) > max) { max = map.get(c); } else if (i == max) { result.add(max - start + 1); if (i < S.length() - 1) { start = i + 1; max = map.get(S.charAt(i + 1)); } } } return result; }","public List < Integer > var_1 ( String var_3 ) { if ( var_3 == null || var_3 . trim ( ) . isEmpty ( ) ) return new ArrayList < > ( ) ; Map < Character , Integer > var_11 = new HashMap < > ( ) ; for ( int var_14 = var_3 . length ( ) - 1 ; var_14 >= 0 ; var_14 -- ) { char var_17 = var_3 . charAt ( var_14 ) ; var_11 . putIfAbsent ( var_17 , var_14 ) ; } List < Integer > var_20 = new ArrayList < > ( ) ; int var_21 = 0 ; int var_23 = var_11 . get ( var_3 . charAt ( 0 ) ) ; for ( int var_14 = 0 ; var_14 < var_3 . length ( ) ; var_14 ++ ) { char var_17 = var_3 . charAt ( var_14 ) ; if ( var_11 . get ( var_17 ) > var_23 ) { var_23 = var_11 . get ( var_17 ) ; } else if ( var_14 == var_23 ) { var_20 . add ( var_23 - var_21 + 1 ) ; if ( var_14 < var_3 . length ( ) - 1 ) { var_21 = var_14 + 1 ; var_23 = var_11 . get ( var_3 . charAt ( var_14 + 1 ) ) ; } } } return var_20 ; } " 1111,two_pointers_RemoveDuplicatesII_1.java,"public int removeDuplicates(int[] nums) { if (nums.length == 0) return 0; int j = 0; int count = 1; for (int i = 1; i < nums.length; i++) { if (nums[i - 1] == nums[i]) { count++; } else { count = 1; } if (count == 1 || count == 2) { j++; nums[j] = nums[i]; } } return j + 1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int var_3 = 0 ; int var_5 = 1 ; for ( int var_6 = 1 ; var_6 < var_0 . length ; var_6 ++ ) { if ( var_0 [ var_6 - 1 ] == var_0 [ var_6 ] ) { var_5 ++ ; } else { var_5 = 1 ; } if ( var_5 == 1 || var_5 == 2 ) { var_3 ++ ; var_0 [ var_3 ] = var_0 [ var_6 ] ; } } return var_3 + 1 ; } " 1112,dynamic_programming_DecodeWays_1.java,"public int numDecodings(String s) { if (s == null || s.isEmpty()) return 0; int[] dp = new int[s.length() + 2]; dp[s.length()] = 1; dp[s.length() + 1] = 1; for (int i = s.length() - 1; i >= 0; i--) { for (int j = i + 1; j < i + 3; j++) { if (j <= s.length()) { String subStr = s.substring(i, j); if (!subStr.startsWith(""0"")) { int intVal = Integer.parseInt(subStr); if (intVal <= 26) { dp[i] += dp[j]; } } } } } return dp[0]; }","public int sample_funcname ( String var_1 ) { if ( var_1 == null || var_1 . isEmpty ( ) ) return 0 ; int [ ] var_7 = new int [ var_1 . length ( ) + 2 ] ; var_7 [ var_1 . length ( ) ] = 1 ; var_7 [ var_1 . length ( ) + 1 ] = 1 ; for ( int var_9 = var_1 . length ( ) - 1 ; var_9 >= 0 ; var_9 -- ) { for ( int var_10 = var_9 + 1 ; var_10 < var_9 + 3 ; var_10 ++ ) { if ( var_10 <= var_1 . length ( ) ) { String var_13 = var_1 . substring ( var_9 , var_10 ) ; if ( ! var_13 . startsWith ( ""0"" ) ) { int var_18 = Integer . parseInt ( var_13 ) ; if ( var_18 <= 26 ) { var_7 [ var_9 ] += var_7 [ var_10 ] ; } } } } } return var_7 [ 0 ] ; } " 1113,string_RotateString_1.java,"public boolean rotateString(String A, String B) { if (A.length() == 1 || A.isEmpty() || B.length() == 1 || B.isEmpty()) { return A.equals(B); } else if (A.length() != B.length()) { return false; } for (int i = 0, l = A.length(); i < l; i++) { char s = A.charAt(0); A = A.substring(1) + s; if (A.equals(B)) return true; } return false; }","public boolean var_0 ( String var_2 , String var_3 ) { if ( var_2 . length ( ) == 1 || var_2 . isEmpty ( ) || var_3 . length ( ) == 1 || var_3 . isEmpty ( ) ) { return var_2 . equals ( var_3 ) ; } else if ( var_2 . length ( ) != var_3 . length ( ) ) { return false ; } for ( int var_9 = 0 , var_10 = var_2 . length ( ) ; var_9 < var_10 ; var_9 ++ ) { char var_12 = var_2 . charAt ( 0 ) ; var_2 = var_2 . substring ( 1 ) + var_12 ; if ( var_2 . equals ( var_3 ) ) return true ; } return false ; } " 1114,dynamic_programming_CornerRectangles_1.java,"public int countCornerRectangles(int[][] grid) { int[][] count = new int[grid[0].length][grid[0].length]; int result = 0; for (int[] row : grid) { for (int i = 0; i < row.length; i++) { if (row[i] == 1) { for (int j = i + 1; j < row.length; j++) { if (row[j] == 1) { if (count[i][j] > 0) { result += count[i][j]; } count[i][j]++; } } } } } return result; }","public int sample_funcname ( int [ ] [ ] var_0 ) { int [ ] [ ] var_3 = new int [ var_0 [ 0 ] . length ] [ var_0 [ 0 ] . length ] ; int var_4 = 0 ; for ( int [ ] var_5 : var_0 ) { for ( int var_6 = 0 ; var_6 < var_5 . length ; var_6 ++ ) { if ( var_5 [ var_6 ] == 1 ) { for ( int var_8 = var_6 + 1 ; var_8 < var_5 . length ; var_8 ++ ) { if ( var_5 [ var_8 ] == 1 ) { if ( var_3 [ var_6 ] [ var_8 ] > 0 ) { var_4 += var_3 [ var_6 ] [ var_8 ] ; } var_3 [ var_6 ] [ var_8 ] ++ ; } } } } } return var_4 ; } " 1115,dynamic_programming_CombinationSumIV_1.java,"private int backtrack(int[] nums, int[] dp, int sum) { int total = 0; if (sum < 0) return 0; if (dp[sum] != -1) return dp[sum]; else { for (int num : nums) { total += backtrack(nums, dp, sum - num); } } dp[sum] = total; return dp[sum]; }","private int sample_funcname ( int [ ] nums , int [ ] dp , int sum ) { int total = 0 ; if ( sum < 0 ) return 0 ; if ( dp [ sum ] != - 1 ) return dp [ sum ] ; else { for ( int num : nums ) { total += backtrack ( nums , dp , sum - num ) ; } } dp [ sum ] = total ; return dp [ sum ] ; } " 1116,dynamic_programming_BestTimeToBuyAndSellStockIII_1.java,"public int maxProfit(int[] prices) { if (prices.length == 0 || prices.length == 1) return 0; int[] dp = new int[prices.length]; int min = prices[0]; int max = prices[prices.length - 1]; for (int i = prices.length - 2; i >= 0; i--) { dp[i] = Math.max(max - prices[i], dp[i + 1]); max = Math.max(max, prices[i]); } max = Integer.MIN_VALUE; for (int i = 0; i < prices.length; i++) { max = Math.max(max, prices[i] - min + dp[i]); min = Math.min(min, prices[i]); } return max; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 || var_0 . length == 1 ) return 0 ; int [ ] var_4 = new int [ var_0 . length ] ; int min = var_0 [ 0 ] ; int max = var_0 [ var_0 . length - 1 ] ; for ( int var_8 = var_0 . length - 2 ; var_8 >= 0 ; var_8 -- ) { var_4 [ var_8 ] = Math . max ( max - var_0 [ var_8 ] , var_4 [ var_8 + 1 ] ) ; max = Math . max ( max , var_0 [ var_8 ] ) ; } max = Integer . MIN_VALUE ; for ( int var_8 = 0 ; var_8 < var_0 . length ; var_8 ++ ) { max = Math . max ( max , var_0 [ var_8 ] - min + var_4 [ var_8 ] ) ; min = Math . min ( min , var_0 [ var_8 ] ) ; } return max ; } " 1117,math_CountPrimes_1.java,"public int countPrimes(int n) { if (n == 0 || n == 1 || n == 2) return 0; else if (n == 3) return 1; BitSet set = new BitSet(); n = n - 1; int sqRt = (int) Math.sqrt(n); int count = n; for (int i = 2; i <= sqRt; i++) { if (!set.get(i)) { for (int j = 2; (i * j) <= n; j++) { if (!set.get(i * j)) { count--; set.set(i * j); } } } } return count - 1; }","public int sample_funcname ( int var_0 ) { if ( var_0 == 0 || var_0 == 1 || var_0 == 2 ) return 0 ; else if ( var_0 == 3 ) return 1 ; BitSet set = new BitSet ( ) ; var_0 = var_0 - 1 ; int var_9 = ( int ) Math . sqrt ( var_0 ) ; int var_10 = var_0 ; for ( int var_11 = 2 ; var_11 <= var_9 ; var_11 ++ ) { if ( ! set . get ( var_11 ) ) { for ( int var_13 = 2 ; ( var_11 * var_13 ) <= var_0 ; var_13 ++ ) { if ( ! set . get ( var_11 * var_13 ) ) { var_10 -- ; set . set ( var_11 * var_13 ) ; } } } } return var_10 - 1 ; } " 1118,depth_first_search_CrackingTheSafe_1.java,"private int getStates(int n, int k) { if (n == 0) return 1; if (n == 1) return k; int result = 1; for (int i = 0; i < n; i++) { result *= k; } return result; }","private int sample_funcname ( int var_0 , int var_1 ) { if ( var_0 == 0 ) return 1 ; if ( var_0 == 1 ) return var_1 ; int var_4 = 1 ; for ( int var_5 = 0 ; var_5 < var_0 ; var_5 ++ ) { var_4 *= var_1 ; } return var_4 ; } " 1119,array_AddToArrayFormOfInteger_1.java,"public List addToArrayForm(int[] A, int K) { StringBuilder sb = new StringBuilder(); for (int a : A) { sb.append(a); } BigInteger big = new BigInteger(sb.toString()); BigInteger result = big.add(BigInteger.valueOf(K)); String resultStr = result.toString(); List list = new ArrayList<>(); for (char a : resultStr.toCharArray()) { list.add(Integer.parseInt(String.valueOf(a))); } return list; }","public List < Integer > var_1 ( int [ ] var_2 , int var_3 ) { StringBuilder var_5 = new StringBuilder ( ) ; for ( int var_6 : var_2 ) { var_5 . append ( var_6 ) ; } BigInteger var_10 = new BigInteger ( var_5 . toString ( ) ) ; BigInteger var_13 = var_10 . add ( BigInteger . valueOf ( var_3 ) ) ; String var_15 = var_13 . toString ( ) ; List < Integer > var_18 = new ArrayList < > ( ) ; for ( char var_6 : var_15 . toCharArray ( ) ) { var_18 . add ( Integer . parseInt ( String . valueOf ( var_6 ) ) ) ; } return var_18 ; } " 1120,dynamic_programming_TossStrangeCoins_1.java,"public double probabilityOfHeads(double[] prob, int target) { double[][] DP = new double[target + 1][prob.length]; DP[0][0] = 1 - prob[0]; DP[1][0] = prob[0]; for (int c = 1; c < prob.length; c++) { for (int t = 0; t <= target; t++) { if (t == 0) DP[t][c] = DP[t][c - 1] * (1 - prob[c]); else DP[t][c] = DP[t][c - 1] * (1 - prob[c]) + DP[t - 1][c - 1] * (prob[c]); } } return DP[target][prob.length - 1]; }","public double sample_funcname ( double [ ] var_0 , int var_1 ) { double [ ] [ ] var_4 = new double [ var_1 + 1 ] [ var_0 . length ] ; var_4 [ 0 ] [ 0 ] = 1 - var_0 [ 0 ] ; var_4 [ 1 ] [ 0 ] = var_0 [ 0 ] ; for ( int var_6 = 1 ; var_6 < var_0 . length ; var_6 ++ ) { for ( int var_7 = 0 ; var_7 <= var_1 ; var_7 ++ ) { if ( var_7 == 0 ) var_4 [ var_7 ] [ var_6 ] = var_4 [ var_7 ] [ var_6 - 1 ] * ( 1 - var_0 [ var_6 ] ) ; else var_4 [ var_7 ] [ var_6 ] = var_4 [ var_7 ] [ var_6 - 1 ] * ( 1 - var_0 [ var_6 ] ) + var_4 [ var_7 - 1 ] [ var_6 - 1 ] * ( var_0 [ var_6 ] ) ; } } return var_4 [ var_1 ] [ var_0 . length - 1 ] ; } " 1121,hashing_CustomSortString_1.java,"public String customSortString(String S, String T) { Map map = new HashMap<>(); for (int i = 0; i < T.length(); i++) { if (!map.containsKey(T.charAt(i))) { map.put(T.charAt(i), 1); } else { map.put(T.charAt(i), map.get(T.charAt(i)) + 1); } } StringBuilder result = new StringBuilder(); for (char c : S.toCharArray()) { if (map.containsKey(c)) { int count = map.remove(c); for (int i = 0; i < count; i++) { result.append(c); } } } for (char c : map.keySet()) { int count = map.get(c); for (int i = 0; i < count; i++) { result.append(c); } } return result.toString(); }","public String var_0 ( String var_2 , String var_3 ) { Map < Character , Integer > var_8 = new HashMap < > ( ) ; for ( int var_10 = 0 ; var_10 < var_3 . length ( ) ; var_10 ++ ) { if ( ! var_8 . containsKey ( var_3 . charAt ( var_10 ) ) ) { var_8 . put ( var_3 . charAt ( var_10 ) , 1 ) ; } else { var_8 . put ( var_3 . charAt ( var_10 ) , var_8 . get ( var_3 . charAt ( var_10 ) ) + 1 ) ; } } StringBuilder var_18 = new StringBuilder ( ) ; for ( char var_20 : var_2 . toCharArray ( ) ) { if ( var_8 . containsKey ( var_20 ) ) { int var_22 = var_8 . remove ( var_20 ) ; for ( int var_10 = 0 ; var_10 < var_22 ; var_10 ++ ) { var_18 . append ( var_20 ) ; } } } for ( char var_20 : var_8 . keySet ( ) ) { int var_22 = var_8 . get ( var_20 ) ; for ( int var_10 = 0 ; var_10 < var_22 ; var_10 ++ ) { var_18 . append ( var_20 ) ; } } return var_18 . toString ( ) ; } " 1122,array_ProductOfArrayExceptSelf_1.java,"public int[] productExceptSelf(int[] nums) { int[] result = new int[nums.length]; for (int i = 0, temp = 1, l = nums.length; i < l; i++) { result[i] = temp; temp *= nums[i]; } for (int i = nums.length - 1, temp = 1; i >= 0; i--) { result[i] = result[i] * temp; temp *= nums[i]; } return result; }","public int [ ] sample_funcname ( int [ ] var_0 ) { int [ ] var_2 = new int [ var_0 . length ] ; for ( int var_4 = 0 , var_6 = 1 , var_7 = var_0 . length ; var_4 < var_7 ; var_4 ++ ) { var_2 [ var_4 ] = var_6 ; var_6 *= var_0 [ var_4 ] ; } for ( int var_4 = var_0 . length - 1 , var_6 = 1 ; var_4 >= 0 ; var_4 -- ) { var_2 [ var_4 ] = var_2 [ var_4 ] * var_6 ; var_6 *= var_0 [ var_4 ] ; } return var_2 ; } " 1123,backtracking_LetterCasePermutation_1.java,"private void backtrack(String s, List result, int i, String r) { if (i == s.length()) { result.add(r); } else { if (Character.isAlphabetic(s.charAt(i))) { backtrack(s, result, i + 1, r + s.charAt(i)); if (Character.isLowerCase(s.charAt(i))) { backtrack(s, result, i + 1, r + Character.toUpperCase(s.charAt(i))); } else { backtrack(s, result, i + 1, r + Character.toLowerCase(s.charAt(i))); } } else { backtrack(s, result, i + 1, r + s.charAt(i)); } } }","private void sample_funcname ( String s , List < String > result , int i , String r ) { if ( i == s . length ( ) ) { result . add ( r ) ; } else { if ( Character . isAlphabetic ( s . charAt ( i ) ) ) { backtrack ( s , result , i + 1 , r + s . charAt ( i ) ) ; if ( Character . isLowerCase ( s . charAt ( i ) ) ) { backtrack ( s , result , i + 1 , r + Character . toUpperCase ( s . charAt ( i ) ) ) ; } else { backtrack ( s , result , i + 1 , r + Character . toLowerCase ( s . charAt ( i ) ) ) ; } } else { backtrack ( s , result , i + 1 , r + s . charAt ( i ) ) ; } } } " 1124,string_SplitConcatenatedStrings_1.java,"private String findMax(String[] strs, int i) { int c = 1; StringBuilder sb = new StringBuilder(); for (int j = i, l = strs.length; c < l; j = (j + 1) % l, c++) { String nextStr = strs[j]; String reverse = new StringBuilder(nextStr).reverse().toString(); String result = nextStr.compareTo(reverse) > 0 ? nextStr : reverse; sb.append(result); } return sb.toString(); }","private String var_0 ( String [ ] var_2 , int var_3 ) { int var_5 = 1 ; StringBuilder var_7 = new StringBuilder ( ) ; for ( int var_8 = var_3 , var_10 = var_2 . length ; var_5 < var_10 ; var_8 = ( var_8 + 1 ) % var_10 , var_5 ++ ) { String var_11 = var_2 [ var_8 ] ; String reverse = new StringBuilder ( var_11 ) . reverse ( ) . toString ( ) ; String var_16 = var_11 . compareTo ( reverse ) > 0 ? var_11 : reverse ; var_7 . append ( var_16 ) ; } return var_7 . toString ( ) ; } " 1125,array_CardFilipGame_1.java,"public int flipgame(int[] fronts, int[] backs) { List numbers = new ArrayList<>(); for (int i = 0; i < fronts.length; i++) { numbers.add(fronts[i]); numbers.add(backs[i]); } Collections.sort(numbers); for (int n : numbers) { boolean success = true; for (int i = 0; i < fronts.length; i++) { if (n == fronts[i] && n == backs[i]) { success = false; break; } } if (success) { return n; } } return 0; }","public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { List < Integer > var_5 = new ArrayList < > ( ) ; for ( int var_7 = 0 ; var_7 < var_0 . length ; var_7 ++ ) { var_5 . add ( var_0 [ var_7 ] ) ; var_5 . add ( var_1 [ var_7 ] ) ; } Collections . sort ( var_5 ) ; for ( int var_12 : var_5 ) { boolean var_14 = true ; for ( int var_7 = 0 ; var_7 < var_0 . length ; var_7 ++ ) { if ( var_12 == var_0 [ var_7 ] && var_12 == var_1 [ var_7 ] ) { var_14 = false ; break ; } } if ( var_14 ) { return var_12 ; } } return 0 ; } " 1126,string_MonotoneIncreasingDigits_1.java,"public int monotoneIncreasingDigits(int N) { String s = String.valueOf(N); if (s.length() == 1) return N; int p = -1; int prev = N % 10; for (int i = s.length() - 2; i >= 0; i--) { int curr = Integer.parseInt(String.valueOf(s.charAt(i))); if (curr > prev) { p = i; prev = curr - 1; } else { prev = curr; } } if (p == -1) return N; StringBuilder result = new StringBuilder(); for (int i = 0; i < s.length(); i++) { if (i == p) { int pV = Integer.parseInt(String.valueOf(s.charAt(i))); result.append(pV - 1); break; } result.append(String.valueOf(s.charAt(i))); } for (int i = p + 1; i < s.length(); i++) { result.append(""9""); } return Integer.parseInt(result.toString()); }","public int sample_funcname ( int var_0 ) { String var_3 = String . valueOf ( var_0 ) ; if ( var_3 . length ( ) == 1 ) return var_0 ; int var_6 = - 1 ; int var_8 = var_0 % 10 ; for ( int var_10 = var_3 . length ( ) - 2 ; var_10 >= 0 ; var_10 -- ) { int var_15 = Integer . parseInt ( String . valueOf ( var_3 . charAt ( var_10 ) ) ) ; if ( var_15 > var_8 ) { var_6 = var_10 ; var_8 = var_15 - 1 ; } else { var_8 = var_15 ; } } if ( var_6 == - 1 ) return var_0 ; StringBuilder var_17 = new StringBuilder ( ) ; for ( int var_10 = 0 ; var_10 < var_3 . length ( ) ; var_10 ++ ) { if ( var_10 == var_6 ) { int var_18 = Integer . parseInt ( String . valueOf ( var_3 . charAt ( var_10 ) ) ) ; var_17 . append ( var_18 - 1 ) ; break ; } var_17 . append ( String . valueOf ( var_3 . charAt ( var_10 ) ) ) ; } for ( int var_10 = var_6 + 1 ; var_10 < var_3 . length ( ) ; var_10 ++ ) { var_17 . append ( ""9"" ) ; } return Integer . parseInt ( var_17 . toString ( ) ) ; } " 1127,backtracking_ExpressionAddOperators_1.java,"private void backTrack( String exp, List list, int curr, String num, int target, long total, long prod) { if (curr == num.length()) { if (total == target) { list.add(exp); } } else { for (int i = curr, l = num.length(); i < l; i++) { String newNum = num.substring(curr, i + 1); if (newNum.length() > 1 && newNum.startsWith(""0"")) { break; } long newNumL = Long.parseLong(newNum); if (curr == 0) { backTrack(newNum, list, i + 1, num, target, newNumL, newNumL); } else { backTrack(exp + ""+"" + newNum, list, i + 1, num, target, total + newNumL, newNumL); backTrack(exp + ""-"" + newNum, list, i + 1, num, target, total - newNumL, newNumL * -1L); backTrack( exp + ""*"" + newNum, list, i + 1, num, target, (total - prod + (prod * newNumL)), prod * newNumL); } } } }","private void sample_funcname ( String exp , List < String > list , int curr , String num , int target , long total , long prod ) { if ( curr == num . length ( ) ) { if ( total == target ) { list . add ( exp ) ; } } else { for ( int i = curr , l = num . length ( ) ; i < l ; i ++ ) { String newNum = num . substring ( curr , i + 1 ) ; if ( newNum . length ( ) > 1 && newNum . startsWith ( ""0"" ) ) { break ; } long newNumL = Long . parseLong ( newNum ) ; if ( curr == 0 ) { backTrack ( newNum , list , i + 1 , num , target , newNumL , newNumL ) ; } else { backTrack ( exp + ""+"" + newNum , list , i + 1 , num , target , total + newNumL , newNumL ) ; backTrack ( exp + ""-"" + newNum , list , i + 1 , num , target , total - newNumL , newNumL * - 1L ) ; backTrack ( exp + ""*"" + newNum , list , i + 1 , num , target , ( total - prod + ( prod * newNumL ) ) , prod * newNumL ) ; } } } } " 1128,math_ReachingPoints_1.java,"private int[] reduce(int x, int y) { int t = x - y; int q = t / y; x -= (y * q); if ((t % y) != 0) { x -= y; } return new int[] {x, y}; }","private int [ ] sample_funcname ( int var_0 , int var_1 ) { int var_2 = var_0 - var_1 ; int var_3 = var_2 / var_1 ; var_0 -= ( var_1 * var_3 ) ; if ( ( var_2 % var_1 ) != 0 ) { var_0 -= var_1 ; } return new int [ ] { var_0 , var_1 }; } " 1129,dynamic_programming_LargestPlusSign_1.java,"public int orderOfLargestPlusSign(int N, int[][] mines) { int[][] A = new int[N][N]; int[][] B = new int[N][N]; for (int[] row : mines) { int r = row[0]; int c = row[1]; A[r][c] = 1; } for (int i = 0; i < A.length; i++) { for (int j = 0; j < A[0].length; j++) { if (A[i][j] == 0) { A[i][j] = 1; } else { A[i][j] = 0; } B[i][j] = Integer.MAX_VALUE; } } for (int i = 0; i < A.length; i++) { int prev = 0; for (int j = 0; j < A[0].length; j++) { if (A[i][j] == 0) { prev = 0; B[i][j] = 0; } else { prev++; B[i][j] = Math.min(B[i][j], prev); } } prev = 0; for (int j = N - 1; j >= 0; j--) { if (A[i][j] == 0) { prev = 0; B[i][j] = 0; } else { prev++; B[i][j] = Math.min(B[i][j], prev); } } } for (int j = 0; j < B[0].length; j++) { int prev = 0; for (int i = 0; i < B.length; i++) { if (A[i][j] == 0) { prev = 0; B[i][j] = 0; } else { prev++; B[i][j] = Math.min(B[i][j], prev); } } prev = 0; for (int i = N - 1; i >= 0; i--) { if (A[i][j] == 0) { prev = 0; B[i][j] = 0; } else { prev++; B[i][j] = Math.min(B[i][j], prev); } } } int result = 0; for (int i = 0; i < B.length; i++) { for (int j = 0; j < B[0].length; j++) { result = Math.max(result, B[i][j]); } } return result; }","public int sample_funcname ( int var_0 , int [ ] [ ] var_1 ) { int [ ] [ ] var_2 = new int [ var_0 ] [ var_0 ] ; int [ ] [ ] var_3 = new int [ var_0 ] [ var_0 ] ; for ( int [ ] var_4 : var_1 ) { int var_6 = var_4 [ 0 ] ; int var_8 = var_4 [ 1 ] ; var_2 [ var_6 ] [ var_8 ] = 1 ; } for ( int var_9 = 0 ; var_9 < var_2 . length ; var_9 ++ ) { for ( int var_11 = 0 ; var_11 < var_2 [ 0 ] . length ; var_11 ++ ) { if ( var_2 [ var_9 ] [ var_11 ] == 0 ) { var_2 [ var_9 ] [ var_11 ] = 1 ; } else { var_2 [ var_9 ] [ var_11 ] = 0 ; } var_3 [ var_9 ] [ var_11 ] = Integer . MAX_VALUE ; } } for ( int var_9 = 0 ; var_9 < var_2 . length ; var_9 ++ ) { int var_14 = 0 ; for ( int var_11 = 0 ; var_11 < var_2 [ 0 ] . length ; var_11 ++ ) { if ( var_2 [ var_9 ] [ var_11 ] == 0 ) { var_14 = 0 ; var_3 [ var_9 ] [ var_11 ] = 0 ; } else { var_14 ++ ; var_3 [ var_9 ] [ var_11 ] = Math . min ( var_3 [ var_9 ] [ var_11 ] , var_14 ) ; } } var_14 = 0 ; for ( int var_11 = var_0 - 1 ; var_11 >= 0 ; var_11 -- ) { if ( var_2 [ var_9 ] [ var_11 ] == 0 ) { var_14 = 0 ; var_3 [ var_9 ] [ var_11 ] = 0 ; } else { var_14 ++ ; var_3 [ var_9 ] [ var_11 ] = Math . min ( var_3 [ var_9 ] [ var_11 ] , var_14 ) ; } } } for ( int var_11 = 0 ; var_11 < var_3 [ 0 ] . length ; var_11 ++ ) { int var_14 = 0 ; for ( int var_9 = 0 ; var_9 < var_3 . length ; var_9 ++ ) { if ( var_2 [ var_9 ] [ var_11 ] == 0 ) { var_14 = 0 ; var_3 [ var_9 ] [ var_11 ] = 0 ; } else { var_14 ++ ; var_3 [ var_9 ] [ var_11 ] = Math . min ( var_3 [ var_9 ] [ var_11 ] , var_14 ) ; } } var_14 = 0 ; for ( int var_9 = var_0 - 1 ; var_9 >= 0 ; var_9 -- ) { if ( var_2 [ var_9 ] [ var_11 ] == 0 ) { var_14 = 0 ; var_3 [ var_9 ] [ var_11 ] = 0 ; } else { var_14 ++ ; var_3 [ var_9 ] [ var_11 ] = Math . min ( var_3 [ var_9 ] [ var_11 ] , var_14 ) ; } } } int var_17 = 0 ; for ( int var_9 = 0 ; var_9 < var_3 . length ; var_9 ++ ) { for ( int var_11 = 0 ; var_11 < var_3 [ 0 ] . length ; var_11 ++ ) { var_17 = Math . max ( var_17 , var_3 [ var_9 ] [ var_11 ] ) ; } } return var_17 ; } " 1130,stack_DecodeString_1.java,"public String decodeString(String s) { Stack stack = new Stack<>(); for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == ']') { StringBuilder stackBuff = new StringBuilder(); while (stack.peek() != '[') { stackBuff.append(stack.pop()); } stack.pop(); String num = """"; while (!stack.isEmpty() && !Character.isAlphabetic(stack.peek()) && stack.peek() != '[') { num = stack.pop() + num; } String str = stackBuff.reverse().toString(); StringBuilder stringMultiple = new StringBuilder(); int N = Integer.parseInt(num); while (N-- > 0) { stringMultiple.append(str); } for (int j = 0; j < stringMultiple.length(); j++) { stack.push(stringMultiple.charAt(j)); } } else stack.push(s.charAt(i)); } StringBuilder result = new StringBuilder(); while (!stack.isEmpty()) { result.append(stack.pop()); } return result.reverse().toString(); }","public String var_0 ( String var_2 ) { Stack < Character > var_5 = new Stack < > ( ) ; for ( int var_7 = 0 ; var_7 < var_2 . length ( ) ; var_7 ++ ) { if ( var_2 . charAt ( var_7 ) == ']' ) { StringBuilder var_12 = new StringBuilder ( ) ; while ( var_5 . peek ( ) != '[' ) { var_12 . append ( var_5 . pop ( ) ) ; } var_5 . pop ( ) ; String var_18 = """" ; while ( ! var_5 . isEmpty ( ) && ! Character . isAlphabetic ( var_5 . peek ( ) ) && var_5 . peek ( ) != '[' ) { var_18 = var_5 . pop ( ) + var_18 ; } String var_23 = var_12 . reverse ( ) . toString ( ) ; StringBuilder var_24 = new StringBuilder ( ) ; int var_27 = Integer . parseInt ( var_18 ) ; while ( var_27 -- > 0 ) { var_24 . append ( var_23 ) ; } for ( int var_28 = 0 ; var_28 < var_24 . length ( ) ; var_28 ++ ) { var_5 . push ( var_24 . charAt ( var_28 ) ) ; } } else var_5 . push ( var_2 . charAt ( var_7 ) ) ; } StringBuilder var_30 = new StringBuilder ( ) ; while ( ! var_5 . isEmpty ( ) ) { var_30 . append ( var_5 . pop ( ) ) ; } return var_30 . reverse ( ) . toString ( ) ; } " 1131,dynamic_programming_OddEvenJump_1.java,"private int dp(int[] A, int i, int[][] next, int[][] possible, int oddOrEven) { if (i == A.length - 1) return 1; else if (possible[oddOrEven][i] == 1 || possible[oddOrEven][i] == 0) { return possible[oddOrEven][i]; } else { int nextPos = oddOrEven == 0 ? next[0][i] : next[1][i]; if (nextPos == -1) { possible[oddOrEven][i] = 0; return possible[oddOrEven][i]; } else { possible[oddOrEven][i] = dp(A, nextPos, next, possible, ((oddOrEven + 1) % 2)); return possible[oddOrEven][i]; } } }","private int sample_funcname ( int [ ] A , int i , int [ ] [ ] next , int [ ] [ ] possible , int oddOrEven ) { if ( i == A . length - 1 ) return 1 ; else if ( possible [ oddOrEven ] [ i ] == 1 || possible [ oddOrEven ] [ i ] == 0 ) { return possible [ oddOrEven ] [ i ] ; } else { int nextPos = oddOrEven == 0 ? next [ 0 ] [ i ] : next [ 1 ] [ i ] ; if ( nextPos == - 1 ) { possible [ oddOrEven ] [ i ] = 0 ; return possible [ oddOrEven ] [ i ] ; } else { possible [ oddOrEven ] [ i ] = dp ( A , nextPos , next , possible , ( ( oddOrEven + 1 ) % 2 ) ) ; return possible [ oddOrEven ] [ i ] ; } } } " 1132,math_BulbSwitcherII_1.java,"public int flipLights(int n, int m) { if (n == 0 || m == 0) return 1; if (n == 1 && m >= 1) return 2; if (n == 2) { if (m == 1) return 3; if (m >= 2) return 4; } else if (n >= 3) { if (m == 1) return 4; if (m == 2) return 7; } return 8; }","public int sample_funcname ( int var_0 , int var_1 ) { if ( var_0 == 0 || var_1 == 0 ) return 1 ; if ( var_0 == 1 && var_1 >= 1 ) return 2 ; if ( var_0 == 2 ) { if ( var_1 == 1 ) return 3 ; if ( var_1 >= 2 ) return 4 ; } else if ( var_0 >= 3 ) { if ( var_1 == 1 ) return 4 ; if ( var_1 == 2 ) return 7 ; } return 8 ; } " 1133,stack_LargestRectangleInHistogram_1.java,"public int largestRectangleArea(int[] heights) { if (heights.length == 0) return 0; int maxArea = Integer.MIN_VALUE; Stack stack = new Stack<>(); int i = 0; for (; i < heights.length; i++) { while (!stack.isEmpty() && heights[stack.peek()] >= heights[i]) { int top = stack.pop(); int base = stack.isEmpty() ? i : i - stack.peek() - 1; maxArea = Math.max(maxArea, base * heights[top]); } stack.push(i); } while (!stack.isEmpty()) { int top = stack.pop(); int base = stack.isEmpty() ? i : i - stack.peek() - 1; maxArea = Math.max(maxArea, base * heights[top]); } return maxArea; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int var_5 = Integer . MIN_VALUE ; Stack < Integer > var_7 = new Stack < > ( ) ; int var_8 = 0 ; for ( ; var_8 < var_0 . length ; var_8 ++ ) { while ( ! var_7 . isEmpty ( ) && var_0 [ var_7 . peek ( ) ] >= var_0 [ var_8 ] ) { int var_12 = var_7 . pop ( ) ; int var_14 = var_7 . isEmpty ( ) ? var_8 : var_8 - var_7 . peek ( ) - 1 ; var_5 = Math . max ( var_5 , var_14 * var_0 [ var_12 ] ) ; } var_7 . push ( var_8 ) ; } while ( ! var_7 . isEmpty ( ) ) { int var_12 = var_7 . pop ( ) ; int var_14 = var_7 . isEmpty ( ) ? var_8 : var_8 - var_7 . peek ( ) - 1 ; var_5 = Math . max ( var_5 , var_14 * var_0 [ var_12 ] ) ; } return var_5 ; } " 1134,hashing_DistributeCandies_1.java,"public int distributeCandies(int[] candies) { int N = candies.length; Set set = new HashSet<>(); for (int c : candies) { set.add(c); } int n = set.size(); return Math.min(N / 2, set.size()); }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; Set < Integer > var_6 = new HashSet < > ( ) ; for ( int var_7 : var_0 ) { var_6 . add ( var_7 ) ; } int var_10 = var_6 . size ( ) ; return Math . min ( var_2 / 2 , var_6 . size ( ) ) ; } " 1135,greedy_PartitionLabels_1.java,"public List partitionLabels(String S) { Map map = new HashMap<>(); for (int i = 0; i < S.length(); i++) { char c = S.charAt(i); map.putIfAbsent(c, i); map.remove(c); map.put(c, i); } char start = S.charAt(0); int currMax = map.get(start); int startIndex = 0; List list = new ArrayList<>(); while (true) { int i = startIndex; for (; i <= currMax; i++) { char c = S.charAt(i); int pos = map.get(c); currMax = Math.max(currMax, pos); } if (i > currMax && i < S.length()) { list.add(i - startIndex); startIndex = i; currMax = map.get(S.charAt(i)); } else { if (i == S.length()) { list.add(i - startIndex); break; } } } return list; }","public List < Integer > var_1 ( String var_3 ) { Map < Character , Integer > var_7 = new HashMap < > ( ) ; for ( int var_9 = 0 ; var_9 < var_3 . length ( ) ; var_9 ++ ) { char var_12 = var_3 . charAt ( var_9 ) ; var_7 . putIfAbsent ( var_12 , var_9 ) ; var_7 . remove ( var_12 ) ; var_7 . put ( var_12 , var_9 ) ; } char var_16 = var_3 . charAt ( 0 ) ; int var_18 = var_7 . get ( var_16 ) ; int var_19 = 0 ; List < Integer > var_22 = new ArrayList < > ( ) ; while ( true ) { int var_9 = var_19 ; for ( ; var_9 <= var_18 ; var_9 ++ ) { char var_12 = var_3 . charAt ( var_9 ) ; int var_23 = var_7 . get ( var_12 ) ; var_18 = Math . max ( var_18 , var_23 ) ; } if ( var_9 > var_18 && var_9 < var_3 . length ( ) ) { var_22 . add ( var_9 - var_19 ) ; var_19 = var_9 ; var_18 = var_7 . get ( var_3 . charAt ( var_9 ) ) ; } else { if ( var_9 == var_3 . length ( ) ) { var_22 . add ( var_9 - var_19 ) ; break ; } } } return var_22 ; } " 1136,array_MinimumSwapsToGroupAll1Together_1.java,"public int minSwaps(int[] data) { int one = 0; int zero = 0; for (int i = 0; i < data.length; i++) { if (data[i] == 1) { one++; } else zero++; } if (one == 0) return 0; int window = one; one = 0; zero = 0; int i = 0, j = window - 1; for (int k = i; k <= j; k++) { if (data[k] == 1) { one++; } else zero++; } i++; j++; int min = zero; for (; j < data.length; i++, j++) { if (data[j] == 0) { zero++; } else one++; if (data[i - 1] == 0) { zero--; } else one--; min = Math.min(min, zero); } return min; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 ; int var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { if ( var_0 [ var_4 ] == 1 ) { var_2 ++ ; } else var_3 ++ ; } if ( var_2 == 0 ) return 0 ; int var_7 = var_2 ; var_2 = 0 ; var_3 = 0 ; int var_4 = 0 , var_8 = var_7 - 1 ; for ( int var_9 = var_4 ; var_9 <= var_8 ; var_9 ++ ) { if ( var_0 [ var_9 ] == 1 ) { var_2 ++ ; } else var_3 ++ ; } var_4 ++ ; var_8 ++ ; int min = var_3 ; for ( ; var_8 < var_0 . length ; var_4 ++ , var_8 ++ ) { if ( var_0 [ var_8 ] == 0 ) { var_3 ++ ; } else var_2 ++ ; if ( var_0 [ var_4 - 1 ] == 0 ) { var_3 -- ; } else var_2 -- ; min = Math . min ( min , var_3 ) ; } return min ; } " 1137,array_HIndex_1.java,"public int hIndex(int[] citations) { int n = citations.length; int[] count = new int[n + 1]; int[] S = new int[n + 1]; for (int i = 0; i < citations.length; i++) { if (citations[i] > n) { citations[i] = n; } } for (int citation : citations) { count[citation]++; } S[n] = count[n]; for (int i = n - 1; i >= 0; i--) { S[i] = count[i] + S[i + 1]; } for (int i = n; i >= 0; i--) { if (i <= S[i]) { return i; } } return 0; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = var_0 . length ; int [ ] var_4 = new int [ var_2 + 1 ] ; int [ ] var_5 = new int [ var_2 + 1 ] ; for ( int var_7 = 0 ; var_7 < var_0 . length ; var_7 ++ ) { if ( var_0 [ var_7 ] > var_2 ) { var_0 [ var_7 ] = var_2 ; } } for ( int var_8 : var_0 ) { var_4 [ var_8 ] ++ ; } var_5 [ var_2 ] = var_4 [ var_2 ] ; for ( int var_7 = var_2 - 1 ; var_7 >= 0 ; var_7 -- ) { var_5 [ var_7 ] = var_4 [ var_7 ] + var_5 [ var_7 + 1 ] ; } for ( int var_7 = var_2 ; var_7 >= 0 ; var_7 -- ) { if ( var_7 <= var_5 [ var_7 ] ) { return var_7 ; } } return 0 ; } " 1138,math_WaterAndJugProblem_1.java,"public boolean canMeasureWater(int x, int y, int z) { if (x == y && y == z) return true; if (z > (x + y)) return false; BigInteger b1 = new BigInteger(String.valueOf(x)); BigInteger b2 = new BigInteger(String.valueOf(y)); BigInteger b3 = b1.gcd(b2); return b3.intValue() != 0 && (z % b3.intValue()) == 0; }","public boolean var_0 ( int var_1 , int var_2 , int var_3 ) { if ( var_1 == var_2 && var_2 == var_3 ) return true ; if ( var_3 > ( var_1 + var_2 ) ) return false ; BigInteger var_7 = new BigInteger ( String . valueOf ( var_1 ) ) ; BigInteger var_8 = new BigInteger ( String . valueOf ( var_2 ) ) ; BigInteger var_10 = var_7 . gcd ( var_8 ) ; return var_10 . intValue ( ) != 0 && ( var_3 % var_10 . intValue ( ) ) == 0 ; } " 1139,array_ThirdMaximumNumber_1.java,"public int thirdMax(int[] nums) { long[] max = {Long.MIN_VALUE, Long.MIN_VALUE, Long.MIN_VALUE}; int count = 0; for (int num : nums) { for (int j = 0; j < 3; j++) { if (max[j] > num) continue; else if (max[j] == num) break; int k = j; long temp1, temp2; temp1 = num; count++; while (k < 3) { temp2 = max[k]; max[k] = temp1; temp1 = temp2; k++; } break; } } System.out.println(Integer.MIN_VALUE); return (count >= 3) ? (int) max[2] : (int) max[0]; }","public int sample_funcname ( int [ ] var_0 ) { long [ ] var_3 = { Long . MIN_VALUE , Long . MIN_VALUE , Long . MIN_VALUE }; int var_5 = 0 ; for ( int var_6 : var_0 ) { for ( int var_7 = 0 ; var_7 < 3 ; var_7 ++ ) { if ( var_3 [ var_7 ] > var_6 ) continue ; else if ( var_3 [ var_7 ] == var_6 ) break ; int var_9 = var_7 ; long var_10 , var_11 ; var_10 = var_6 ; var_5 ++ ; while ( var_9 < 3 ) { var_11 = var_3 [ var_9 ] ; var_3 [ var_9 ] = var_10 ; var_10 = var_11 ; var_9 ++ ; } break ; } } System . out . println ( Integer . MIN_VALUE ) ; return ( var_5 >= 3 ) ? ( int ) var_3 [ 2 ] : ( int ) var_3 [ 0 ] ; } " 1140,math_Base7_1.java,"public String convertToBase7(int num) { Integer.toString(7, 7); if (num == 0) return ""0""; int q = Math.abs(num), r; StringBuilder sb = new StringBuilder(); while (q != 0) { r = q % 7; sb.append(r); q /= 7; } if (num < 0) { return ""-"" + sb.reverse().toString(); } else return sb.reverse().toString(); }","public String var_0 ( int var_1 ) { Integer . toString ( 7 , 7 ) ; if ( var_1 == 0 ) return ""0"" ; int var_9 = Math . abs ( var_1 ) , var_10 ; StringBuilder var_12 = new StringBuilder ( ) ; while ( var_9 != 0 ) { var_10 = var_9 % 7 ; var_12 . append ( var_10 ) ; var_9 /= 7 ; } if ( var_1 < 0 ) { return ""-"" + var_12 . reverse ( ) . toString ( ) ; } else return var_12 . reverse ( ) . toString ( ) ; } " 1141,math_RomanToInteger_1.java,"public int romanToInt(String s) { Map map = new HashMap<>(); map.put('I', 1); map.put('V', 5); map.put('X', 10); map.put('L', 50); map.put('C', 100); map.put('D', 500); map.put('M', 1000); String str = new StringBuilder(s).reverse().toString(); int sum = 0, prev = -1; for (int i = 0, l = str.length(); i < l; i++) { int curr = map.get(str.charAt(i)); if (curr < prev) { sum -= curr; } else { sum += curr; } prev = curr; } return sum; }","public int sample_funcname ( String var_1 ) { Map < Character , Integer > var_6 = new HashMap < > ( ) ; var_6 . put ( 'I' , 1 ) ; var_6 . put ( 'V' , 5 ) ; var_6 . put ( 'X' , 10 ) ; var_6 . put ( 'L' , 50 ) ; var_6 . put ( 'C' , 100 ) ; var_6 . put ( 'D' , 500 ) ; var_6 . put ( 'M' , 1000 ) ; String var_25 = new StringBuilder ( var_1 ) . reverse ( ) . toString ( ) ; int var_27 = 0 , var_28 = - 1 ; for ( int var_29 = 0 , var_31 = var_25 . length ( ) ; var_29 < var_31 ; var_29 ++ ) { int var_34 = var_6 . get ( var_25 . charAt ( var_29 ) ) ; if ( var_34 < var_28 ) { var_27 -= var_34 ; } else { var_27 += var_34 ; } var_28 = var_34 ; } return var_27 ; } " 1142,bit_manipulation_BinaryNumberWithAlternatingBits_1.java,"public boolean hasAlternatingBits(int n) { int curr = n & 1; int pos = 0; for (int i = 0; i < 32; i++) { if ((n & (1 << i)) > 0) { pos = i; } } for (int i = 1; i <= pos; i++) { int temp = (1 << i) & n; if ((temp > 0 && curr > 0) || (temp == 0 && curr == 0)) return false; curr = temp; } return true; }","public boolean var_0 ( int var_1 ) { int var_3 = var_1 & 1 ; int var_5 = 0 ; for ( int var_6 = 0 ; var_6 < 32 ; var_6 ++ ) { if ( ( var_1 & ( 1 << var_6 ) ) > 0 ) { var_5 = var_6 ; } } for ( int var_6 = 1 ; var_6 <= var_5 ; var_6 ++ ) { int var_8 = ( 1 << var_6 ) & var_1 ; if ( ( var_8 > 0 && var_3 > 0 ) || ( var_8 == 0 && var_3 == 0 ) ) return false ; var_3 = var_8 ; } return true ; } " 1143,dynamic_programming_OnesAndZeroes_1.java,"public int findMaxForm(String[] strs, int m, int n) { int[][][] dp = new int[strs.length + 1][m + 1][n + 1]; for (int i = strs.length - 1; i >= 0; i--) { String string = strs[i]; int zero = 0; int one = 0; for (char c : string.toCharArray()) { if (c == '0') { zero++; } else { one++; } } for (int p = m; p >= 0; p--) { for (int q = n; q >= 0; q--) { dp[i][p][q] = dp[i + 1][p][q]; if (p - zero >= 0 && q - one >= 0) { dp[i][p][q] = Math.max(dp[i][p][q], dp[i + 1][p - zero][q - one] + 1); } } } } return dp[0][m][n]; }","public int sample_funcname ( String [ ] var_1 , int var_2 , int var_3 ) { int [ ] [ ] [ ] var_6 = new int [ var_1 . length + 1 ] [ var_2 + 1 ] [ var_3 + 1 ] ; for ( int var_7 = var_1 . length - 1 ; var_7 >= 0 ; var_7 -- ) { String var_9 = var_1 [ var_7 ] ; int var_10 = 0 ; int var_11 = 0 ; for ( char var_13 : var_9 . toCharArray ( ) ) { if ( var_13 == '0' ) { var_10 ++ ; } else { var_11 ++ ; } } for ( int var_15 = var_2 ; var_15 >= 0 ; var_15 -- ) { for ( int var_16 = var_3 ; var_16 >= 0 ; var_16 -- ) { var_6 [ var_7 ] [ var_15 ] [ var_16 ] = var_6 [ var_7 + 1 ] [ var_15 ] [ var_16 ] ; if ( var_15 - var_10 >= 0 && var_16 - var_11 >= 0 ) { var_6 [ var_7 ] [ var_15 ] [ var_16 ] = Math . max ( var_6 [ var_7 ] [ var_15 ] [ var_16 ] , var_6 [ var_7 + 1 ] [ var_15 - var_10 ] [ var_16 - var_11 ] + 1 ) ; } } } } return var_6 [ 0 ] [ var_2 ] [ var_3 ] ; } " 1144,dynamic_programming_InterleavingString_1.java,"public boolean isInterleave(String s1, String s2, String s3) { boolean[][] DP = new boolean[s1.length() + 1][s2.length() + 1]; DP[0][0] = true; if (s3.length() != (s2.length() + s1.length())) return false; for (int i = 0; i <= s1.length(); i++) { for (int j = 0; j <= s2.length(); j++) { if (i == 0 && j == 0) continue; int index = (i + j); if (j > 0) { if (s3.charAt(index - 1) == s2.charAt(j - 1) && DP[i][j - 1]) { DP[i][j] = true; } } if (i > 0) { if (s3.charAt(index - 1) == s1.charAt(i - 1) && DP[i - 1][j]) { DP[i][j] = true; } } } } return DP[s1.length()][s2.length()]; }","public boolean var_0 ( String var_2 , String var_3 , String var_4 ) { boolean [ ] [ ] var_8 = new boolean [ var_2 . length ( ) + 1 ] [ var_3 . length ( ) + 1 ] ; var_8 [ 0 ] [ 0 ] = true ; if ( var_4 . length ( ) != ( var_3 . length ( ) + var_2 . length ( ) ) ) return false ; for ( int var_10 = 0 ; var_10 <= var_2 . length ( ) ; var_10 ++ ) { for ( int var_11 = 0 ; var_11 <= var_3 . length ( ) ; var_11 ++ ) { if ( var_10 == 0 && var_11 == 0 ) continue ; int var_12 = ( var_10 + var_11 ) ; if ( var_11 > 0 ) { if ( var_4 . charAt ( var_12 - 1 ) == var_3 . charAt ( var_11 - 1 ) && var_8 [ var_10 ] [ var_11 - 1 ] ) { var_8 [ var_10 ] [ var_11 ] = true ; } } if ( var_10 > 0 ) { if ( var_4 . charAt ( var_12 - 1 ) == var_2 . charAt ( var_10 - 1 ) && var_8 [ var_10 - 1 ] [ var_11 ] ) { var_8 [ var_10 ] [ var_11 ] = true ; } } } } return var_8 [ var_2 . length ( ) ] [ var_3 . length ( ) ] ; } " 1145,array_SparseMatrixMultiplication_1.java,"public int[][] multiply(int[][] A, int[][] B) { boolean[] AH = new boolean[A.length]; boolean[] BH = new boolean[B[0].length]; for (int i = 0; i < A.length; i++) { for (int j = 0; j < A[0].length; j++) { if (A[i][j] != 0) { AH[i] = true; break; } } } for (int i = 0; i < B[0].length; i++) { for (int j = 0; j < B.length; j++) { if (B[j][i] != 0) { BH[i] = true; break; } } } int[][] C = new int[A.length][B[0].length]; for (int i = 0; i < C.length; i++) { if (AH[i]) { for (int j = 0; j < C[0].length; j++) { if (BH[j]) { int sum = 0; for (int k = 0; k < A[0].length; k++) { sum += A[i][k] * B[k][j]; } C[i][j] = sum; } } } } return C; }","public int [ ] [ ] sample_funcname ( int [ ] [ ] var_0 , int [ ] [ ] var_1 ) { boolean [ ] var_4 = new boolean [ var_0 . length ] ; boolean [ ] var_6 = new boolean [ var_1 [ 0 ] . length ] ; for ( int var_7 = 0 ; var_7 < var_0 . length ; var_7 ++ ) { for ( int var_8 = 0 ; var_8 < var_0 [ 0 ] . length ; var_8 ++ ) { if ( var_0 [ var_7 ] [ var_8 ] != 0 ) { var_4 [ var_7 ] = true ; break ; } } } for ( int var_7 = 0 ; var_7 < var_1 [ 0 ] . length ; var_7 ++ ) { for ( int var_8 = 0 ; var_8 < var_1 . length ; var_8 ++ ) { if ( var_1 [ var_8 ] [ var_7 ] != 0 ) { var_6 [ var_7 ] = true ; break ; } } } int [ ] [ ] var_9 = new int [ var_0 . length ] [ var_1 [ 0 ] . length ] ; for ( int var_7 = 0 ; var_7 < var_9 . length ; var_7 ++ ) { if ( var_4 [ var_7 ] ) { for ( int var_8 = 0 ; var_8 < var_9 [ 0 ] . length ; var_8 ++ ) { if ( var_6 [ var_8 ] ) { int var_10 = 0 ; for ( int var_11 = 0 ; var_11 < var_0 [ 0 ] . length ; var_11 ++ ) { var_10 += var_0 [ var_7 ] [ var_11 ] * var_1 [ var_11 ] [ var_8 ] ; } var_9 [ var_7 ] [ var_8 ] = var_10 ; } } } } return var_9 ; } " 1146,math_MinimumIndexSumOfTwoLists_1.java,"public String[] findRestaurant(String[] list1, String[] list2) { Map index = new HashMap<>(); for (int i = 0; i < list2.length; i++) { String s = list2[i]; index.put(s, i); } int min = Integer.MAX_VALUE; List list = new ArrayList<>(); for (int i = 0; i < list1.length; i++) { if (index.containsKey(list1[i])) { if (i + index.get(list1[i]) <= min) { min = i + index.get(list1[i]); } } } for (int i = 0; i < list1.length; i++) { if (index.containsKey(list1[i])) { if (i + index.get(list1[i]) == min) { list.add(list1[i]); } } } String[] ans = new String[list.size()]; int i = 0; for (String s : list) { ans[i++] = s; } return ans; }","public String [ ] var_0 ( String [ ] var_2 , String [ ] var_3 ) { Map < String , Integer > var_7 = new HashMap < > ( ) ; for ( int var_9 = 0 ; var_9 < var_3 . length ; var_9 ++ ) { String var_11 = var_3 [ var_9 ] ; var_7 . put ( var_11 , var_9 ) ; } int var_14 = Integer . MAX_VALUE ; List < String > var_17 = new ArrayList < > ( ) ; for ( int var_9 = 0 ; var_9 < var_2 . length ; var_9 ++ ) { if ( var_7 . containsKey ( var_2 [ var_9 ] ) ) { if ( var_9 + var_7 . get ( var_2 [ var_9 ] ) <= var_14 ) { var_14 = var_9 + var_7 . get ( var_2 [ var_9 ] ) ; } } } for ( int var_9 = 0 ; var_9 < var_2 . length ; var_9 ++ ) { if ( var_7 . containsKey ( var_2 [ var_9 ] ) ) { if ( var_9 + var_7 . get ( var_2 [ var_9 ] ) == var_14 ) { var_17 . add ( var_2 [ var_9 ] ) ; } } } String [ ] var_22 = new String [ var_17 . size ( ) ] ; int var_9 = 0 ; for ( String var_11 : var_17 ) { var_22 [ var_9 ++ ] = var_11 ; } return var_22 ; } " 1147,string_ValidPalindrome_1.java,"public boolean isPalindrome(String s) { if (s == null || s.isEmpty()) return true; s = s.toLowerCase(); for (int i = 0, j = s.length() - 1; i < j; ) { char f = s.charAt(i); char l = s.charAt(j); if (!(f >= 'a' && f <= 'z') && !(f >= '0' && f <= '9')) { i++; continue; } if (!(l >= 'a' && l <= 'z') && !(l >= '0' && l <= '9')) { j--; continue; } if (f != l) return false; i++; j--; } return true; }","public boolean var_0 ( String var_2 ) { if ( var_2 == null || var_2 . isEmpty ( ) ) return true ; var_2 = var_2 . toLowerCase ( ) ; for ( int var_7 = 0 , var_10 = var_2 . length ( ) - 1 ; var_7 < var_10 ; ) { char var_12 = var_2 . charAt ( var_7 ) ; char var_13 = var_2 . charAt ( var_10 ) ; if ( ! ( var_12 >= 'a' && var_12 <= 'z' ) && ! ( var_12 >= '0' && var_12 <= '9' ) ) { var_7 ++ ; continue ; } if ( ! ( var_13 >= 'a' && var_13 <= 'z' ) && ! ( var_13 >= '0' && var_13 <= '9' ) ) { var_10 -- ; continue ; } if ( var_12 != var_13 ) return false ; var_7 ++ ; var_10 -- ; } return true ; } " 1148,dynamic_programming_StoneGameIV_1.java,"private int dp(int n, int p, int[] perfectSquares, int[] DP) { if (n == 0) return 1; else if (DP[n] != 0) return DP[n]; else { int result = 1; for (int sq : perfectSquares) { if (n < sq) break; int r = dp(n - sq, ((p + 1) % 2), perfectSquares, DP); if (r == 1) { result = 2; break; } } DP[n] = result; return result; } }","private int sample_funcname ( int n , int p , int [ ] perfectSquares , int [ ] DP ) { if ( n == 0 ) return 1 ; else if ( DP [ n ] != 0 ) return DP [ n ] ; else { int result = 1 ; for ( int sq : perfectSquares ) { if ( n < sq ) break ; int r = dp ( n - sq , ( ( p + 1 ) % 2 ) , perfectSquares , DP ) ; if ( r == 1 ) { result = 2 ; break ; } } DP [ n ] = result ; return result ; } } " 1149,string_LongestWordInDictonary_1.java,"public String findLongestWord(String s, List d) { Collections.sort( d, Comparator.comparing(String::length).reversed().thenComparing(String::compareTo)); for (String str : d) { if (str.length() <= s.length()) { int i = 0, j = 0; for (int l1 = s.length(), l2 = str.length(); i < l1 && j < l2; ) { if (s.charAt(i) == str.charAt(j)) { i++; j++; } else { i++; } } if (j >= str.length()) return str; } } return """"; }","public String var_0 ( String var_2 , List < String > var_4 ) { Collections . sort ( var_4 , Comparator . comparing ( String :: length ) . reversed ( ) . thenComparing ( String :: compareTo ) ) ; for ( String var_13 : var_4 ) { if ( var_13 . length ( ) <= var_2 . length ( ) ) { int var_15 = 0 , var_16 = 0 ; for ( int var_17 = var_2 . length ( ) , var_18 = var_13 . length ( ) ; var_15 < var_17 && var_16 < var_18 ; ) { if ( var_2 . charAt ( var_15 ) == var_13 . charAt ( var_16 ) ) { var_15 ++ ; var_16 ++ ; } else { var_15 ++ ; } } if ( var_16 >= var_13 . length ( ) ) return var_13 ; } } return """" ; } " 1150,backtracking_SubsetsII_1.java,"public List> subsetsWithDup(int[] nums) { List> result = new ArrayList<>(); result.add(new ArrayList<>()); int start = 0, newStart = 0; Arrays.sort(nums); for (int i = 0, l = nums.length; i < l; i++) { newStart = result.size(); if (i == 0 || nums[i] != nums[i - 1]) { start = 0; } for (int j = start, resLen = result.size(); j < resLen; j++) { List newList = new ArrayList<>(result.get(j)); newList.add(nums[i]); result.add(newList); } start = newStart; } return result; }","public List < List < Integer >> var_2 ( int [ ] var_3 ) { List < List < Integer >> var_5 = new ArrayList < > ( ) ; var_5 . add ( new ArrayList < > ( ) ) ; int var_8 = 0 , var_9 = 0 ; Arrays . sort ( var_3 ) ; for ( int var_12 = 0 , var_14 = var_3 . length ; var_12 < var_14 ; var_12 ++ ) { var_9 = var_5 . size ( ) ; if ( var_12 == 0 || var_3 [ var_12 ] != var_3 [ var_12 - 1 ] ) { var_8 = 0 ; } for ( int var_17 = var_8 , var_18 = var_5 . size ( ) ; var_17 < var_18 ; var_17 ++ ) { List < Integer > var_20 = new ArrayList < > ( var_5 . get ( var_17 ) ) ; var_20 . add ( var_3 [ var_12 ] ) ; var_5 . add ( var_20 ) ; } var_8 = var_9 ; } return var_5 ; } " 1151,array_TwoSumII_1.java,"public int[] twoSum(int[] numbers, int target) { int i = 0, j = numbers.length - 1; while (i < j) { int x = (numbers[i] + numbers[j]); if (x == target) { int[] result = new int[2]; result[0] = i + 1; result[1] = j + 1; return result; } else if (x < target) i++; else j--; } return new int[2]; }","public int [ ] sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = 0 , var_6 = var_0 . length - 1 ; while ( var_3 < var_6 ) { int var_7 = ( var_0 [ var_3 ] + var_0 [ var_6 ] ) ; if ( var_7 == var_1 ) { int [ ] var_9 = new int [ 2 ] ; var_9 [ 0 ] = var_3 + 1 ; var_9 [ 1 ] = var_6 + 1 ; return var_9 ; } else if ( var_7 < var_1 ) var_3 ++ ; else var_6 -- ; } return new int [ 2 ] ; } " 1152,dynamic_programming_MaximumProductSubarray_1.java,"public int maxProduct(int[] nums) { if (nums.length == 1) return nums[0]; int min = nums[0]; int max = nums[0]; int result = max; for (int i = 1; i < nums.length; i++) { int prevMin = min, prevMax = max; min = Math.min(nums[i], Math.min(nums[i] * prevMin, nums[i] * prevMax)); max = Math.max(nums[i], Math.max(nums[i] * prevMin, nums[i] * prevMax)); result = Math.max(result, max); } return result; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 1 ) return var_0 [ 0 ] ; int min = var_0 [ 0 ] ; int max = var_0 [ 0 ] ; int var_6 = max ; for ( int var_7 = 1 ; var_7 < var_0 . length ; var_7 ++ ) { int var_8 = min , var_9 = max ; min = Math . min ( var_0 [ var_7 ] , Math . min ( var_0 [ var_7 ] * var_8 , var_0 [ var_7 ] * var_9 ) ) ; max = Math . max ( var_0 [ var_7 ] , Math . max ( var_0 [ var_7 ] * var_8 , var_0 [ var_7 ] * var_9 ) ) ; var_6 = Math . max ( var_6 , max ) ; } return var_6 ; } " 1153,dynamic_programming_BestTimeToBuyAndSellStocks_1.java,"public int maxProfit(int[] prices) { if (prices.length == 0) return 0; int[] max = new int[prices.length]; max[prices.length - 1] = prices[prices.length - 1]; for (int i = prices.length - 2; i >= 0; i--) { max[i] = Math.max(prices[i], max[i + 1]); } int result = Integer.MIN_VALUE; for (int i = 0, l = max.length; i < l; i++) { result = Math.max(result, max[i] - prices[i]); } return result; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int [ ] max = new int [ var_0 . length ] ; max [ var_0 . length - 1 ] = var_0 [ var_0 . length - 1 ] ; for ( int var_6 = var_0 . length - 2 ; var_6 >= 0 ; var_6 -- ) { max [ var_6 ] = Math . max ( var_0 [ var_6 ] , max [ var_6 + 1 ] ) ; } int var_10 = Integer . MIN_VALUE ; for ( int var_6 = 0 , var_11 = max . length ; var_6 < var_11 ; var_6 ++ ) { var_10 = Math . max ( var_10 , max [ var_6 ] - var_0 [ var_6 ] ) ; } return var_10 ; } " 1154,array_FindPivotIndex_1.java,"public int pivotIndex(int[] nums) { if (nums.length == 1) return 0; int[] left = new int[nums.length]; int[] right = new int[nums.length]; left[0] = nums[0]; for (int i = 1; i < nums.length; i++) { left[i] = left[i - 1] + nums[i]; } right[nums.length - 1] = nums[nums.length - 1]; for (int i = nums.length - 2; i >= 0; i--) { right[i] = right[i + 1] + nums[i]; } for (int i = 0; i < nums.length; i++) { int l, r; if (i == 0) { l = 0; } else { l = left[i - 1]; } if (i == nums.length - 1) { r = 0; } else { r = right[i + 1]; } if (l == r) return i; } return -1; }","public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 1 ) return 0 ; int [ ] var_4 = new int [ var_0 . length ] ; int [ ] var_5 = new int [ var_0 . length ] ; var_4 [ 0 ] = var_0 [ 0 ] ; for ( int var_6 = 1 ; var_6 < var_0 . length ; var_6 ++ ) { var_4 [ var_6 ] = var_4 [ var_6 - 1 ] + var_0 [ var_6 ] ; } var_5 [ var_0 . length - 1 ] = var_0 [ var_0 . length - 1 ] ; for ( int var_6 = var_0 . length - 2 ; var_6 >= 0 ; var_6 -- ) { var_5 [ var_6 ] = var_5 [ var_6 + 1 ] + var_0 [ var_6 ] ; } for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { int var_8 , var_9 ; if ( var_6 == 0 ) { var_8 = 0 ; } else { var_8 = var_4 [ var_6 - 1 ] ; } if ( var_6 == var_0 . length - 1 ) { var_9 = 0 ; } else { var_9 = var_5 [ var_6 + 1 ] ; } if ( var_8 == var_9 ) return var_6 ; } return - 1 ; } " 1155,string_ValidWordSquare_1.java,"public boolean validWordSquare(List words) { List newList = new ArrayList<>(); int max = 0; for (int i = 0; i < words.size(); i++) { max = Math.max(max, words.get(i).length()); } for (int i = 0; i < max; i++) { StringBuilder sb = new StringBuilder(); for (String w : words) { if (i < w.length()) { sb.append(w.charAt(i)); } else break; } newList.add(sb.toString()); } if (words.size() != newList.size()) return false; for (int i = 0, l = words.size(); i < l; i++) { if (!words.get(i).equals(newList.get(i))) return false; } return true; }","public boolean var_0 ( List < String > var_3 ) { List < String > var_5 = new ArrayList < > ( ) ; int max = 0 ; for ( int var_8 = 0 ; var_8 < var_3 . size ( ) ; var_8 ++ ) { max = Math . max ( max , var_3 . get ( var_8 ) . length ( ) ) ; } for ( int var_8 = 0 ; var_8 < max ; var_8 ++ ) { StringBuilder var_14 = new StringBuilder ( ) ; for ( String var_15 : var_3 ) { if ( var_8 < var_15 . length ( ) ) { var_14 . append ( var_15 . charAt ( var_8 ) ) ; } else break ; } var_5 . add ( var_14 . toString ( ) ) ; } if ( var_3 . size ( ) != var_5 . size ( ) ) return false ; for ( int var_8 = 0 , var_20 = var_3 . size ( ) ; var_8 < var_20 ; var_8 ++ ) { if ( ! var_3 . get ( var_8 ) . equals ( var_5 . get ( var_8 ) ) ) return false ; } return true ; } " 1156,dynamic_programming_WordBreak_1.java,"private boolean dp(int i, String s, Map dic, Set dictionary) { if (i == s.length()) return true; else if (dic.containsKey(i)) return dic.get(i); else { for (int j = i, l = s.length(); j < l; j++) { String subStr = s.substring(i, j + 1); if (dictionary.contains(subStr)) { if (dp(j + 1, s, dic, dictionary)) { dic.put(i, true); break; } } } } if (!dic.containsKey(i)) dic.put(i, false); return dic.get(i); }","private boolean sample_funcname ( int i , String s , Map < Integer , Boolean > dic , Set < String > dictionary ) { if ( i == s . length ( ) ) return true ; else if ( dic . containsKey ( i ) ) return dic . get ( i ) ; else { for ( int j = i , l = s . length ( ) ; j < l ; j ++ ) { String subStr = s . substring ( i , j + 1 ) ; if ( dictionary . contains ( subStr ) ) { if ( dp ( j + 1 , s , dic , dictionary ) ) { dic . put ( i , true ) ; break ; } } } } if ( ! dic . containsKey ( i ) ) dic . put ( i , false ) ; return dic . get ( i ) ; } " 1157,hashing_LargestUniqueNumber_1.java,"public int largestUniqueNumber(int[] A) { Map map = new HashMap<>(); for (int i : A) { map.putIfAbsent(i, 0); int v = map.get(i) + 1; map.put(i, v); } int max = -1; for (int k : map.keySet()) { if (map.get(k) == 1) { max = Math.max(max, k); } } return max; }","public int sample_funcname ( int [ ] var_0 ) { Map < Integer , Integer > var_4 = new HashMap < > ( ) ; for ( int var_5 : var_0 ) { var_4 . putIfAbsent ( var_5 , 0 ) ; int var_10 = var_4 . get ( var_5 ) + 1 ; var_4 . put ( var_5 , var_10 ) ; } int max = - 1 ; for ( int var_14 : var_4 . keySet ( ) ) { if ( var_4 . get ( var_14 ) == 1 ) { max = Math . max ( max , var_14 ) ; } } return max ; } " 1158,dynamic_programming_CountVowelsPermutation_1.java,"public int countVowelPermutation(int n) { if (n == 1) return 5; Map> graph = new HashMap<>(); List vowels = Arrays.asList('a', 'e', 'i', 'o', 'u'); Map count = new HashMap<>(); vowels.forEach(v -> graph.put(v, new ArrayList<>())); graph.get('a').add('e'); graph.get('e').add('a'); graph.get('e').add('i'); graph.get('i').add('a'); graph.get('i').add('e'); graph.get('i').add('o'); graph.get('i').add('u'); graph.get('u').add('a'); graph.get('o').add('i'); graph.get('o').add('u'); count.put('a', 1); count.put('e', 2); count.put('i', 4); count.put('o', 2); count.put('u', 1); int[] charCount = new int[5]; for (int i = 2; i < n; i++) { int j = 0; Arrays.fill(charCount, 0); for (char c : vowels) { List children = graph.get(c); for (char child : children) { charCount[j] = ((charCount[j] + count.get(child)) % 1000000007); } j++; } j = 0; for (char c : vowels) { count.put(c, charCount[j++]); } } int sum = 0; for (char c : vowels) { sum = ((sum + (count.get(c))) % 1000000007); } return sum; }","public int sample_funcname ( int var_0 ) { if ( var_0 == 1 ) return 5 ; Map < Character , List < Character >> var_7 = new HashMap < > ( ) ; List < Character > var_15 = Arrays . asList ( 'a' , 'e' , 'i' , 'o' , 'u' ) ; Map < Character , Integer > var_17 = new HashMap < > ( ) ; var_15 . forEach ( var_19 -> var_7 . put ( var_19 , new ArrayList < > ( ) ) ) ; var_7 . get ( 'a' ) . add ( 'e' ) ; var_7 . get ( 'e' ) . add ( 'a' ) ; var_7 . get ( 'e' ) . add ( 'i' ) ; var_7 . get ( 'i' ) . add ( 'a' ) ; var_7 . get ( 'i' ) . add ( 'e' ) ; var_7 . get ( 'i' ) . add ( 'o' ) ; var_7 . get ( 'i' ) . add ( 'u' ) ; var_7 . get ( 'u' ) . add ( 'a' ) ; var_7 . get ( 'o' ) . add ( 'i' ) ; var_7 . get ( 'o' ) . add ( 'u' ) ; var_17 . put ( 'a' , 1 ) ; var_17 . put ( 'e' , 2 ) ; var_17 . put ( 'i' , 4 ) ; var_17 . put ( 'o' , 2 ) ; var_17 . put ( 'u' , 1 ) ; int [ ] var_26 = new int [ 5 ] ; for ( int var_27 = 2 ; var_27 < var_0 ; var_27 ++ ) { int var_29 = 0 ; Arrays . fill ( var_26 , 0 ) ; for ( char var_31 : var_15 ) { List < Character > var_32 = var_7 . get ( var_31 ) ; for ( char var_33 : var_32 ) { var_26 [ var_29 ] = ( ( var_26 [ var_29 ] + var_17 . get ( var_33 ) ) % 1000000007 ) ; } var_29 ++ ; } var_29 = 0 ; for ( char var_31 : var_15 ) { var_17 . put ( var_31 , var_26 [ var_29 ++ ] ) ; } } int var_35 = 0 ; for ( char var_31 : var_15 ) { var_35 = ( ( var_35 + ( var_17 . get ( var_31 ) ) ) % 1000000007 ) ; } return var_35 ; } " 1159,greedy_MinimumTimeToBuildBlocks_1.java,"public int minBuildTime(int[] blocks, int split) { PriorityQueue queue = new PriorityQueue<>(); for (int b : blocks) queue.offer(b); while (queue.size() != 1) { int a = queue.poll(); int b = queue.poll(); queue.offer(Math.max(a, b) + split); } return queue.poll(); }","public int sample_funcname ( int [ ] var_0 , int var_1 ) { PriorityQueue < Integer > var_4 = new PriorityQueue < > ( ) ; for ( int var_5 : var_0 ) var_4 . offer ( var_5 ) ; while ( var_4 . size ( ) != 1 ) { int var_10 = var_4 . poll ( ) ; int var_5 = var_4 . poll ( ) ; var_4 . offer ( Math . max ( var_10 , var_5 ) + var_1 ) ; } return var_4 . poll ( ) ; } " 1160,bit_manipulation_BinaryWatch_1.java,"public List readBinaryWatch(int num) { int H = 11, M = 59; List result = new ArrayList<>(); if (num == 0) { result.add(""0:00""); return result; } for (int i = 0; i <= H; i++) { for (int j = 0; j <= M; j++) { int count = 0; for (int k = 0; k < 4; k++) { if (((1 << k) & i) > 0) { count++; } } for (int k = 0; k < 6; k++) { if (((1 << k) & j) > 0) { count++; } } if (count == num) { result.add(i + "":"" + ((String.valueOf(j).length() == 1) ? (""0"" + j) : j)); } } } return result; }","public List < String > var_1 ( int var_2 ) { int var_4 = 11 , var_6 = 59 ; List < String > var_9 = new ArrayList < > ( ) ; if ( var_2 == 0 ) { var_9 . add ( ""0:00"" ) ; return var_9 ; } for ( int var_13 = 0 ; var_13 <= var_4 ; var_13 ++ ) { for ( int var_14 = 0 ; var_14 <= var_6 ; var_14 ++ ) { int var_15 = 0 ; for ( int var_16 = 0 ; var_16 < 4 ; var_16 ++ ) { if ( ( ( 1 << var_16 ) & var_13 ) > 0 ) { var_15 ++ ; } } for ( int var_16 = 0 ; var_16 < 6 ; var_16 ++ ) { if ( ( ( 1 << var_16 ) & var_14 ) > 0 ) { var_15 ++ ; } } if ( var_15 == var_2 ) { var_9 . add ( var_13 + "":"" + ( ( String . valueOf ( var_14 ) . length ( ) == 1 ) ? ( ""0"" + var_14 ) : var_14 ) ) ; } } } return var_9 ; } " 1161,bit_manipulation_TotalHammingDistance_1.java,"public int totalHammingDistance(int[] nums) { int sum = 0; for (int i = 0; i < 32; i++) { int numOfOnes = 0; int p = (1 << i); for (int num : nums) { if ((num & p) > 0) { numOfOnes++; } } sum += ((nums.length - numOfOnes) * numOfOnes); } return sum; }","public int sample_funcname ( int [ ] var_0 ) { int var_2 = 0 ; for ( int var_3 = 0 ; var_3 < 32 ; var_3 ++ ) { int var_5 = 0 ; int var_7 = ( 1 << var_3 ) ; for ( int var_8 : var_0 ) { if ( ( var_8 & var_7 ) > 0 ) { var_5 ++ ; } } var_2 += ( ( var_0 . length - var_5 ) * var_5 ) ; } return var_2 ; } " 1162,greedy_MaximumLengthOfPairChain_1.java,"public int findLongestChain(int[][] pairs) { Arrays.sort( pairs, (o1, o2) -> o1[1] == o2[1] ? Integer.compare(o1[0], o2[0]) : Integer.compare(o1[1], o2[1])); int count = 1; int[] curr = pairs[0]; for (int i = 1; i < pairs.length; i++) { if (pairs[i][0] > curr[1]) { count++; curr = pairs[i]; } } return count; }","public int sample_funcname ( int [ ] [ ] var_0 ) { Arrays . sort ( var_0 , ( var_3 , var_4 ) -> var_3 [ 1 ] == var_4 [ 1 ] ? Integer . compare ( var_3 [ 0 ] , var_4 [ 0 ] ) : Integer . compare ( var_3 [ 1 ] , var_4 [ 1 ] ) ) ; int var_9 = 1 ; int [ ] var_10 = var_0 [ 0 ] ; for ( int var_11 = 1 ; var_11 < var_0 . length ; var_11 ++ ) { if ( var_0 [ var_11 ] [ 0 ] > var_10 [ 1 ] ) { var_9 ++ ; var_10 = var_0 [ var_11 ] ; } } return var_9 ; } " 1163,string_StudentAttendanceRecordI_1.java,"public boolean checkRecord(String s) { int count = 0; for (int c : s.toCharArray()) { if (c == 'A') { count++; } if (count > 1) return false; } if (s.contains(""LLL"")) return false; return true; }","public boolean var_0 ( String var_2 ) { int var_4 = 0 ; for ( int var_6 : var_2 . toCharArray ( ) ) { if ( var_6 == 'A' ) { var_4 ++ ; } if ( var_4 > 1 ) return false ; } if ( var_2 . contains ( ""LLL"" ) ) return false ; return true ; } " 1164,dynamic_programming_MakeArrayStrictlyIncreasing_1.java,"private int binarySearch(int[] A, int k) { int l = 0, h = A.length; int ans = -1; while (l < h) { int m = l + (h - l) / 2; if (A[m] > k) { ans = m; h = m; } else l = m + 1; } return ans; }","private int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_3 = 0 , var_5 = var_0 . length ; int var_7 = - 1 ; while ( var_3 < var_5 ) { int var_9 = var_3 + ( var_5 - var_3 ) / 2 ; if ( var_0 [ var_9 ] > var_1 ) { var_7 = var_9 ; var_5 = var_9 ; } else var_3 = var_9 + 1 ; } return var_7 ; } " 1165,math_RectangleOverlap_1.java,"public boolean isRectangleOverlap(int[] rec1, int[] rec2) { boolean x = ((rec1[0] >= rec2[0] && rec1[0] < rec2[2]) || (rec2[0] >= rec1[0] && rec2[0] < rec1[2])); boolean y = ((rec1[1] >= rec2[1] && rec1[1] < rec2[3]) || (rec2[1] >= rec1[1] && rec2[1] < rec1[3])); return x && y; }","public boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { boolean var_6 = ( ( var_1 [ 0 ] >= var_2 [ 0 ] && var_1 [ 0 ] < var_2 [ 2 ] ) || ( var_2 [ 0 ] >= var_1 [ 0 ] && var_2 [ 0 ] < var_1 [ 2 ] ) ) ; boolean var_9 = ( ( var_1 [ 1 ] >= var_2 [ 1 ] && var_1 [ 1 ] < var_2 [ 3 ] ) || ( var_2 [ 1 ] >= var_1 [ 1 ] && var_2 [ 1 ] < var_1 [ 3 ] ) ) ; return var_6 && var_9 ; } " 1166,string_AddBinary_1.java,"private String calculate(String a, String b) { int carry = 0; int d = a.length() - b.length(); StringBuilder sb = new StringBuilder(); for (int i = a.length() - 1; i >= 0; i--) { int first = Integer.parseInt(String.valueOf(a.charAt(i))); int second = i - d >= 0 ? Integer.parseInt(String.valueOf(b.charAt(i - d))) : 0; int sum = (first + second + carry); carry = sum / 2; sb.append(sum % 2); } if (carry != 0) sb.append(carry); return sb.reverse().toString(); }","private String var_0 ( String var_2 , String var_3 ) { int var_5 = 0 ; int var_7 = var_2 . length ( ) - var_3 . length ( ) ; StringBuilder var_9 = new StringBuilder ( ) ; for ( int var_11 = var_2 . length ( ) - 1 ; var_11 >= 0 ; var_11 -- ) { int var_16 = Integer . parseInt ( String . valueOf ( var_2 . charAt ( var_11 ) ) ) ; int var_17 = var_11 - var_7 >= 0 ? Integer . parseInt ( String . valueOf ( var_3 . charAt ( var_11 - var_7 ) ) ) : 0 ; int var_18 = ( var_16 + var_17 + var_5 ) ; var_5 = var_18 / 2 ; var_9 . append ( var_18 % 2 ) ; } if ( var_5 != 0 ) var_9 . append ( var_5 ) ; return var_9 . reverse ( ) . toString ( ) ; } " 1167,dynamic_programming_MaximumVacationDays_1.java,"public int maxVacationDays(int[][] flights, int[][] days) { int N = days.length; int W = days[0].length; int[][] DP = new int[N][W + 1]; for (int w = W - 1; w >= 0; w--) { for (int n = 0; n < N; n++) { DP[n][w] = days[n][w] + DP[n][w + 1]; } for (int n = 0; n < N; n++) { int max = Integer.MIN_VALUE; int[] F = flights[n]; for (int i = 0; i < F.length; i++) { if (F[i] == 1) { max = Math.max(max, days[i][w] + DP[i][w + 1]); } } DP[n][w] = Math.max(DP[n][w], max); } } return DP[0][0]; }","public int sample_funcname ( int [ ] [ ] var_0 , int [ ] [ ] var_1 ) { int var_3 = var_1 . length ; int var_5 = var_1 [ 0 ] . length ; int [ ] [ ] var_7 = new int [ var_3 ] [ var_5 + 1 ] ; for ( int var_8 = var_5 - 1 ; var_8 >= 0 ; var_8 -- ) { for ( int var_9 = 0 ; var_9 < var_3 ; var_9 ++ ) { var_7 [ var_9 ] [ var_8 ] = var_1 [ var_9 ] [ var_8 ] + var_7 [ var_9 ] [ var_8 + 1 ] ; } for ( int var_9 = 0 ; var_9 < var_3 ; var_9 ++ ) { int max = Integer . MIN_VALUE ; int [ ] var_13 = var_0 [ var_9 ] ; for ( int var_14 = 0 ; var_14 < var_13 . length ; var_14 ++ ) { if ( var_13 [ var_14 ] == 1 ) { max = Math . max ( max , var_1 [ var_14 ] [ var_8 ] + var_7 [ var_14 ] [ var_8 + 1 ] ) ; } } var_7 [ var_9 ] [ var_8 ] = Math . max ( var_7 [ var_9 ] [ var_8 ] , max ) ; } } return var_7 [ 0 ] [ 0 ] ; } " 1168,dynamic_programming_MaximalSquare_1.java,"public int maximalSquare(char[][] matrix) { if (matrix.length == 0) return 0; int[][] dp = new int[matrix.length][matrix[0].length]; for (int i = 0; i < matrix.length; i++) { for (int j = 0; j < matrix[0].length; j++) { if (j - 1 >= 0 && i - 1 >= 0) { if (matrix[i][j] == '1') { dp[i][j] = Math.min(dp[i - 1][j], dp[i][j - 1]); dp[i][j] = Math.min(dp[i][j], dp[i - 1][j - 1]) + 1; } } else { dp[i][j] = matrix[i][j] == '1' ? 1 : 0; } } } int max = 0; for (int i = 0; i < dp.length; i++) { for (int j = 0; j < dp[0].length; j++) { max = Math.max(max, dp[i][j]); } } return max * max; }","public int sample_funcname ( char [ ] [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int [ ] [ ] var_3 = new int [ var_0 . length ] [ var_0 [ 0 ] . length ] ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { for ( int var_5 = 0 ; var_5 < var_0 [ 0 ] . length ; var_5 ++ ) { if ( var_5 - 1 >= 0 && var_4 - 1 >= 0 ) { if ( var_0 [ var_4 ] [ var_5 ] == '1' ) { var_3 [ var_4 ] [ var_5 ] = Math . min ( var_3 [ var_4 - 1 ] [ var_5 ] , var_3 [ var_4 ] [ var_5 - 1 ] ) ; var_3 [ var_4 ] [ var_5 ] = Math . min ( var_3 [ var_4 ] [ var_5 ] , var_3 [ var_4 - 1 ] [ var_5 - 1 ] ) + 1 ; } } else { var_3 [ var_4 ] [ var_5 ] = var_0 [ var_4 ] [ var_5 ] == '1' ? 1 : 0 ; } } } int max = 0 ; for ( int var_4 = 0 ; var_4 < var_3 . length ; var_4 ++ ) { for ( int var_5 = 0 ; var_5 < var_3 [ 0 ] . length ; var_5 ++ ) { max = Math . max ( max , var_3 [ var_4 ] [ var_5 ] ) ; } } return max * max ; } " 1169,string_CompareVersionNumbers_1.java,"public int compareVersion(String version1, String version2) { StringTokenizer st1 = new StringTokenizer(version1, "".""); StringTokenizer st2 = new StringTokenizer(version2, "".""); while (st1.hasMoreTokens() & st2.hasMoreTokens()) { int token1 = Integer.parseInt(st1.nextToken()); int token2 = Integer.parseInt(st2.nextToken()); if (token1 > token2) return 1; else if (token2 > token1) return -1; } if (st1.countTokens() > st2.countTokens()) { while (st1.hasMoreTokens()) { if (Integer.parseInt(st1.nextToken()) > 0) return 1; } } else if (st2.countTokens() > st1.countTokens()) { while (st2.hasMoreTokens()) { if (Integer.parseInt(st2.nextToken()) > 0) return -1; } } return 0; }","public int sample_funcname ( String var_1 , String var_2 ) { StringTokenizer var_5 = new StringTokenizer ( var_1 , ""."" ) ; StringTokenizer var_6 = new StringTokenizer ( var_2 , ""."" ) ; while ( var_5 . hasMoreTokens ( ) & var_6 . hasMoreTokens ( ) ) { int var_11 = Integer . parseInt ( var_5 . nextToken ( ) ) ; int var_12 = Integer . parseInt ( var_6 . nextToken ( ) ) ; if ( var_11 > var_12 ) return 1 ; else if ( var_12 > var_11 ) return - 1 ; } if ( var_5 . countTokens ( ) > var_6 . countTokens ( ) ) { while ( var_5 . hasMoreTokens ( ) ) { if ( Integer . parseInt ( var_5 . nextToken ( ) ) > 0 ) return 1 ; } } else if ( var_6 . countTokens ( ) > var_5 . countTokens ( ) ) { while ( var_6 . hasMoreTokens ( ) ) { if ( Integer . parseInt ( var_6 . nextToken ( ) ) > 0 ) return - 1 ; } } return 0 ; } " 1170,stack_MaximalRectangle_1.java,"private int getMaxRectangle(int[] heights) { int maxArea = Integer.MIN_VALUE; Stack stack = new Stack<>(); int i = 0; for (; i < heights.length; i++) { while (!stack.isEmpty() && heights[stack.peek()] >= heights[i]) { int top = stack.pop(); int base = stack.isEmpty() ? i : i - stack.peek() - 1; maxArea = Math.max(maxArea, base * heights[top]); } stack.push(i); } while (!stack.isEmpty()) { int top = stack.pop(); int base = stack.isEmpty() ? i : i - stack.peek() - 1; maxArea = Math.max(maxArea, base * heights[top]); } return maxArea; }","private int sample_funcname ( int [ ] var_0 ) { int var_3 = Integer . MIN_VALUE ; Stack < Integer > var_5 = new Stack < > ( ) ; int var_7 = 0 ; for ( ; var_7 < var_0 . length ; var_7 ++ ) { while ( ! var_5 . isEmpty ( ) && var_0 [ var_5 . peek ( ) ] >= var_0 [ var_7 ] ) { int var_12 = var_5 . pop ( ) ; int var_14 = var_5 . isEmpty ( ) ? var_7 : var_7 - var_5 . peek ( ) - 1 ; var_3 = Math . max ( var_3 , var_14 * var_0 [ var_12 ] ) ; } var_5 . push ( var_7 ) ; } while ( ! var_5 . isEmpty ( ) ) { int var_12 = var_5 . pop ( ) ; int var_14 = var_5 . isEmpty ( ) ? var_7 : var_7 - var_5 . peek ( ) - 1 ; var_3 = Math . max ( var_3 , var_14 * var_0 [ var_12 ] ) ; } return var_3 ; } "