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
0
<qiyuangong>011_Container_With_Most_Water_1.java
public int maxArea(int[] height) { int maxArea = 0; int left = 0; int right = height.length - 1; while (left < right) { maxArea = Math.max(maxArea, (right - left) * Math.min(height[left], height[right])); if (height[left] < height[right]) left++; else right--; } return maxArea; }
public int sample_funcname ( int [ ] var_0 ) { int var_1 = 0 ; int var_2 = 0 ; int var_3 = var_0 . length - 1 ; while ( var_2 < var_3 ) { var_1 = Math . max ( var_1 , ( var_3 - var_2 ) * Math . min ( var_0 [ var_2 ] , var_0 [ var_3 ] ) ) ; if ( var_0 [ var_2 ] < var_0 [ var_3 ] ) var_2 ++ ; else var_3 -- ; } return var_1 ; }
2
0<SEP>1
1
<qiyuangong>415_Add_Strings_1.java
public String addStrings(String num1, String num2) { StringBuilder sb = new StringBuilder(); int carry = 0; for(int i = num1.length() - 1, j = num2.length() - 1; i >= 0 || j >= 0 || carry == 1; i--, j--){ int x = i < 0 ? 0 : num1.charAt(i) - '0'; int y = j < 0 ? 0 : num2.charAt(j) - '0'; sb.append((x + y + carry) % 10); carry = (x + y + carry) / 10; } return sb.reverse().toString(); }
public String var_0 ( String var_1 , String var_2 ) { StringBuilder var_3 = new StringBuilder ( ) ; int var_4 = 0 ; for ( int var_5 = var_1 . length ( ) - 1 , var_6 = var_2 . length ( ) - 1 ; var_5 >= 0 || var_6 >= 0 || var_4 == 1 ; var_5 -- , var_6 -- ) { int var_7 = var_5 < 0 ? 0 : var_1 . charAt ( var_5 ) - '0' ; int var_8 = var_6 < 0 ? 0 : var_2 . charAt ( var_6 ) - '0' ; var_3 . append ( ( var_7 + var_8 + var_4 ) % 10 ) ; var_4 = ( var_7 + var_8 + var_4 ) / 10 ; } return var_3 . reverse ( ) . toString ( ) ; }
4
10<SEP>0<SEP><S_QUOTE>0<S_QUOTE><SEP>1
2
<qiyuangong>005_Longest_Palindromic_Substring_3.java
private static char[] removeBoundaries(char[] cs) { if (cs==null || cs.length<3) return "".toCharArray(); char[] cs2 = new char[(cs.length-1)/2]; for (int i = 0; i<cs2.length; i++) { cs2[i] = cs[i*2+1]; } return cs2; }
private static char [ ] sample_funcname ( char [ ] var_0 ) { if ( var_0 == null || var_0 . length < 3 ) return "" . toCharArray ( ) ; char [ ] var_1 = new char [ ( var_0 . length - 1 ) / 2 ] ; for ( int var_2 = 0 ; var_2 < var_1 . length ; var_2 ++ ) { var_1 [ var_2 ] = var_0 [ var_2 * 2 + 1 ] ; } return var_1 ; }
5
2<SEP>0<SEP>1<SEP>3<SEP><D_QUOTE><D_QUOTE>
4
<qiyuangong>654_Maximum_Binary_Tree_1.java
public int max(int[] nums, int l, int r) { int max_i = l; for (int i = l; i < r; i++) { if (nums[max_i] < nums[i]) max_i = i; } return max_i; }
public int sample_funcname ( int [ ] var_0 , int var_1 , int var_2 ) { int var_3 = var_1 ; for ( int var_4 = var_1 ; var_4 < var_2 ; var_4 ++ ) { if ( var_0 [ var_3 ] < var_0 [ var_4 ] ) var_3 = var_4 ; } return var_3 ; }
0
null
5
<qiyuangong>1323_Maximum_69_Number_1.java
public int maximum69Number (int num) { return Integer.valueOf(String.valueOf(num).replaceFirst("6", "9")); }
public int sample_funcname ( int var_0 ) { return Integer . valueOf ( String . valueOf ( var_0 ) . replaceFirst ( "6" , "9" ) ) ; }
2
<D_QUOTE>9<D_QUOTE><SEP><D_QUOTE>6<D_QUOTE>
6
<qiyuangong>692_Top_K_Frequent_Words_2.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); } PriorityQueue<String> heap = new PriorityQueue<String>( (w1, w2) -> count.get(w1).equals(count.get(w2)) ? w2.compareTo(w1) : count.get(w1) - count.get(w2) ); for (String word: count.keySet()) { heap.offer(word); if (heap.size() > k) heap.poll(); } List<String> ans = new ArrayList(); while (!heap.isEmpty()) ans.add(heap.poll()); Collections.reverse(ans); return ans; }
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 ) ; } PriorityQueue < String > var_7 = new PriorityQueue < String > ( ( var_5 , var_6 ) -> var_3 . get ( var_5 ) . equals ( var_3 . get ( var_6 ) ) ? var_6 . compareTo ( var_5 ) : var_3 . get ( var_5 ) - var_3 . get ( var_6 ) ) ; for ( String var_4 : var_3 . keySet ( ) ) { var_7 . offer ( var_4 ) ; if ( var_7 . size ( ) > var_2 ) var_7 . poll ( ) ; } List < String > var_8 = new ArrayList ( ) ; while ( ! var_7 . isEmpty ( ) ) var_8 . add ( var_7 . poll ( ) ) ; Collections . reverse ( var_8 ) ; return var_8 ; }
2
0<SEP>1
7
<qiyuangong>204_Count_Primes_1.java
public int countPrimes(int n) { boolean[] isPrime = new boolean[n]; int count = 0; Arrays.fill(isPrime, true); for (int i = 2; i < n; i++) { if (i * i >= n) break; if (!isPrime[i]) continue; for (int j = i * i; j < n; j += i) isPrime[j] = false; } for (int i = 2; i < n; i++) if (isPrime[i]) count++; return count; }
public int sample_funcname ( int var_0 ) { boolean [ ] var_1 = new boolean [ var_0 ] ; int var_2 = 0 ; Arrays . fill ( var_1 , true ) ; for ( int var_3 = 2 ; var_3 < var_0 ; var_3 ++ ) { if ( var_3 * var_3 >= var_0 ) break ; if ( ! var_1 [ var_3 ] ) continue ; for ( int var_4 = var_3 * var_3 ; var_4 < var_0 ; var_4 += var_3 ) var_1 [ var_4 ] = false ; } for ( int var_3 = 2 ; var_3 < var_0 ; var_3 ++ ) if ( var_1 [ var_3 ] ) var_2 ++ ; return var_2 ; }
2
0<SEP>2
8
<qiyuangong>007_Reverse_Integer_1.java
public int reverse(int x) { if (x == 0) return 0; long res = 0; while (x != 0) { res = res * 10 + x % 10; if (res > Integer.MAX_VALUE || res < Integer.MIN_VALUE) return 0; x /= 10; } return (int) res; }
public int sample_funcname ( int var_0 ) { if ( var_0 == 0 ) return 0 ; long var_1 = 0 ; while ( var_0 != 0 ) { var_1 = var_1 * 10 + var_0 % 10 ; if ( var_1 > Integer . MAX_VALUE || var_1 < Integer . MIN_VALUE ) return 0 ; var_0 /= 10 ; } return ( int ) var_1 ; }
2
10<SEP>0
9
<qiyuangong>003_Longest_Substring_Without_Repeating_Characters_2.java
public int lengthOfLongestSubstring(String s) { int[] charMap = new int[256]; Arrays.fill(charMap, -1); int i = 0, maxLen = 0; for (int j = 0; j < s.length(); j++) { if (charMap[s.charAt(j)] >= i) { i = charMap[s.charAt(j)] + 1; } charMap[s.charAt(j)] = j; maxLen = Math.max(j - i + 1, maxLen); } return maxLen; }
public int sample_funcname ( String var_0 ) { int [ ] var_1 = new int [ 256 ] ; Arrays . fill ( var_1 , - 1 ) ; int var_2 = 0 , var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ( ) ; var_4 ++ ) { if ( var_1 [ var_0 . charAt ( var_4 ) ] >= var_2 ) { var_2 = var_1 [ var_0 . charAt ( var_4 ) ] + 1 ; } var_1 [ var_0 . charAt ( var_4 ) ] = var_4 ; var_3 = Math . max ( var_4 - var_2 + 1 , var_3 ) ; } return var_3 ; }
3
1<SEP>0<SEP>256
11
<qiyuangong>238_Product_of_Array_Except_Self_1.java
public int[] productExceptSelf(int[] nums) { int n = nums.length; int[] res = new int[n]; res[0] = 1; for (int i = 1; i < n; i++) { res[i] = res[i - 1] * nums[i - 1]; } int right = 1; for (int i = n - 1; i >= 0; i--) { res[i] *= right; right *= nums[i]; } return res; }
public int [ ] sample_funcname ( int [ ] var_0 ) { int var_1 = var_0 . length ; int [ ] var_2 = new int [ var_1 ] ; var_2 [ 0 ] = 1 ; for ( int var_3 = 1 ; var_3 < var_1 ; var_3 ++ ) { var_2 [ var_3 ] = var_2 [ var_3 - 1 ] * var_0 [ var_3 - 1 ] ; } int var_4 = 1 ; for ( int var_3 = var_1 - 1 ; var_3 >= 0 ; var_3 -- ) { var_2 [ var_3 ] *= var_4 ; var_4 *= var_0 [ var_3 ] ; } return var_2 ; }
2
0<SEP>1
12
<qiyuangong>581_Shortest_Unsorted_Continuous_Subarray_1.java
public int findUnsortedSubarray(int[] nums) { Stack < Integer > stack = new Stack < Integer > (); int l = nums.length, r = 0; for (int i = 0; i < nums.length; i++) { while (!stack.isEmpty() && nums[stack.peek()] > nums[i]) l = Math.min(l, stack.pop()); stack.push(i); } stack.clear(); for (int i = nums.length - 1; i >= 0; i--) { while (!stack.isEmpty() && nums[stack.peek()] < nums[i]) r = Math.max(r, stack.pop()); stack.push(i); } return r - l > 0 ? r - l + 1 : 0; }
public int sample_funcname ( int [ ] var_0 ) { Stack < Integer > var_1 = new Stack < Integer > ( ) ; int var_2 = var_0 . length , var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { while ( ! var_1 . isEmpty ( ) && var_0 [ var_1 . peek ( ) ] > var_0 [ var_4 ] ) var_2 = Math . min ( var_2 , var_1 . pop ( ) ) ; var_1 . push ( var_4 ) ; } var_1 . clear ( ) ; for ( int var_4 = var_0 . length - 1 ; var_4 >= 0 ; var_4 -- ) { while ( ! var_1 . isEmpty ( ) && var_0 [ var_1 . peek ( ) ] < var_0 [ var_4 ] ) var_3 = Math . max ( var_3 , var_1 . pop ( ) ) ; var_1 . push ( var_4 ) ; } return var_3 - var_2 > 0 ? var_3 - var_2 + 1 : 0 ; }
2
0<SEP>1
13
<qiyuangong>929_Unique_Email_Addresses_1.java
public int numUniqueEmails(String[] emails) { HashSet<String> emailSet = new HashSet<>(); for (String email: emails) { String firstSplit[] = email.split("@"); String secondSplit[] = firstSplit[0].replaceAll(".", "").split("[+]"); emailSet.add(secondSplit[0] + firstSplit[1]); } return emailSet.size(); }
public int sample_funcname ( String [ ] var_0 ) { HashSet < String > var_1 = new HashSet < > ( ) ; for ( String var_2 : var_0 ) { String var_3 [ ] = var_2 . split ( "@" ) ; String var_4 [ ] = var_3 [ 0 ] . replaceAll ( "." , "" ) . split ( "[+]" ) ; var_1 . add ( var_4 [ 0 ] + var_3 [ 1 ] ) ; } return var_1 . size ( ) ; }
6
<D_QUOTE>[+]<D_QUOTE><SEP>0<SEP>1<SEP><D_QUOTE>.<D_QUOTE><SEP><D_QUOTE>@<D_QUOTE><SEP><D_QUOTE><D_QUOTE>
14
<qiyuangong>724_Find_Pivot_Index_1.java
public int pivotIndex(int[] nums) { int totalsum = 0, leftsum = 0; for (int i = 0; i < nums.length; i++) totalsum += nums[i]; for (int i = 0; i < nums.length; i++) { if (leftsum == totalsum - leftsum - nums[i]) return i; leftsum += nums[i]; } return -1; }
public int sample_funcname ( int [ ] var_0 ) { int var_1 = 0 , var_2 = 0 ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) var_1 += var_0 [ var_3 ] ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { if ( var_2 == var_1 - var_2 - var_0 [ var_3 ] ) return var_3 ; var_2 += var_0 [ var_3 ] ; } return - 1 ; }
2
0<SEP>1
15
<qiyuangong>560_Subarray_Sum_Equals_K_2.java
public int subarraySum(int[] nums, int k) { int count = 0, sum = 0; HashMap < Integer, Integer > map = new HashMap < > (); map.put(0, 1); for (int i = 0; i < nums.length; i++) { sum += nums[i]; if (map.containsKey(sum - k)) count += map.get(sum - k); map.put(sum, map.getOrDefault(sum, 0) + 1); } return count; }
public int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_2 = 0 , var_3 = 0 ; HashMap < Integer , Integer > var_4 = new HashMap < > ( ) ; var_4 . put ( 0 , 1 ) ; for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { var_3 += var_0 [ var_5 ] ; if ( var_4 . containsKey ( var_3 - var_1 ) ) var_2 += var_4 . get ( var_3 - var_1 ) ; var_4 . put ( var_3 , var_4 . getOrDefault ( var_3 , 0 ) + 1 ) ; } return var_2 ; }
2
0<SEP>1
16
<qiyuangong>434_Number_of_Segments_in_a_String_2.java
public int countSegments(String s) { int segmentCount = 0; for (int i = 0; i < s.length(); i++) { if ((i == 0 || s.charAt(i-1) == ' ') && s.charAt(i) != ' ') { segmentCount++; } } return segmentCount; }
public int sample_funcname ( String var_0 ) { int var_1 = 0 ; for ( int var_2 = 0 ; var_2 < var_0 . length ( ) ; var_2 ++ ) { if ( ( var_2 == 0 || var_0 . charAt ( var_2 - 1 ) == ' ' ) && var_0 . charAt ( var_2 ) != ' ' ) { var_1 ++ ; } } return var_1 ; }
3
0<SEP><S_QUOTE> <S_QUOTE><SEP>1
17
<qiyuangong>179_Largest_Number_1.java
public int compare(String a, String b) { String order1 = a + b; String order2 = b + a; return order2.compareTo(order1); }
public int sample_funcname ( String var_0 , String var_1 ) { String var_2 = var_0 + var_1 ; String var_3 = var_1 + var_0 ; return var_3 . compareTo ( var_2 ) ; }
0
null
18
<qiyuangong>784_Letter_Case_Permutation_2.java
public List<String> letterCasePermutation(String S) { int B = 0; for (char c: S.toCharArray()) if (Character.isLetter(c)) B++; List<String> ans = new ArrayList(); for (int bits = 0; bits < 1<<B; bits++) { int b = 0; StringBuilder word = new StringBuilder(); for (char letter: S.toCharArray()) { if (Character.isLetter(letter)) { if (((bits >> b++) & 1) == 1) word.append(Character.toLowerCase(letter)); else word.append(Character.toUpperCase(letter)); } else { word.append(letter); } } ans.add(word.toString()); } return ans; }
public List < String > var_0 ( String var_1 ) { int var_2 = 0 ; for ( char var_3 : var_1 . toCharArray ( ) ) if ( Character . isLetter ( var_3 ) ) var_2 ++ ; List < String > var_4 = new ArrayList ( ) ; for ( int var_5 = 0 ; var_5 < 1 << var_2 ; var_5 ++ ) { int var_6 = 0 ; StringBuilder var_7 = new StringBuilder ( ) ; for ( char var_8 : var_1 . toCharArray ( ) ) { if ( Character . isLetter ( var_8 ) ) { if ( ( ( var_5 >> var_6 ++ ) & 1 ) == 1 ) var_7 . append ( Character . toLowerCase ( var_8 ) ) ; else var_7 . append ( Character . toUpperCase ( var_8 ) ) ; } else { var_7 . append ( var_8 ) ; } } var_4 . add ( var_7 . toString ( ) ) ; } return var_4 ; }
2
0<SEP>1
19
<qiyuangong>438_Find_All_Anagrams_in_a_String_2.java
public List<Integer> findAnagrams(String s, String p) { List<Integer> list = new ArrayList<Integer>(); int ls = s.length(), lp = p.length(); for (int i = 0; i <= ls - lp; i++) { boolean flag = true; String sub = s.substring(i, i + lp); int[] charCnt = new int[256]; for (int j = 0; j < sub.length(); j++) { charCnt[sub.charAt(j)]++; } for (int j = 0; j < lp; j++) { charCnt[p.charAt(j)]--; } for (int j = 0; j < charCnt.length; j++) { if (charCnt[j] != 0) { flag = false; break; } } if (flag) { list.add(i); } } return list; }
public List < Integer > var_0 ( String var_1 , String var_2 ) { List < Integer > var_3 = new ArrayList < Integer > ( ) ; int var_4 = var_1 . length ( ) , var_5 = var_2 . length ( ) ; for ( int var_6 = 0 ; var_6 <= var_4 - var_5 ; var_6 ++ ) { boolean var_10 = true ; String var_7 = var_1 . substring ( var_6 , var_6 + var_5 ) ; int [ ] var_8 = new int [ 256 ] ; for ( int var_9 = 0 ; var_9 < var_7 . length ( ) ; var_9 ++ ) { var_8 [ var_7 . charAt ( var_9 ) ] ++ ; } for ( int var_9 = 0 ; var_9 < var_5 ; var_9 ++ ) { var_8 [ var_2 . charAt ( var_9 ) ] -- ; } for ( int var_9 = 0 ; var_9 < var_8 . length ; var_9 ++ ) { if ( var_8 [ var_9 ] != 0 ) { var_10 = false ; break ; } } if ( var_10 ) { var_3 . add ( var_6 ) ; } } return var_3 ; }
2
0<SEP>256
20
<qiyuangong>479_Largest_Palindrome_Product_1.java
private long createPalindrom(long num) { String str = num + new StringBuilder().append(num).reverse().toString(); return Long.parseLong(str); }
private long sample_funcname ( long var_0 ) { String var_1 = var_0 + new StringBuilder ( ) . append ( var_0 ) . reverse ( ) . toString ( ) ; return Long . parseLong ( var_1 ) ; }
0
null
21
<qiyuangong>811_Subdomain_Visit_Count_1.java
public List<String> subdomainVisits(String[] cpdomains) { Map<String, Integer> map = new HashMap(); for (String cpdomain : cpdomains) { int i = cpdomain.indexOf(' '); int n = Integer.valueOf(cpdomain.substring(0, i)); String domain = cpdomain.substring(i + 1); for (i = 0; i < domain.length(); ++i) { if (domain.charAt(i) == '.') { String d = domain.substring(i + 1); map.put(d, map.getOrDefault(d, 0) + n); } } map.put(domain, map.getOrDefault(domain, 0) + n); } List<String> res = new ArrayList(); for (String domain : map.keySet()) res.add(map.get(domain) + " " + domain); return res; }
public List < String > var_0 ( String [ ] var_1 ) { Map < String , Integer > var_2 = new HashMap ( ) ; for ( String var_3 : var_1 ) { int var_4 = var_3 . indexOf ( ' ' ) ; int var_5 = Integer . valueOf ( var_3 . substring ( 0 , var_4 ) ) ; String var_6 = var_3 . substring ( var_4 + 1 ) ; for ( var_4 = 0 ; var_4 < var_6 . length ( ) ; ++ var_4 ) { if ( var_6 . charAt ( var_4 ) == '.' ) { String var_7 = var_6 . substring ( var_4 + 1 ) ; var_2 . put ( var_7 , var_2 . getOrDefault ( var_7 , 0 ) + var_5 ) ; } } var_2 . put ( var_6 , var_2 . getOrDefault ( var_6 , 0 ) + var_5 ) ; } List < String > var_8 = new ArrayList ( ) ; for ( String var_6 : var_2 . keySet ( ) ) var_8 . add ( var_2 . get ( var_6 ) + " " + var_6 ) ; return var_8 ; }
5
0<SEP><S_QUOTE> <S_QUOTE><SEP>1<SEP><D_QUOTE> <D_QUOTE><SEP><S_QUOTE>.<S_QUOTE>
22
<qiyuangong>1539_Kth_Missing_Positive_Number_1.java
public int findKthPositive(int[] a, int k) { int B[] = new int[a.length]; for (int i = 0; i < a.length; i++) B[i] = a[i] - i - 1; // -1 is done as here missing numbers start from 1 and not 0 int lo = 0, hi = B.length - 1; while (lo <= hi) { int mid = lo + (hi - lo) / 2; if (B[mid] >= k) hi = mid - 1; else lo = mid + 1; } return lo + k; }
public int sample_funcname ( int [ ] var_0 , int var_1 ) { int var_2 [ ] = new int [ var_0 . length ] ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) var_2 [ var_3 ] = var_0 [ var_3 ] - var_3 - 1 ; int var_4 = 0 , var_5 = var_2 . length - 1 ; while ( var_4 <= var_5 ) { int var_6 = var_4 + ( var_5 - var_4 ) / 2 ; if ( var_2 [ var_6 ] >= var_1 ) var_5 = var_6 - 1 ; else var_4 = var_6 + 1 ; } return var_4 + var_1 ; }
3
2<SEP>0<SEP>1
24
<qiyuangong>547_Friend_Circles_1.java
public void dfs(int[][] M, int[] visited, int i) { for (int j = 0; j < M.length; j++) { if (M[i][j] == 1 && visited[j] == 0) { visited[j] = 1; dfs(M, visited, j); } } }
public void sample_funcname ( int [ ] [ ] M , int [ ] visited , int i ) { for ( int j = 0 ; j < M . length ; j ++ ) { if ( M [ i ] [ j ] == 1 && visited [ j ] == 0 ) { visited [ j ] = 1 ; dfs ( M , visited , j ) ; } } }
2
0<SEP>1
25
<qiyuangong>973_K_Closest_Points_to_Origin_1.java
private int dist(int[] point) { return point[0] * point[0] + point[1] * point[1]; }
private int sample_funcname ( int [ ] var_0 ) { return var_0 [ 0 ] * var_0 [ 0 ] + var_0 [ 1 ] * var_0 [ 1 ] ; }
2
0<SEP>1
26
<qiyuangong>1089_Duplicate_Zeros_1.java
public void duplicateZeros(int[] arr) { int movePos = 0; int lastPos = arr.length - 1; for (int i = 0; i <= lastPos - movePos; i++) { if (arr[i] == 0) { if (i == lastPos - movePos) { arr[lastPos] = 0; lastPos--; break; } movePos++; } } lastPos = lastPos - movePos; for (int i = lastPos; i >= 0; i--) { if (arr[i] == 0) { arr[i + movePos] = 0; movePos--; arr[i + movePos] = 0; } else { arr[i + movePos] = arr[i]; } } }
public void var_0 ( int [ ] var_1 ) { int var_2 = 0 ; int var_3 = var_1 . length - 1 ; for ( int var_4 = 0 ; var_4 <= var_3 - var_2 ; var_4 ++ ) { if ( var_1 [ var_4 ] == 0 ) { if ( var_4 == var_3 - var_2 ) { var_1 [ var_3 ] = 0 ; var_3 -- ; break ; } var_2 ++ ; } } var_3 = var_3 - var_2 ; for ( int var_4 = var_3 ; var_4 >= 0 ; var_4 -- ) { if ( var_1 [ var_4 ] == 0 ) { var_1 [ var_4 + var_2 ] = 0 ; var_2 -- ; var_1 [ var_4 + var_2 ] = 0 ; } else { var_1 [ var_4 + var_2 ] = var_1 [ var_4 ] ; } } }
2
0<SEP>1
27
<qiyuangong>387_First_Unique_Character_in_a_String_1.java
public int firstUniqChar(String s) { int freq [] = new int[26]; for(int i = 0; i < s.length(); i ++) freq [s.charAt(i) - 'a'] ++; for(int i = 0; i < s.length(); i ++) if(freq [s.charAt(i) - 'a'] == 1) return i; return -1; }
public int sample_funcname ( String var_0 ) { int var_1 [ ] = new int [ 26 ] ; for ( int var_2 = 0 ; var_2 < var_0 . length ( ) ; var_2 ++ ) var_1 [ var_0 . charAt ( var_2 ) - 'a' ] ++ ; for ( int var_2 = 0 ; var_2 < var_0 . length ( ) ; var_2 ++ ) if ( var_1 [ var_0 . charAt ( var_2 ) - 'a' ] == 1 ) return var_2 ; return - 1 ; }
4
0<SEP>26<SEP>1<SEP><S_QUOTE>a<S_QUOTE>
28
<qiyuangong>771_Jewels_and_Stones_1.java
public int numJewelsInStones(String J, String S) { int result = 0; HashSet jHash = new HashSet<>(); for (int j = 0; j < J.length(); j++) { jHash.add(J.charAt(j)); } for (int s = 0; s < S.length(); s++) { if (jHash.contains(S.charAt(s))) { result++; } } return result; }
public int sample_funcname ( String var_0 , String var_1 ) { int var_2 = 0 ; HashSet var_3 = new HashSet < > ( ) ; for ( int var_4 = 0 ; var_4 < var_0 . length ( ) ; var_4 ++ ) { var_3 . add ( var_0 . charAt ( var_4 ) ) ; } for ( int var_5 = 0 ; var_5 < var_1 . length ( ) ; var_5 ++ ) { if ( var_3 . contains ( var_1 . charAt ( var_5 ) ) ) { var_2 ++ ; } } return var_2 ; }
1
0
29
<qiyuangong>665_Non-decreasing_Array_1.java
public boolean checkPossibility(int[] nums) { int brokenPoint = 0; for (int i = 0; i < nums.length - 1; i++) { if (nums[i] > nums[i + 1]) { brokenPoint++; if (brokenPoint >= 2) return false; if (i - 1 < 0 || nums[i - 1] <= nums[i + 1]) nums[i] = nums[i + 1]; else nums[i + 1] = nums[i]; } } return true; }
public boolean var_0 ( int [ ] var_1 ) { int var_2 = 0 ; for ( int var_3 = 0 ; var_3 < var_1 . length - 1 ; var_3 ++ ) { if ( var_1 [ var_3 ] > var_1 [ var_3 + 1 ] ) { var_2 ++ ; if ( var_2 >= 2 ) return false ; if ( var_3 - 1 < 0 || var_1 [ var_3 - 1 ] <= var_1 [ var_3 + 1 ] ) var_1 [ var_3 ] = var_1 [ var_3 + 1 ] ; else var_1 [ var_3 + 1 ] = var_1 [ var_3 ] ; } } return true ; }
3
2<SEP>0<SEP>1
30
<qiyuangong>009_Palindrome_Number_1.java
public boolean isPalindrome(int x) { if (x < 0) return false; int temp = x; int len = 0; while (temp != 0) { temp /= 10; len ++; } temp = x; int left, right; for (int i = 0; i < len / 2; i++) { right = temp % 10; left = temp / (int) Math.pow(10, len - 2 * i - 1); left = left % 10; if (left != right) return false; temp /= 10; } return true; }
public boolean var_0 ( int var_1 ) { if ( var_1 < 0 ) return false ; int var_2 = var_1 ; int var_3 = 0 ; while ( var_2 != 0 ) { var_2 /= 10 ; var_3 ++ ; } var_2 = var_1 ; int var_4 , var_5 ; for ( int var_6 = 0 ; var_6 < var_3 / 2 ; var_6 ++ ) { var_5 = var_2 % 10 ; var_4 = var_2 / ( int ) Math . pow ( 10 , var_3 - 2 * var_6 - 1 ) ; var_4 = var_4 % 10 ; if ( var_4 != var_5 ) return false ; var_2 /= 10 ; } return true ; }
4
10<SEP>0<SEP>1<SEP>2
31
<qiyuangong>668_Kth_Smallest_Number_in_Multiplication_Table_1.java
public boolean enough(int x, int m, int n, int k) { int count = 0; for (int i = 1; i <= m; i++) { count += Math.min(x / i, n); } return count >= k; }
public boolean var_0 ( int var_1 , int var_2 , int var_3 , int var_4 ) { int var_5 = 0 ; for ( int var_6 = 1 ; var_6 <= var_2 ; var_6 ++ ) { var_5 += Math . min ( var_1 / var_6 , var_3 ) ; } return var_5 >= var_4 ; }
2
0<SEP>1
32
<qiyuangong>760_Find_Anagram_Mappings_1.java
public int[] anagramMappings(int[] A, int[] B) { int[] ans = new int[A.length]; HashMap<Integer, Integer> valIndex = new HashMap<>(); for (int i = 0; i < B.length; i++) valIndex.put(B[i], i); for (int i = 0; i < A.length; i++) ans[i] = valIndex.get(A[i]); return ans; }
public int [ ] sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { int [ ] var_2 = new int [ var_0 . length ] ; HashMap < Integer , Integer > var_3 = new HashMap < > ( ) ; for ( int var_4 = 0 ; var_4 < var_1 . length ; var_4 ++ ) var_3 . put ( var_1 [ var_4 ] , var_4 ) ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) var_2 [ var_4 ] = var_3 . get ( var_0 [ var_4 ] ) ; return var_2 ; }
1
0
33
<qiyuangong>709_To_Lower_Case_2.java
public String toLowerCase(String str) { char[] a = str.toCharArray(); for (int i = 0; i < a.length; i++) if ('A' <= a[i] && a[i] <= 'Z') a[i] = (char) (a[i] - 'A' + 'a'); return new String(a); }
public String var_0 ( String var_1 ) { char [ ] var_2 = var_1 . toCharArray ( ) ; for ( int var_3 = 0 ; var_3 < var_2 . length ; var_3 ++ ) if ( 'A' <= var_2 [ var_3 ] && var_2 [ var_3 ] <= 'Z' ) var_2 [ var_3 ] = ( char ) ( var_2 [ var_3 ] - 'A' + 'a' ) ; return new String ( var_2 ) ; }
4
<S_QUOTE>Z<S_QUOTE><SEP>0<SEP><S_QUOTE>a<S_QUOTE><SEP><S_QUOTE>A<S_QUOTE>
34
<qiyuangong>005_Longest_Palindromic_Substring_2.java
private static char[] addBoundaries(char[] cs) { if (cs==null || cs.length==0) return "||".toCharArray(); char[] cs2 = new char[cs.length*2+1]; for (int i = 0; i<(cs2.length-1); i = i+2) { cs2[i] = '|'; cs2[i+1] = cs[i/2]; } cs2[cs2.length-1] = '|'; return cs2; }
private static char [ ] sample_funcname ( char [ ] var_0 ) { if ( var_0 == null || var_0 . length == 0 ) return "||" . toCharArray ( ) ; char [ ] var_1 = new char [ var_0 . length * 2 + 1 ] ; for ( int var_2 = 0 ; var_2 < ( var_1 . length - 1 ) ; var_2 = var_2 + 2 ) { var_1 [ var_2 ] = '|' ; var_1 [ var_2 + 1 ] = var_0 [ var_2 / 2 ] ; } var_1 [ var_1 . length - 1 ] = '|' ; return var_1 ; }
5
2<SEP><S_QUOTE>|<S_QUOTE><SEP>0<SEP>1<SEP><D_QUOTE>||<D_QUOTE>
35
<qiyuangong>1108_Defanging_an_IP_Address_1.java
public String defangIPaddr(String address) { return address.replace(".", "[.]"); }
public String var_0 ( String var_1 ) { return var_1 . replace ( "." , "[.]" ) ; }
2
<D_QUOTE>.<D_QUOTE><SEP><D_QUOTE>[.]<D_QUOTE>
36
<qiyuangong>1064_Fixed_Point_1.java
public int fixedPoint(int[] A) { int l = 0; int h = A.length; while (l <= h) { int mid = (l + h) / 2; if (A[mid] > mid) h = mid - 1; else if (A[mid] < mid) l = mid + 1; else return mid; } return -1; }
public int sample_funcname ( int [ ] var_0 ) { int var_1 = 0 ; int var_2 = var_0 . length ; while ( var_1 <= var_2 ) { int var_3 = ( var_1 + var_2 ) / 2 ; if ( var_0 [ var_3 ] > var_3 ) var_2 = var_3 - 1 ; else if ( var_0 [ var_3 ] < var_3 ) var_1 = var_3 + 1 ; else return var_3 ; } return - 1 ; }
3
0<SEP>1<SEP>2
37
<qiyuangong>962_Maximum_Width_Ramp_1.java
public int maxWidthRamp(int[] A) { int N = A.length; Integer[] B = new Integer[N]; for (int i = 0; i < N; ++i) B[i] = i; Arrays.sort(B, (i, j) -> ((Integer) A[i]).compareTo(A[j])); int ans = 0; int m = N; for (int i: B) { ans = Math.max(ans, i - m); m = Math.min(m, i); } return ans; }
public int sample_funcname ( int [ ] var_0 ) { int var_1 = var_0 . length ; Integer [ ] var_2 = new Integer [ var_1 ] ; for ( int var_3 = 0 ; var_3 < var_1 ; ++ var_3 ) var_2 [ var_3 ] = var_3 ; Arrays . sort ( var_2 , ( var_3 , var_4 ) -> ( ( Integer ) var_0 [ var_3 ] ) . compareTo ( var_0 [ var_4 ] ) ) ; int var_5 = 0 ; int var_6 = var_1 ; for ( int var_3 : var_2 ) { var_5 = Math . max ( var_5 , var_3 - var_6 ) ; var_6 = Math . min ( var_6 , var_3 ) ; } return var_5 ; }
1
0
38
<qiyuangong>937_Reorder_Log_Files_1.java
public String[] reorderLogFiles(String[] logs) { Arrays.sort(logs, (log1, log2) -> { String[] split1 = log1.split(" ", 2); String[] split2 = log2.split(" ", 2); boolean isDigit1 = Character.isDigit(split1[1].charAt(0)); boolean isDigit2 = Character.isDigit(split2[1].charAt(0)); if (!isDigit1 && !isDigit2) { int cmp = split1[1].compareTo(split2[1]); if (cmp != 0) return cmp; return split1[0].compareTo(split2[0]); } return isDigit1 ? (isDigit2 ? 0 : 1) : -1; }); return logs; }
public String [ ] var_0 ( String [ ] var_1 ) { Arrays . sort ( var_1 , ( var_2 , var_3 ) -> { String [ ] var_4 = var_2 . split ( " " , 2 ) ; String [ ] var_5 = var_3 . split ( " " , 2 ) ; boolean var_6 = Character . isDigit ( var_4 [ 1 ] . charAt ( 0 ) ) ; boolean var_7 = Character . isDigit ( var_5 [ 1 ] . charAt ( 0 ) ) ; if ( ! var_6 && ! var_7 ) { int var_8 = var_4 [ 1 ] . compareTo ( var_5 [ 1 ] ) ; if ( var_8 != 0 ) return var_8 ; return var_4 [ 0 ] . compareTo ( var_5 [ 0 ] ) ; } return var_6 ? ( var_7 ? 0 : 1 ) : - 1 ; } ) ; return var_1 ; }
4
1<SEP>0<SEP><D_QUOTE> <D_QUOTE><SEP>2
39
<qiyuangong>852_Peak_Index_in_a_Mountain_Array_2.java
public int peakIndexInMountainArray(int[] A) { int lo = 0, hi = A.length - 1; while (lo < hi) { int mid = (lo + hi) / 2; if (A[mid] < A[mid + 1]) lo = mid + 1; else hi = mid; } return lo; }
public int sample_funcname ( int [ ] var_0 ) { int var_1 = 0 , var_2 = var_0 . length - 1 ; while ( var_1 < var_2 ) { int var_3 = ( var_1 + var_2 ) / 2 ; if ( var_0 [ var_3 ] < var_0 [ var_3 + 1 ] ) var_1 = var_3 + 1 ; else var_2 = var_3 ; } return var_1 ; }
3
2<SEP>0<SEP>1
40
<qiyuangong>961_N-Repeated_Element_in_Size_2N_Array_1.java
public int repeatedNTimes(int[] A) { HashMap<Integer, Integer> hash = new HashMap<>(); int ans = A[0]; for (int n: A) { int count = hash.getOrDefault(n, 0) + 1; hash.put(n, count); if (count >= hash.get(ans)) ans = n; } return ans; }
public int sample_funcname ( int [ ] var_0 ) { HashMap < Integer , Integer > var_1 = new HashMap < > ( ) ; int var_2 = var_0 [ 0 ] ; for ( int var_3 : var_0 ) { int var_4 = var_1 . getOrDefault ( var_3 , 0 ) + 1 ; var_1 . put ( var_3 , var_4 ) ; if ( var_4 >= var_1 . get ( var_2 ) ) var_2 = var_3 ; } return var_2 ; }
2
0<SEP>1
41
<qiyuangong>215_Kth_Largest_Element_in_an_Array_1.java
private void exch(int[] a, int i, int j) { final int tmp = a[i]; a[i] = a[j]; a[j] = tmp; }
private void var_0 ( int [ ] var_1 , int var_2 , int var_3 ) { final int var_4 = var_1 [ var_2 ] ; var_1 [ var_2 ] = var_1 [ var_3 ] ; var_1 [ var_3 ] = var_4 ; }
0
null
42
<qiyuangong>720_Longest_Word_in_Dictionary_1.java
public String longestWord(String[] words) { String ans = ""; Set<String> wordset = new HashSet(); for (String word: words) wordset.add(word); for (String word: words) { if (word.length() > ans.length() || word.length() == ans.length() && word.compareTo(ans) < 0) { boolean good = true; for (int k = 1; k < word.length(); ++k) { if (!wordset.contains(word.substring(0, k))) { good = false; break; } } if (good) ans = word; } } return ans; }
public String var_0 ( String [ ] var_1 ) { String var_2 = "" ; Set < String > var_3 = new HashSet ( ) ; for ( String var_4 : var_1 ) var_3 . add ( var_4 ) ; for ( String var_4 : var_1 ) { if ( var_4 . length ( ) > var_2 . length ( ) || var_4 . length ( ) == var_2 . length ( ) && var_4 . compareTo ( var_2 ) < 0 ) { boolean var_6 = true ; for ( int var_5 = 1 ; var_5 < var_4 . length ( ) ; ++ var_5 ) { if ( ! var_3 . contains ( var_4 . substring ( 0 , var_5 ) ) ) { var_6 = false ; break ; } } if ( var_6 ) var_2 = var_4 ; } } return var_2 ; }
3
0<SEP><D_QUOTE><D_QUOTE><SEP>1
43
<qiyuangong>728_Self_Dividing_Numbers_1.java
public boolean isSelfDiving(int num) { int digit = num % 10; int temp = num; boolean isTrue = true; while(temp != 0) { if(digit == 0 || num % digit != 0) { isTrue = false; break; } else { temp /= 10; digit = temp % 10; } } return isTrue; }
public boolean var_0 ( int var_1 ) { int var_2 = var_1 % 10 ; int var_3 = var_1 ; boolean var_4 = true ; while ( var_3 != 0 ) { if ( var_2 == 0 || var_1 % var_2 != 0 ) { var_4 = false ; break ; } else { var_3 /= 10 ; var_2 = var_3 % 10 ; } } return var_4 ; }
2
10<SEP>0
44
<qiyuangong>945_Minimum_Increment_to_Make_Array_Unique_1.java
public int minIncrementForUnique(int[] A) { if (A.length == 0) return 0; HashSet<Integer> numSet = new HashSet<>(); List<Integer> duplicated = new ArrayList<>(); int res = 0; Arrays.sort(A); int left = A[0]; int right = A[A.length - 1]; int holes = right - left + 1; for (int v: A) { if (numSet.contains(v)) duplicated.add(v); else numSet.add(v); } holes -= numSet.size(); for (int i = left + 1; i < right; i++) { if (holes == 0 || duplicated.size() == 0) break; if (!numSet.contains(i) && i > duplicated.get(0)) { res += i - duplicated.get(0); holes --; duplicated.remove(0); } } if (duplicated.size() == 0) return res; while (duplicated.size() != 0) { right += 1; res += right - duplicated.get(0); duplicated.remove(0); } return res; }
public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; HashSet < Integer > var_1 = new HashSet < > ( ) ; List < Integer > var_2 = new ArrayList < > ( ) ; int var_3 = 0 ; Arrays . sort ( var_0 ) ; int var_4 = var_0 [ 0 ] ; int var_5 = var_0 [ var_0 . length - 1 ] ; int var_6 = var_5 - var_4 + 1 ; for ( int var_7 : var_0 ) { if ( var_1 . contains ( var_7 ) ) var_2 . add ( var_7 ) ; else var_1 . add ( var_7 ) ; } var_6 -= var_1 . size ( ) ; for ( int var_8 = var_4 + 1 ; var_8 < var_5 ; var_8 ++ ) { if ( var_6 == 0 || var_2 . size ( ) == 0 ) break ; if ( ! var_1 . contains ( var_8 ) && var_8 > var_2 . get ( 0 ) ) { var_3 += var_8 - var_2 . get ( 0 ) ; var_6 -- ; var_2 . remove ( 0 ) ; } } if ( var_2 . size ( ) == 0 ) return var_3 ; while ( var_2 . size ( ) != 0 ) { var_5 += 1 ; var_3 += var_5 - var_2 . get ( 0 ) ; var_2 . remove ( 0 ) ; } return var_3 ; }
2
0<SEP>1
45
<qiyuangong>751_IP_to_CIDR_3.java
private int bitLength(long x) { if (x == 0) return 1; int ans = 0; while (x > 0) { x >>= 1; ans++; } return ans; }
private int sample_funcname ( long var_0 ) { if ( var_0 == 0 ) return 1 ; int var_1 = 0 ; while ( var_0 > 0 ) { var_0 >>= 1 ; var_1 ++ ; } return var_1 ; }
2
0<SEP>1
46
<qiyuangong>1480_Running_Sum_of_1d_Array_1.java
public int[] runningSum(int[] nums) { if (nums.length <= 1) return nums; for (int i = 1; i < nums.length; i++) nums[i] += nums[i - 1]; return nums; }
public int [ ] sample_funcname ( int [ ] var_0 ) { if ( var_0 . length <= 1 ) return var_0 ; for ( int var_1 = 1 ; var_1 < var_0 . length ; var_1 ++ ) var_0 [ var_1 ] += var_0 [ var_1 - 1 ] ; return var_0 ; }
1
1
47
<qiyuangong>223_Rectangle_Area_1.java
public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { int left = Math.max(A, E), right = Math.max(Math.min(C, G), left); int bottom = Math.max(B, F), top = Math.max(Math.min(D, H), bottom); return (C - A) * (D - B) - (right - left) * (top - bottom) + (G - E) * (H - F); }
public int sample_funcname ( int var_0 , int var_1 , int var_2 , int var_3 , int var_4 , int var_5 , int var_6 , int var_7 ) { int var_8 = Math . max ( var_0 , var_4 ) , var_9 = Math . max ( Math . min ( var_2 , var_6 ) , var_8 ) ; int var_10 = Math . max ( var_1 , var_5 ) , var_11 = Math . max ( Math . min ( var_3 , var_7 ) , var_10 ) ; return ( var_2 - var_0 ) * ( var_3 - var_1 ) - ( var_9 - var_8 ) * ( var_11 - var_10 ) + ( var_6 - var_4 ) * ( var_7 - var_5 ) ; }
0
null
48
<qiyuangong>680_Valid_Palindrome_II_1.java
public boolean isPalindromeRange(String s, int i, int j) { for (int k = i; k <= i + (j - i) / 2; k++) { if (s.charAt(k) != s.charAt(j - k + i)) return false; } return true; }
public boolean var_0 ( String var_1 , int var_2 , int var_3 ) { for ( int var_4 = var_2 ; var_4 <= var_2 + ( var_3 - var_2 ) / 2 ; var_4 ++ ) { if ( var_1 . charAt ( var_4 ) != var_1 . charAt ( var_3 - var_4 + var_2 ) ) return false ; } return true ; }
1
2
49
<qiyuangong>628_Maximum_Product_of_Three_Numbers_2.java
public int maximumProduct(int[] nums) { int min1 = Integer.MAX_VALUE, min2 = Integer.MAX_VALUE; int max1 = Integer.MIN_VALUE, max2 = Integer.MIN_VALUE, max3 = Integer.MIN_VALUE; for (int n: nums) { if (n <= min1) { min2 = min1; min1 = n; } else if (n <= min2) { // n lies between min1 and min2 min2 = n; } if (n >= max1) { // n is greater than max1, max2 and max3 max3 = max2; max2 = max1; max1 = n; } else if (n >= max2) { // n lies betweeen max1 and max2 max3 = max2; max2 = n; } else if (n >= max3) { // n lies betwen max2 and max3 max3 = n; } } return Math.max(min1 * min2 * max1, max1 * max2 * max3); }
public int sample_funcname ( int [ ] var_0 ) { int var_1 = Integer . MAX_VALUE , var_2 = Integer . MAX_VALUE ; int var_3 = Integer . MIN_VALUE , var_4 = Integer . MIN_VALUE , var_5 = Integer . MIN_VALUE ; for ( int var_6 : var_0 ) { if ( var_6 <= var_1 ) { var_2 = var_1 ; var_1 = var_6 ; } else if ( var_6 <= var_2 ) { var_2 = var_6 ; } if ( var_6 >= var_3 ) { var_5 = var_4 ; var_4 = var_3 ; var_3 = var_6 ; } else if ( var_6 >= var_4 ) { var_5 = var_4 ; var_4 = var_6 ; } else if ( var_6 >= var_5 ) { var_5 = var_6 ; } } return Math . max ( var_1 * var_2 * var_3 , var_3 * var_4 * var_5 ) ; }
0
null
50
<qiyuangong>485_Max_Consecutive_Ones_1.java
public int findMaxConsecutiveOnes(int[] nums) { int ans = 0; int curr = 0; for (int i = 0; i < nums.length; i++) { if (nums[i] == 1) { curr++; if (curr > ans) ans = curr; } else { curr = 0; } } return ans; }
public int sample_funcname ( int [ ] var_0 ) { int var_1 = 0 ; int var_2 = 0 ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { if ( var_0 [ var_3 ] == 1 ) { var_2 ++ ; if ( var_2 > var_1 ) var_1 = var_2 ; } else { var_2 = 0 ; } } return var_1 ; }
2
0<SEP>1
51
<qiyuangong>400_Nth_Digit_1.java
public int findNthDigit(int n) { int len = 1; long count = 9; int start = 1; while (n > len * count) { n -= len * count; len += 1; count *= 10; start *= 10; } start += (n - 1) / len; String s = Integer.toString(start); return Character.getNumericValue(s.charAt((n - 1) % len)); }
public int sample_funcname ( int var_0 ) { int var_1 = 1 ; long var_2 = 9 ; int var_3 = 1 ; while ( var_0 > var_1 * var_2 ) { var_0 -= var_1 * var_2 ; var_1 += 1 ; var_2 *= 10 ; var_3 *= 10 ; } var_3 += ( var_0 - 1 ) / var_1 ; String var_4 = Integer . toString ( var_3 ) ; return Character . getNumericValue ( var_4 . charAt ( ( var_0 - 1 ) % var_1 ) ) ; }
3
10<SEP>1<SEP>9
52
<qiyuangong>954_Array_of_Doubled_Pairs_1.java
public boolean canReorderDoubled(int[] A) { HashMap<Integer, Integer> valueMap = new HashMap<>(); A = Arrays.stream(A). boxed(). sorted((a, b) -> Integer.compare(Math.abs(a), Math.abs(b))). mapToInt(i -> i). toArray(); for (int n: A) valueMap.put(n, valueMap.getOrDefault(n, 0) + 1); for (int n: A) { if (valueMap.get(n) <= 0) continue; if (valueMap.containsKey(2 * n) && valueMap.get(2 * n) > 0) { valueMap.put(n, valueMap.get(n) - 1); valueMap.put(2 * n, valueMap.get(2 * n) - 1); } else { return false; } } return true; }
public boolean var_0 ( int [ ] var_1 ) { HashMap < Integer , Integer > var_2 = new HashMap < > ( ) ; var_1 = Arrays . stream ( var_1 ) . boxed ( ) . sorted ( ( var_5 , var_3 ) -> Integer . compare ( Math . abs ( var_5 ) , Math . abs ( var_3 ) ) ) . mapToInt ( var_4 -> var_4 ) . toArray ( ) ; for ( int var_6 : var_1 ) var_2 . put ( var_6 , var_2 . getOrDefault ( var_6 , 0 ) + 1 ) ; for ( int var_6 : var_1 ) { if ( var_2 . get ( var_6 ) <= 0 ) continue ; if ( var_2 . containsKey ( 2 * var_6 ) && var_2 . get ( 2 * var_6 ) > 0 ) { var_2 . put ( var_6 , var_2 . get ( var_6 ) - 1 ) ; var_2 . put ( 2 * var_6 , var_2 . get ( 2 * var_6 ) - 1 ) ; } else { return false ; } } return true ; }
3
2<SEP>0<SEP>1
53
<qiyuangong>697_Degree_of_an_Array_1.java
public int findShortestSubArray(int[] nums) { Map<Integer, Integer> left = new HashMap(), right = new HashMap(), count = new HashMap(); for (int i = 0; i < nums.length; i++) { int x = nums[i]; if (left.get(x) == null) left.put(x, i); right.put(x, i); count.put(x, count.getOrDefault(x, 0) + 1); } int ans = nums.length; int degree = Collections.max(count.values()); for (int x: count.keySet()) { if (count.get(x) == degree) { ans = Math.min(ans, right.get(x) - left.get(x) + 1); } } return ans; }
public int sample_funcname ( int [ ] var_0 ) { Map < Integer , Integer > var_1 = new HashMap ( ) , var_2 = new HashMap ( ) , var_3 = new HashMap ( ) ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { int var_5 = var_0 [ var_4 ] ; if ( var_1 . get ( var_5 ) == null ) var_1 . put ( var_5 , var_4 ) ; var_2 . put ( var_5 , var_4 ) ; var_3 . put ( var_5 , var_3 . getOrDefault ( var_5 , 0 ) + 1 ) ; } int var_6 = var_0 . length ; int var_7 = Collections . max ( var_3 . values ( ) ) ; for ( int var_5 : var_3 . keySet ( ) ) { if ( var_3 . get ( var_5 ) == var_7 ) { var_6 = Math . min ( var_6 , var_2 . get ( var_5 ) - var_1 . get ( var_5 ) + 1 ) ; } } return var_6 ; }
2
0<SEP>1
54
<qiyuangong>268_Missing_Number_1.java
public int missingNumber(int[] nums) { int res = nums.length; for (int i = 0; i < nums.length; i++) { res ^= i; res ^= nums[i]; } return res; }
public int sample_funcname ( int [ ] var_0 ) { int var_1 = var_0 . length ; for ( int var_2 = 0 ; var_2 < var_0 . length ; var_2 ++ ) { var_1 ^= var_2 ; var_1 ^= var_0 [ var_2 ] ; } return var_1 ; }
1
0
55
<qiyuangong>605_Can_Place_Flowers_1.java
public boolean canPlaceFlowers(int[] flowerbed, int n) { int i = 0, count = 0; while (i < flowerbed.length) { if (flowerbed[i] == 0 && (i == 0 || flowerbed[i - 1] == 0) && (i == flowerbed.length - 1 || flowerbed[i + 1] == 0)) { flowerbed[i++] = 1; count++; } if(count >= n) return true; i++; } return false; }
public boolean var_0 ( int [ ] var_1 , int var_2 ) { int var_3 = 0 , var_4 = 0 ; while ( var_3 < var_1 . length ) { if ( var_1 [ var_3 ] == 0 && ( var_3 == 0 || var_1 [ var_3 - 1 ] == 0 ) && ( var_3 == var_1 . length - 1 || var_1 [ var_3 + 1 ] == 0 ) ) { var_1 [ var_3 ++ ] = 1 ; var_4 ++ ; } if ( var_4 >= var_2 ) return true ; var_3 ++ ; } return false ; }
2
0<SEP>1
56
<qiyuangong>867_Transpose_Matrix_1.java
public int[][] transpose(int[][] A) { int R = A.length, C = A[0].length; int[][] ans = new int[C][R]; for (int r = 0; r < R; ++r) for (int c = 0; c < C; ++c) { ans[c][r] = A[r][c]; } return ans; }
public int [ ] [ ] sample_funcname ( int [ ] [ ] var_0 ) { int var_1 = var_0 . length , var_2 = var_0 [ 0 ] . length ; int [ ] [ ] var_3 = new int [ var_2 ] [ var_1 ] ; 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_5 ] [ var_4 ] = var_0 [ var_4 ] [ var_5 ] ; } return var_3 ; }
1
0
57
<qiyuangong>946_Validate_Stack_Sequences_1.java
public boolean validateStackSequences(int[] pushed, int[] popped) { Stack<Integer> inStack = new Stack<>(); int posPush = 0, posPop = 0; while (posPush != pushed.length) { int curr = pushed[posPush]; while (!inStack.empty() && popped.length > 0 && inStack.peek() == popped[posPop]) { inStack.pop(); posPop++; } if (popped.length == 0) break; if (curr == popped[posPop]) posPop++; else inStack.push(curr); posPush++; } while (!inStack.empty() && popped.length > 0 && inStack.peek() == popped[posPop]) { inStack.pop(); posPop++; } if (inStack.empty()) return true; return false; }
public boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { Stack < Integer > var_3 = new Stack < > ( ) ; int var_4 = 0 , var_5 = 0 ; while ( var_4 != var_1 . length ) { int var_6 = var_1 [ var_4 ] ; while ( ! var_3 . empty ( ) && var_2 . length > 0 && var_3 . peek ( ) == var_2 [ var_5 ] ) { var_3 . pop ( ) ; var_5 ++ ; } if ( var_2 . length == 0 ) break ; if ( var_6 == var_2 [ var_5 ] ) var_5 ++ ; else var_3 . push ( var_6 ) ; var_4 ++ ; } while ( ! var_3 . empty ( ) && var_2 . length > 0 && var_3 . peek ( ) == var_2 [ var_5 ] ) { var_3 . pop ( ) ; var_5 ++ ; } if ( var_3 . empty ( ) ) return true ; return false ; }
1
0
58
<qiyuangong>1337_The_K_Weakest_Rows_in_a_Matrix_1.java
public int[] kWeakestRows(int[][] mat, int k) { List<Integer> res = new ArrayList<>(); int col = 0; boolean flag = true; while (col < mat[0].length && flag) { for (int i = 0; i < mat.length; i++) { if (res.contains(i)) continue; if (mat[i][col] == 0) res.add(i); if (res.size() == k) { flag = false; break; } } col += 1; } if (flag) { for (int i = 0; i < mat.length; i++) { if (res.contains(i)) continue; res.add(i); if (res.size() == k) break; } } int[] ret = new int[k]; for (int i = 0; i < k; i++) ret[i] = res.get(i); return ret; }
public int [ ] sample_funcname ( int [ ] [ ] var_0 , int var_1 ) { List < Integer > var_2 = new ArrayList < > ( ) ; int var_3 = 0 ; boolean var_4 = true ; while ( var_3 < var_0 [ 0 ] . length && var_4 ) { for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { if ( var_2 . contains ( var_5 ) ) continue ; if ( var_0 [ var_5 ] [ var_3 ] == 0 ) var_2 . add ( var_5 ) ; if ( var_2 . size ( ) == var_1 ) { var_4 = false ; break ; } } var_3 += 1 ; } if ( var_4 ) { for ( int var_5 = 0 ; var_5 < var_0 . length ; var_5 ++ ) { if ( var_2 . contains ( var_5 ) ) continue ; var_2 . add ( var_5 ) ; if ( var_2 . size ( ) == var_1 ) break ; } } int [ ] var_6 = new int [ var_1 ] ; for ( int var_5 = 0 ; var_5 < var_1 ; var_5 ++ ) var_6 [ var_5 ] = var_2 . get ( var_5 ) ; return var_6 ; }
2
0<SEP>1
59
<qiyuangong>844_Backspace_String_Compare_1.java
public boolean backspaceCompare(String S, String T) { int i = S.length() - 1, j = T.length() - 1; while (true) { for (int back = 0; i >= 0 && (back > 0 || S.charAt(i) == '#'); --i) back += S.charAt(i) == '#' ? 1 : -1; for (int back = 0; j >= 0 && (back > 0 || T.charAt(j) == '#'); --j) back += T.charAt(j) == '#' ? 1 : -1; if (i >= 0 && j >= 0 && S.charAt(i) == T.charAt(j)) { i--; j--; } else return i == -1 && j == -1; } }
public boolean var_0 ( String var_1 , String var_2 ) { int var_3 = var_1 . length ( ) - 1 , var_4 = var_2 . length ( ) - 1 ; while ( true ) { for ( int var_5 = 0 ; var_3 >= 0 && ( var_5 > 0 || var_1 . charAt ( var_3 ) == '#' ) ; -- var_3 ) var_5 += var_1 . charAt ( var_3 ) == '#' ? 1 : - 1 ; for ( int var_5 = 0 ; var_4 >= 0 && ( var_5 > 0 || var_2 . charAt ( var_4 ) == '#' ) ; -- var_4 ) var_5 += var_2 . charAt ( var_4 ) == '#' ? 1 : - 1 ; if ( var_3 >= 0 && var_4 >= 0 && var_1 . charAt ( var_3 ) == var_2 . charAt ( var_4 ) ) { var_3 -- ; var_4 -- ; } else return var_3 == - 1 && var_4 == - 1 ; } }
3
<S_QUOTE>#<S_QUOTE><SEP>1<SEP>0
60
<qiyuangong>751_IP_to_CIDR_2.java
private String longToIP(long x) { return String.format("%s.%s.%s.%s", x >> 24, (x >> 16) % 256, (x >> 8) % 256, x % 256); }
private String var_0 ( long var_1 ) { return String . format ( "%s.%s.%s.%s" , var_1 >> 24 , ( var_1 >> 16 ) % 256 , ( var_1 >> 8 ) % 256 , var_1 % 256 ) ; }
5
16<SEP>24<SEP>8<SEP><D_QUOTE>%s.%s.%s.%s<D_QUOTE><SEP>256
61
<qiyuangong>409_Longest_Palindrome_1.java
public int longestPalindrome(String s) { int[] count = new int[128]; for (char c: s.toCharArray()) count[c]++; int ans = 0; for (int v: count) { ans += v / 2 * 2; if (ans % 2 == 0 && v % 2 == 1) ans++; } return ans; }
public int sample_funcname ( String var_0 ) { int [ ] var_1 = new int [ 128 ] ; for ( char var_2 : var_0 . toCharArray ( ) ) var_1 [ var_2 ] ++ ; int var_3 = 0 ; for ( int var_4 : var_1 ) { var_3 += var_4 / 2 * 2 ; if ( var_3 % 2 == 0 && var_4 % 2 == 1 ) var_3 ++ ; } return var_3 ; }
4
128<SEP>0<SEP>1<SEP>2
62
<qiyuangong>463_Island_Perimeter_1.java
public int islandPerimeter(int[][] grid) { int islands = 0, neighbours = 0; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[i].length; j++) { if (grid[i][j] == 1) { islands++; // count islands if (i < grid.length - 1 && grid[i + 1][j] == 1) neighbours++; // count down neighbours if (j < grid[i].length - 1 && grid[i][j + 1] == 1) neighbours++; // count right neighbours } } } return islands * 4 - neighbours * 2; }
public int sample_funcname ( int [ ] [ ] var_0 ) { int var_1 = 0 , var_2 = 0 ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { for ( int var_4 = 0 ; var_4 < var_0 [ var_3 ] . length ; var_4 ++ ) { if ( var_0 [ var_3 ] [ var_4 ] == 1 ) { var_1 ++ ; if ( var_3 < var_0 . length - 1 && var_0 [ var_3 + 1 ] [ var_4 ] == 1 ) var_2 ++ ; if ( var_4 < var_0 [ var_3 ] . length - 1 && var_0 [ var_3 ] [ var_4 + 1 ] == 1 ) var_2 ++ ; } } } return var_1 * 4 - var_2 * 2 ; }
4
4<SEP>2<SEP>0<SEP>1
63
<qiyuangong>836_Rectangle_Overlap_1.java
public boolean isRectangleOverlap(int[] rec1, int[] rec2) { return !(rec1[2] <= rec2[0] || // left rec1[3] <= rec2[1] || // bottom rec1[0] >= rec2[2] || // right rec1[1] >= rec2[3]); // top }
public boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { return ! ( var_1 [ 2 ] <= var_2 [ 0 ] || var_1 [ 3 ] <= var_2 [ 1 ] || var_1 [ 0 ] >= var_2 [ 2 ] || var_1 [ 1 ] >= var_2 [ 3 ] ) ; }
4
0<SEP>3<SEP>1<SEP>2
64
<qiyuangong>905_Sort_Array_By_Parity_1.java
public int[] sortArrayByParity(int[] A) { int[] ans = new int[A.length]; int pos = 0; for (int num: A) if (num % 2 == 0) ans[pos++] = num; for (int num: A) if (num % 2 == 1) ans[pos++] = num; return ans; }
public int [ ] sample_funcname ( int [ ] var_0 ) { int [ ] var_1 = new int [ var_0 . length ] ; int var_2 = 0 ; for ( int var_3 : var_0 ) if ( var_3 % 2 == 0 ) var_1 [ var_2 ++ ] = var_3 ; for ( int var_3 : var_0 ) if ( var_3 % 2 == 1 ) var_1 [ var_2 ++ ] = var_3 ; return var_1 ; }
3
0<SEP>1<SEP>2
65
<qiyuangong>695_Max_Area_of_Island_1.java
public int maxAreaOfIsland(int[][] grid) { int[] dr = new int[]{1, -1, 0, 0}; int[] dc = new int[]{0, 0, 1, -1}; int ans = 0; for (int r0 = 0; r0 < grid.length; r0++) { for (int c0 = 0; c0 < grid[0].length; c0++) { if (grid[r0][c0] == 1) { int shape = 0; Stack<int[]> stack = new Stack(); stack.push(new int[]{r0, c0}); grid[r0][c0] = 0; while (!stack.empty()) { int[] node = stack.pop(); int r = node[0], c = node[1]; shape++; for (int k = 0; k < 4; k++) { int nr = r + dr[k]; int nc = c + dc[k]; if (0 <= nr && nr < grid.length && 0 <= nc && nc < grid[0].length && grid[nr][nc] == 1) { stack.push(new int[]{nr, nc}); grid[nr][nc] = 0; } } } ans = Math.max(ans, shape); } } } return ans; }
public int sample_funcname ( int [ ] [ ] var_0 ) { int [ ] var_1 = new int [ ] { 1 , - 1 , 0 , 0 }; int [ ] var_2 = new int [ ] { 0 , 0 , 1 , - 1 }; int var_3 = 0 ; for ( int var_4 = 0 ; var_4 < var_0 . length ; var_4 ++ ) { for ( int var_5 = 0 ; var_5 < var_0 [ 0 ] . length ; var_5 ++ ) { if ( var_0 [ var_4 ] [ var_5 ] == 1 ) { int var_6 = 0 ; Stack < int [ ] > var_7 = new Stack ( ) ; var_7 . push ( new int [ ] { var_4 , var_5 } ) ; var_0 [ var_4 ] [ var_5 ] = 0 ; while ( ! var_7 . empty ( ) ) { int [ ] var_8 = var_7 . pop ( ) ; int var_9 = var_8 [ 0 ] , var_10 = var_8 [ 1 ] ; var_6 ++ ; for ( int var_11 = 0 ; var_11 < 4 ; var_11 ++ ) { int var_12 = var_9 + var_1 [ var_11 ] ; int var_13 = var_10 + var_2 [ var_11 ] ; if ( 0 <= var_12 && var_12 < var_0 . length && 0 <= var_13 && var_13 < var_0 [ 0 ] . length && var_0 [ var_12 ] [ var_13 ] == 1 ) { var_7 . push ( new int [ ] { var_12 , var_13 } ) ; var_0 [ var_12 ] [ var_13 ] = 0 ; } } } var_3 = Math . max ( var_3 , var_6 ) ; } } } return var_3 ; }
3
4<SEP>1<SEP>0
66
<qiyuangong>453_Minimum_Moves_to_Equal_Array_Elements_1.java
public int minMoves(int[] nums) { if (nums.length == 0) return 0; Arrays.sort(nums); int min_num = nums[0]; int ans = 0; for (int num : nums) { ans += num - min_num; } return ans; }
public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; Arrays . sort ( var_0 ) ; int var_1 = var_0 [ 0 ] ; int var_2 = 0 ; for ( int var_3 : var_0 ) { var_2 += var_3 - var_1 ; } return var_2 ; }
1
0
67
<qiyuangong>922_Sort_Array_By_Parity_II_1.java
public int[] sortArrayByParityII(int[] A) { int N = A.length; int[] ans = new int[N]; int t = 0; for (int x: A) if (x % 2 == 0) { ans[t] = x; t += 2; } t = 1; for (int x: A) if (x % 2 == 1) { ans[t] = x; t += 2; } return ans; }
public int [ ] sample_funcname ( int [ ] var_0 ) { int var_1 = var_0 . length ; int [ ] var_2 = new int [ var_1 ] ; int var_3 = 0 ; for ( int var_4 : var_0 ) if ( var_4 % 2 == 0 ) { var_2 [ var_3 ] = var_4 ; var_3 += 2 ; } var_3 = 1 ; for ( int var_4 : var_0 ) if ( var_4 % 2 == 1 ) { var_2 [ var_3 ] = var_4 ; var_3 += 2 ; } return var_2 ; }
3
0<SEP>1<SEP>2
68
<qiyuangong>482_License_Key_Formatting_1.java
public String licenseKeyFormatting(String s, int k) { StringBuilder sb = new StringBuilder(); for (int i = s.length() - 1; i >= 0; i--) if (s.charAt(i) != '-') sb.append(sb.length() % (k + 1) == k ? '-' : "").append(s.charAt(i)); return sb.reverse().toString().toUpperCase(); }
public String var_0 ( String var_1 , int var_2 ) { StringBuilder var_3 = new StringBuilder ( ) ; for ( int var_4 = var_1 . length ( ) - 1 ; var_4 >= 0 ; var_4 -- ) if ( var_1 . charAt ( var_4 ) != '-' ) var_3 . append ( var_3 . length ( ) % ( var_2 + 1 ) == var_2 ? '-' : "" ) . append ( var_1 . charAt ( var_4 ) ) ; return var_3 . reverse ( ) . toString ( ) . toUpperCase ( ) ; }
4
<D_QUOTE><D_QUOTE><SEP>1<SEP>0<SEP><S_QUOTE>-<S_QUOTE>
69
<qiyuangong>1260_Shift_2D_Grid_1.java
public List<List<Integer>> shiftGrid(int[][] grid, int k) { int[][] newGrid = new int[grid.length][grid[0].length]; int m = grid.length; int n = grid[0].length; int true_k = k % (m * n); int move_i = true_k / n; int move_j = true_k % n; for (int i = 0; i < grid.length; i++) { for (int j = 0; j < grid[i].length; j++) { int new_i = i + move_i; int new_j = (j + move_j) % n; if (move_j + j >= n) new_i ++; new_i %= m; newGrid[new_i][new_j] = grid[i][j]; } } List<List<Integer>> result = new ArrayList<>(); for (int[] row : newGrid) { List<Integer> listRow = new ArrayList<>(); result.add(listRow); for (int v : row) listRow.add(v); } return result; }
public List < List < Integer >> var_0 ( int [ ] [ ] var_1 , int var_2 ) { int [ ] [ ] var_3 = new int [ var_1 . length ] [ var_1 [ 0 ] . length ] ; int var_4 = var_1 . length ; int var_5 = var_1 [ 0 ] . length ; int var_6 = var_2 % ( var_4 * var_5 ) ; int var_7 = var_6 / var_5 ; int var_8 = var_6 % var_5 ; for ( int var_9 = 0 ; var_9 < var_1 . length ; var_9 ++ ) { for ( int var_10 = 0 ; var_10 < var_1 [ var_9 ] . length ; var_10 ++ ) { int var_11 = var_9 + var_7 ; int var_12 = ( var_10 + var_8 ) % var_5 ; if ( var_8 + var_10 >= var_5 ) var_11 ++ ; var_11 %= var_4 ; var_3 [ var_11 ] [ var_12 ] = var_1 [ var_9 ] [ var_10 ] ; } } List < List < Integer >> var_13 = new ArrayList < > ( ) ; for ( int [ ] var_14 : var_3 ) { List < Integer > var_15 = new ArrayList < > ( ) ; var_13 . add ( var_15 ) ; for ( int var_16 : var_14 ) var_15 . add ( var_16 ) ; } return var_13 ; }
1
0
70
<qiyuangong>836_Rectangle_Overlap_2.java
public boolean isRectangleOverlap(int[] rec1, int[] rec2) { int left = Math.max(rec1[0], rec2[0]), right = Math.max(Math.min(rec1[2], rec2[2]), left); int bottom = Math.max(rec1[1], rec2[1]), top = Math.max(Math.min(rec1[3], rec2[3]), bottom); return (right - left) * (top - bottom) != 0; }
public boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { int var_3 = Math . max ( var_1 [ 0 ] , var_2 [ 0 ] ) , var_4 = Math . max ( Math . min ( var_1 [ 2 ] , var_2 [ 2 ] ) , var_3 ) ; int var_5 = Math . max ( var_1 [ 1 ] , var_2 [ 1 ] ) , var_6 = Math . max ( Math . min ( var_1 [ 3 ] , var_2 [ 3 ] ) , var_5 ) ; return ( var_4 - var_3 ) * ( var_6 - var_5 ) != 0 ; }
4
0<SEP>3<SEP>1<SEP>2
71
<qiyuangong>905_Sort_Array_By_Parity_2.java
public int[] sortArrayByParity(int[] A) { int lo = 0, hi = A.length - 1; while (lo < hi) { if (A[lo] % 2 > A[hi] % 2) { int tmp = A[hi]; A[hi] = A[lo]; A[lo] = tmp; } if (A[lo] % 2 == 0) lo++; if (A[hi] % 2 == 1) hi--; } return A; }
public int [ ] sample_funcname ( int [ ] var_0 ) { int var_1 = 0 , var_2 = var_0 . length - 1 ; while ( var_1 < var_2 ) { if ( var_0 [ var_1 ] % 2 > var_0 [ var_2 ] % 2 ) { int var_3 = var_0 [ var_2 ] ; var_0 [ var_2 ] = var_0 [ var_1 ] ; var_0 [ var_1 ] = var_3 ; } if ( var_0 [ var_1 ] % 2 == 0 ) var_1 ++ ; if ( var_0 [ var_2 ] % 2 == 1 ) var_2 -- ; } return var_0 ; }
3
2<SEP>0<SEP>1
72
<qiyuangong>922_Sort_Array_By_Parity_II_2.java
public int[] sortArrayByParityII(int[] A) { int j = 1; for (int i = 0; i < A.length; i += 2) if (A[i] % 2 == 1) { while (A[j] % 2 == 1) j += 2; int tmp = A[i]; A[i] = A[j]; A[j] = tmp; } return A; }
public int [ ] sample_funcname ( int [ ] var_0 ) { int var_1 = 1 ; for ( int var_2 = 0 ; var_2 < var_0 . length ; var_2 += 2 ) if ( var_0 [ var_2 ] % 2 == 1 ) { while ( var_0 [ var_1 ] % 2 == 1 ) var_1 += 2 ; int var_3 = var_0 [ var_2 ] ; var_0 [ var_2 ] = var_0 [ var_1 ] ; var_0 [ var_1 ] = var_3 ; } return var_0 ; }
3
1<SEP>0<SEP>2
73
<qiyuangong>868_Binary_Gap_1.java
public int binaryGap(int N) { int last = -1, ans = 0; for (int i = 0; i < 32; ++i) if (((N >> i) & 1) > 0) { if (last >= 0) ans = Math.max(ans, i - last); last = i; } return ans; }
public int sample_funcname ( int var_0 ) { int var_1 = - 1 , var_2 = 0 ; for ( int var_3 = 0 ; var_3 < 32 ; ++ var_3 ) if ( ( ( var_0 >> var_3 ) & 1 ) > 0 ) { if ( var_1 >= 0 ) var_2 = Math . max ( var_2 , var_3 - var_1 ) ; var_1 = var_3 ; } return var_2 ; }
3
1<SEP>0<SEP>32
74
<qiyuangong>605_Can_Place_Flowers_2.java
public boolean canPlaceFlowers(int[] flowerbed, int n) { int count = 0, curr; for (int i = 0; i < flowerbed.length; i++) { curr = flowerbed[i]; if (i - 1 >= 0) curr += flowerbed[i - 1]; if (i + 1 < flowerbed.length) curr += flowerbed[i + 1]; if (curr == 0) { count++; flowerbed[i] = 1; } if (count >= n) return true; } return false; }
public boolean var_0 ( int [ ] var_1 , int var_2 ) { int var_3 = 0 , var_4 ; for ( int var_5 = 0 ; var_5 < var_1 . length ; var_5 ++ ) { var_4 = var_1 [ var_5 ] ; if ( var_5 - 1 >= 0 ) var_4 += var_1 [ var_5 - 1 ] ; if ( var_5 + 1 < var_1 . length ) var_4 += var_1 [ var_5 + 1 ] ; if ( var_4 == 0 ) { var_3 ++ ; var_1 [ var_5 ] = 1 ; } if ( var_3 >= var_2 ) return true ; } return false ; }
2
0<SEP>1
75
<qiyuangong>389_Find_the_Difference_1.java
public char findTheDifference(String s, String t) { int total = t.charAt(s.length()); for (int i = 0; i < s.length(); i++) total += (t.charAt(i) - s.charAt(i)); return (char) total; }
public char sample_funcname ( String var_0 , String var_1 ) { int var_2 = var_1 . charAt ( var_0 . length ( ) ) ; for ( int var_3 = 0 ; var_3 < var_0 . length ( ) ; var_3 ++ ) var_2 += ( var_1 . charAt ( var_3 ) - var_0 . charAt ( var_3 ) ) ; return ( char ) var_2 ; }
1
0
76
<qiyuangong>401_Binary_Watch_1.java
public List<String> readBinaryWatch(int num) { List<String> times = new ArrayList<>(); for (int h = 0; h < 12; h++) for (int m = 0; m < 60; m++) if (Integer.bitCount(h * 64 + m) == num) times.add(String.format("%d:%02d", h, m)); return times; }
public List < String > var_0 ( int var_1 ) { List < String > var_2 = new ArrayList < > ( ) ; for ( int var_3 = 0 ; var_3 < 12 ; var_3 ++ ) for ( int var_4 = 0 ; var_4 < 60 ; var_4 ++ ) if ( Integer . bitCount ( var_3 * 64 + var_4 ) == var_1 ) var_2 . add ( String . format ( "%d:%02d" , var_3 , var_4 ) ) ; return var_2 ; }
5
<D_QUOTE>%d:%02d<D_QUOTE><SEP>0<SEP>60<SEP>12<SEP>64
77
<qiyuangong>383_Ransom_Note_1.java
public boolean canConstruct(String ransomNote, String magazine) { int[] table = new int[128]; for (char c : magazine.toCharArray()) table[c]++; for (char c : ransomNote.toCharArray()) if (--table[c] < 0) return false; return true; }
public boolean var_0 ( String var_1 , String var_2 ) { int [ ] var_3 = new int [ 128 ] ; for ( char var_4 : var_2 . toCharArray ( ) ) var_3 [ var_4 ] ++ ; for ( char var_4 : var_1 . toCharArray ( ) ) if ( -- var_3 [ var_4 ] < 0 ) return false ; return true ; }
2
128<SEP>0
78
<qiyuangong>844_Backspace_String_Compare_2.java
private String trans(String str) { StringBuilder sb = new StringBuilder(); for (char c : str.toCharArray()) { if (c != '#') { sb.append(c); } // if not '#', append it at the end of sb. else if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } // remove last char in sb, if sb is not empty. } return sb.toString(); }
private String var_0 ( String var_1 ) { StringBuilder var_2 = new StringBuilder ( ) ; for ( char var_3 : var_1 . toCharArray ( ) ) { if ( var_3 != '#' ) { var_2 . append ( var_3 ) ; } else if ( var_2 . length ( ) > 0 ) { var_2 . deleteCharAt ( var_2 . length ( ) - 1 ) ; } } return var_2 . toString ( ) ; }
3
<S_QUOTE>#<S_QUOTE><SEP>0<SEP>1
79
<qiyuangong>751_IP_to_CIDR_1.java
private long ipToLong(String ip) { long ans = 0; for (String x: ip.split("\\.")) { ans = 256 * ans + Integer.valueOf(x); } return ans; }
private long sample_funcname ( String var_0 ) { long var_1 = 0 ; for ( String var_2 : var_0 . split ( "\\." ) ) { var_1 = 256 * var_1 + Integer . valueOf ( var_2 ) ; } return var_1 ; }
3
<D_QUOTE>\\.<D_QUOTE><SEP>0<SEP>256
80
<qiyuangong>1310_XOR_Queries_of_a_Subarray_1.java
public int[] xorQueries(int[] arr, int[][] queries) { int[] res = new int[queries.length], q; for (int i = 1; i < arr.length; i++) arr[i] ^= arr[i - 1]; for (int i = 0; i < queries.length; i++) { q = queries[i]; res[i] = q[0] > 0 ? arr[q[0] - 1] ^ arr[q[1]] : arr[q[1]]; } return res; }
public int [ ] sample_funcname ( int [ ] var_0 , int [ ] [ ] var_1 ) { int [ ] var_2 = new int [ var_1 . length ] , var_3 ; for ( int var_4 = 1 ; var_4 < var_0 . length ; var_4 ++ ) var_0 [ var_4 ] ^= var_0 [ var_4 - 1 ] ; for ( int var_4 = 0 ; var_4 < var_1 . length ; var_4 ++ ) { var_3 = var_1 [ var_4 ] ; var_2 [ var_4 ] = var_3 [ 0 ] > 0 ? var_0 [ var_3 [ 0 ] - 1 ] ^ var_0 [ var_3 [ 1 ] ] : var_0 [ var_3 [ 1 ] ] ; } return var_2 ; }
2
1<SEP>0
81
<qiyuangong>443_String_Compression_1.java
public int compress(char[] chars) { int anchor = 0, write = 0; for (int read = 0; read < chars.length; read++) { if (read + 1 == chars.length || chars[read + 1] != chars[read]) { chars[write++] = chars[anchor]; if (read > anchor) { for (char c: ("" + (read - anchor + 1)).toCharArray()) { chars[write++] = c; } } anchor = read + 1; } } return write; }
public int sample_funcname ( char [ ] var_0 ) { int var_1 = 0 , var_2 = 0 ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { if ( var_3 + 1 == var_0 . length || var_0 [ var_3 + 1 ] != var_0 [ var_3 ] ) { var_0 [ var_2 ++ ] = var_0 [ var_1 ] ; if ( var_3 > var_1 ) { for ( char var_4 : ( "" + ( var_3 - var_1 + 1 ) ) . toCharArray ( ) ) { var_0 [ var_2 ++ ] = var_4 ; } } var_1 = var_3 + 1 ; } } return var_2 ; }
3
0<SEP><D_QUOTE><D_QUOTE><SEP>1
82
<qiyuangong>557_Reverse_Words_in_a_String_III_1.java
public String reverseWords(String s) { String words[] = s.split(" "); StringBuilder ans = new StringBuilder(); for (String word: words) ans.append(new StringBuffer(word).reverse().toString() + " "); return ans.toString().trim(); }
public String var_0 ( String var_1 ) { String var_2 [ ] = var_1 . split ( " " ) ; StringBuilder var_3 = new StringBuilder ( ) ; for ( String var_4 : var_2 ) var_3 . append ( new StringBuffer ( var_4 ) . reverse ( ) . toString ( ) + " " ) ; return var_3 . toString ( ) . trim ( ) ; }
1
<D_QUOTE> <D_QUOTE>
83
<qiyuangong>509_Fibonacci_Number_1.java
public int fib(int N) { if (N == 0) return 0; if (N == 1) return 1; return fib(N - 1) + fib(N - 2); }
public int sample_funcname ( int N ) { if ( N == 0 ) return 0 ; if ( N == 1 ) return 1 ; return fib ( N - 1 ) + fib ( N - 2 ) ; }
3
2<SEP>0<SEP>1
84
<qiyuangong>628_Maximum_Product_of_Three_Numbers_1.java
public int maximumProduct(int[] nums) { Arrays.sort(nums); return Math.max(nums[0] * nums[1] * nums[nums.length - 1], nums[nums.length - 1] * nums[nums.length - 2] * nums[nums.length - 3]); }
public int sample_funcname ( int [ ] var_0 ) { Arrays . sort ( var_0 ) ; return Math . max ( var_0 [ 0 ] * var_0 [ 1 ] * var_0 [ var_0 . length - 1 ] , var_0 [ var_0 . length - 1 ] * var_0 [ var_0 . length - 2 ] * var_0 [ var_0 . length - 3 ] ) ; }
4
2<SEP>0<SEP>3<SEP>1
85
<qiyuangong>367_Valid_Perfect_Square_1.java
public boolean isPerfectSquare(int num) { int low = 1; int high = num; while (low <= high) { long mid = (low + high) >>> 1; if (mid * mid == num) { return true; } else if (mid * mid < num) { low = (int) mid + 1; } else { high = (int) mid - 1; } } return false; }
public boolean var_0 ( int var_1 ) { int var_2 = 1 ; int var_3 = var_1 ; while ( var_2 <= var_3 ) { long var_4 = ( var_2 + var_3 ) >>> 1 ; if ( var_4 * var_4 == var_1 ) { return true ; } else if ( var_4 * var_4 < var_1 ) { var_2 = ( int ) var_4 + 1 ; } else { var_3 = ( int ) var_4 - 1 ; } } return false ; }
1
1
86
<qiyuangong>832_Flipping_an_Image_1.java
public int[][] flipAndInvertImage(int[][] A) { int C = A[0].length; for (int[] row: A) for (int i = 0; i < (C + 1) / 2; ++i) { int tmp = row[i] ^ 1; row[i] = row[C - 1 - i] ^ 1; row[C - 1 - i] = tmp; } return A; }
public int [ ] [ ] sample_funcname ( int [ ] [ ] var_0 ) { int var_1 = var_0 [ 0 ] . length ; for ( int [ ] var_2 : var_0 ) for ( int var_3 = 0 ; var_3 < ( var_1 + 1 ) / 2 ; ++ var_3 ) { int var_4 = var_2 [ var_3 ] ^ 1 ; var_2 [ var_3 ] = var_2 [ var_1 - 1 - var_3 ] ^ 1 ; var_2 [ var_1 - 1 - var_3 ] = var_4 ; } return var_0 ; }
3
2<SEP>0<SEP>1
87
<qiyuangong>336_Palindrome_Pairs_1.java
private boolean isPalindrome(String word, int i, int j) { while (i < j) { if (word.charAt(i++) != word.charAt(j--)) return false; } return true; }
private boolean var_0 ( String var_1 , int var_2 , int var_3 ) { while ( var_2 < var_3 ) { if ( var_1 . charAt ( var_2 ++ ) != var_1 . charAt ( var_3 -- ) ) return false ; } return true ; }
0
null
88
<qiyuangong>962_Maximum_Width_Ramp_2.java
public int maxWidthRamp(int[] A) { int N = A.length; int ans = 0; List<Point> candidates = new ArrayList(); candidates.add(new Point(A[N-1], N-1)); for (int i = N-2; i >= 0; --i) { int lo = 0, hi = candidates.size(); while (lo < hi) { int mi = lo + (hi - lo) / 2; if (candidates.get(mi).x < A[i]) lo = mi + 1; else hi = mi; } if (lo < candidates.size()) { int j = candidates.get(lo).y; ans = Math.max(ans, j - i); } else { candidates.add(new Point(A[i], i)); } } return ans; }
public int sample_funcname ( int [ ] A ) { int N = A . length ; int ans = 0 ; List < Point > candidates = new ArrayList ( ) ; candidates . add ( new Point ( A [ N - 1 ] , N - 1 ) ) ; for ( int i = N - 2 ; i >= 0 ; -- i ) { int lo = 0 , hi = candidates . size ( ) ; while ( lo < hi ) { int mi = lo + ( hi - lo ) / 2 ; if ( candidates . get ( mi ) . x < A [ i ] ) lo = mi + 1 ; else hi = mi ; } if ( lo < candidates . size ( ) ) { int j = candidates . get ( lo ) . y ; ans = Math . max ( ans , j - i ) ; } else { candidates . add ( new Point ( A [ i ] , i ) ) ; } } return ans ; }
3
2<SEP>0<SEP>1
89
<qiyuangong>674_Longest_Continuous_Increasing_Subsequence_1.java
public int findLengthOfLCIS(int[] nums) { if (nums.length == 0) return 0; int curr = 1, ans = 1; for (int i = 0; i < nums.length - 1; i++) { if (nums[i] < nums[i + 1]) { curr ++; if (curr >= ans) ans = curr; } else { curr = 1; } } return ans; }
public int sample_funcname ( int [ ] var_0 ) { if ( var_0 . length == 0 ) return 0 ; int var_1 = 1 , var_2 = 1 ; for ( int var_3 = 0 ; var_3 < var_0 . length - 1 ; var_3 ++ ) { if ( var_0 [ var_3 ] < var_0 [ var_3 + 1 ] ) { var_1 ++ ; if ( var_1 >= var_2 ) var_2 = var_1 ; } else { var_1 = 1 ; } } return var_2 ; }
2
0<SEP>1
90
<qiyuangong>852_Peak_Index_in_a_Mountain_Array_1.java
public int peakIndexInMountainArray(int[] A) { int i = 0; for (; A[i] < A[i + 1]; i++); return i; }
public int sample_funcname ( int [ ] var_0 ) { int var_1 = 0 ; for ( ; var_0 [ var_1 ] < var_0 [ var_1 + 1 ] ; var_1 ++ ) ; return var_1 ; }
2
0<SEP>1
91
<qiyuangong>836_Rectangle_Overlap_3.java
public boolean isRectangleOverlap(int[] rec1, int[] rec2) { return (Math.min(rec1[2], rec2[2]) > Math.max(rec1[0], rec2[0]) && // width > 0 Math.min(rec1[3], rec2[3]) > Math.max(rec1[1], rec2[1])); // height > 0 }
public boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) { return ( Math . min ( var_1 [ 2 ] , var_2 [ 2 ] ) > Math . max ( var_1 [ 0 ] , var_2 [ 0 ] ) && Math . min ( var_1 [ 3 ] , var_2 [ 3 ] ) > Math . max ( var_1 [ 1 ] , var_2 [ 1 ] ) ) ; }
4
0<SEP>3<SEP>1<SEP>2
92
<qiyuangong>215_Kth_Largest_Element_in_an_Array_2.java
private boolean less(int v, int w) { return v < w; }
private boolean var_0 ( int var_1 , int var_2 ) { return var_1 < var_2 ; }
0
null
93
<qiyuangong>475_Heaters_1.java
public int findRadius(int[] houses, int[] heaters) { Arrays.sort(heaters); int result = Integer.MIN_VALUE; for (int house : houses) { int index = Arrays.binarySearch(heaters, house); if (index < 0) index = -(index + 1); int dist1 = index - 1 >= 0 ? house - heaters[index - 1] : Integer.MAX_VALUE; int dist2 = index < heaters.length ? heaters[index] - house : Integer.MAX_VALUE; result = Math.max(result, Math.min(dist1, dist2)); } return result; }
public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) { Arrays . sort ( var_1 ) ; int var_2 = Integer . MIN_VALUE ; for ( int var_3 : var_0 ) { int var_4 = Arrays . binarySearch ( var_1 , var_3 ) ; if ( var_4 < 0 ) var_4 = - ( var_4 + 1 ) ; int var_5 = var_4 - 1 >= 0 ? var_3 - var_1 [ var_4 - 1 ] : Integer . MAX_VALUE ; int var_6 = var_4 < var_1 . length ? var_1 [ var_4 ] - var_3 : Integer . MAX_VALUE ; var_2 = Math . max ( var_2 , Math . min ( var_5 , var_6 ) ) ; } return var_2 ; }
2
0<SEP>1
94
<qiyuangong>009_Palindrome_Number_2.java
public boolean isPalindrome(int x) { if (x < 0) return false; int div = 1; while ( x / div >= 10) { div *= 10; } while (x !=0) { int l = x / div; int r = x % 10; if (l != r) return false; x = (x % div) / 10; div /= 100; } return true; }
public boolean var_0 ( int var_1 ) { if ( var_1 < 0 ) return false ; int var_2 = 1 ; while ( var_1 / var_2 >= 10 ) { var_2 *= 10 ; } while ( var_1 != 0 ) { int var_3 = var_1 / var_2 ; int var_4 = var_1 % 10 ; if ( var_3 != var_4 ) return false ; var_1 = ( var_1 % var_2 ) / 10 ; var_2 /= 100 ; } return true ; }
4
10<SEP>0<SEP>100<SEP>1
95
<qiyuangong>717_1-bit_and_2-bit_Characters_1.java
public boolean isOneBitCharacter(int[] bits) { int pos = 0; while (pos < bits.length - 1) { pos += bits[pos] + 1; } return pos == bits.length - 1; }
public boolean var_0 ( int [ ] var_1 ) { int var_2 = 0 ; while ( var_2 < var_1 . length - 1 ) { var_2 += var_1 [ var_2 ] + 1 ; } return var_2 == var_1 . length - 1 ; }
2
0<SEP>1
96
<qiyuangong>541_Reverse_String_II_1.java
public String reverseStr(String s, int k) { char[] a = s.toCharArray(); for (int start = 0; start < a.length; start += 2 * k) { int i = start, j = Math.min(start + k - 1, a.length - 1); while (i < j) { char tmp = a[i]; a[i++] = a[j]; a[j--] = tmp; } } return new String(a); }
public String var_0 ( String var_1 , int var_2 ) { char [ ] var_3 = var_1 . toCharArray ( ) ; for ( int var_4 = 0 ; var_4 < var_3 . length ; var_4 += 2 * var_2 ) { int var_5 = var_4 , var_6 = Math . min ( var_4 + var_2 - 1 , var_3 . length - 1 ) ; while ( var_5 < var_6 ) { char var_7 = var_3 [ var_5 ] ; var_3 [ var_5 ++ ] = var_3 [ var_6 ] ; var_3 [ var_6 -- ] = var_7 ; } } return new String ( var_3 ) ; }
3
0<SEP>1<SEP>2
97
<qiyuangong>709_To_Lower_Case_1.java
public String toLowerCase(String str) { return str.toLowerCase(); }
public String var_0 ( String var_1 ) { return var_1 . toLowerCase ( ) ; }
0
null
98
<qiyuangong>819_Most_Common_Word_1.java
public String mostCommonWord(String paragraph, String[] banned) { paragraph += "."; Set<String> banset = new HashSet(); for (String word: banned) banset.add(word); Map<String, Integer> count = new HashMap(); String ans = ""; int ansfreq = 0; StringBuilder word = new StringBuilder(); for (char c: paragraph.toCharArray()) { if (Character.isLetter(c)) { word.append(Character.toLowerCase(c)); } else if (word.length() > 0) { String finalword = word.toString(); if (!banset.contains(finalword)) { count.put(finalword, count.getOrDefault(finalword, 0) + 1); if (count.get(finalword) > ansfreq) { ans = finalword; ansfreq = count.get(finalword); } } word = new StringBuilder(); } } return ans; }
public String var_0 ( String var_1 , String [ ] var_2 ) { var_1 += "." ; Set < String > var_3 = new HashSet ( ) ; for ( String var_4 : var_2 ) var_3 . add ( var_4 ) ; Map < String , Integer > var_5 = new HashMap ( ) ; String var_6 = "" ; int var_7 = 0 ; StringBuilder var_4 = new StringBuilder ( ) ; for ( char var_8 : var_1 . toCharArray ( ) ) { if ( Character . isLetter ( var_8 ) ) { var_4 . append ( Character . toLowerCase ( var_8 ) ) ; } else if ( var_4 . length ( ) > 0 ) { String var_9 = var_4 . toString ( ) ; if ( ! var_3 . contains ( var_9 ) ) { var_5 . put ( var_9 , var_5 . getOrDefault ( var_9 , 0 ) + 1 ) ; if ( var_5 . get ( var_9 ) > var_7 ) { var_6 = var_9 ; var_7 = var_5 . get ( var_9 ) ; } } var_4 = new StringBuilder ( ) ; } } return var_6 ; }
4
<D_QUOTE>.<D_QUOTE><SEP>0<SEP><D_QUOTE><D_QUOTE><SEP>1
99
<qiyuangong>1304_Find_N_Unique_Integers_Sum_up_to_Zero_1.java
public int[] sumZero(int n) { int[] res = new int[n]; for (int i = 1; i < n; i++) { res[i] = i; res[0] -= i; } return res; }
public int [ ] sample_funcname ( int var_0 ) { int [ ] var_1 = new int [ var_0 ] ; for ( int var_2 = 1 ; var_2 < var_0 ; var_2 ++ ) { var_1 [ var_2 ] = var_2 ; var_1 [ 0 ] -= var_2 ; } return var_1 ; }
2
1<SEP>0
100
<qiyuangong>005_Longest_Palindromic_Substring_1.java
private int expandAroundCenter(String s, int left, int right) { int L = left, R = right; while (L >= 0 && R < s.length() && s.charAt(L) == s.charAt(R)) { L--; R++; } return R - L - 1; }
private int sample_funcname ( String var_0 , int var_1 , int var_2 ) { int var_3 = var_1 , var_4 = var_2 ; while ( var_3 >= 0 && var_4 < var_0 . length ( ) && var_0 . charAt ( var_3 ) == var_0 . charAt ( var_4 ) ) { var_3 -- ; var_4 ++ ; } return var_4 - var_3 - 1 ; }
2
0<SEP>1
101
<qiyuangong>347_Top_K_Frequent_Elements_1.java
public List<Integer> topKFrequent(int[] nums, int k) { HashMap<Integer, Integer> count = new HashMap(); for (int n: nums) { count.put(n, count.getOrDefault(n, 0) + 1); } PriorityQueue<Integer> heap = new PriorityQueue<Integer>((n1, n2) -> count.get(n1) - count.get(n2)); for (int n: count.keySet()) { heap.add(n); if (heap.size() > k) heap.poll(); } List<Integer> top_k = new LinkedList(); while (!heap.isEmpty()) top_k.add(heap.poll()); Collections.reverse(top_k); return top_k; }
public List < Integer > var_0 ( int [ ] var_1 , int var_2 ) { HashMap < Integer , Integer > var_3 = new HashMap ( ) ; for ( int var_4 : var_1 ) { var_3 . put ( var_4 , var_3 . getOrDefault ( var_4 , 0 ) + 1 ) ; } PriorityQueue < Integer > var_7 = new PriorityQueue < Integer > ( ( var_5 , var_6 ) -> var_3 . get ( var_5 ) - var_3 . get ( var_6 ) ) ; for ( int var_4 : var_3 . keySet ( ) ) { var_7 . add ( var_4 ) ; if ( var_7 . size ( ) > var_2 ) var_7 . poll ( ) ; } List < Integer > var_8 = new LinkedList ( ) ; while ( ! var_7 . isEmpty ( ) ) var_8 . add ( var_7 . poll ( ) ) ; Collections . reverse ( var_8 ) ; return var_8 ; }
2
0<SEP>1
102
<qiyuangong>1365_How_Many_Numbers_Are_Smaller_Than_the_Current_Number_1.java
public int[] smallerNumbersThanCurrent(int[] nums) { int[] countList = new int[101]; int[] res = new int[nums.length]; for (int i = 0; i < nums.length; i++) countList[nums[i]]++; for (int i = 1; i < 101; i++) countList[i] += countList[i-1]; for (int i = 0; i < nums.length; i++) { if (nums[i] == 0) res[i] = 0; else res[i] = countList[nums[i]-1]; } return res; }
public int [ ] sample_funcname ( int [ ] var_0 ) { int [ ] var_1 = new int [ 101 ] ; int [ ] var_2 = new int [ var_0 . length ] ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) var_1 [ var_0 [ var_3 ] ] ++ ; for ( int var_3 = 1 ; var_3 < 101 ; var_3 ++ ) var_1 [ var_3 ] += var_1 [ var_3 - 1 ] ; for ( int var_3 = 0 ; var_3 < var_0 . length ; var_3 ++ ) { if ( var_0 [ var_3 ] == 0 ) var_2 [ var_3 ] = 0 ; else var_2 [ var_3 ] = var_1 [ var_0 [ var_3 ] - 1 ] ; } return var_2 ; }
3
0<SEP>101<SEP>1

No dataset card yet

New: Create and edit this dataset card directly on the website!

Contribute a Dataset Card
Downloads last month
16
Add dataset card