id
int64
0
1.17k
comefrom
stringlengths
21
84
code
stringlengths
50
1.89k
masked
stringlengths
63
2.42k
unique_words_num
int64
0
6
words
stringlengths
1
139
103
<qiyuangong>438_Find_All_Anagrams_in_a_String_1.java
public List<Integer> findAnagrams(String s, String p) { List<Integer> 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_0 ( String var_1 , String var_2 ) { List < Integer > var_3 = new ArrayList < > ( ) ; if ( var_1 == null || var_1 . length ( ) == 0 || var_2 == null || var_2 . length ( ) == 0 ) return var_3 ; int [ ] var_4 = new int [ 256 ] ; for ( char var_5 : var_2 . toCharArray ( ) ) { var_4 [ var_5 ] ++ ; } int var_6 = 0 , var_7 = 0 , var_8 = var_2 . length ( ) ; while ( var_7 < var_1 . length ( ) ) { if ( var_4 [ var_1 . charAt ( var_7 ++ ) ] -- >= 1 ) var_8 -- ; if ( var_8 == 0 ) var_3 . add ( var_6 ) ; if ( var_7 - var_6 == var_2 . length ( ) && var_4 [ var_1 . charAt ( var_6 ++ ) ] ++ >= 0 ) var_8 ++ ; } return var_3 ; }
3
0<SEP>256<SEP>1
104
<qiyuangong>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 ) ; } }
2
1<SEP>0
106
<qiyuangong>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_1 = new int [ var_0 . length ] ; int var_2 = 0 ; Queue < Integer > var_3 = new LinkedList < > ( ) ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { if ( var_1 [ var_4 ] == 0 ) { var_3 . add ( var_4 ) ; while ( ! var_3 . isEmpty ( ) ) { int var_5 = var_3 . remove ( ) ; var_1 [ var_5 ] = 1 ; for ( int var_6 = 0 ; var_6 < var_0 . length ; var_6 ++ ) { if ( var_0 [ var_5 ] [ var_6 ] == 1 && var_1 [ var_6 ] == 0 ) var_3 . add ( var_6 ) ; } } var_2 ++ ; } } return var_2 ; }
2
0<SEP>1
108
<qiyuangong>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_2 = 1 ; var_2 < var_1 . length ; ++ var_2 ) for ( int var_3 = 1 ; var_3 < var_1 [ 0 ] . length ; ++ var_3 ) if ( var_1 [ var_2 - 1 ] [ var_3 - 1 ] != var_1 [ var_2 ] [ var_3 ] ) return false ; return true ; }
2
1<SEP>0
109
<qiyuangong>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_0 ) { boolean [ ] var_1 = new boolean [ 256 ] ; int var_2 = 0 , var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ( ) ; var_4 ++ ) { while ( var_1 [ var_0 . charAt ( var_4 ) ] ) { var_1 [ var_0 . charAt ( var_2 ) ] = false ; var_2 ++ ; } var_1 [ var_0 . charAt ( var_4 ) ] = true ; var_3 = Math . max ( var_4 - var_2 + 1 , var_3 ) ; } return var_3 ; }
3
0<SEP>256<SEP>1
110
<qiyuangong>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_3 = var_2 / var_1 + 1 ; int var_4 = 0 ; while ( Math . pow ( var_3 , var_4 ) < var_0 ) var_4 ++ ; return var_4 ; }
2
1<SEP>0
111
<qiyuangong>001_Two_Sum_1.java
public int[] twoSum(int[] nums, int target) { Map<Integer, Integer> 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_2 = new HashMap < > ( ) ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { int var_4 = var_0 [ var_3 ] ; if ( var_2 . containsKey ( var_1 - var_4 ) ) { return new int [ ] { var_2 . get ( var_1 - var_4 ) , var_3 }; } var_2 . put ( var_4 , var_3 ) ; } throw new IllegalArgumentException ( "No two sum solution" ) ; }
2
0<SEP><D_QUOTE>No two sum solution<D_QUOTE>
112
<qiyuangong>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_2 = 0 , var_3 = 0 , var_4 = 0 ; int var_5 = var_0 . length , var_6 = var_1 . length ; int [ ] var_7 = new int [ var_5 + var_6 ] ; double var_8 = 0.0 ; while ( var_2 < var_5 && var_3 < var_6 ) { if ( var_0 [ var_2 ] <= var_1 [ var_3 ] ) var_7 [ var_4 ++ ] = var_0 [ var_2 ++ ] ; else var_7 [ var_4 ++ ] = var_1 [ var_3 ++ ] ; } while ( var_2 < var_5 ) var_7 [ var_4 ++ ] = var_0 [ var_2 ++ ] ; while ( var_3 < var_6 ) var_7 [ var_4 ++ ] = var_1 [ var_3 ++ ] ; if ( ( var_5 + var_6 ) % 2 == 1 ) var_8 = var_7 [ ( var_5 + var_6 ) / 2 ] ; else var_8 = ( var_7 [ ( var_5 + var_6 ) / 2 ] + var_7 [ ( var_5 + var_6 ) / 2 - 1 ] ) / 2.0 ; return var_8 ; }
5
2<SEP>2.0<SEP>0<SEP>1<SEP>0.0
113
<qiyuangong>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 ; } }
3
9<SEP>1<SEP>0
114
<qiyuangong>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_0 ) { String var_1 = var_0 . trim ( ) ; if ( var_1 . equals ( "" ) ) { return 0 ; } return var_1 . split ( "\\s+" ) . length ; }
3
0<SEP><D_QUOTE><D_QUOTE><SEP><D_QUOTE>\\s+<D_QUOTE>
115
<qiyuangong>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_2 = 0 ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { int var_4 = 0 ; for ( int var_5 = var_3 ; var_5 < var_0 . length ; var_5 ++ ) { var_4 += var_0 [ var_5 ] ; if ( var_4 == var_1 ) var_2 ++ ; } } return var_2 ; }
1
0
116
<qiyuangong>784_Letter_Case_Permutation_1.java
public List<String> letterCasePermutation(String S) { List<StringBuilder> 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<String> finalans = new ArrayList(); for (StringBuilder sb: ans) finalans.add(sb.toString()); return finalans; }
public List < String > var_0 ( String var_1 ) { List < StringBuilder > var_2 = new ArrayList ( ) ; var_2 . add ( new StringBuilder ( ) ) ; for ( char var_3 : var_1 . toCharArray ( ) ) { int var_4 = var_2 . size ( ) ; if ( Character . isLetter ( var_3 ) ) { for ( int var_5 = 0 ; var_5 < var_4 ; ++ var_5 ) { var_2 . add ( new StringBuilder ( var_2 . get ( var_5 ) ) ) ; var_2 . get ( var_5 ) . append ( Character . toLowerCase ( var_3 ) ) ; var_2 . get ( var_4 + var_5 ) . append ( Character . toUpperCase ( var_3 ) ) ; } } else { for ( int var_5 = 0 ; var_5 < var_4 ; ++ var_5 ) var_2 . get ( var_5 ) . append ( var_3 ) ; } } List < String > var_6 = new ArrayList ( ) ; for ( StringBuilder var_7 : var_2 ) var_6 . add ( var_7 . toString ( ) ) ; return var_6 ; }
1
0
117
<qiyuangong>414_Third_Maximum_Number_1.java
public int thirdMax(int[] nums) { PriorityQueue<Integer> pq = new PriorityQueue<>(3); Set<Integer> 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_1 = new PriorityQueue < > ( 3 ) ; Set < Integer > var_2 = new HashSet < > ( ) ; for ( int var_3 : var_0 ) { if ( var_2 . contains ( var_3 ) ) continue ; var_1 . offer ( var_3 ) ; var_2 . add ( var_3 ) ; if ( var_1 . size ( ) > 3 ) var_2 . remove ( var_1 . poll ( ) ) ; } while ( var_1 . size ( ) < 3 && var_1 . size ( ) > 1 ) { var_1 . poll ( ) ; } return var_1 . peek ( ) ; }
2
1<SEP>3
118
<qiyuangong>448_Find_All_Numbers_Disappeared_in_an_Array_1.java
public List<Integer> findDisappearedNumbers(int[] nums) { List<Integer> ret = new ArrayList<Integer>(); 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_0 ( int [ ] var_1 ) { List < Integer > var_2 = new ArrayList < Integer > ( ) ; for ( int var_3 = 0 ; var_3 < var_1 . length ; var_3 ++ ) { int var_4 = Math . abs ( var_1 [ var_3 ] ) - 1 ; if ( var_1 [ var_4 ] > 0 ) { var_1 [ var_4 ] = - var_1 [ var_4 ] ; } } for ( int var_3 = 0 ; var_3 < var_1 . length ; var_3 ++ ) { if ( var_1 [ var_3 ] > 0 ) { var_2 . add ( var_3 + 1 ) ; } } return var_2 ; }
2
0<SEP>1
119
<qiyuangong>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 ) ; }
0
null
120
<qiyuangong>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_1 = 0 ; int [ ] var_2 = new int [ var_0 . length ] ; int var_3 = 0 ; while ( var_1 < var_0 . length && var_0 [ var_1 ] < 0 ) var_1 ++ ; int var_4 = var_1 - 1 ; while ( var_1 < var_0 . length && var_4 >= 0 ) { if ( var_0 [ var_1 ] * var_0 [ var_1 ] < var_0 [ var_4 ] * var_0 [ var_4 ] ) { var_2 [ var_3 ++ ] = var_0 [ var_1 ] * var_0 [ var_1 ] ; var_1 ++ ; } else { var_2 [ var_3 ++ ] = var_0 [ var_4 ] * var_0 [ var_4 ] ; var_4 -- ; } } while ( var_4 >= 0 ) { var_2 [ var_3 ++ ] = var_0 [ var_4 ] * var_0 [ var_4 ] ; var_4 -- ; } while ( var_1 < var_0 . length ) { var_2 [ var_3 ++ ] = var_0 [ var_1 ] * var_0 [ var_1 ] ; var_1 ++ ; } return var_2 ; }
2
0<SEP>1
121
<qiyuangong>692_Top_K_Frequent_Words_1.java
public List<String> topKFrequent(String[] words, int k) { Map<String, Integer> count = new HashMap(); for (String word: words) { count.put(word, count.getOrDefault(word, 0) + 1); } List<String> 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_0 ( String [ ] var_1 , int var_2 ) { Map < String , Integer > var_3 = new HashMap ( ) ; for ( String var_4 : var_1 ) { var_3 . put ( var_4 , var_3 . getOrDefault ( var_4 , 0 ) + 1 ) ; } List < String > var_5 = new ArrayList ( var_3 . keySet ( ) ) ; Collections . sort ( var_5 , ( var_6 , var_7 ) -> var_3 . get ( var_6 ) . equals ( var_3 . get ( var_7 ) ) ? var_6 . compareTo ( var_7 ) : var_3 . get ( var_7 ) - var_3 . get ( var_6 ) ) ; return var_5 . subList ( 0 , var_2 ) ; }
2
0<SEP>1
122
<qiyuangong>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_3 = 0 , var_4 = var_1 ; if ( var_4 < 0 ) { return false ; } while ( var_4 != 0 ) { var_2 = var_4 % 10 ; var_3 = var_3 * 10 + var_2 ; var_4 /= 10 ; } if ( var_3 == var_1 ) { return true ; } else { return false ; } }
2
10<SEP>0
123
<awangdev>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_4 = 0 ; var_4 < 32 ; var_4 ++ ) { if ( ( var_3 & 1 ) == 1 ) var_2 [ var_4 ] ++ ; else var_1 [ var_4 ] ++ ; var_3 = ( var_3 >> 1 ) ; } }
3
0<SEP>32<SEP>1
124
<awangdev>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_4 = 0 ; for ( int var_5 : var_3 ) { var_4 += var_5 / var_1 ; } return var_4 >= var_2 ; }
1
0
125
<awangdev>Single Number III_1.java
public List<Integer> singleNumberIII(int[] A) { if (A == null || A.length == 0) { return null; } List<Integer> rst = new ArrayList<Integer>(); 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_0 ( int [ ] var_1 ) { if ( var_1 == null || var_1 . length == 0 ) { return null ; } List < Integer > var_2 = new ArrayList < Integer > ( ) ; int var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_1 . length ; var_4 ++ ) { var_3 ^= var_1 [ var_4 ] ; } int var_5 = 0 ; for ( int var_4 = 0 ; var_4 < 32 ; var_4 ++ ) { if ( ( var_3 >> var_4 & 1 ) == 1 ) { var_5 = var_4 ; } } int var_6 = 0 ; int var_7 = 0 ; for ( int var_4 = 0 ; var_4 < var_1 . length ; var_4 ++ ) { if ( ( var_1 [ var_4 ] >> var_5 & 1 ) == 1 ) { var_6 ^= var_1 [ var_4 ] ; } else { var_7 ^= var_1 [ var_4 ] ; } } var_2 . add ( var_6 ) ; var_2 . add ( var_7 ) ; return var_2 ; }
3
0<SEP>32<SEP>1
126
<awangdev>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_2 = new int [ var_0 ] [ var_1 ] ; for ( int var_3 = 0 ; var_3 < var_0 ; var_3 ++ ) var_2 [ var_3 ] [ 0 ] = 1 ; for ( int var_3 = 0 ; var_3 < var_1 ; var_3 ++ ) var_2 [ 0 ] [ var_3 ] = 1 ; for ( int var_3 = 1 ; var_3 < var_0 ; var_3 ++ ) { for ( int var_4 = 1 ; var_4 < var_1 ; var_4 ++ ) { var_2 [ var_3 ] [ var_4 ] = var_2 [ var_3 - 1 ] [ var_4 ] + var_2 [ var_3 ] [ var_4 - 1 ] ; } } return var_2 [ var_0 - 1 ] [ var_1 - 1 ] ; }
2
0<SEP>1
127
<awangdev>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<Integer> 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_2 = Math . min ( var_0 . length , var_0 [ 0 ] . length ) ; int var_3 = Math . max ( var_0 . length , var_0 [ 0 ] . length ) ; boolean var_4 = var_0 . length < var_0 [ 0 ] . length ; int max = Integer . MIN_VALUE ; for ( int var_5 = 0 ; var_5 < var_2 ; var_5 ++ ) { int [ ] var_6 = new int [ var_3 ] ; for ( int var_7 = var_5 ; var_7 < var_2 ; var_7 ++ ) { TreeSet < Integer > var_8 = new TreeSet < > ( ) ; int var_9 = 0 ; for ( int var_10 = 0 ; var_10 < var_3 ; var_10 ++ ) { var_6 [ var_10 ] += var_4 ? var_0 [ var_7 ] [ var_10 ] : var_0 [ var_10 ] [ var_7 ] ; var_9 += var_6 [ var_10 ] ; if ( var_9 <= var_1 ) max = Math . max ( max , var_9 ) ; Integer var_11 = var_8 . ceiling ( var_9 - var_1 ) ; if ( var_11 != null ) { max = Math . max ( max , var_9 - var_11 ) ; } var_8 . add ( var_9 ) ; } } } return max == Integer . MIN_VALUE ? - 1 : max ; }
2
0<SEP>1
128
<awangdev>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_1 = var_0 . length , var_2 = var_0 [ 0 ] . length ; int [ ] [ ] var_3 = new int [ 2 ] [ var_2 ] ; for ( int var_4 = 0 ; var_4 < var_1 ; var_4 ++ ) { for ( int var_5 = 0 ; var_5 < var_2 ; var_5 ++ ) { var_3 [ var_4 % 2 ] [ var_5 ] = var_0 [ var_4 ] [ var_5 ] ; if ( var_4 == 0 && var_5 == 0 ) continue ; if ( var_4 == 0 && var_5 > 0 ) var_3 [ var_4 % 2 ] [ var_5 ] += var_3 [ var_4 % 2 ] [ var_5 - 1 ] ; else if ( var_4 > 0 && var_5 == 0 ) var_3 [ var_4 % 2 ] [ var_5 ] += var_3 [ ( var_4 - 1 ) % 2 ] [ var_5 ] ; else var_3 [ var_4 % 2 ] [ var_5 ] += Math . min ( var_3 [ ( var_4 - 1 ) % 2 ] [ var_5 ] , var_3 [ var_4 % 2 ] [ var_5 - 1 ] ) ; } } return var_3 [ ( var_1 - 1 ) % 2 ] [ var_2 - 1 ] ; }
3
0<SEP>1<SEP>2
129
<awangdev>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_3 = String . valueOf ( var_2 ) ; for ( char var_4 : var_3 . toCharArray ( ) ) { var_0 [ var_1 ++ ] = var_4 ; } return var_1 ; }
0
null
130
<awangdev>332. Reconstruct Itinerary_1.java
private Map<String, List<String>> buildMap(List<List<String>> tickets) { Map<String, List<String>> map = new HashMap<>(); for (List<String> 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_0 ( List < List < String >> var_1 ) { Map < String , List < String >> var_2 = new HashMap < > ( ) ; for ( List < String > var_3 : var_1 ) { var_2 . putIfAbsent ( var_3 . get ( 0 ) , new LinkedList < > ( ) ) ; var_2 . get ( var_3 . get ( 0 ) ) . add ( var_3 . get ( 1 ) ) ; } for ( String var_4 : var_2 . keySet ( ) ) Collections . sort ( var_2 . get ( var_4 ) ) ; return var_2 ; }
2
0<SEP>1
131
<awangdev>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 ; } }
3
2<SEP>0<SEP>1
132
<awangdev>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_2 = var_1 . length ; boolean [ ] [ ] var_3 = new boolean [ 2 ] [ var_0 + 1 ] ; int var_4 = 0 ; int var_5 = 1 ; var_3 [ var_4 ] [ 0 ] = true ; for ( int var_6 = 1 ; var_6 <= var_0 ; var_6 ++ ) { var_3 [ var_4 ] [ var_6 ] = false ; } for ( int var_7 = 1 ; var_7 <= var_2 ; var_7 ++ ) { var_4 = var_5 ; var_5 = 1 - var_4 ; for ( int var_6 = 0 ; var_6 <= var_0 ; var_6 ++ ) { var_3 [ var_4 ] [ var_6 ] = var_3 [ var_5 ] [ var_6 ] ; if ( var_6 - var_1 [ var_7 - 1 ] >= 0 ) { var_3 [ var_4 ] [ var_6 ] |= var_3 [ var_5 ] [ var_6 - var_1 [ var_7 - 1 ] ] ; } } } for ( int var_6 = var_0 ; var_6 >= 0 ; var_6 -- ) { if ( var_3 [ var_4 ] [ var_6 ] ) { return var_6 ; } } return 0 ; }
3
0<SEP>1<SEP>2
133
<awangdev>Triangles_3.java
public int minimumTotal(List<List<Integer>> 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_0 ) { if ( var_0 == null || var_0 . size ( ) == 0 ) { return 0 ; } int var_1 = var_0 . size ( ) ; int [ ] var_2 = new int [ var_1 ] ; for ( int var_3 = 0 ; var_3 < var_1 ; var_3 ++ ) { var_2 [ var_3 ] = var_0 . get ( var_1 - 1 ) . get ( var_3 ) ; } for ( int var_4 = var_1 - 2 ; var_4 >= 0 ; var_4 -- ) { for ( int var_3 = 0 ; var_3 <= var_4 ; var_3 ++ ) { var_2 [ var_3 ] = Math . min ( var_2 [ var_3 ] , var_2 [ var_3 + 1 ] ) + var_0 . get ( var_4 ) . get ( var_3 ) ; } } return var_2 [ 0 ] ; }
3
2<SEP>0<SEP>1
134
<awangdev>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_1 = var_0 . length - 1 ; while ( var_1 > 0 ) { if ( var_0 [ var_1 - 1 ] < var_0 [ var_1 ] ) return var_1 - 1 ; var_1 -- ; } return - 1 ; }
2
1<SEP>0
135
<awangdev>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_1 ) { if ( var_1 == null || var_1 . length ( ) <= 1 ) return var_1 ; int var_2 = var_1 . length ( ) ; boolean var_3 [ ] [ ] = new boolean [ var_2 ] [ var_2 ] ; String var_4 = String . valueOf ( var_1 . charAt ( var_2 - 1 ) ) ; for ( int var_5 = var_2 - 1 ; var_5 >= 0 ; var_5 -- ) { var_3 [ var_5 ] [ var_5 ] = true ; for ( int var_6 = var_5 + 1 ; var_6 < var_2 ; var_6 ++ ) { if ( var_1 . charAt ( var_5 ) == var_1 . charAt ( var_6 ) && ( var_5 + 1 == var_6 || var_3 [ var_5 + 1 ] [ var_6 - 1 ] ) ) { var_3 [ var_5 ] [ var_6 ] = true ; var_4 = var_4 . length ( ) <= ( var_6 - var_5 + 1 ) ? var_1 . substring ( var_5 , var_6 + 1 ) : var_4 ; } } } return var_4 ; }
2
1<SEP>0
136
<awangdev>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_1 ) { List [ ] var_2 = new List [ 17 ] ; for ( String var_3 : var_1 ) { int var_4 = var_3 . length ( ) ; if ( var_2 [ var_4 ] == null ) var_2 [ var_4 ] = new ArrayList < > ( ) ; var_2 [ var_4 ] . add ( var_3 ) ; } return var_2 ; }
1
17
137
<awangdev>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_3 = 0 , var_4 = 0 ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { if ( var_0 [ var_5 ] != var_2 && var_1 [ var_5 ] != var_2 ) return - 1 ; else if ( var_0 [ var_5 ] != var_2 ) var_3 ++ ; else if ( var_1 [ var_5 ] != var_2 ) var_4 ++ ; } return Math . min ( var_3 , var_4 ) ; }
2
0<SEP>1
138
<awangdev>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_1 = 1 ; int var_2 = 1 ; int var_3 = 1 ; for ( int var_4 = 1 ; var_4 < var_0 . length ; var_4 ++ ) { if ( var_0 [ var_4 ] > var_0 [ var_4 - 1 ] ) { var_1 ++ ; } else { var_1 = 1 ; } var_3 = Math . max ( var_3 , var_1 ) ; } for ( int var_4 = var_0 . length - 2 ; var_4 >= 0 ; var_4 -- ) { if ( var_0 [ var_4 ] > var_0 [ var_4 + 1 ] ) { var_2 ++ ; } else { var_2 = 1 ; } var_3 = Math . max ( var_3 , var_2 ) ; } return var_3 ; }
3
2<SEP>0<SEP>1
139
<awangdev>Perfect Squares_3.java
public int numSquares(int n) { if (n <= 0) { return 0; } Queue<Integer> queue = new LinkedList<>(); Set<Integer> 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_1 = new LinkedList < > ( ) ; Set < Integer > var_2 = new HashSet < > ( ) ; var_1 . offer ( var_0 ) ; int var_3 = 1 ; while ( ! var_1 . isEmpty ( ) ) { int size = var_1 . size ( ) ; for ( int var_4 = 0 ; var_4 < size ; var_4 ++ ) { int var_5 = var_1 . poll ( ) ; for ( int var_6 = 1 ; var_6 <= var_5 ; var_6 ++ ) { int var_7 = var_5 - var_6 * var_6 ; if ( var_7 == 0 ) { return var_3 ; } else if ( var_7 > 0 && ! var_2 . contains ( var_7 ) ) { var_1 . offer ( var_7 ) ; var_2 . add ( var_7 ) ; } else if ( var_7 < 0 ) { break ; } } } var_3 ++ ; } return var_3 ; }
2
0<SEP>1
140
<awangdev>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_1 = var_0 . length ; int [ ] [ ] var_2 = new int [ var_1 ] [ 2 ] ; var_2 [ 0 ] [ 0 ] = - var_0 [ 0 ] ; var_2 [ 0 ] [ 1 ] = 0 ; for ( int var_3 = 1 ; var_3 < var_1 ; var_3 ++ ) { var_2 [ var_3 ] [ 1 ] = Math . max ( var_2 [ var_3 - 1 ] [ 1 ] , var_2 [ var_3 - 1 ] [ 0 ] + var_0 [ var_3 ] ) ; var_2 [ var_3 ] [ 0 ] = var_2 [ var_3 - 1 ] [ 0 ] ; if ( var_3 >= 2 ) { var_2 [ var_3 ] [ 0 ] = Math . max ( var_2 [ var_3 ] [ 0 ] , var_2 [ var_3 - 2 ] [ 1 ] - var_0 [ var_3 ] ) ; } else { var_2 [ var_3 ] [ 0 ] = Math . max ( var_2 [ var_3 ] [ 0 ] , - var_0 [ var_3 ] ) ; } } return var_2 [ var_1 - 1 ] [ 1 ] ; }
3
1<SEP>0<SEP>2
141
<awangdev>Decode String_2.java
private String popStack(Stack<Object> stack) { StringBuffer sb = new StringBuffer(); Stack<String> 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_1 ) { StringBuffer var_2 = new StringBuffer ( ) ; Stack < String > var_3 = new Stack < > ( ) ; while ( ! var_1 . isEmpty ( ) && ( var_1 . peek ( ) instanceof String ) ) { var_3 . push ( ( String ) var_1 . pop ( ) ) ; } while ( ! var_3 . isEmpty ( ) ) { var_2 . append ( var_3 . pop ( ) ) ; } return var_2 . toString ( ) ; }
0
null
142
<awangdev>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_1 , String var_2 , String var_3 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) + var_2 . length ( ) != var_3 . length ( ) ) { return false ; } int var_4 = var_1 . length ( ) ; int var_5 = var_2 . length ( ) ; boolean [ ] [ ] var_6 = new boolean [ 2 ] [ var_5 + 1 ] ; int var_7 = 0 ; int var_8 = 0 ; for ( int var_9 = 0 ; var_9 <= var_4 ; var_9 ++ ) { var_8 = var_7 ; var_7 = 1 - var_8 ; for ( int var_10 = 0 ; var_10 <= var_5 ; var_10 ++ ) { if ( var_9 == 0 && var_10 == 0 ) { var_6 [ var_7 ] [ var_10 ] = true ; continue ; } var_6 [ var_7 ] [ var_10 ] = false ; if ( var_9 > 0 && var_1 . charAt ( var_9 - 1 ) == var_3 . charAt ( var_9 + var_10 - 1 ) ) { var_6 [ var_7 ] [ var_10 ] |= var_6 [ var_8 ] [ var_10 ] ; } if ( var_10 > 0 && var_2 . charAt ( var_10 - 1 ) == var_3 . charAt ( var_9 + var_10 - 1 ) ) { var_6 [ var_7 ] [ var_10 ] |= var_6 [ var_7 ] [ var_10 - 1 ] ; } } } return var_6 [ var_7 ] [ var_5 ] ; }
3
1<SEP>0<SEP>2
143
<awangdev>Find Peak Element II_1.java
private List<Integer> 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 ) ) ; }
1
1
144
<awangdev>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 ; }
5
2<SEP>0<SEP>3<SEP>5<SEP>1
145
<awangdev>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 ; }
6
<S_QUOTE>Z<S_QUOTE><SEP><S_QUOTE>9<S_QUOTE><SEP><S_QUOTE>z<S_QUOTE><SEP><S_QUOTE>0<S_QUOTE><SEP><S_QUOTE>a<S_QUOTE><SEP><S_QUOTE>A<S_QUOTE>
146
<awangdev>Summary Ranges_1.java
public List<String> summaryRanges(int[] nums) { List<String> rst = new ArrayList<>(); if (nums == null || nums.length == 0) { return rst; } List<Integer> 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<Integer>(); } } return rst; }
public List < String > var_0 ( int [ ] var_1 ) { List < String > var_2 = new ArrayList < > ( ) ; if ( var_1 == null || var_1 . length == 0 ) { return var_2 ; } List < Integer > var_3 = new ArrayList < > ( ) ; for ( int var_4 = 0 ; var_4 < var_1 . length ; var_4 ++ ) { var_3 . add ( var_1 [ var_4 ] ) ; if ( var_4 + 1 == var_1 . length || var_1 [ var_4 ] + 1 != var_1 [ var_4 + 1 ] ) { if ( var_3 . size ( ) == 1 ) { var_2 . add ( var_3 . get ( 0 ) + "" ) ; } else { var_2 . add ( var_3 . get ( 0 ) + "->" + var_3 . get ( var_3 . size ( ) - 1 ) ) ; } var_3 = new ArrayList < Integer > ( ) ; } } return var_2 ; }
4
0<SEP><D_QUOTE>-><D_QUOTE><SEP><D_QUOTE><D_QUOTE><SEP>1
147
<awangdev>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_3 = var_0 . length ; int [ ] [ ] var_4 = new int [ var_3 + 1 ] [ var_2 + 1 ] ; var_4 [ 0 ] [ 0 ] = 0 ; for ( int var_5 = 1 ; var_5 <= var_3 ; var_5 ++ ) { for ( int var_6 = 0 ; var_6 <= var_2 ; var_6 ++ ) { var_4 [ var_5 ] [ var_6 ] = var_4 [ var_5 - 1 ] [ var_6 ] ; if ( var_6 >= var_0 [ var_5 - 1 ] ) { var_4 [ var_5 ] [ var_6 ] = Math . max ( var_4 [ var_5 ] [ var_6 ] , var_4 [ var_5 ] [ var_6 - var_0 [ var_5 - 1 ] ] + var_1 [ var_5 - 1 ] ) ; } } } return var_4 [ var_3 ] [ var_2 ] ; }
2
0<SEP>1
148
<awangdev>Word Ladder_2.java
public int ladderLength(String start, String end, Set<String> dict) { if (start == null || end == null || dict == null || start.length() != end.length()) { return 0; } Queue<String> q = new LinkedList<String>(); HashSet<String> set = new HashSet<String>(); 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_0 , String var_1 , Set < String > var_2 ) { if ( var_0 == null || var_1 == null || var_2 == null || var_0 . length ( ) != var_1 . length ( ) ) { return 0 ; } Queue < String > var_3 = new LinkedList < String > ( ) ; HashSet < String > var_4 = new HashSet < String > ( ) ; int var_5 = 1 ; int var_6 = Integer . MAX_VALUE ; var_3 . offer ( var_0 ) ; var_4 . add ( var_0 ) ; while ( ! var_3 . isEmpty ( ) ) { int size = var_3 . size ( ) ; var_5 ++ ; for ( int var_7 = 0 ; var_7 < size ; var_7 ++ ) { String var_8 = var_3 . poll ( ) ; for ( int var_9 = 0 ; var_9 < var_8 . length ( ) ; var_9 ++ ) { for ( int var_10 = 0 ; var_10 < 26 ; var_10 ++ ) { String var_11 ; if ( var_9 == 0 && var_8 . length ( ) == 1 ) { var_11 = "" + ( char ) ( 'a' + var_10 ) ; } else if ( var_9 == var_8 . length ( ) - 1 ) { var_11 = var_8 . substring ( 0 , var_9 ) + ( char ) ( 'a' + var_10 ) ; } else { var_11 = var_8 . substring ( 0 , var_9 ) + ( char ) ( 'a' + var_10 ) + var_8 . substring ( var_9 + 1 ) ; } if ( ! var_4 . contains ( var_11 ) && var_2 . contains ( var_11 ) ) { if ( var_11 . equals ( var_1 ) ) { var_6 = Math . min ( var_6 , var_5 ) ; } else { var_4 . add ( var_11 ) ; var_3 . offer ( var_11 ) ; } } } } } } return var_6 ; }
5
0<SEP>1<SEP><S_QUOTE>a<S_QUOTE><SEP>26<SEP><D_QUOTE><D_QUOTE>
149
<awangdev>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_1 , String var_2 ) { if ( var_1 == null || var_2 == null ) { return false ; } int var_3 = var_1 . length ( ) ; int var_4 = var_2 . length ( ) ; boolean [ ] [ ] var_5 = new boolean [ 2 ] [ var_4 + 1 ] ; char [ ] var_6 = var_1 . toCharArray ( ) ; char [ ] var_7 = var_2 . toCharArray ( ) ; int var_8 = 0 ; int var_9 = 1 ; for ( int var_10 = 0 ; var_10 <= var_3 ; var_10 ++ ) { var_9 = var_8 ; var_8 = 1 - var_9 ; for ( int var_11 = 0 ; var_11 <= var_4 ; var_11 ++ ) { if ( var_10 == 0 && var_11 == 0 ) { var_5 [ var_8 ] [ var_11 ] = true ; continue ; } if ( var_11 == 0 ) { var_5 [ var_8 ] [ var_11 ] = false ; continue ; } var_5 [ var_8 ] [ var_11 ] = false ; if ( var_7 [ var_11 - 1 ] != '*' ) { if ( var_10 >= 1 && ( var_6 [ var_10 - 1 ] == var_7 [ var_11 - 1 ] || var_7 [ var_11 - 1 ] == '?' ) ) { var_5 [ var_8 ] [ var_11 ] = var_5 [ var_9 ] [ var_11 - 1 ] ; } } else { var_5 [ var_8 ] [ var_11 ] |= var_5 [ var_8 ] [ var_11 - 1 ] ; if ( var_10 >= 1 ) { var_5 [ var_8 ] [ var_11 ] |= var_5 [ var_9 ] [ var_11 ] ; } } } } return var_5 [ var_8 ] [ var_4 ] ; }
5
2<SEP>1<SEP>0<SEP><S_QUOTE>?<S_QUOTE><SEP><S_QUOTE>*<S_QUOTE>
150
<awangdev>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 ; }
2
0<SEP>1
151
<awangdev>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_2 = var_1 [ 0 ] . length ; int var_3 = var_1 . length ; int [ ] [ ] var_4 = new int [ var_2 ] [ var_3 ] ; for ( int var_5 = 0 ; var_5 < var_2 ; var_5 ++ ) { for ( int var_6 = 0 ; var_6 < var_3 ; var_6 ++ ) { if ( var_5 == 0 ) { var_4 [ var_5 ] [ var_6 ] = var_6 == 0 || var_0 [ 0 ] [ var_6 ] != 0 ? var_1 [ var_6 ] [ var_5 ] : Integer . MIN_VALUE ; continue ; } var_4 [ var_5 ] [ var_6 ] = Integer . MIN_VALUE ; for ( int var_7 = 0 ; var_7 < var_2 ; var_7 ++ ) { if ( ( var_7 == var_6 || var_0 [ var_7 ] [ var_6 ] == 1 ) && var_4 [ var_5 - 1 ] [ var_7 ] != Integer . MIN_VALUE ) { var_4 [ var_5 ] [ var_6 ] = Math . max ( var_4 [ var_5 - 1 ] [ var_7 ] + var_1 [ var_6 ] [ var_5 ] , var_4 [ var_5 ] [ var_6 ] ) ; } } } } int max = 0 ; for ( int var_5 = 0 ; var_5 < var_3 ; var_5 ++ ) { max = Math . max ( max , var_4 [ var_2 - 1 ] [ var_5 ] ) ; } return max ; }
2
0<SEP>1
152
<awangdev>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_2 = var_1 . length ; boolean [ ] [ ] var_3 = new boolean [ var_2 ] [ var_2 ] ; for ( int var_4 = 0 ; var_4 < var_2 ; var_4 ++ ) { int var_5 = var_4 , var_6 = var_4 ; while ( var_5 >= 0 && var_6 < var_2 && var_1 [ var_5 ] == var_1 [ var_6 ] ) { var_3 [ var_5 ] [ var_6 ] = true ; var_5 -- ; var_6 ++ ; } var_5 = var_4 ; var_6 = var_4 + 1 ; while ( var_5 >= 0 && var_6 < var_2 && var_1 [ var_5 ] == var_1 [ var_6 ] ) { var_3 [ var_5 ] [ var_6 ] = true ; var_5 -- ; var_6 ++ ; } } return var_3 ; }
2
0<SEP>1
153
<awangdev>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_1 = new int [ 121 ] ; for ( int var_2 : var_0 ) { var_1 [ var_2 ] ++ ; } int var_3 = 0 ; for ( int var_4 = 15 ; var_4 < 121 ; var_4 ++ ) { for ( int var_5 = ( int ) ( var_4 * 0.5 + 8 ) ; var_5 <= var_4 ; var_5 ++ ) { var_3 += var_4 == var_5 ? var_1 [ var_5 ] * ( var_1 [ var_4 ] - 1 ) : var_1 [ var_5 ] * var_1 [ var_4 ] ; } } return var_3 ; }
6
121<SEP>0<SEP>15<SEP>1<SEP>8<SEP>0.5
154
<awangdev>229. Majority Element II_1.java
public List<Integer> majorityElement(int[] nums) { List<Integer> 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_0 ( int [ ] var_1 ) { List < Integer > var_2 = new ArrayList < > ( ) ; if ( var_1 == null || var_1 . length == 0 ) { return var_2 ; } int var_3 = 0 , var_4 = 0 , var_5 = 0 , var_6 = 0 ; for ( int var_7 : var_1 ) { if ( var_7 == var_3 ) { var_5 ++ ; } else if ( var_7 == var_4 ) { var_6 ++ ; } else if ( var_5 == 0 ) { var_3 = var_7 ; var_5 ++ ; } else if ( var_6 == 0 ) { var_4 = var_7 ; var_6 ++ ; } else { var_5 -- ; var_6 -- ; } } var_5 = 0 ; var_6 = 0 ; for ( int var_7 : var_1 ) { if ( var_7 == var_3 ) { var_5 ++ ; } else if ( var_7 == var_4 ) { var_6 ++ ; } } if ( var_5 > var_1 . length / 3 ) var_2 . add ( var_3 ) ; if ( var_6 > var_1 . length / 3 ) var_2 . add ( var_4 ) ; return var_2 ; }
2
0<SEP>3
155
<awangdev>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_1 = var_0 . length ; Arrays . sort ( var_0 ) ; int var_2 = var_1 ; for ( int var_3 = var_1 - 1 ; var_3 >= 0 ; var_3 -- ) { if ( var_0 [ var_3 ] >= var_1 - var_3 ) { var_2 = var_3 ; continue ; } break ; } return var_1 - var_2 ; }
2
0<SEP>1
156
<awangdev>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_1 = 0 ; for ( int var_2 = 0 ; var_2 < var_0 . length ; var_2 ++ ) { var_1 += var_2 % 2 == 0 ? var_0 [ var_2 ] : 0 ; } return ( int ) var_1 ; }
3
1<SEP>0<SEP>2
157
<awangdev>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_1 ) { StringBuffer var_2 = new StringBuffer ( ) ; int var_3 = var_1 . charAt ( 0 ) - 'a' ; for ( char var_4 : var_1 . toCharArray ( ) ) { char var_5 = ( char ) ( var_4 - var_3 ) ; if ( var_5 < 'a' ) var_5 += 26 ; var_2 . append ( var_5 ) ; } return var_2 . toString ( ) ; }
3
0<SEP>26<SEP><S_QUOTE>a<S_QUOTE>
158
<awangdev>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_2 = 0 ; int var_3 = var_1 ; while ( var_2 + 1 < var_3 ) { int var_4 = var_2 + ( var_3 - var_2 ) / 2 ; long var_5 = ( long ) Math . pow ( 3 , var_4 ) ; if ( var_5 == var_1 ) { return true ; } if ( var_5 < var_1 ) { var_2 = var_4 ; } else { var_3 = var_4 ; } } return Math . pow ( 3 , var_2 ) == var_1 ; }
4
2<SEP>0<SEP>3<SEP>1
159
<awangdev>119. Pascal's Triangle II_1.java
public List<Integer> getRow(int rowIndex) { List<Integer> result = new ArrayList<>(); if (rowIndex == 0) result.add(1); if (rowIndex >= 1) result.add(1); for (int row = 1; row <= rowIndex; row++) { List<Integer> list = new ArrayList<>(Arrays.asList(1, 1)); List<Integer> 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_0 ( int var_1 ) { List < Integer > var_2 = new ArrayList < > ( ) ; if ( var_1 == 0 ) var_2 . add ( 1 ) ; if ( var_1 >= 1 ) var_2 . add ( 1 ) ; for ( int var_3 = 1 ; var_3 <= var_1 ; var_3 ++ ) { List < Integer > var_4 = new ArrayList < > ( Arrays . asList ( 1 , 1 ) ) ; List < Integer > var_5 = var_2 ; int var_6 = var_3 - 1 ; for ( int var_7 = 1 ; var_7 <= var_6 ; var_7 ++ ) { var_4 . add ( var_7 , var_5 . get ( var_7 ) + var_5 . get ( var_7 - 1 ) ) ; } var_2 = var_4 ; } return var_2 ; }
2
0<SEP>1
160
<awangdev>169. Majority Element_1.java
public int majorityElement(int[] nums) { if (nums == null || nums.length == 0) { return -1; } Map<Integer, Integer> 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<Integer, Integer> 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_1 = new HashMap < > ( ) ; for ( int var_2 : var_0 ) { if ( ! var_1 . containsKey ( var_2 ) ) { var_1 . put ( var_2 , 0 ) ; } var_1 . put ( var_2 , var_1 . get ( var_2 ) + 1 ) ; } int var_3 = var_0 . length / 2 ; for ( Map . Entry < Integer , Integer > var_4 : var_1 . entrySet ( ) ) { if ( var_4 . getValue ( ) > var_3 ) { return var_4 . getKey ( ) ; } } return - 1 ; }
3
2<SEP>0<SEP>1
161
<awangdev>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_2 = var_1 . length ; for ( int var_3 = 0 ; var_3 < var_2 / 2 ; var_3 ++ ) { for ( int var_4 = 0 ; var_4 < Math . ceil ( var_2 / 2.0 ) ; var_4 ++ ) { int var_5 = var_1 [ var_3 ] [ var_4 ] ; var_1 [ var_3 ] [ var_4 ] = var_1 [ var_2 - 1 - var_4 ] [ var_3 ] ; var_1 [ var_2 - 1 - var_4 ] [ var_3 ] = var_1 [ var_2 - 1 - var_3 ] [ var_2 - 1 - var_4 ] ; var_1 [ var_2 - 1 - var_3 ] [ var_2 - 1 - var_4 ] = var_1 [ var_4 ] [ var_2 - 1 - var_3 ] ; var_1 [ var_4 ] [ var_2 - 1 - var_3 ] = var_5 ; } } }
4
2.0<SEP>0<SEP>1<SEP>2
162
<awangdev>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 ; }
2
0<SEP>1
163
<awangdev>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_2 = var_0 . length ; int [ ] var_3 = new int [ var_1 + 1 ] ; var_3 [ 0 ] = 1 ; for ( int var_4 = 1 ; var_4 <= var_1 ; var_4 ++ ) { for ( int var_5 = 0 ; var_5 < var_2 ; var_5 ++ ) { if ( var_4 - var_0 [ var_5 ] >= 0 ) { var_3 [ var_4 ] += var_3 [ var_4 - var_0 [ var_5 ] ] ; } } } return var_3 [ var_1 ] ; }
2
0<SEP>1
165
<awangdev>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 ; }
0
null
166
<awangdev>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_0 , String var_1 , String var_2 ) { Integer var_3 = null , var_4 = null ; int min = Integer . MAX_VALUE ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { if ( var_0 [ var_5 ] . equals ( var_1 ) ) var_3 = var_5 ; if ( var_0 [ var_5 ] . equals ( var_2 ) ) var_4 = var_5 ; if ( var_3 != null && var_4 != null ) min = Math . min ( min , Math . abs ( var_3 - var_4 ) ) ; } return min ; }
1
0
167
<awangdev>15. 3Sum_1.java
public List<List<Integer>> threeSum(int[] nums) { List<List<Integer>> 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_0 ( int [ ] var_1 ) { List < List < Integer >> var_2 = new ArrayList < > ( ) ; Arrays . sort ( var_1 ) ; int var_3 = var_1 . length ; for ( int var_4 = 0 ; var_4 < var_3 - 2 ; var_4 ++ ) { if ( var_4 > 0 && var_1 [ var_4 ] == var_1 [ var_4 - 1 ] ) continue ; int var_5 = var_4 + 1 , var_6 = var_3 - 1 ; while ( var_5 < var_6 ) { int var_7 = var_1 [ var_4 ] + var_1 [ var_5 ] + var_1 [ var_6 ] ; if ( var_7 == 0 ) { var_2 . add ( Arrays . asList ( var_1 [ var_4 ] , var_1 [ var_5 ] , var_1 [ var_6 ] ) ) ; while ( var_5 < var_6 && var_1 [ var_5 ] == var_1 [ var_5 + 1 ] ) var_5 ++ ; while ( var_5 < var_6 && var_1 [ var_6 ] == var_1 [ var_6 - 1 ] ) var_6 -- ; var_5 ++ ; var_6 -- ; } else if ( var_7 < 0 ) { var_5 ++ ; } else { var_6 -- ; } } } return var_2 ; }
3
0<SEP>1<SEP>2
168
<awangdev>43. Multiply Strings_2.java
private int toInt(String s, int x) { return s.charAt(x) - '0'; }
private int sample_funcname ( String var_0 , int var_1 ) { return var_0 . charAt ( var_1 ) - '0' ; }
1
<S_QUOTE>0<S_QUOTE>
169
<awangdev>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 ; }
1
1
170
<awangdev>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_2 = var_1 . length ; for ( int var_3 = 0 ; var_3 < var_2 / 2 ; var_3 ++ ) { char var_4 = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_1 [ var_2 - var_3 - 1 ] ; var_1 [ var_2 - var_3 - 1 ] = var_4 ; } }
3
1<SEP>0<SEP>2
171
<awangdev>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_1 = null ; if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) { return var_1 ; } int var_2 = var_0 . length ; int var_3 = var_0 [ 0 ] . length ; var_1 = new int [ var_2 * var_3 ] ; if ( var_0 . length == 1 ) { return var_0 [ 0 ] ; } int var_4 = 0 , var_5 = 0 ; int var_6 = 0 ; var_1 [ var_6 ] = var_0 [ var_4 ] [ var_5 ] ; var_6 ++ ; while ( var_6 < var_1 . length ) { if ( var_5 + 1 < var_3 || var_4 + 1 < var_2 ) { if ( var_5 + 1 < var_3 ) var_5 ++ ; else if ( var_4 + 1 < var_2 ) var_4 ++ ; var_1 [ var_6 ++ ] = var_0 [ var_4 ] [ var_5 ] ; } while ( var_5 - 1 >= 0 && var_4 + 1 < var_2 ) { var_1 [ var_6 ++ ] = var_0 [ ++ var_4 ] [ -- var_5 ] ; } if ( var_5 + 1 < var_3 || var_4 + 1 < var_2 ) { if ( var_4 + 1 < var_2 ) var_4 ++ ; else if ( var_5 + 1 < var_3 ) var_5 ++ ; var_1 [ var_6 ++ ] = var_0 [ var_4 ] [ var_5 ] ; } while ( var_5 + 1 < var_3 && var_4 - 1 >= 0 ) { var_1 [ var_6 ++ ] = var_0 [ -- var_4 ] [ ++ var_5 ] ; } } return var_1 ; }
2
0<SEP>1
172
<awangdev>1213. Intersection of Three Sorted Arrays_3.java
public List<Integer> arraysIntersection(int[] arr1, int[] arr2, int[] arr3) { List<Integer> 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_0 ( int [ ] var_1 , int [ ] var_2 , int [ ] var_3 ) { List < Integer > var_4 = new LinkedList < > ( ) ; int var_5 = 0 , var_6 = 0 , var_7 = 0 ; while ( var_5 < var_1 . length && var_6 < var_2 . length && var_7 < var_3 . length ) { if ( var_1 [ var_5 ] == var_2 [ var_6 ] && var_2 [ var_6 ] == var_3 [ var_7 ] ) { if ( var_4 . isEmpty ( ) || var_1 [ var_5 ] != var_4 . get ( var_4 . size ( ) - 1 ) ) var_4 . add ( var_1 [ var_5 ] ) ; var_5 ++ ; var_6 ++ ; var_7 ++ ; } else if ( var_1 [ var_5 ] < var_2 [ var_6 ] ) var_5 ++ ; else if ( var_2 [ var_6 ] < var_3 [ var_7 ] ) var_6 ++ ; else var_7 ++ ; } return var_4 ; }
2
0<SEP>1
173
<awangdev>219. Contains Duplicate II_1.java
public boolean containsNearbyDuplicate(int[] nums, int k) { if (nums == null || nums.length == 0 || k <= 0) { return false; } Set<Integer> 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_3 = new HashSet < > ( ) ; for ( int var_4 = 0 ; var_4 < var_1 . length ; var_4 ++ ) { if ( var_4 > var_2 ) { var_3 . remove ( var_1 [ var_4 - var_2 - 1 ] ) ; } if ( ! var_3 . add ( var_1 [ var_4 ] ) ) { return true ; } } return false ; }
2
0<SEP>1
174
<awangdev>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_1 , String var_2 ) { StringBuilder var_3 = new StringBuilder ( ) ; int var_4 = var_1 . length ( ) - 1 , var_5 = var_2 . length ( ) - 1 , var_6 = 0 ; while ( var_4 >= 0 || var_5 >= 0 ) { int var_7 = var_6 ; if ( var_4 >= 0 ) var_7 += var_1 . charAt ( var_4 -- ) - '0' ; if ( var_5 >= 0 ) var_7 += var_2 . charAt ( var_5 -- ) - '0' ; var_3 . insert ( 0 , var_7 % 2 ) ; var_6 = var_7 / 2 ; } if ( var_6 != 0 ) var_3 . insert ( 0 , var_6 ) ; return var_3 . toString ( ) ; }
4
1<SEP>0<SEP><S_QUOTE>0<S_QUOTE><SEP>2
175
<awangdev>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_1 = new int [ var_0 + 1 ] ; var_1 [ 0 ] = 1 ; var_1 [ 1 ] = 1 ; for ( int var_2 = 2 ; var_2 <= var_0 ; var_2 ++ ) { var_1 [ var_2 ] = var_1 [ var_2 - 1 ] + var_1 [ var_2 - 2 ] ; } return var_1 [ var_0 ] ; }
3
1<SEP>0<SEP>2
176
<awangdev>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 ; }
1
1
177
<awangdev>[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_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) < var_2 . length ( ) ) { return false ; } int [ ] var_3 = new int [ 26 ] ; for ( char var_4 : var_1 . toCharArray ( ) ) { var_3 [ var_4 - 'A' ] ++ ; } for ( char var_4 : var_2 . toCharArray ( ) ) { var_3 [ var_4 - 'A' ] -- ; if ( var_3 [ var_4 - 'A' ] < 0 ) { return false ; } } return true ; }
3
0<SEP>26<SEP><S_QUOTE>A<S_QUOTE>
178
<awangdev>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_1 = 0 ; for ( int var_2 = 0 ; var_2 < var_0 . length ; var_2 ++ ) { if ( var_0 [ var_2 ] > var_0 [ var_1 ] ) var_1 = var_2 ; } int var_3 = 0 , var_4 = 0 ; for ( int var_2 = 0 ; var_2 < var_1 ; var_2 ++ ) { if ( var_0 [ var_2 ] > var_4 ) { var_3 += ( var_1 - var_2 ) * ( var_0 [ var_2 ] - var_4 ) ; var_4 = var_0 [ var_2 ] ; } var_3 -= var_0 [ var_2 ] ; } var_4 = 0 ; for ( int var_2 = var_0 . length - 1 ; var_2 > var_1 ; var_2 -- ) { if ( var_0 [ var_2 ] > var_4 ) { var_3 += ( var_2 - var_1 ) * ( var_0 [ var_2 ] - var_4 ) ; var_4 = var_0 [ var_2 ] ; } var_3 -= var_0 [ var_2 ] ; } return var_3 ; }
2
0<SEP>1
179
<awangdev>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_1 = 0 ; while ( var_0 != 0 ) { long var_2 = var_0 % 10 ; var_1 += var_2 * var_2 ; var_0 /= 10 ; } return var_1 ; }
2
10<SEP>0
180
<awangdev>Subsets II_1.java
private void dfs(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); } }
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 ) ; } }
1
1
181
<awangdev>String Permutation_1.java
public boolean Permutation(String A, String B) { if (A == null || B == null || A.length() != B.length()) { return false; } final Map<Character, Integer> 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<Character, Integer> entry : strMap.entrySet()) { if (entry.getValue() != 0) { return false; } } return true; }
public boolean var_0 ( String var_1 , String var_2 ) { if ( var_1 == null || var_2 == null || var_1 . length ( ) != var_2 . length ( ) ) { return false ; } final Map < Character , Integer > var_3 = new HashMap < > ( ) ; for ( int var_4 = 0 ; var_4 < var_1 . length ( ) ; var_4 ++ ) { final char var_5 = var_1 . charAt ( var_4 ) ; final char var_6 = var_2 . charAt ( var_4 ) ; if ( ! var_3 . containsKey ( var_5 ) ) { var_3 . put ( var_5 , 0 ) ; } var_3 . put ( var_5 , var_3 . get ( var_5 ) + 1 ) ; if ( ! var_3 . containsKey ( var_6 ) ) { var_3 . put ( var_6 , 0 ) ; } var_3 . put ( var_6 , var_3 . get ( var_6 ) - 1 ) ; } for ( Map . Entry < Character , Integer > var_7 : var_3 . entrySet ( ) ) { if ( var_7 . getValue ( ) != 0 ) { return false ; } } return true ; }
2
0<SEP>1
182
<awangdev>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_2 = 0 ; for ( int var_3 : var_1 ) var_2 += var_3 ; if ( var_2 % 2 != 0 ) return false ; var_2 /= 2 ; boolean [ ] var_4 = new boolean [ var_2 + 1 ] ; var_4 [ 0 ] = true ; for ( int var_5 = 0 ; var_5 < var_1 . length ; var_5 ++ ) { int var_3 = var_1 [ var_5 ] ; for ( int var_6 = var_2 ; var_6 >= var_3 ; var_6 -- ) { var_4 [ var_6 ] = var_4 [ var_6 ] || var_4 [ var_6 - var_3 ] ; } } return var_4 [ var_2 ] ; }
3
0<SEP>1<SEP>2
183
<awangdev>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_1 = 0 ; int var_2 = 1 ; while ( var_2 < var_0 . length ) { while ( var_2 < var_0 . length && var_0 [ var_1 ] == var_0 [ var_2 ] ) { var_2 ++ ; } if ( var_2 < var_0 . length && var_0 [ var_1 ] != var_0 [ var_2 ] ) { var_0 [ var_1 + 1 ] = var_0 [ var_2 ] ; var_1 ++ ; var_2 ++ ; } } return var_1 + 1 ; }
2
0<SEP>1
184
<awangdev>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<Character, Integer> 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_0 , int var_1 ) { if ( var_0 == null || var_0 . length ( ) == 0 ) return 0 ; int var_2 = var_0 . length ( ) ; Map < Character , Integer > var_3 = new HashMap < > ( ) ; int var_4 = 0 , var_5 = 0 , max = 0 ; while ( var_5 < var_2 ) { if ( var_3 . size ( ) <= var_1 ) { var_3 . put ( var_0 . charAt ( var_5 ) , var_5 ++ ) ; } if ( var_3 . size ( ) > var_1 ) { int var_6 = var_5 ; for ( int var_7 : var_3 . values ( ) ) { var_6 = Math . min ( var_6 , var_7 ) ; } var_3 . remove ( var_0 . charAt ( var_6 ) ) ; var_4 = var_6 + 1 ; } max = Math . max ( max , var_5 - var_4 ) ; } return max ; }
2
0<SEP>1
185
<awangdev>Longest Substring Without Repeating Characters_4.java
public int lengthOfLongestSubstring(String s) { if (s == null || s.length() == 0) { return 0; } HashMap<Character, Integer> map = new HashMap<Character, Integer>(); 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<Character, Integer>(); count = 0; } max = Math.max(max, count); } return max; }
public int sample_funcname ( String var_0 ) { if ( var_0 == null || var_0 . length ( ) == 0 ) { return 0 ; } HashMap < Character , Integer > var_1 = new HashMap < Character , Integer > ( ) ; int var_2 = 0 ; int max = 0 ; for ( int var_3 = 0 ; var_3 < var_0 . length ( ) ; var_3 ++ ) { if ( ! var_1 . containsKey ( var_0 . charAt ( var_3 ) ) ) { var_1 . put ( var_0 . charAt ( var_3 ) , var_3 ) ; var_2 ++ ; } else { var_3 = var_1 . get ( var_0 . charAt ( var_3 ) ) ; var_1 = new HashMap < Character , Integer > ( ) ; var_2 = 0 ; } max = Math . max ( max , var_2 ) ; } return max ; }
1
0
186
<awangdev>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 ; }
1
<D_QUOTE>-><D_QUOTE>
187
<awangdev>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 ; }
1
<D_QUOTE>@<D_QUOTE>
188
<awangdev>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_2 = 0 ; int var_3 = var_0 . length - 1 ; int var_4 ; while ( var_2 + 1 < var_3 ) { var_4 = var_2 + ( var_3 - var_2 ) / 2 ; if ( var_0 [ var_4 ] == var_1 ) { return var_4 ; } else if ( var_4 - 1 >= 0 && var_0 [ var_4 - 1 ] <= var_1 && var_1 < var_0 [ var_4 ] ) { return ( var_1 - var_0 [ var_4 - 1 ] ) < ( var_0 [ var_4 ] - var_1 ) ? ( var_4 - 1 ) : 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_1 - var_0 [ var_4 ] ) < ( var_0 [ var_4 + 1 ] - var_1 ) ? var_4 : var_4 + 1 ; } else if ( var_0 [ var_4 ] < var_1 ) { var_2 = var_4 ; } else { var_3 = var_4 ; } } return ( var_1 - var_0 [ var_2 ] ) < ( var_0 [ var_3 ] - var_1 ) ? var_2 : var_3 ; }
3
2<SEP>0<SEP>1
189
<awangdev>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 ; }
1
0
190
<awangdev>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 ; }
0
null
191
<awangdev>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_1 = 0 ; long var_2 = var_0 ; while ( var_1 + 1 < var_2 ) { long var_3 = ( var_1 + var_2 ) >> 1 ; if ( var_3 * var_3 < var_0 ) { var_1 = var_3 ; } else if ( var_3 * var_3 > var_0 ) { var_2 = var_3 ; } else { return ( int ) var_3 ; } } if ( var_2 * var_2 <= var_0 ) { return ( int ) var_2 ; } else { return ( int ) var_1 ; } }
2
0<SEP>1
192
<awangdev>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 ; }
0
null
193
<awangdev>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_0 , String var_1 ) { if ( var_0 == null && var_1 != null ) { return var_1 . length ( ) ; } else if ( var_0 != null && var_1 == null ) { return var_0 . length ( ) ; } else if ( var_0 == null && var_1 == null ) { return 0 ; } int [ ] [ ] var_2 = new int [ var_0 . length ( ) + 1 ] [ var_1 . length ( ) + 1 ] ; for ( int var_3 = 1 ; var_3 <= var_0 . length ( ) ; var_3 ++ ) { var_2 [ var_3 ] [ 0 ] = var_3 ; } for ( int var_4 = 1 ; var_4 <= var_1 . length ( ) ; var_4 ++ ) { var_2 [ 0 ] [ var_4 ] = var_4 ; } for ( int var_3 = 1 ; var_3 <= var_0 . length ( ) ; var_3 ++ ) { for ( int var_4 = 1 ; var_4 <= var_1 . length ( ) ; var_4 ++ ) { var_2 [ var_3 ] [ var_4 ] = Math . min ( Math . min ( var_2 [ var_3 - 1 ] [ var_4 ] + 1 , var_2 [ var_3 ] [ var_4 - 1 ] + 1 ) , var_0 . charAt ( var_3 - 1 ) == var_1 . charAt ( var_4 - 1 ) ? var_2 [ var_3 - 1 ] [ var_4 - 1 ] : var_2 [ var_3 - 1 ] [ var_4 - 1 ] + 1 ) ; } } return var_2 [ var_0 . length ( ) ] [ var_1 . length ( ) ] ; }
2
0<SEP>1
194
<awangdev>78. Subsets_2.java
private void dfs(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); } }
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 ) ; } }
1
1
195
<awangdev>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_1 = var_0 . length ; long [ ] [ ] var_2 = new long [ 2 ] [ 2 ] ; var_2 [ 0 ] [ 0 ] = 0 ; var_2 [ 1 ] [ 0 ] = 0 ; var_2 [ 1 ] [ 1 ] = var_0 [ 0 ] ; for ( int var_3 = 2 ; var_3 < var_1 ; var_3 ++ ) { var_2 [ var_3 % 2 ] [ 0 ] = Math . max ( var_2 [ ( var_3 - 1 ) % 2 ] [ 0 ] , var_2 [ ( var_3 - 2 ) % 2 ] [ 0 ] + var_0 [ var_3 - 1 ] ) ; var_2 [ var_3 % 2 ] [ 1 ] = Math . max ( var_2 [ ( var_3 - 1 ) % 2 ] [ 1 ] , var_2 [ ( var_3 - 2 ) % 2 ] [ 1 ] + var_0 [ var_3 - 1 ] ) ; } var_2 [ var_1 % 2 ] [ 0 ] = Math . max ( var_2 [ ( var_1 - 1 ) % 2 ] [ 0 ] , var_2 [ ( var_1 - 2 ) % 2 ] [ 0 ] + var_0 [ var_1 - 1 ] ) ; var_2 [ var_1 % 2 ] [ 1 ] = var_2 [ ( var_1 - 1 ) % 2 ] [ 1 ] ; return ( int ) Math . max ( var_2 [ var_1 % 2 ] [ 0 ] , var_2 [ var_1 % 2 ] [ 1 ] ) ; }
3
2<SEP>0<SEP>1
196
<awangdev>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_0 , int var_1 , int var_2 ) { if ( var_0 == null || var_0 . length == 0 || ( var_1 == 0 && var_2 == 0 ) ) { return 0 ; } int var_3 = var_0 . length ; int [ ] [ ] [ ] var_4 = new int [ var_1 + 1 ] [ var_2 + 1 ] [ var_3 + 1 ] ; for ( int var_5 = 0 ; var_5 <= var_1 ; var_5 ++ ) { for ( int var_6 = 0 ; var_6 <= var_2 ; var_6 ++ ) { for ( int var_7 = 0 ; var_7 <= var_3 ; var_7 ++ ) { if ( var_7 == 0 || ( var_5 == 0 && var_6 == 0 ) ) { var_4 [ var_5 ] [ var_6 ] [ var_7 ] = 0 ; continue ; } char [ ] var_8 = var_0 [ var_7 - 1 ] . toCharArray ( ) ; int var_9 = 0 ; int var_10 = 0 ; for ( char var_11 : var_8 ) { var_9 += var_11 == '1' ? 1 : 0 ; var_10 += var_11 == '0' ? 1 : 0 ; } var_4 [ var_5 ] [ var_6 ] [ var_7 ] = var_4 [ var_5 ] [ var_6 ] [ var_7 - 1 ] ; if ( var_5 >= var_10 && var_6 >= var_9 ) { var_4 [ var_5 ] [ var_6 ] [ var_7 ] = Math . max ( var_4 [ var_5 ] [ var_6 ] [ var_7 ] , var_4 [ var_5 - var_10 ] [ var_6 - var_9 ] [ var_7 - 1 ] + 1 ) ; } } } } return var_4 [ var_1 ] [ var_2 ] [ var_3 ] ; }
4
0<SEP><S_QUOTE>1<S_QUOTE><SEP><S_QUOTE>0<S_QUOTE><SEP>1
197
<awangdev>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_1 = - 1 ; int var_2 = 0 ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { if ( var_0 [ var_3 ] >= max ) { var_1 = max ; max = var_0 [ var_3 ] ; var_2 = var_3 ; } else { var_1 = Math . max ( var_1 , var_0 [ var_3 ] ) ; } } return max >= var_1 * 2 ? var_2 : - 1 ; }
3
1<SEP>0<SEP>2
198
<awangdev>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_1 = var_0 . length , var_2 = 0 ; int var_3 = var_0 [ 0 ] == 1 ? 0 : - 1 ; for ( int var_4 = 1 ; var_4 < var_1 ; var_4 ++ ) { if ( var_0 [ var_4 ] == 1 ) { if ( var_3 == - 1 ) var_2 = var_4 ; else var_2 = Math . max ( var_2 , ( var_4 - var_3 ) / 2 ) ; var_3 = var_4 ; } } if ( var_0 [ var_1 - 1 ] == 0 ) var_2 = Math . max ( var_2 , var_1 - 1 - var_3 ) ; return var_2 ; }
3
2<SEP>0<SEP>1
199
<awangdev>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_1 = 0 ; while ( var_0 != 0 ) { var_1 = var_1 * 10 + var_0 % 10 ; var_0 /= 10 ; if ( var_1 > Integer . MAX_VALUE || var_1 < Integer . MIN_VALUE ) return 0 ; } return ( int ) var_1 ; }
2
10<SEP>0
200
<awangdev>Maximum Subarray II_4.java
public int maxTwoSubArrays(ArrayList<Integer> 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_0 ) { if ( var_0 == null || var_0 . size ( ) == 0 ) { return 0 ; } int var_1 = 0 ; int var_2 = 0 ; int max = Integer . MIN_VALUE ; int var_3 = var_0 . size ( ) ; int [ ] var_4 = new int [ var_3 ] ; int [ ] var_5 = new int [ var_3 ] ; for ( int var_6 = 0 ; var_6 < var_3 ; var_6 ++ ) { var_1 += var_0 . get ( var_6 ) ; max = Math . max ( max , var_1 - var_2 ) ; var_2 = Math . min ( var_2 , var_1 ) ; var_4 [ var_6 ] = max ; } var_1 = 0 ; var_2 = 0 ; max = Integer . MIN_VALUE ; for ( int var_6 = var_3 - 1 ; var_6 >= 0 ; var_6 -- ) { var_1 += var_0 . get ( var_6 ) ; max = Math . max ( max , var_1 - var_2 ) ; var_2 = Math . min ( var_2 , var_1 ) ; var_5 [ var_6 ] = max ; } max = Integer . MIN_VALUE ; for ( int var_6 = 0 ; var_6 < var_3 - 1 ; var_6 ++ ) { int var_7 = var_4 [ var_6 ] + var_5 [ var_6 + 1 ] ; max = Math . max ( max , var_7 ) ; } return max ; }
2
0<SEP>1
201
<awangdev>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_1 = var_0 . length , var_2 = var_0 [ 0 ] . length ; int [ ] [ ] var_3 = new int [ 2 ] [ var_2 ] ; for ( int var_4 = 1 ; var_4 <= var_1 ; var_4 ++ ) { int var_5 = var_4 % 2 , var_6 = ( var_4 - 1 ) % 2 ; for ( int var_7 = 0 ; var_7 < var_2 ; var_7 ++ ) { var_3 [ var_5 ] [ var_7 ] = Integer . MAX_VALUE ; for ( int var_8 = 0 ; var_8 < var_2 ; var_8 ++ ) { if ( var_7 == var_8 ) continue ; var_3 [ var_5 ] [ var_7 ] = Math . min ( var_3 [ var_5 ] [ var_7 ] , var_3 [ var_6 ] [ var_8 ] + var_0 [ var_4 - 1 ] [ var_7 ] ) ; } } } int min = Integer . MAX_VALUE ; for ( int var_7 = 0 ; var_7 < var_2 ; var_7 ++ ) min = Math . min ( min , var_3 [ var_1 % 2 ] [ var_7 ] ) ; return min ; }
3
0<SEP>1<SEP>2
202
<awangdev>1203. Sort Items by Groups Respecting Dependencies_2.java
private List<Integer> topoSort(Map<Integer, List<Integer>> graph, Set<Integer> set) { Map<Integer, Integer> 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<Integer> queue = new LinkedList<>(); for (int key : indegree.keySet()) { if (indegree.get(key) == 0) queue.offer(key); } List<Integer> 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_0 ( Map < Integer , List < Integer >> var_1 , Set < Integer > var_2 ) { Map < Integer , Integer > var_3 = new HashMap < > ( ) ; for ( int var_4 : var_2 ) { var_3 . put ( var_4 , 0 ) ; } for ( int var_5 : var_1 . keySet ( ) ) { if ( ! var_2 . contains ( var_5 ) ) continue ; for ( int var_6 : var_1 . get ( var_5 ) ) { var_3 . put ( var_6 , var_3 . get ( var_6 ) + 1 ) ; } } Queue < Integer > var_7 = new LinkedList < > ( ) ; for ( int var_8 : var_3 . keySet ( ) ) { if ( var_3 . get ( var_8 ) == 0 ) var_7 . offer ( var_8 ) ; } List < Integer > var_9 = new ArrayList < > ( ) ; while ( ! var_7 . isEmpty ( ) ) { int var_5 = var_7 . poll ( ) ; var_9 . add ( var_5 ) ; if ( ! var_1 . containsKey ( var_5 ) ) continue ; for ( int var_6 : var_1 . get ( var_5 ) ) { var_3 . put ( var_6 , var_3 . get ( var_6 ) - 1 ) ; if ( var_3 . get ( var_6 ) == 0 ) var_7 . offer ( var_6 ) ; } } return var_9 ; }
2
0<SEP>1
203
<awangdev>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_3 = var_1 . length ; int var_4 = var_1 [ 0 ] . length ; int var_5 = 0 ; int var_6 = var_3 * var_4 - 1 ; int var_7 ; while ( var_5 + 1 < var_6 ) { var_7 = var_5 + ( var_6 - var_5 ) / 2 ; int var_8 = var_1 [ var_7 / var_4 ] [ var_7 % var_4 ] ; if ( var_2 == var_8 ) { return true ; } else if ( var_8 < var_2 ) { var_5 = var_7 ; } else { var_6 = var_7 ; } } return ( var_1 [ var_5 / var_4 ] [ var_5 % var_4 ] == var_2 || var_1 [ var_6 / var_4 ] [ var_6 % var_4 ] == var_2 ) ; }
3
2<SEP>0<SEP>1
204
<awangdev>1106. Parsing A Boolean Expression_2.java
private boolean evalList(List<Boolean> 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_1 , char var_2 ) { if ( var_2 == '&' ) { for ( boolean var_3 : var_1 ) { if ( ! var_3 ) return false ; } return true ; } for ( boolean var_3 : var_1 ) { if ( var_3 ) return true ; } return false ; }
1
<S_QUOTE>&<S_QUOTE>
206
<awangdev>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_1 = new int [ var_0 . length + 1 ] ; for ( int var_2 = 1 ; var_2 <= var_0 . length ; var_2 ++ ) { var_1 [ var_2 ] += var_1 [ var_2 - 1 ] + var_0 [ var_2 - 1 ] ; } return var_1 ; }
1
1