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
⌀ |
---|---|---|---|---|---|
1,025 | <gouthampradhan>math_RotateFunction_1.java | public int maxRotateFunction(int[] A) {
if (A.length == 0 || A.length == 1) return 0;
int max = Integer.MIN_VALUE;
int l = A.length;
int sum = 0, prodSum = 0;
for (int i = 0; i < l; i++) {
prodSum += (A[i] * i);
sum += A[i];
}
max = Math.max(max, prodSum);
for (int i = 0; i < l - 1; i++) {
prodSum = (prodSum - sum + A[i] + ((l - 1) * A[i]));
max = Math.max(max, prodSum);
}
return max;
} | public int sample_funcname ( int [ ] var_0 ) {
if ( var_0 . length == 0 || var_0 . length == 1 ) return 0 ;
int max = Integer . MIN_VALUE ;
int var_1 = var_0 . length ;
int var_2 = 0 , var_3 = 0 ;
for ( int var_4 = 0 ;
var_4 < var_1 ;
var_4 ++ ) {
var_3 += ( var_0 [ var_4 ] * var_4 ) ;
var_2 += var_0 [ var_4 ] ;
}
max = Math . max ( max , var_3 ) ;
for ( int var_4 = 0 ;
var_4 < var_1 - 1 ;
var_4 ++ ) {
var_3 = ( var_3 - var_2 + var_0 [ var_4 ] + ( ( var_1 - 1 ) * var_0 [ var_4 ] ) ) ;
max = Math . max ( max , var_3 ) ;
}
return max ;
}
| 2 | 0<SEP>1 |
1,026 | <gouthampradhan>backtracking_Combinations_1.java | private void getNext(int i, int count, int n, int k, int[] subArr, List<List<Integer>> result) {
if (k == 0) {
List<Integer> subList = new ArrayList<>();
for (int a : subArr) subList.add(a);
result.add(subList);
} else {
for (int j = i + 1; j <= n; j++) {
subArr[count] = j;
getNext(j, count + 1, n, k - 1, subArr, result);
}
}
} | private void sample_funcname ( int i , int count , int n , int k , int [ ] subArr , List < List < Integer >> result ) {
if ( k == 0 ) {
List < Integer > subList = new ArrayList < > ( ) ;
for ( int a : subArr ) subList . add ( a ) ;
result . add ( subList ) ;
}
else {
for ( int j = i + 1 ;
j <= n ;
j ++ ) {
subArr [ count ] = j ;
getNext ( j , count + 1 , n , k - 1 , subArr , result ) ;
}
}
}
| 2 | 0<SEP>1 |
1,027 | <gouthampradhan>depth_first_search_AllPathsFromSourceToTarget_1.java | private void dfs(
List<List<Integer>> result, Set<Integer> done, int i, Stack<Integer> stack, int[][] graph) {
done.add(i);
stack.push(i);
int[] children = graph[i];
if (children.length == 0) {
List<Integer> childList = new ArrayList<>(stack);
result.add(childList);
} else {
for (int c : children) {
dfs(result, done, c, stack, graph);
}
}
stack.pop();
done.remove(i);
} | private void sample_funcname ( List < List < Integer >> result , Set < Integer > done , int i , Stack < Integer > stack , int [ ] [ ] graph ) {
done . add ( i ) ;
stack . push ( i ) ;
int [ ] children = graph [ i ] ;
if ( children . length == 0 ) {
List < Integer > childList = new ArrayList < > ( stack ) ;
result . add ( childList ) ;
}
else {
for ( int c : children ) {
dfs ( result , done , c , stack , graph ) ;
}
}
stack . pop ( ) ;
done . remove ( i ) ;
}
| 1 | 0 |
1,029 | <gouthampradhan>array_MaxProductOfThreeNumbers_1.java | public int maximumProduct(int[] nums) {
Arrays.sort(nums);
int prod1 = nums[nums.length - 1] * nums[nums.length - 2] * nums[nums.length - 3];
int prod2 = nums[nums.length - 1] * nums[0] * nums[1];
return prod1 > prod2 ? prod1 : prod2;
} | public int sample_funcname ( int [ ] var_0 ) {
Arrays . sort ( var_0 ) ;
int var_1 = var_0 [ var_0 . length - 1 ] * var_0 [ var_0 . length - 2 ] * var_0 [ var_0 . length - 3 ] ;
int var_2 = var_0 [ var_0 . length - 1 ] * var_0 [ 0 ] * var_0 [ 1 ] ;
return var_1 > var_2 ? var_1 : var_2 ;
}
| 4 | 0<SEP>1<SEP>3<SEP>2 |
1,030 | <gouthampradhan>two_pointers_ThreeSumClosest_1.java | public int threeSumClosest(int[] a, int target) {
Arrays.sort(a);
int min = Integer.MAX_VALUE, ans = -1;
for (int i = 0, l = a.length; i < l - 2; i++) {
if (i == 0 || !(a[i] == a[i - 1])) {
int j = i + 1, k = l - 1;
while (k > j) {
if (j != i + 1 && (a[j] == a[j - 1])) {
j++;
continue;
}
int sum = a[i] + a[j] + a[k];
if (sum < target) {
int diff = Math.abs(sum - target);
if (diff < min) {
min = diff;
ans = sum;
}
j++;
} else if (sum > target) {
int diff = Math.abs(sum - target);
if (diff < min) {
min = diff;
ans = sum;
}
k--;
} else {
return sum;
}
}
}
}
return ans;
} | public int sample_funcname ( int [ ] var_0 , int var_1 ) {
Arrays . sort ( var_0 ) ;
int var_2 = Integer . MAX_VALUE , var_3 = - 1 ;
for ( int var_4 = 0 , var_5 = var_0 . length ;
var_4 < var_5 - 2 ;
var_4 ++ ) {
if ( var_4 == 0 || ! ( var_0 [ var_4 ] == var_0 [ var_4 - 1 ] ) ) {
int var_6 = var_4 + 1 , var_7 = var_5 - 1 ;
while ( var_7 > var_6 ) {
if ( var_6 != var_4 + 1 && ( var_0 [ var_6 ] == var_0 [ var_6 - 1 ] ) ) {
var_6 ++ ;
continue ;
}
int var_8 = var_0 [ var_4 ] + var_0 [ var_6 ] + var_0 [ var_7 ] ;
if ( var_8 < var_1 ) {
int var_9 = Math . abs ( var_8 - var_1 ) ;
if ( var_9 < var_2 ) {
var_2 = var_9 ;
var_3 = var_8 ;
}
var_6 ++ ;
}
else if ( var_8 > var_1 ) {
int var_9 = Math . abs ( var_8 - var_1 ) ;
if ( var_9 < var_2 ) {
var_2 = var_9 ;
var_3 = var_8 ;
}
var_7 -- ;
}
else {
return var_8 ;
}
}
}
}
return var_3 ;
}
| 3 | 1<SEP>0<SEP>2 |
1,032 | <gouthampradhan>string_ValidWordAbbreviation_1.java | public boolean validWordAbbreviation(String word, String abbr) {
if (abbr.length() > word.length()) return false;
StringBuilder num = new StringBuilder();
int j = 0;
for (int i = 0; i < abbr.length() && j < word.length(); i++) {
char curr = abbr.charAt(i);
if (curr == '0' && num.toString().isEmpty()) return false;
if (curr >= '0' && curr <= '9') {
num.append(curr);
} else {
if (num.toString().isEmpty()) {
if (word.charAt(j) != abbr.charAt(i)) {
return false;
}
j++;
} else {
int next = Integer.parseInt(num.toString());
j += next;
if (word.length() <= j) {
return false;
}
if (word.charAt(j) != abbr.charAt(i)) {
return false;
}
num = new StringBuilder();
j++;
}
}
}
if (!num.toString().isEmpty()) {
int next = Integer.parseInt(num.toString());
j += next;
if (j > word.length() || j < word.length()) {
return false;
}
}
return true;
} | public boolean var_0 ( String var_1 , String var_2 ) {
if ( var_2 . length ( ) > var_1 . length ( ) ) return false ;
StringBuilder var_3 = new StringBuilder ( ) ;
int var_4 = 0 ;
for ( int var_5 = 0 ;
var_5 < var_2 . length ( ) && var_4 < var_1 . length ( ) ;
var_5 ++ ) {
char var_6 = var_2 . charAt ( var_5 ) ;
if ( var_6 == '0' && var_3 . toString ( ) . isEmpty ( ) ) return false ;
if ( var_6 >= '0' && var_6 <= '9' ) {
var_3 . append ( var_6 ) ;
}
else {
if ( var_3 . toString ( ) . isEmpty ( ) ) {
if ( var_1 . charAt ( var_4 ) != var_2 . charAt ( var_5 ) ) {
return false ;
}
var_4 ++ ;
}
else {
int var_7 = Integer . parseInt ( var_3 . toString ( ) ) ;
var_4 += var_7 ;
if ( var_1 . length ( ) <= var_4 ) {
return false ;
}
if ( var_1 . charAt ( var_4 ) != var_2 . charAt ( var_5 ) ) {
return false ;
}
var_3 = new StringBuilder ( ) ;
var_4 ++ ;
}
}
}
if ( ! var_3 . toString ( ) . isEmpty ( ) ) {
int var_7 = Integer . parseInt ( var_3 . toString ( ) ) ;
var_4 += var_7 ;
if ( var_4 > var_1 . length ( ) || var_4 < var_1 . length ( ) ) {
return false ;
}
}
return true ;
}
| 3 | <S_QUOTE>9<S_QUOTE><SEP>0<SEP><S_QUOTE>0<S_QUOTE> |
1,033 | <gouthampradhan>greedy_GasStation_1.java | public int canCompleteCircuit(int[] gas, int[] cost) {
int debt = 0, sum = 0, start = 0;
for (int i = 0; i < gas.length; i++) {
sum += gas[i] - cost[i];
if (sum < 0) {
debt += sum;
sum = 0;
start = i + 1;
}
}
debt += sum;
return debt >= 0 ? start : -1;
} | public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) {
int var_2 = 0 , var_3 = 0 , var_4 = 0 ;
for ( int var_5 = 0 ;
var_5 < var_0 . length ;
var_5 ++ ) {
var_3 += var_0 [ var_5 ] - var_1 [ var_5 ] ;
if ( var_3 < 0 ) {
var_2 += var_3 ;
var_3 = 0 ;
var_4 = var_5 + 1 ;
}
}
var_2 += var_3 ;
return var_2 >= 0 ? var_4 : - 1 ;
}
| 2 | 0<SEP>1 |
1,034 | <gouthampradhan>dynamic_programming_HouseRobberII_1.java | public int rob(int[] nums) {
if (nums.length == 0) return 0;
if (nums.length == 1) return nums[0];
else if (nums.length == 2) {
if (nums[0] > nums[1]) return nums[0];
return nums[1];
} else if (nums.length == 3) return Math.max(Math.max(nums[0], nums[1]), nums[2]);
int[] DP = new int[nums.length];
for (int i = nums.length - 1; i > 0; i--) {
if (i + 3 < nums.length) DP[i] = Math.max(nums[i] + DP[i + 2], nums[i] + DP[i + 3]);
else if (i + 2 < nums.length) DP[i] = nums[i] + DP[i + 2];
else DP[i] = nums[i];
}
int max = Math.max(DP[1], DP[2]);
Arrays.fill(DP, 0);
for (int i = nums.length - 2; i >= 0; i--) {
if (i + 3 < nums.length) DP[i] = Math.max(nums[i] + DP[i + 2], nums[i] + DP[i + 3]);
else if (i + 2 < nums.length) DP[i] = nums[i] + DP[i + 2];
else DP[i] = nums[i];
}
max = Math.max(max, Math.max(DP[0], DP[1]));
return max;
} | public int sample_funcname ( int [ ] var_0 ) {
if ( var_0 . length == 0 ) return 0 ;
if ( var_0 . length == 1 ) return var_0 [ 0 ] ;
else if ( var_0 . length == 2 ) {
if ( var_0 [ 0 ] > var_0 [ 1 ] ) return var_0 [ 0 ] ;
return var_0 [ 1 ] ;
}
else if ( var_0 . length == 3 ) return Math . max ( Math . max ( var_0 [ 0 ] , var_0 [ 1 ] ) , var_0 [ 2 ] ) ;
int [ ] var_1 = new int [ var_0 . length ] ;
for ( int var_2 = var_0 . length - 1 ;
var_2 > 0 ;
var_2 -- ) {
if ( var_2 + 3 < var_0 . length ) var_1 [ var_2 ] = Math . max ( var_0 [ var_2 ] + var_1 [ var_2 + 2 ] , var_0 [ var_2 ] + var_1 [ var_2 + 3 ] ) ;
else if ( var_2 + 2 < var_0 . length ) var_1 [ var_2 ] = var_0 [ var_2 ] + var_1 [ var_2 + 2 ] ;
else var_1 [ var_2 ] = var_0 [ var_2 ] ;
}
int max = Math . max ( var_1 [ 1 ] , var_1 [ 2 ] ) ;
Arrays . fill ( var_1 , 0 ) ;
for ( int var_2 = var_0 . length - 2 ;
var_2 >= 0 ;
var_2 -- ) {
if ( var_2 + 3 < var_0 . length ) var_1 [ var_2 ] = Math . max ( var_0 [ var_2 ] + var_1 [ var_2 + 2 ] , var_0 [ var_2 ] + var_1 [ var_2 + 3 ] ) ;
else if ( var_2 + 2 < var_0 . length ) var_1 [ var_2 ] = var_0 [ var_2 ] + var_1 [ var_2 + 2 ] ;
else var_1 [ var_2 ] = var_0 [ var_2 ] ;
}
max = Math . max ( max , Math . max ( var_1 [ 0 ] , var_1 [ 1 ] ) ) ;
return max ;
}
| 4 | 2<SEP>0<SEP>3<SEP>1 |
1,035 | <gouthampradhan>array_LongestIncreasingSubsequence_1.java | public int findLengthOfLCIS(int[] nums) {
int max = 1, count = 1;
if (nums.length == 1) return max;
if (nums.length == 0) return 0;
for (int i = 0, j = i + 1; j < nums.length; ) {
if (nums[j] > nums[i]) {
count++;
i++;
j++;
} else {
max = Math.max(max, count);
count = 0;
i = j;
j = i + 1;
}
}
return max;
} | public int sample_funcname ( int [ ] var_0 ) {
int max = 1 , var_1 = 1 ;
if ( var_0 . length == 1 ) return max ;
if ( var_0 . length == 0 ) return 0 ;
for ( int var_2 = 0 , var_3 = var_2 + 1 ;
var_3 < var_0 . length ;
) {
if ( var_0 [ var_3 ] > var_0 [ var_2 ] ) {
var_1 ++ ;
var_2 ++ ;
var_3 ++ ;
}
else {
max = Math . max ( max , var_1 ) ;
var_1 = 0 ;
var_2 = var_3 ;
var_3 = var_2 + 1 ;
}
}
return max ;
}
| 2 | 1<SEP>0 |
1,036 | <gouthampradhan>greedy_JumpGameII_1.java | public int jump(int[] nums) {
int step = 0;
int e = 0, max = 0;
for (int i = 0; i < nums.length - 1; i++) {
max = Math.max(max, i + nums[i]);
if (i == e) {
step++;
e = max;
}
}
return step;
} | public int sample_funcname ( int [ ] var_0 ) {
int var_1 = 0 ;
int var_2 = 0 , max = 0 ;
for ( int var_3 = 0 ;
var_3 < var_0 . length - 1 ;
var_3 ++ ) {
max = Math . max ( max , var_3 + var_0 [ var_3 ] ) ;
if ( var_3 == var_2 ) {
var_1 ++ ;
var_2 = max ;
}
}
return var_1 ;
}
| 2 | 0<SEP>1 |
1,037 | <gouthampradhan>dynamic_programming_ClimbingStairs_1.java | public int climbStairs(int n) {
if (n == 0 || n == 1) return 1;
int[] A = new int[n + 1];
A[n] = 1;
A[n - 1] = 1;
for (int i = n - 2; i >= 0; i--) A[i] = A[i + 1] + A[i + 2];
return A[0];
} | public int sample_funcname ( int var_0 ) {
if ( var_0 == 0 || var_0 == 1 ) return 1 ;
int [ ] var_1 = new int [ var_0 + 1 ] ;
var_1 [ var_0 ] = 1 ;
var_1 [ var_0 - 1 ] = 1 ;
for ( int var_2 = var_0 - 2 ;
var_2 >= 0 ;
var_2 -- ) var_1 [ var_2 ] = var_1 [ var_2 + 1 ] + var_1 [ var_2 + 2 ] ;
return var_1 [ 0 ] ;
}
| 3 | 2<SEP>0<SEP>1 |
1,038 | <gouthampradhan>array_MaximumSwap_1.java | public int maximumSwap(int num) {
int[] D = new int[10];
char[] A = String.valueOf(num).toCharArray();
for (int i = 0; i < A.length; i++) {
D[A[i] - '0'] = i;
}
boolean found = false;
for (int i = 0; i < A.length; i++) {
int digit = A[i] - '0';
for (int j = 9; j > digit; j--) {
if (D[j] > i) {
char temp = A[i];
A[i] = (char) (j + '0');
A[D[j]] = temp;
found = true;
break;
}
}
if (found) break;
}
return Integer.parseInt(String.valueOf(A));
} | public int sample_funcname ( int var_0 ) {
int [ ] var_1 = new int [ 10 ] ;
char [ ] var_2 = String . valueOf ( var_0 ) . toCharArray ( ) ;
for ( int var_3 = 0 ;
var_3 < var_2 . length ;
var_3 ++ ) {
var_1 [ var_2 [ var_3 ] - '0' ] = var_3 ;
}
boolean var_7 = false ;
for ( int var_3 = 0 ;
var_3 < var_2 . length ;
var_3 ++ ) {
int var_4 = var_2 [ var_3 ] - '0' ;
for ( int var_5 = 9 ;
var_5 > var_4 ;
var_5 -- ) {
if ( var_1 [ var_5 ] > var_3 ) {
char var_6 = var_2 [ var_3 ] ;
var_2 [ var_3 ] = ( char ) ( var_5 + '0' ) ;
var_2 [ var_1 [ var_5 ] ] = var_6 ;
var_7 = true ;
break ;
}
}
if ( var_7 ) break ;
}
return Integer . parseInt ( String . valueOf ( var_2 ) ) ;
}
| 4 | 10<SEP>0<SEP>9<SEP><S_QUOTE>0<S_QUOTE> |
1,039 | <gouthampradhan>backtracking_CombinationSumII_1.java | private void combination(
int i, int target, int[] candidates, List<Integer> row, List<List<Integer>> result) {
if (target == 0) {
result.add(new ArrayList<>(row));
} else if (target > 0) {
for (int j = i, l = candidates.length; j < l; j++) {
if (j > i && candidates[j] == candidates[j - 1]) continue;
row.add(candidates[j]);
combination(j + 1, target - candidates[j], candidates, row, result);
row.remove(row.size() - 1);
}
}
} | private void sample_funcname ( int i , int target , int [ ] candidates , List < Integer > row , List < List < Integer >> result ) {
if ( target == 0 ) {
result . add ( new ArrayList < > ( row ) ) ;
}
else if ( target > 0 ) {
for ( int j = i , l = candidates . length ;
j < l ;
j ++ ) {
if ( j > i && candidates [ j ] == candidates [ j - 1 ] ) continue ;
row . add ( candidates [ j ] ) ;
combination ( j + 1 , target - candidates [ j ] , candidates , row , result ) ;
row . remove ( row . size ( ) - 1 ) ;
}
}
}
| 2 | 0<SEP>1 |
1,040 | <gouthampradhan>greedy_ScoreAfterFlippingMatrix_2.java | private void flip(int[] A) {
for (int i = 0; i < A.length; i++) {
if (A[i] == 1) {
A[i] = 0;
} else {
A[i] = 1;
}
}
} | private void var_0 ( int [ ] var_1 ) {
for ( int var_2 = 0 ;
var_2 < var_1 . length ;
var_2 ++ ) {
if ( var_1 [ var_2 ] == 1 ) {
var_1 [ var_2 ] = 0 ;
}
else {
var_1 [ var_2 ] = 1 ;
}
}
}
| 2 | 0<SEP>1 |
1,041 | <gouthampradhan>string_ImplementStrStr_1.java | private boolean isEqual(String haystack, String needle, int i) {
int hL = haystack.length();
int nL = needle.length();
int j = 0;
while (i < hL && j < nL) {
if (haystack.charAt(i) != needle.charAt(j)) return false;
i++;
j++;
}
return j >= nL;
} | private boolean var_0 ( String var_1 , String var_2 , int var_3 ) {
int var_4 = var_1 . length ( ) ;
int var_5 = var_2 . length ( ) ;
int var_6 = 0 ;
while ( var_3 < var_4 && var_6 < var_5 ) {
if ( var_1 . charAt ( var_3 ) != var_2 . charAt ( var_6 ) ) return false ;
var_3 ++ ;
var_6 ++ ;
}
return var_6 >= var_5 ;
}
| 1 | 0 |
1,042 | <gouthampradhan>array_RelativeSortArray_1.java | public int[] relativeSortArray(int[] arr1, int[] arr2) {
List<Integer> notPresent = new ArrayList<>();
Map<Integer, Integer> map = new HashMap<>();
Set<Integer> set = new HashSet<>();
for (int i : arr2) {
set.add(i);
}
for (int i : arr1) {
map.putIfAbsent(i, 0);
map.put(i, map.get(i) + 1);
}
List<Integer> result = new ArrayList<>();
for (int i : arr2) {
int count = map.get(i);
for (int j = 0; j < count; j++) {
result.add(i);
}
}
for (int k : map.keySet()) {
if (!set.contains(k)) {
int count = map.get(k);
for (int i = 0; i < count; i++) {
notPresent.add(k);
}
}
}
notPresent.sort(Comparator.comparingInt(o -> o));
result.addAll(notPresent);
int[] resA = new int[result.size()];
for (int i = 0; i < result.size(); i++) {
resA[i] = result.get(i);
}
return resA;
} | public int [ ] sample_funcname ( int [ ] var_0 , int [ ] var_1 ) {
List < Integer > var_2 = new ArrayList < > ( ) ;
Map < Integer , Integer > var_3 = new HashMap < > ( ) ;
Set < Integer > var_4 = new HashSet < > ( ) ;
for ( int var_5 : var_1 ) {
var_4 . add ( var_5 ) ;
}
for ( int var_5 : var_0 ) {
var_3 . putIfAbsent ( var_5 , 0 ) ;
var_3 . put ( var_5 , var_3 . get ( var_5 ) + 1 ) ;
}
List < Integer > var_6 = new ArrayList < > ( ) ;
for ( int var_5 : var_1 ) {
int var_7 = var_3 . get ( var_5 ) ;
for ( int var_8 = 0 ;
var_8 < var_7 ;
var_8 ++ ) {
var_6 . add ( var_5 ) ;
}
}
for ( int var_9 : var_3 . keySet ( ) ) {
if ( ! var_4 . contains ( var_9 ) ) {
int var_7 = var_3 . get ( var_9 ) ;
for ( int var_5 = 0 ;
var_5 < var_7 ;
var_5 ++ ) {
var_2 . add ( var_9 ) ;
}
}
}
var_2 . sort ( Comparator . comparingInt ( var_10 -> var_10 ) ) ;
var_6 . addAll ( var_2 ) ;
int [ ] var_11 = new int [ var_6 . size ( ) ] ;
for ( int var_5 = 0 ;
var_5 < var_6 . size ( ) ;
var_5 ++ ) {
var_11 [ var_5 ] = var_6 . get ( var_5 ) ;
}
return var_11 ;
}
| 2 | 0<SEP>1 |
1,043 | <gouthampradhan>binary_search_SqrtX_1.java | public int mySqrt(int x) {
int s = 0, e = x;
long ans = 0L;
while (s <= e) {
long m = s + (e - s) / 2;
long prod = m * m;
if (prod <= x) {
s = (int) (m + 1);
ans = m;
} else e = (int) m - 1;
}
return (int) ans;
} | public int sample_funcname ( int var_0 ) {
int var_1 = 0 , var_2 = var_0 ;
long var_3 = 0L ;
while ( var_1 <= var_2 ) {
long var_4 = var_1 + ( var_2 - var_1 ) / 2 ;
long var_5 = var_4 * var_4 ;
if ( var_5 <= var_0 ) {
var_1 = ( int ) ( var_4 + 1 ) ;
var_3 = var_4 ;
}
else var_2 = ( int ) var_4 - 1 ;
}
return ( int ) var_3 ;
}
| 3 | 0<SEP>1<SEP>2 |
1,044 | <gouthampradhan>breadth_first_search_SlidingPuzzle_1.java | private int[][] clone(int[][] original) {
int[][] cloned = new int[2][3];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 3; j++) {
cloned[i][j] = original[i][j];
}
}
return cloned;
} | private int [ ] [ ] sample_funcname ( int [ ] [ ] var_0 ) {
int [ ] [ ] var_1 = new int [ 2 ] [ 3 ] ;
for ( int var_2 = 0 ;
var_2 < 2 ;
var_2 ++ ) {
for ( int var_3 = 0 ;
var_3 < 3 ;
var_3 ++ ) {
var_1 [ var_2 ] [ var_3 ] = var_0 [ var_2 ] [ var_3 ] ;
}
}
return var_1 ;
}
| 3 | 0<SEP>3<SEP>2 |
1,045 | <gouthampradhan>array_SubArraysWithBoundedMaximum_1.java | public int numSubarrayBoundedMax(int[] A, int L, int R) {
int[] DP = new int[A.length];
int v = -1;
for (int i = A.length - 1; i >= 0; i--) {
if (A[i] >= L && A[i] <= R) {
if (v != -1) {
DP[i] = v - i + 1;
} else {
DP[i] = 1;
v = i;
}
} else if (A[i] < L) {
if (v == -1) {
v = i;
}
if (i + 1 < A.length) {
if (A[i + 1] < L || (A[i + 1] >= L && A[i + 1] <= R)) {
DP[i] = DP[i + 1];
} else {
DP[i] = 0;
}
}
} else {
v = -1;
}
}
int sum = 0;
for (int i = 0; i < DP.length; i++) {
sum += DP[i];
}
return sum;
} | public int sample_funcname ( int [ ] var_0 , int var_1 , int var_2 ) {
int [ ] var_3 = new int [ var_0 . length ] ;
int var_4 = - 1 ;
for ( int var_5 = var_0 . length - 1 ;
var_5 >= 0 ;
var_5 -- ) {
if ( var_0 [ var_5 ] >= var_1 && var_0 [ var_5 ] <= var_2 ) {
if ( var_4 != - 1 ) {
var_3 [ var_5 ] = var_4 - var_5 + 1 ;
}
else {
var_3 [ var_5 ] = 1 ;
var_4 = var_5 ;
}
}
else if ( var_0 [ var_5 ] < var_1 ) {
if ( var_4 == - 1 ) {
var_4 = var_5 ;
}
if ( var_5 + 1 < var_0 . length ) {
if ( var_0 [ var_5 + 1 ] < var_1 || ( var_0 [ var_5 + 1 ] >= var_1 && var_0 [ var_5 + 1 ] <= var_2 ) ) {
var_3 [ var_5 ] = var_3 [ var_5 + 1 ] ;
}
else {
var_3 [ var_5 ] = 0 ;
}
}
}
else {
var_4 = - 1 ;
}
}
int var_6 = 0 ;
for ( int var_5 = 0 ;
var_5 < var_3 . length ;
var_5 ++ ) {
var_6 += var_3 [ var_5 ] ;
}
return var_6 ;
}
| 2 | 1<SEP>0 |
1,046 | <gouthampradhan>two_pointers_MinimumSizeSubarraySum_1.java | public int minSubArrayLen(int s, int[] nums) {
int sum = 0, count = 0, min = Integer.MAX_VALUE;
for (int i = 0, j = 0; j < nums.length; ) {
if (nums[j] >= s) {
return 1;
} else {
sum += nums[j];
count++;
if (sum >= s) {
min = Math.min(min, count);
while (j > i) {
sum -= nums[i];
count--;
i++;
if (sum < s) break;
min = Math.min(min, count);
}
}
}
j++;
}
if (min == Integer.MAX_VALUE) {
return 0;
}
return min;
} | public int sample_funcname ( int var_0 , int [ ] var_1 ) {
int var_2 = 0 , var_3 = 0 , min = Integer . MAX_VALUE ;
for ( int var_4 = 0 , var_5 = 0 ;
var_5 < var_1 . length ;
) {
if ( var_1 [ var_5 ] >= var_0 ) {
return 1 ;
}
else {
var_2 += var_1 [ var_5 ] ;
var_3 ++ ;
if ( var_2 >= var_0 ) {
min = Math . min ( min , var_3 ) ;
while ( var_5 > var_4 ) {
var_2 -= var_1 [ var_4 ] ;
var_3 -- ;
var_4 ++ ;
if ( var_2 < var_0 ) break ;
min = Math . min ( min , var_3 ) ;
}
}
}
var_5 ++ ;
}
if ( min == Integer . MAX_VALUE ) {
return 0 ;
}
return min ;
}
| 2 | 0<SEP>1 |
1,047 | <gouthampradhan>string_MinimumAddtoMakeParenthesesValid_1.java | public int minAddToMakeValid(String S) {
int result = 0;
int open = 0;
for (char c : S.toCharArray()) {
if (c == '(') {
open++;
} else if (c == ')') {
if (open > 0) {
open--;
} else result++;
}
}
return result + open;
} | public int sample_funcname ( String var_0 ) {
int var_1 = 0 ;
int var_2 = 0 ;
for ( char var_3 : var_0 . toCharArray ( ) ) {
if ( var_3 == '(' ) {
var_2 ++ ;
}
else if ( var_3 == ')' ) {
if ( var_2 > 0 ) {
var_2 -- ;
}
else var_1 ++ ;
}
}
return var_1 + var_2 ;
}
| 3 | 0<SEP><S_QUOTE>)<S_QUOTE><SEP><S_QUOTE>(<S_QUOTE> |
1,048 | <gouthampradhan>two_pointers_RemoveDuplicates_1.java | public int removeDuplicates(int[] nums) {
if (nums.length == 1) return 1;
int size = 1;
for (int j = 0, i = 1; i < nums.length; i++) {
if (nums[i] != nums[i - 1]) {
size++;
j++;
nums[j] = nums[i];
}
}
return size;
} | public int sample_funcname ( int [ ] var_0 ) {
if ( var_0 . length == 1 ) return 1 ;
int var_1 = 1 ;
for ( int var_2 = 0 , var_3 = 1 ;
var_3 < var_0 . length ;
var_3 ++ ) {
if ( var_0 [ var_3 ] != var_0 [ var_3 - 1 ] ) {
var_1 ++ ;
var_2 ++ ;
var_0 [ var_2 ] = var_0 [ var_3 ] ;
}
}
return var_1 ;
}
| 2 | 1<SEP>0 |
1,049 | <gouthampradhan>math_LargestComponentSizebyCommonFactor_1.java | private List<Integer> primes(int N, int[] A) {
boolean[] P = new boolean[N + 1];
int[] pF = new int[N + 1];
int sqRt = (int) Math.sqrt(N);
for (int i = 2; i <= sqRt; i++) {
if (!P[i]) {
for (int j = 2; ; j++) {
if (i * j > N) break;
P[i * j] = true;
if (pF[i * j] == 0) {
pF[i * j] = i;
}
}
}
}
Map<Integer, Integer> result = new HashMap<>();
for (int a : A) {
if (a == 1) continue;
int n = pF[a];
while (n != 0) {
result.putIfAbsent(n, 0);
result.put(n, result.get(n) + 1);
a /= n;
n = pF[a];
}
result.putIfAbsent(a, 0);
result.put(a, result.get(a) + 1);
}
return result.keySet().stream().filter(x -> result.get(x) > 1).collect(Collectors.toList());
} | private List < Integer > var_0 ( int var_1 , int [ ] var_2 ) {
boolean [ ] var_3 = new boolean [ var_1 + 1 ] ;
int [ ] var_4 = new int [ var_1 + 1 ] ;
int var_5 = ( int ) Math . sqrt ( var_1 ) ;
for ( int var_6 = 2 ;
var_6 <= var_5 ;
var_6 ++ ) {
if ( ! var_3 [ var_6 ] ) {
for ( int var_7 = 2 ;
;
var_7 ++ ) {
if ( var_6 * var_7 > var_1 ) break ;
var_3 [ var_6 * var_7 ] = true ;
if ( var_4 [ var_6 * var_7 ] == 0 ) {
var_4 [ var_6 * var_7 ] = var_6 ;
}
}
}
}
Map < Integer , Integer > var_8 = new HashMap < > ( ) ;
for ( int var_9 : var_2 ) {
if ( var_9 == 1 ) continue ;
int var_10 = var_4 [ var_9 ] ;
while ( var_10 != 0 ) {
var_8 . putIfAbsent ( var_10 , 0 ) ;
var_8 . put ( var_10 , var_8 . get ( var_10 ) + 1 ) ;
var_9 /= var_10 ;
var_10 = var_4 [ var_9 ] ;
}
var_8 . putIfAbsent ( var_9 , 0 ) ;
var_8 . put ( var_9 , var_8 . get ( var_9 ) + 1 ) ;
}
return var_8 . keySet ( ) . stream ( ) . filter ( var_11 -> var_8 . get ( var_11 ) > 1 ) . collect ( Collectors . toList ( ) ) ;
}
| 3 | 1<SEP>0<SEP>2 |
1,050 | <gouthampradhan>string_StringCompression_1.java | public int compress(char[] chars) {
int count = 0;
int i = 0;
int p = 0;
for (int j = 0; j < chars.length; j++) {
if (chars[i] == chars[j]) {
count++;
} else {
chars[p] = chars[i];
p++;
if (count > 1) {
String countStr = String.valueOf(count);
for (int l = 0; l < countStr.length(); l++) {
chars[p++] = countStr.charAt(l);
}
}
i = j;
count = 1;
}
}
chars[p] = chars[i];
p++;
if (count > 1) {
String countStr = String.valueOf(count);
for (int l = 0; l < countStr.length(); l++) {
chars[p++] = countStr.charAt(l);
}
}
return p;
} | public int sample_funcname ( char [ ] var_0 ) {
int var_1 = 0 ;
int var_2 = 0 ;
int var_3 = 0 ;
for ( int var_4 = 0 ;
var_4 < var_0 . length ;
var_4 ++ ) {
if ( var_0 [ var_2 ] == var_0 [ var_4 ] ) {
var_1 ++ ;
}
else {
var_0 [ var_3 ] = var_0 [ var_2 ] ;
var_3 ++ ;
if ( var_1 > 1 ) {
String var_5 = String . valueOf ( var_1 ) ;
for ( int var_6 = 0 ;
var_6 < var_5 . length ( ) ;
var_6 ++ ) {
var_0 [ var_3 ++ ] = var_5 . charAt ( var_6 ) ;
}
}
var_2 = var_4 ;
var_1 = 1 ;
}
}
var_0 [ var_3 ] = var_0 [ var_2 ] ;
var_3 ++ ;
if ( var_1 > 1 ) {
String var_5 = String . valueOf ( var_1 ) ;
for ( int var_6 = 0 ;
var_6 < var_5 . length ( ) ;
var_6 ++ ) {
var_0 [ var_3 ++ ] = var_5 . charAt ( var_6 ) ;
}
}
return var_3 ;
}
| 2 | 0<SEP>1 |
1,051 | <gouthampradhan>string_FindTheClosestPalindrome_3.java | private boolean isPaliandrome(String s) {
for (int i = 0, j = s.length() - 1; i < j; i++, j--) {
if (s.charAt(i) != s.charAt(j)) {
return false;
}
}
return true;
} | private boolean var_0 ( String var_1 ) {
for ( int var_2 = 0 , var_3 = var_1 . length ( ) - 1 ;
var_2 < var_3 ;
var_2 ++ , var_3 -- ) {
if ( var_1 . charAt ( var_2 ) != var_1 . charAt ( var_3 ) ) {
return false ;
}
}
return true ;
}
| 2 | 0<SEP>1 |
1,052 | <gouthampradhan>array_CanPlaceFlowers_1.java | public boolean canPlaceFlowers(int[] flowerbed, int n) {
int[] T = new int[flowerbed.length + 4];
for (int i = 0, j = 2; i < flowerbed.length; i++) T[j++] = flowerbed[i];
T[0] = 1;
T[T.length - 1] = 1;
int total = 0, count = 0;
for (int i = 1; i < T.length; i++) {
if (T[i] == 0) count++;
else {
if ((count % 2) == 0) total += ((count / 2) - 1);
else total += (count / 2);
count = 0;
}
}
return (total >= n);
} | public boolean var_0 ( int [ ] var_1 , int var_2 ) {
int [ ] var_3 = new int [ var_1 . length + 4 ] ;
for ( int var_4 = 0 , var_5 = 2 ;
var_4 < var_1 . length ;
var_4 ++ ) var_3 [ var_5 ++ ] = var_1 [ var_4 ] ;
var_3 [ 0 ] = 1 ;
var_3 [ var_3 . length - 1 ] = 1 ;
int var_6 = 0 , var_7 = 0 ;
for ( int var_4 = 1 ;
var_4 < var_3 . length ;
var_4 ++ ) {
if ( var_3 [ var_4 ] == 0 ) var_7 ++ ;
else {
if ( ( var_7 % 2 ) == 0 ) var_6 += ( ( var_7 / 2 ) - 1 ) ;
else var_6 += ( var_7 / 2 ) ;
var_7 = 0 ;
}
}
return ( var_6 >= var_2 ) ;
}
| 4 | 4<SEP>0<SEP>1<SEP>2 |
1,053 | <gouthampradhan>dynamic_programming_BestTimeToBuyAndSellStocksWithFee_1.java | public int maxProfit(int[] prices, int fee) {
int cash = 0, stock = -prices[0];
for (int i = 1; i < prices.length; i++) {
cash = Math.max(cash, prices[i] + stock - fee);
stock = Math.max(stock, cash - prices[i]);
}
return cash;
} | public int sample_funcname ( int [ ] var_0 , int var_1 ) {
int var_2 = 0 , var_3 = - var_0 [ 0 ] ;
for ( int var_4 = 1 ;
var_4 < var_0 . length ;
var_4 ++ ) {
var_2 = Math . max ( var_2 , var_0 [ var_4 ] + var_3 - var_1 ) ;
var_3 = Math . max ( var_3 , var_2 - var_0 [ var_4 ] ) ;
}
return var_2 ;
}
| 2 | 0<SEP>1 |
1,055 | <gouthampradhan>greedy_ScoreAfterFlippingMatrix_1.java | private int makeNum(int[] a) {
int n = 0;
for (int i = 0; i < a.length; i++) {
if (a[i] == 1) {
n |= (1 << (a.length - i - 1));
}
}
return n;
} | private int sample_funcname ( int [ ] var_0 ) {
int var_1 = 0 ;
for ( int var_2 = 0 ;
var_2 < var_0 . length ;
var_2 ++ ) {
if ( var_0 [ var_2 ] == 1 ) {
var_1 |= ( 1 << ( var_0 . length - var_2 - 1 ) ) ;
}
}
return var_1 ;
}
| 2 | 0<SEP>1 |
1,056 | <gouthampradhan>math_SmallestRangeI_1.java | public int smallestRangeI(int[] A, int K) {
Arrays.sort(A);
if (A.length == 0 || A.length == 1) return 0;
else {
int low = A[0];
int high = A[A.length - 1];
int l = low + (K);
int r = high - (K);
if (r > l) return r - l;
else return 0;
}
} | public int sample_funcname ( int [ ] var_0 , int var_1 ) {
Arrays . sort ( var_0 ) ;
if ( var_0 . length == 0 || var_0 . length == 1 ) return 0 ;
else {
int var_2 = var_0 [ 0 ] ;
int var_3 = var_0 [ var_0 . length - 1 ] ;
int var_4 = var_2 + ( var_1 ) ;
int var_5 = var_3 - ( var_1 ) ;
if ( var_5 > var_4 ) return var_5 - var_4 ;
else return 0 ;
}
}
| 2 | 0<SEP>1 |
1,057 | <gouthampradhan>array_ReadNCharacters_1.java | private int read4(char[] buf) {
return 1;
} | private int sample_funcname ( char [ ] var_0 ) {
return 1 ;
}
| 1 | 1 |
1,058 | <gouthampradhan>dynamic_programming_MinimumNumberOfRefuelingStops_1.java | public int minRefuelStops(int target, int startFuel, int[][] stations) {
long[] dp = new long[stations.length + 1];
dp[0] = startFuel;
for (int i = 0; i < stations.length; i++) {
int d = stations[i][0];
int f = stations[i][1];
for (int j = i; j >= 0; j--) {
if (dp[j] >= d) {
dp[j + 1] = Math.max(dp[j + 1], dp[j] + f);
}
}
}
for (int i = 0; i < dp.length; i++) {
if (dp[i] >= target) {
return i;
}
}
return -1;
} | public int sample_funcname ( int var_0 , int var_1 , int [ ] [ ] var_2 ) {
long [ ] var_3 = new long [ var_2 . length + 1 ] ;
var_3 [ 0 ] = var_1 ;
for ( int var_4 = 0 ;
var_4 < var_2 . length ;
var_4 ++ ) {
int var_5 = var_2 [ var_4 ] [ 0 ] ;
int var_6 = var_2 [ var_4 ] [ 1 ] ;
for ( int var_7 = var_4 ;
var_7 >= 0 ;
var_7 -- ) {
if ( var_3 [ var_7 ] >= var_5 ) {
var_3 [ var_7 + 1 ] = Math . max ( var_3 [ var_7 + 1 ] , var_3 [ var_7 ] + var_6 ) ;
}
}
}
for ( int var_4 = 0 ;
var_4 < var_3 . length ;
var_4 ++ ) {
if ( var_3 [ var_4 ] >= var_0 ) {
return var_4 ;
}
}
return - 1 ;
}
| 2 | 1<SEP>0 |
1,059 | <gouthampradhan>array_MaxConsecutiveOnesII_1.java | public int findMaxConsecutiveOnes(int[] nums) {
int[] L = new int[nums.length];
int[] R = new int[nums.length];
boolean flag = false;
int count = 0;
int max = 0;
for (int j = 0; j < nums.length; j++) {
if (nums[j] == 1) {
if (!flag) {
flag = true;
}
count++;
L[j] = count;
} else {
count = 0;
flag = false;
L[j] = count;
}
max = Math.max(max, count);
}
flag = false;
count = 0;
for (int j = nums.length - 1; j >= 0; j--) {
if (nums[j] == 1) {
if (!flag) {
flag = true;
}
count++;
R[j] = count;
} else {
count = 0;
flag = false;
R[j] = count;
}
}
for (int i = 0; i < nums.length; i++) {
if (nums[i] == 0) {
int l = i == 0 ? 0 : L[i - 1];
int r = i == nums.length - 1 ? 0 : R[i + 1];
max = Math.max(max, l + r + 1);
}
}
return max;
} | public int sample_funcname ( int [ ] var_0 ) {
int [ ] var_1 = new int [ var_0 . length ] ;
int [ ] var_2 = new int [ var_0 . length ] ;
boolean var_5 = false ;
int var_3 = 0 ;
int max = 0 ;
for ( int var_4 = 0 ;
var_4 < var_0 . length ;
var_4 ++ ) {
if ( var_0 [ var_4 ] == 1 ) {
if ( ! var_5 ) {
var_5 = true ;
}
var_3 ++ ;
var_1 [ var_4 ] = var_3 ;
}
else {
var_3 = 0 ;
var_5 = false ;
var_1 [ var_4 ] = var_3 ;
}
max = Math . max ( max , var_3 ) ;
}
var_5 = false ;
var_3 = 0 ;
for ( int var_4 = var_0 . length - 1 ;
var_4 >= 0 ;
var_4 -- ) {
if ( var_0 [ var_4 ] == 1 ) {
if ( ! var_5 ) {
var_5 = true ;
}
var_3 ++ ;
var_2 [ var_4 ] = var_3 ;
}
else {
var_3 = 0 ;
var_5 = false ;
var_2 [ var_4 ] = var_3 ;
}
}
for ( int var_6 = 0 ;
var_6 < var_0 . length ;
var_6 ++ ) {
if ( var_0 [ var_6 ] == 0 ) {
int var_7 = var_6 == 0 ? 0 : var_1 [ var_6 - 1 ] ;
int var_8 = var_6 == var_0 . length - 1 ? 0 : var_2 [ var_6 + 1 ] ;
max = Math . max ( max , var_7 + var_8 + 1 ) ;
}
}
return max ;
}
| 2 | 0<SEP>1 |
1,060 | <gouthampradhan>dynamic_programming_MinCostClimbingStairs_1.java | public int minCostClimbingStairs(int[] cost) {
for (int i = cost.length - 1; i >= 0; i--) {
if (i + 1 < cost.length && i + 2 < cost.length) {
cost[i] = Math.min(cost[i] + cost[i + 1], cost[i] + cost[i + 2]);
}
}
return Math.min(cost[0], cost[1]);
} | public int sample_funcname ( int [ ] var_0 ) {
for ( int var_1 = var_0 . length - 1 ;
var_1 >= 0 ;
var_1 -- ) {
if ( var_1 + 1 < var_0 . length && var_1 + 2 < var_0 . length ) {
var_0 [ var_1 ] = Math . min ( var_0 [ var_1 ] + var_0 [ var_1 + 1 ] , var_0 [ var_1 ] + var_0 [ var_1 + 2 ] ) ;
}
}
return Math . min ( var_0 [ 0 ] , var_0 [ 1 ] ) ;
}
| 3 | 1<SEP>0<SEP>2 |
1,061 | <gouthampradhan>math_ProjectionAreaOf3DShapes_1.java | public int projectionArea(int[][] grid) {
int area = 0;
for (int i = 0; i < grid.length; i++) {
for (int j = 0; j < grid.length; j++) {
area += (grid[i][j] > 0 ? 1 : 0);
}
}
for (int i = 0; i < grid.length; i++) {
int max = 0;
for (int j = 0; j < grid[0].length; j++) {
max = Math.max(max, grid[i][j]);
}
area += max;
}
for (int i = 0; i < grid[0].length; i++) {
int max = 0;
for (int j = 0; j < grid.length; j++) {
max = Math.max(max, grid[j][i]);
}
area += max;
}
return area;
} | public int sample_funcname ( int [ ] [ ] var_0 ) {
int var_1 = 0 ;
for ( int var_2 = 0 ;
var_2 < var_0 . length ;
var_2 ++ ) {
for ( int var_3 = 0 ;
var_3 < var_0 . length ;
var_3 ++ ) {
var_1 += ( var_0 [ var_2 ] [ var_3 ] > 0 ? 1 : 0 ) ;
}
}
for ( int var_2 = 0 ;
var_2 < var_0 . length ;
var_2 ++ ) {
int max = 0 ;
for ( int var_3 = 0 ;
var_3 < var_0 [ 0 ] . length ;
var_3 ++ ) {
max = Math . max ( max , var_0 [ var_2 ] [ var_3 ] ) ;
}
var_1 += max ;
}
for ( int var_2 = 0 ;
var_2 < var_0 [ 0 ] . length ;
var_2 ++ ) {
int max = 0 ;
for ( int var_3 = 0 ;
var_3 < var_0 . length ;
var_3 ++ ) {
max = Math . max ( max , var_0 [ var_3 ] [ var_2 ] ) ;
}
var_1 += max ;
}
return var_1 ;
}
| 2 | 0<SEP>1 |
1,062 | <gouthampradhan>two_pointers_SubarrayProductLessThanK_1.java | public int numSubarrayProductLessThanK(int[] nums, int k) {
long prod = 1;
int count = 0;
Queue<Integer> queue = new ArrayDeque<>();
for (int i = 0; i < nums.length; i++) {
if (nums[i] < k) {
count++;
if ((prod * nums[i]) < k) {
prod *= nums[i];
if (!queue.isEmpty()) {
count += (i - queue.peek());
}
} else {
while (!queue.isEmpty()) {
int last = queue.poll();
prod /= nums[last];
if ((prod * nums[i]) < k) {
prod = prod * nums[i];
if (!queue.isEmpty()) {
count += (i - queue.peek());
}
break;
}
}
}
if (queue.isEmpty()) {
prod = nums[i];
}
queue.offer(i);
} else {
queue.clear();
}
}
return count;
} | public int sample_funcname ( int [ ] var_0 , int var_1 ) {
long var_2 = 1 ;
int var_3 = 0 ;
Queue < Integer > var_4 = new ArrayDeque < > ( ) ;
for ( int var_5 = 0 ;
var_5 < var_0 . length ;
var_5 ++ ) {
if ( var_0 [ var_5 ] < var_1 ) {
var_3 ++ ;
if ( ( var_2 * var_0 [ var_5 ] ) < var_1 ) {
var_2 *= var_0 [ var_5 ] ;
if ( ! var_4 . isEmpty ( ) ) {
var_3 += ( var_5 - var_4 . peek ( ) ) ;
}
}
else {
while ( ! var_4 . isEmpty ( ) ) {
int var_6 = var_4 . poll ( ) ;
var_2 /= var_0 [ var_6 ] ;
if ( ( var_2 * var_0 [ var_5 ] ) < var_1 ) {
var_2 = var_2 * var_0 [ var_5 ] ;
if ( ! var_4 . isEmpty ( ) ) {
var_3 += ( var_5 - var_4 . peek ( ) ) ;
}
break ;
}
}
}
if ( var_4 . isEmpty ( ) ) {
var_2 = var_0 [ var_5 ] ;
}
var_4 . offer ( var_5 ) ;
}
else {
var_4 . clear ( ) ;
}
}
return var_3 ;
}
| 2 | 1<SEP>0 |
1,063 | <gouthampradhan>backtracking_RegularExpressionMatching_1.java | private boolean backTrack(int si, int pi, String s, String p) {
if (si >= s.length() && pi >= p.length())
return true;
else {
if (pi >= p.length()) return false;
else if (si >= s.length()) {
if (pi + 1 < p.length() && p.charAt(pi + 1) == '*') {
return backTrack(si, pi + 2, s, p);
} else
return false;
} else if (s.charAt(si) == p.charAt(pi) || p.charAt(pi) == '.') {
if (pi + 1 < p.length() && p.charAt(pi + 1) == '*') {
if (backTrack(si, pi + 2, s, p)) return true;
for (int i = si, l = s.length(); i < l; i++) {
if (s.charAt(i) == p.charAt(pi) || p.charAt(pi) == '.') {
if (backTrack(i + 1, pi + 2, s, p)) return true;
} else {
return false;
}
}
return backTrack(s.length(), pi, s, p);
} else {
return backTrack(si + 1, pi + 1, s, p);
}
} else {
if (pi + 1 < p.length() && p.charAt(pi + 1) == '*') {
return backTrack(si, pi + 2, s, p);
} else return false;
}
}
} | private boolean sample_funcname ( int si , int pi , String s , String p ) {
if ( si >= s . length ( ) && pi >= p . length ( ) ) return true ;
else {
if ( pi >= p . length ( ) ) return false ;
else if ( si >= s . length ( ) ) {
if ( pi + 1 < p . length ( ) && p . charAt ( pi + 1 ) == '*' ) {
return backTrack ( si , pi + 2 , s , p ) ;
}
else return false ;
}
else if ( s . charAt ( si ) == p . charAt ( pi ) || p . charAt ( pi ) == '.' ) {
if ( pi + 1 < p . length ( ) && p . charAt ( pi + 1 ) == '*' ) {
if ( backTrack ( si , pi + 2 , s , p ) ) return true ;
for ( int i = si , l = s . length ( ) ;
i < l ;
i ++ ) {
if ( s . charAt ( i ) == p . charAt ( pi ) || p . charAt ( pi ) == '.' ) {
if ( backTrack ( i + 1 , pi + 2 , s , p ) ) return true ;
}
else {
return false ;
}
}
return backTrack ( s . length ( ) , pi , s , p ) ;
}
else {
return backTrack ( si + 1 , pi + 1 , s , p ) ;
}
}
else {
if ( pi + 1 < p . length ( ) && p . charAt ( pi + 1 ) == '*' ) {
return backTrack ( si , pi + 2 , s , p ) ;
}
else return false ;
}
}
}
| 4 | <S_QUOTE>.<S_QUOTE><SEP>2<SEP>1<SEP><S_QUOTE>*<S_QUOTE> |
1,064 | <gouthampradhan>array_BestMeetingPoint_1.java | public int minTotalDistance(int[][] grid) {
int[] countR = new int[grid.length];
int[] countC = new int[grid[0].length];
int[] distR = new int[grid.length];
int[] distC = new int[grid[0].length];
for (int i = 0; i < grid.length; i++) {
for (int j = 0; j < grid[0].length; j++) {
if (grid[i][j] == 1) {
countR[i]++;
countC[j]++;
}
}
}
for (int i = 0; i < distR.length; i++) {
for (int j = 0; j < distR.length; j++) {
if (countR[j] != 0) {
distR[i] += Math.abs(j - i) * countR[j];
}
}
}
for (int i = 0; i < distC.length; i++) {
for (int j = 0; j < distC.length; j++) {
if (countC[j] != 0) {
distC[i] += Math.abs(j - i) * countC[j];
}
}
}
int min = Integer.MAX_VALUE;
for (int i = 0; i < distR.length; i++) {
for (int j = 0; j < distC.length; j++) {
min = Math.min(min, distR[i] + distC[j]);
}
}
return min;
} | public int sample_funcname ( int [ ] [ ] var_0 ) {
int [ ] var_1 = new int [ var_0 . length ] ;
int [ ] var_2 = new int [ var_0 [ 0 ] . length ] ;
int [ ] var_3 = new int [ var_0 . length ] ;
int [ ] var_4 = new int [ var_0 [ 0 ] . length ] ;
for ( int var_5 = 0 ;
var_5 < var_0 . length ;
var_5 ++ ) {
for ( int var_6 = 0 ;
var_6 < var_0 [ 0 ] . length ;
var_6 ++ ) {
if ( var_0 [ var_5 ] [ var_6 ] == 1 ) {
var_1 [ var_5 ] ++ ;
var_2 [ var_6 ] ++ ;
}
}
}
for ( int var_5 = 0 ;
var_5 < var_3 . length ;
var_5 ++ ) {
for ( int var_6 = 0 ;
var_6 < var_3 . length ;
var_6 ++ ) {
if ( var_1 [ var_6 ] != 0 ) {
var_3 [ var_5 ] += Math . abs ( var_6 - var_5 ) * var_1 [ var_6 ] ;
}
}
}
for ( int var_5 = 0 ;
var_5 < var_4 . length ;
var_5 ++ ) {
for ( int var_6 = 0 ;
var_6 < var_4 . length ;
var_6 ++ ) {
if ( var_2 [ var_6 ] != 0 ) {
var_4 [ var_5 ] += Math . abs ( var_6 - var_5 ) * var_2 [ var_6 ] ;
}
}
}
int min = Integer . MAX_VALUE ;
for ( int var_5 = 0 ;
var_5 < var_3 . length ;
var_5 ++ ) {
for ( int var_6 = 0 ;
var_6 < var_4 . length ;
var_6 ++ ) {
min = Math . min ( min , var_3 [ var_5 ] + var_4 [ var_6 ] ) ;
}
}
return min ;
}
| 2 | 0<SEP>1 |
1,065 | <gouthampradhan>two_pointers_MoveZeroes_1.java | public void moveZeroes(int[] nums) {
int i = 0;
for (int j = 0, l = nums.length; j < l; ) {
if (nums[j] == 0) j++;
else {
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
i++;
j++;
}
}
while (i < nums.length) nums[i++] = 0;
} | public void var_0 ( int [ ] var_1 ) {
int var_2 = 0 ;
for ( int var_3 = 0 , var_4 = var_1 . length ;
var_3 < var_4 ;
) {
if ( var_1 [ var_3 ] == 0 ) var_3 ++ ;
else {
int var_5 = var_1 [ var_2 ] ;
var_1 [ var_2 ] = var_1 [ var_3 ] ;
var_1 [ var_3 ] = var_5 ;
var_2 ++ ;
var_3 ++ ;
}
}
while ( var_2 < var_1 . length ) var_1 [ var_2 ++ ] = 0 ;
}
| 1 | 0 |
1,066 | <gouthampradhan>breadth_first_search_BusRoutes_1.java | private boolean intersect(int[] A, int[] B) {
for (int i = 0, j = 0; i < A.length && j < B.length; ) {
if (A[i] == B[j]) return true;
else if (A[i] < B[j]) i++;
else j++;
}
return false;
} | private boolean var_0 ( int [ ] var_1 , int [ ] var_2 ) {
for ( int var_3 = 0 , var_4 = 0 ;
var_3 < var_1 . length && var_4 < var_2 . length ;
) {
if ( var_1 [ var_3 ] == var_2 [ var_4 ] ) return true ;
else if ( var_1 [ var_3 ] < var_2 [ var_4 ] ) var_3 ++ ;
else var_4 ++ ;
}
return false ;
}
| 1 | 0 |
1,067 | <gouthampradhan>backtracking_PalindromePartitioning_1.java | private boolean isPalindrome(String s) {
int i = 0, j = s.length() - 1;
while (i <= j) {
if (s.charAt(i) != s.charAt(j)) return false;
i++;
j--;
}
return true;
} | private boolean var_0 ( String var_1 ) {
int var_2 = 0 , var_3 = var_1 . length ( ) - 1 ;
while ( var_2 <= var_3 ) {
if ( var_1 . charAt ( var_2 ) != var_1 . charAt ( var_3 ) ) return false ;
var_2 ++ ;
var_3 -- ;
}
return true ;
}
| 2 | 0<SEP>1 |
1,068 | <gouthampradhan>bit_manipulation_DivideTwoIntegers_1.java | public int divide(int dividend, int divisor) {
if (divisor == 0) return Integer.MAX_VALUE;
else if (dividend == Integer.MIN_VALUE && divisor == -1) return Integer.MAX_VALUE;
else if (divisor == 1) return dividend;
boolean isNegative = ((dividend < 0 && divisor > 0) || (dividend > 0 && divisor < 0));
dividend = (dividend < 0) ? -dividend : dividend;
divisor = (divisor < 0) ? -divisor : divisor;
int sum, result = 0;
while (true) {
int d1 = divisor;
sum = 0;
if (dividend - d1 == 0) {
sum += 1;
result += sum;
break;
}
if (dividend - d1 < 0) break;
while (dividend - (d1 << 1) > 0) {
d1 <<= 1;
sum += 1;
}
result += (1 << sum);
dividend = dividend - d1;
}
return isNegative ? -result : result;
} | public int sample_funcname ( int var_0 , int var_1 ) {
if ( var_1 == 0 ) return Integer . MAX_VALUE ;
else if ( var_0 == Integer . MIN_VALUE && var_1 == - 1 ) return Integer . MAX_VALUE ;
else if ( var_1 == 1 ) return var_0 ;
boolean var_2 = ( ( var_0 < 0 && var_1 > 0 ) || ( var_0 > 0 && var_1 < 0 ) ) ;
var_0 = ( var_0 < 0 ) ? - var_0 : var_0 ;
var_1 = ( var_1 < 0 ) ? - var_1 : var_1 ;
int var_3 , var_4 = 0 ;
while ( true ) {
int var_5 = var_1 ;
var_3 = 0 ;
if ( var_0 - var_5 == 0 ) {
var_3 += 1 ;
var_4 += var_3 ;
break ;
}
if ( var_0 - var_5 < 0 ) break ;
while ( var_0 - ( var_5 << 1 ) > 0 ) {
var_5 <<= 1 ;
var_3 += 1 ;
}
var_4 += ( 1 << var_3 ) ;
var_0 = var_0 - var_5 ;
}
return var_2 ? - var_4 : var_4 ;
}
| 2 | 0<SEP>1 |
1,069 | <gouthampradhan>dynamic_programming_SplitArrayLargestSum_1.java | public int splitArray(int[] nums, int m) {
int[][] dp = new int[m][nums.length];
for (int i = nums.length - 1; i >= 0; i--) {
int sum = 0;
for (int j = i; j < nums.length; j++) {
sum += nums[j];
if (j + 1 >= nums.length) break;
for (int k = 0; k < m - 1; k++) {
dp[k + 1][i] = (dp[k + 1][i] == 0) ? Integer.MAX_VALUE : dp[k + 1][i];
int temp = Math.max(sum, dp[k][j + 1]);
dp[k + 1][i] = Math.min(dp[k + 1][i], temp);
}
}
dp[0][i] = sum;
}
return dp[m - 1][0];
} | public int sample_funcname ( int [ ] var_0 , int var_1 ) {
int [ ] [ ] var_2 = new int [ var_1 ] [ var_0 . length ] ;
for ( int var_3 = var_0 . length - 1 ;
var_3 >= 0 ;
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_5 + 1 >= var_0 . length ) break ;
for ( int var_6 = 0 ;
var_6 < var_1 - 1 ;
var_6 ++ ) {
var_2 [ var_6 + 1 ] [ var_3 ] = ( var_2 [ var_6 + 1 ] [ var_3 ] == 0 ) ? Integer . MAX_VALUE : var_2 [ var_6 + 1 ] [ var_3 ] ;
int var_7 = Math . max ( var_4 , var_2 [ var_6 ] [ var_5 + 1 ] ) ;
var_2 [ var_6 + 1 ] [ var_3 ] = Math . min ( var_2 [ var_6 + 1 ] [ var_3 ] , var_7 ) ;
}
}
var_2 [ 0 ] [ var_3 ] = var_4 ;
}
return var_2 [ var_1 - 1 ] [ 0 ] ;
}
| 2 | 1<SEP>0 |
1,070 | <gouthampradhan>backtracking_Permutations_1.java | private void nextPermutation(int i, int[] nums, List<List<Integer>> result) {
if (i == nums.length - 1) {
List<Integer> list = new ArrayList<>();
for (int n : nums) list.add(n);
result.add(list);
} else {
for (int j = i, l = nums.length; j < l; j++) {
int temp = nums[j];
nums[j] = nums[i];
nums[i] = temp;
nextPermutation(i + 1, nums, result);
temp = nums[j];
nums[j] = nums[i];
nums[i] = temp;
}
}
} | private void sample_funcname ( int i , int [ ] nums , List < List < Integer >> result ) {
if ( i == nums . length - 1 ) {
List < Integer > list = new ArrayList < > ( ) ;
for ( int n : nums ) list . add ( n ) ;
result . add ( list ) ;
}
else {
for ( int j = i , l = nums . length ;
j < l ;
j ++ ) {
int temp = nums [ j ] ;
nums [ j ] = nums [ i ] ;
nums [ i ] = temp ;
nextPermutation ( i + 1 , nums , result ) ;
temp = nums [ j ] ;
nums [ j ] = nums [ i ] ;
nums [ i ] = temp ;
}
}
}
| 1 | 1 |
1,071 | <gouthampradhan>string_NumberOfMatchingSubsequences_1.java | private boolean isSubsequence(String S, String P) {
int i = 0, j = 0;
if (P.length() > S.length()) return false;
for (; ; ) {
if (j >= P.length()) return true;
else if (i >= S.length()) return false;
else {
if (S.charAt(i) == P.charAt(j)) {
i++;
j++;
} else {
i++;
}
}
}
} | private boolean var_0 ( String var_1 , String var_2 ) {
int var_3 = 0 , var_4 = 0 ;
if ( var_2 . length ( ) > var_1 . length ( ) ) return false ;
for ( ;
;
) {
if ( var_4 >= var_2 . length ( ) ) return true ;
else if ( var_3 >= var_1 . length ( ) ) return false ;
else {
if ( var_1 . charAt ( var_3 ) == var_2 . charAt ( var_4 ) ) {
var_3 ++ ;
var_4 ++ ;
}
else {
var_3 ++ ;
}
}
}
}
| 1 | 0 |
1,072 | <gouthampradhan>math_RangeAdditionII_1.java | public int maxCount(int m, int n, int[][] ops) {
int minR = m;
int minC = n;
for (int[] v : ops) {
minR = Math.min(minR, v[0]);
minC = Math.min(minC, v[1]);
}
return minR * minC;
} | public int sample_funcname ( int var_0 , int var_1 , int [ ] [ ] var_2 ) {
int var_3 = var_0 ;
int var_4 = var_1 ;
for ( int [ ] var_5 : var_2 ) {
var_3 = Math . min ( var_3 , var_5 [ 0 ] ) ;
var_4 = Math . min ( var_4 , var_5 [ 1 ] ) ;
}
return var_3 * var_4 ;
}
| 2 | 0<SEP>1 |
1,073 | <gouthampradhan>math_SuperWashingMachines_1.java | public int findMinMoves(int[] machines) {
long sum = Arrays.stream(machines).asLongStream().sum();
if (((sum / machines.length) < 0) || ((sum % machines.length) != 0)) return -1;
int n = (int) (sum / machines.length);
int count = 0, moves = Integer.MIN_VALUE;
for (int i = 0; i < machines.length; i++) {
count += (machines[i] - n);
moves = Math.max(moves, Math.max(Math.abs(count), (machines[i] - n)));
}
return moves;
} | public int sample_funcname ( int [ ] var_0 ) {
long sum = Arrays . stream ( var_0 ) . asLongStream ( ) . sum ( ) ;
if ( ( ( sum / var_0 . length ) < 0 ) || ( ( sum % var_0 . length ) != 0 ) ) return - 1 ;
int var_1 = ( int ) ( sum / var_0 . length ) ;
int var_2 = 0 , var_3 = Integer . MIN_VALUE ;
for ( int var_4 = 0 ;
var_4 < var_0 . length ;
var_4 ++ ) {
var_2 += ( var_0 [ var_4 ] - var_1 ) ;
var_3 = Math . max ( var_3 , Math . max ( Math . abs ( var_2 ) , ( var_0 [ var_4 ] - var_1 ) ) ) ;
}
return var_3 ;
}
| 2 | 0<SEP>1 |
1,074 | <gouthampradhan>dynamic_programming_CherryPickup_1.java | private int dp(int N, int r1, int c1, int c2, int[][][] DP, int[][] grid) {
int r2 = r1 + (c1 - c2);
if (r1 >= N || c1 >= N || c2 >= N || r2 >= N || grid[r1][c1] == -1 || grid[r2][c2] == -1)
return Integer.MIN_VALUE;
else if (DP[r1][c1][c2] != -1) return DP[r1][c1][c2];
else if (r1 == N - 1 && c1 == N - 1) return grid[N - 1][N - 1];
else {
int max = (c1 == c2) ? grid[r1][c1] : (grid[r1][c1] + grid[r2][c2]);
max +=
Math.max(
Math.max(
Math.max(dp(N, r1 + 1, c1, c2, DP, grid), dp(N, r1 + 1, c1, c2 + 1, DP, grid)),
dp(N, r1, c1 + 1, c2, DP, grid)),
dp(N, r1, c1 + 1, c2 + 1, DP, grid));
DP[r1][c1][c2] = max;
return max;
}
} | private int sample_funcname ( int N , int r1 , int c1 , int c2 , int [ ] [ ] [ ] DP , int [ ] [ ] grid ) {
int r2 = r1 + ( c1 - c2 ) ;
if ( r1 >= N || c1 >= N || c2 >= N || r2 >= N || grid [ r1 ] [ c1 ] == - 1 || grid [ r2 ] [ c2 ] == - 1 ) return Integer . MIN_VALUE ;
else if ( DP [ r1 ] [ c1 ] [ c2 ] != - 1 ) return DP [ r1 ] [ c1 ] [ c2 ] ;
else if ( r1 == N - 1 && c1 == N - 1 ) return grid [ N - 1 ] [ N - 1 ] ;
else {
int max = ( c1 == c2 ) ? grid [ r1 ] [ c1 ] : ( grid [ r1 ] [ c1 ] + grid [ r2 ] [ c2 ] ) ;
max += Math . max ( Math . max ( Math . max ( dp ( N , r1 + 1 , c1 , c2 , DP , grid ) , dp ( N , r1 + 1 , c1 , c2 + 1 , DP , grid ) ) , dp ( N , r1 , c1 + 1 , c2 , DP , grid ) ) , dp ( N , r1 , c1 + 1 , c2 + 1 , DP , grid ) ) ;
DP [ r1 ] [ c1 ] [ c2 ] = max ;
return max ;
}
}
| 1 | 1 |
1,075 | <gouthampradhan>backtracking_WildcardMatching_1.java | public boolean isMatch(String s, String p) {
int starIdx = -1;
int starPosAtStr = -1;
int j = 0;
for (int i = 0, l = s.length(); i < l; ) {
if (j < p.length()) {
if (s.charAt(i) == p.charAt(j) || p.charAt(j) == '?') {
i++;
j++;
} else if (p.charAt(j) == '*') {
starIdx = j;
starPosAtStr = i;
j++;
} else if (starIdx != -1) {
i = ++starPosAtStr;
j = starIdx + 1;
} else return false;
} else if (starIdx != -1) {
i = ++starPosAtStr;
j = starIdx + 1;
} else return false;
}
while (j < p.length()) {
if (p.charAt(j) == '*') {
j++;
} else break;
}
return j == p.length();
} | public boolean var_0 ( String var_1 , String var_2 ) {
int var_3 = - 1 ;
int var_4 = - 1 ;
int var_5 = 0 ;
for ( int var_6 = 0 , var_7 = var_1 . length ( ) ;
var_6 < var_7 ;
) {
if ( var_5 < var_2 . length ( ) ) {
if ( var_1 . charAt ( var_6 ) == var_2 . charAt ( var_5 ) || var_2 . charAt ( var_5 ) == '?' ) {
var_6 ++ ;
var_5 ++ ;
}
else if ( var_2 . charAt ( var_5 ) == '*' ) {
var_3 = var_5 ;
var_4 = var_6 ;
var_5 ++ ;
}
else if ( var_3 != - 1 ) {
var_6 = ++ var_4 ;
var_5 = var_3 + 1 ;
}
else return false ;
}
else if ( var_3 != - 1 ) {
var_6 = ++ var_4 ;
var_5 = var_3 + 1 ;
}
else return false ;
}
while ( var_5 < var_2 . length ( ) ) {
if ( var_2 . charAt ( var_5 ) == '*' ) {
var_5 ++ ;
}
else break ;
}
return var_5 == var_2 . length ( ) ;
}
| 4 | 1<SEP>0<SEP><S_QUOTE>?<S_QUOTE><SEP><S_QUOTE>*<S_QUOTE> |
1,076 | <gouthampradhan>string_PushDominoes_1.java | public String pushDominoes(String dominoes) {
int R = -1, L = -1;
char[] A = dominoes.toCharArray();
for (int i = 0; i < A.length; i++) {
if (A[i] == 'L') {
if (R > L) {
int d = (i - R);
int st;
st = R + d / 2;
if ((d % 2) == 0) {
A[st] = '.';
}
for (int j = st + 1; j < i; j++) {
A[j] = 'L';
}
} else {
for (int j = (L == -1 ? 0 : L); j < i; j++) {
A[j] = 'L';
}
}
L = i;
} else {
if (A[i] == 'R') {
R = i;
} else {
if (R > L) {
A[i] = 'R';
}
}
}
}
return String.valueOf(A);
} | public String var_0 ( String var_1 ) {
int var_2 = - 1 , var_3 = - 1 ;
char [ ] var_4 = var_1 . toCharArray ( ) ;
for ( int var_5 = 0 ;
var_5 < var_4 . length ;
var_5 ++ ) {
if ( var_4 [ var_5 ] == 'L' ) {
if ( var_2 > var_3 ) {
int var_6 = ( var_5 - var_2 ) ;
int var_7 ;
var_7 = var_2 + var_6 / 2 ;
if ( ( var_6 % 2 ) == 0 ) {
var_4 [ var_7 ] = '.' ;
}
for ( int var_8 = var_7 + 1 ;
var_8 < var_5 ;
var_8 ++ ) {
var_4 [ var_8 ] = 'L' ;
}
}
else {
for ( int var_8 = ( var_3 == - 1 ? 0 : var_3 ) ;
var_8 < var_5 ;
var_8 ++ ) {
var_4 [ var_8 ] = 'L' ;
}
}
var_3 = var_5 ;
}
else {
if ( var_4 [ var_5 ] == 'R' ) {
var_2 = var_5 ;
}
else {
if ( var_2 > var_3 ) {
var_4 [ var_5 ] = 'R' ;
}
}
}
}
return String . valueOf ( var_4 ) ;
}
| 6 | <S_QUOTE>R<S_QUOTE><SEP><S_QUOTE>L<S_QUOTE><SEP>2<SEP>1<SEP>0<SEP><S_QUOTE>.<S_QUOTE> |
1,077 | <gouthampradhan>array_NextGreaterElementI_1.java | public int[] nextGreaterElement(int[] nums1, int[] nums2) {
int[] result = new int[nums1.length];
for (int i = 0; i < nums1.length; i++) {
int n = nums1[i];
boolean found = false;
int nF = 0;
for (int j = 0; j < nums2.length; j++) {
if (nums2[j] == n) {
found = true;
}
if (found) {
if (nums2[j] > n) {
nF = nums2[j];
break;
}
}
}
if (found) {
result[i] = nF;
} else {
result[i] = -1;
}
}
return result;
} | public int [ ] sample_funcname ( int [ ] var_0 , int [ ] var_1 ) {
int [ ] var_2 = new int [ var_0 . length ] ;
for ( int var_3 = 0 ;
var_3 < var_0 . length ;
var_3 ++ ) {
int var_4 = var_0 [ var_3 ] ;
boolean var_7 = false ;
int var_5 = 0 ;
for ( int var_6 = 0 ;
var_6 < var_1 . length ;
var_6 ++ ) {
if ( var_1 [ var_6 ] == var_4 ) {
var_7 = true ;
}
if ( var_7 ) {
if ( var_1 [ var_6 ] > var_4 ) {
var_5 = var_1 [ var_6 ] ;
break ;
}
}
}
if ( var_7 ) {
var_2 [ var_3 ] = var_5 ;
}
else {
var_2 [ var_3 ] = - 1 ;
}
}
return var_2 ;
}
| 2 | 0<SEP>1 |
1,078 | <gouthampradhan>hashing_NumberOfAtoms_1.java | private Map<String, Integer> merge(Map<String, Integer> left, Map<String, Integer> right) {
for (String k : left.keySet()) {
if (right.containsKey(k)) {
right.put(k, right.get(k) + left.get(k));
} else right.put(k, left.get(k));
}
return right;
} | private Map < String , Integer > var_0 ( Map < String , Integer > var_1 , Map < String , Integer > var_2 ) {
for ( String var_3 : var_1 . keySet ( ) ) {
if ( var_2 . containsKey ( var_3 ) ) {
var_2 . put ( var_3 , var_2 . get ( var_3 ) + var_1 . get ( var_3 ) ) ;
}
else var_2 . put ( var_3 , var_1 . get ( var_3 ) ) ;
}
return var_2 ;
}
| 0 | null |
1,079 | <gouthampradhan>array_MaxConsecutiveOnes_1.java | public int findMaxConsecutiveOnes(int[] nums) {
int max = 0;
boolean flag = false;
int count = 0;
for (int i = 0; i < nums.length; i++) {
if (nums[i] == 1) {
if (!flag) {
flag = true;
}
count++;
max = Math.max(max, count);
} else {
count = 0;
flag = false;
}
}
return max;
} | public int sample_funcname ( int [ ] var_0 ) {
int max = 0 ;
boolean var_3 = false ;
int var_1 = 0 ;
for ( int var_2 = 0 ;
var_2 < var_0 . length ;
var_2 ++ ) {
if ( var_0 [ var_2 ] == 1 ) {
if ( ! var_3 ) {
var_3 = true ;
}
var_1 ++ ;
max = Math . max ( max , var_1 ) ;
}
else {
var_1 = 0 ;
var_3 = false ;
}
}
return max ;
}
| 2 | 0<SEP>1 |
1,080 | <gouthampradhan>binary_search_SearchInsertPosition_1.java | public int searchInsert(int[] nums, int target) {
int pos = nums.length;
int s = 0, e = nums.length - 1;
while (s <= e) {
int m = s + (e - s) / 2;
if (nums[m] >= target) {
pos = m;
e = m - 1;
} else s = m + 1;
}
return pos;
} | public int sample_funcname ( int [ ] var_0 , int var_1 ) {
int var_2 = var_0 . length ;
int var_3 = 0 , var_4 = var_0 . length - 1 ;
while ( var_3 <= var_4 ) {
int var_5 = var_3 + ( var_4 - var_3 ) / 2 ;
if ( var_0 [ var_5 ] >= var_1 ) {
var_2 = var_5 ;
var_4 = var_5 - 1 ;
}
else var_3 = var_5 + 1 ;
}
return var_2 ;
}
| 3 | 2<SEP>0<SEP>1 |
1,081 | <gouthampradhan>math_SquirrelSimulation_1.java | public int minDistance(int height, int width, int[] tree, int[] squirrel, int[][] nuts) {
int dist = 0;
for (int[] n : nuts) {
dist += Math.abs(n[0] - tree[0]) + Math.abs(n[1] - tree[1]);
}
dist *= 2;
int ans = Integer.MAX_VALUE;
for (int[] n : nuts) {
int nutDist = Math.abs(n[0] - squirrel[0]) + Math.abs(n[1] - squirrel[1]);
ans = Math.min(ans, dist - (Math.abs(n[0] - tree[0]) + Math.abs(n[1] - tree[1])) + nutDist);
}
return ans;
} | public int sample_funcname ( int var_0 , int var_1 , int [ ] var_2 , int [ ] var_3 , int [ ] [ ] var_4 ) {
int var_5 = 0 ;
for ( int [ ] var_6 : var_4 ) {
var_5 += Math . abs ( var_6 [ 0 ] - var_2 [ 0 ] ) + Math . abs ( var_6 [ 1 ] - var_2 [ 1 ] ) ;
}
var_5 *= 2 ;
int var_7 = Integer . MAX_VALUE ;
for ( int [ ] var_6 : var_4 ) {
int var_8 = Math . abs ( var_6 [ 0 ] - var_3 [ 0 ] ) + Math . abs ( var_6 [ 1 ] - var_3 [ 1 ] ) ;
var_7 = Math . min ( var_7 , var_5 - ( Math . abs ( var_6 [ 0 ] - var_2 [ 0 ] ) + Math . abs ( var_6 [ 1 ] - var_2 [ 1 ] ) ) + var_8 ) ;
}
return var_7 ;
}
| 3 | 2<SEP>0<SEP>1 |
1,082 | <gouthampradhan>string_ReconstructOriginalDigitsFromEnglish_1.java | private void update(
Map<Character, Integer> map,
Map<Integer, Integer> intMap,
int num,
char id,
List<Character> list) {
if (map.containsKey(id)) {
int count = map.get(id);
intMap.put(num, count);
while (count-- > 0) {
for (char c : list) {
map.put(c, map.get(c) - 1);
}
}
}
} | private void var_0 ( Map < Character , Integer > var_1 , Map < Integer , Integer > var_2 , int var_3 , char var_4 , List < Character > var_5 ) {
if ( var_1 . containsKey ( var_4 ) ) {
int var_6 = var_1 . get ( var_4 ) ;
var_2 . put ( var_3 , var_6 ) ;
while ( var_6 -- > 0 ) {
for ( char var_7 : var_5 ) {
var_1 . put ( var_7 , var_1 . get ( var_7 ) - 1 ) ;
}
}
}
}
| 2 | 0<SEP>1 |
1,083 | <gouthampradhan>math_CouplesHoldingHands_1.java | private int find(int[] A, int n) {
for (int i = 0; i < A.length; i++) {
if (A[i] == n) {
return i;
}
}
return -1;
} | private int sample_funcname ( int [ ] var_0 , int var_1 ) {
for ( int var_2 = 0 ;
var_2 < var_0 . length ;
var_2 ++ ) {
if ( var_0 [ var_2 ] == var_1 ) {
return var_2 ;
}
}
return - 1 ;
}
| 2 | 0<SEP>1 |
1,084 | <gouthampradhan>string_LongestCommonPrefix_1.java | public String longestCommonPrefix(String[] strs) {
if (strs.length == 0) return "";
String result = strs[0];
for (int i = 1; i < strs.length; i++) {
String s = strs[i];
for (int j = 0; j < result.length(); j++) {
if (j >= s.length() || result.charAt(j) != s.charAt(j)) {
result = result.substring(0, j);
break;
}
}
}
return result;
} | public String var_0 ( String [ ] var_1 ) {
if ( var_1 . length == 0 ) return "" ;
String var_2 = var_1 [ 0 ] ;
for ( int var_3 = 1 ;
var_3 < var_1 . length ;
var_3 ++ ) {
String var_4 = var_1 [ var_3 ] ;
for ( int var_5 = 0 ;
var_5 < var_2 . length ( ) ;
var_5 ++ ) {
if ( var_5 >= var_4 . length ( ) || var_2 . charAt ( var_5 ) != var_4 . charAt ( var_5 ) ) {
var_2 = var_2 . substring ( 0 , var_5 ) ;
break ;
}
}
}
return var_2 ;
}
| 3 | 0<SEP><D_QUOTE><D_QUOTE><SEP>1 |
1,085 | <gouthampradhan>binary_search_SingleElementInASortedArray_1.java | public int singleNonDuplicate(int[] nums) {
if (nums.length == 1) return nums[0];
int l = 0, h = nums.length - 1;
while (l <= h) {
int m = l + ((h - l) / 2);
int N = nums[m];
if (m + 1 >= nums.length) {
if (nums[m - 1] != N) {
return N;
}
h = m - 1;
} else if (m - 1 < 0) {
if (nums[m + 1] != N) {
return N;
}
l = m + 1;
} else {
if (m % 2 == 0) {
if (nums[m + 1] != N && nums[m - 1] != N) {
return N;
} else if (nums[m + 1] != N) {
h = m - 1;
} else l = m + 1;
} else {
if (nums[m + 1] != N && nums[m - 1] != N) {
return N;
} else if (nums[m - 1] != N) {
h = m - 1;
} else l = m + 1;
}
}
}
return -1;
} | public int sample_funcname ( int [ ] var_0 ) {
if ( var_0 . length == 1 ) return var_0 [ 0 ] ;
int var_1 = 0 , var_2 = var_0 . length - 1 ;
while ( var_1 <= var_2 ) {
int var_3 = var_1 + ( ( var_2 - var_1 ) / 2 ) ;
int var_4 = var_0 [ var_3 ] ;
if ( var_3 + 1 >= var_0 . length ) {
if ( var_0 [ var_3 - 1 ] != var_4 ) {
return var_4 ;
}
var_2 = var_3 - 1 ;
}
else if ( var_3 - 1 < 0 ) {
if ( var_0 [ var_3 + 1 ] != var_4 ) {
return var_4 ;
}
var_1 = var_3 + 1 ;
}
else {
if ( var_3 % 2 == 0 ) {
if ( var_0 [ var_3 + 1 ] != var_4 && var_0 [ var_3 - 1 ] != var_4 ) {
return var_4 ;
}
else if ( var_0 [ var_3 + 1 ] != var_4 ) {
var_2 = var_3 - 1 ;
}
else var_1 = var_3 + 1 ;
}
else {
if ( var_0 [ var_3 + 1 ] != var_4 && var_0 [ var_3 - 1 ] != var_4 ) {
return var_4 ;
}
else if ( var_0 [ var_3 - 1 ] != var_4 ) {
var_2 = var_3 - 1 ;
}
else var_1 = var_3 + 1 ;
}
}
}
return - 1 ;
}
| 3 | 1<SEP>0<SEP>2 |
1,086 | <gouthampradhan>array_ValidTicTacToeState_1.java | private boolean hasWon(String[] board, char c) {
boolean diagnol =
((board[0].charAt(0) == c && board[1].charAt(1) == c && board[2].charAt(2) == c)
|| (board[0].charAt(2) == c && board[1].charAt(1) == c && board[2].charAt(0) == c));
if (diagnol) return true;
for (int i = 0; i < 3; i++) {
if (board[i].charAt(0) == c && board[i].charAt(1) == c && board[i].charAt(2) == c)
return true;
}
for (int i = 0; i < 3; i++) {
if (board[0].charAt(i) == c && board[1].charAt(i) == c && board[2].charAt(i) == c)
return true;
}
return false;
} | private boolean var_0 ( String [ ] var_1 , char var_2 ) {
boolean var_3 = ( ( var_1 [ 0 ] . charAt ( 0 ) == var_2 && var_1 [ 1 ] . charAt ( 1 ) == var_2 && var_1 [ 2 ] . charAt ( 2 ) == var_2 ) || ( var_1 [ 0 ] . charAt ( 2 ) == var_2 && var_1 [ 1 ] . charAt ( 1 ) == var_2 && var_1 [ 2 ] . charAt ( 0 ) == var_2 ) ) ;
if ( var_3 ) return true ;
for ( int var_4 = 0 ;
var_4 < 3 ;
var_4 ++ ) {
if ( var_1 [ var_4 ] . charAt ( 0 ) == var_2 && var_1 [ var_4 ] . charAt ( 1 ) == var_2 && var_1 [ var_4 ] . charAt ( 2 ) == var_2 ) return true ;
}
for ( int var_4 = 0 ;
var_4 < 3 ;
var_4 ++ ) {
if ( var_1 [ 0 ] . charAt ( var_4 ) == var_2 && var_1 [ 1 ] . charAt ( var_4 ) == var_2 && var_1 [ 2 ] . charAt ( var_4 ) == var_2 ) return true ;
}
return false ;
}
| 4 | 2<SEP>0<SEP>3<SEP>1 |
1,087 | <gouthampradhan>greedy_ReducingDishes_1.java | public int maxSatisfaction(int[] satisfaction) {
Queue<Integer> pq = new PriorityQueue<>(((o1, o2) -> o2 - o1));
Arrays.stream(satisfaction).forEach(pq::offer);
int max = 0, sum = 0;
while (!pq.isEmpty()) {
if ((max + sum) >= max) {
max += sum;
sum += pq.poll();
} else break;
}
return max;
} | public int sample_funcname ( int [ ] var_0 ) {
Queue < Integer > var_3 = new PriorityQueue < > ( ( ( var_1 , var_2 ) -> var_2 - var_1 ) ) ;
Arrays . stream ( var_0 ) . forEach ( var_3 :: offer ) ;
int var_4 = 0 , var_5 = 0 ;
while ( ! var_3 . isEmpty ( ) ) {
if ( ( var_4 + var_5 ) >= var_4 ) {
var_4 += var_5 ;
var_5 += var_3 . poll ( ) ;
}
else break ;
}
return var_4 ;
}
| 1 | 0 |
1,088 | <gouthampradhan>string_ValidPalindromeII_1.java | private boolean isPaliandrome(String s) {
for (int i = 0, j = s.length() - 1; i < j; ) {
if (s.charAt(i) == s.charAt(j)) {
i++;
j--;
} else return false;
}
return true;
} | private boolean var_0 ( String var_1 ) {
for ( int var_2 = 0 , var_3 = var_1 . length ( ) - 1 ;
var_2 < var_3 ;
) {
if ( var_1 . charAt ( var_2 ) == var_1 . charAt ( var_3 ) ) {
var_2 ++ ;
var_3 -- ;
}
else return false ;
}
return true ;
}
| 2 | 0<SEP>1 |
1,089 | <gouthampradhan>two_pointers_ThreeSum_1.java | public List<List<Integer>> threeSum(int[] nums) {
List<List<Integer>> result = new ArrayList<>();
if (nums.length < 3) return result;
Arrays.sort(nums);
for (int i = 0, l = nums.length; i < l - 2; i++) {
if (i == 0 || nums[i] != nums[i - 1]) {
int j = i + 1, k = l - 1;
while (k > j) {
if (j != i + 1 && nums[j] == nums[j - 1]) {
j++;
continue;
}
int sum = nums[i] + nums[j] + nums[k];
if (sum == 0) {
result.add(Arrays.asList(nums[i], nums[j], nums[k]));
k--;
j++;
} else if (sum > 0) k--;
else j++;
}
}
}
return result;
} | public List < List < Integer >> var_0 ( int [ ] var_1 ) {
List < List < Integer >> var_2 = new ArrayList < > ( ) ;
if ( var_1 . length < 3 ) return var_2 ;
Arrays . sort ( var_1 ) ;
for ( int var_3 = 0 , var_4 = var_1 . length ;
var_3 < var_4 - 2 ;
var_3 ++ ) {
if ( var_3 == 0 || var_1 [ var_3 ] != var_1 [ var_3 - 1 ] ) {
int var_5 = var_3 + 1 , var_6 = var_4 - 1 ;
while ( var_6 > var_5 ) {
if ( var_5 != var_3 + 1 && var_1 [ var_5 ] == var_1 [ var_5 - 1 ] ) {
var_5 ++ ;
continue ;
}
int var_7 = var_1 [ var_3 ] + var_1 [ var_5 ] + var_1 [ var_6 ] ;
if ( var_7 == 0 ) {
var_2 . add ( Arrays . asList ( var_1 [ var_3 ] , var_1 [ var_5 ] , var_1 [ var_6 ] ) ) ;
var_6 -- ;
var_5 ++ ;
}
else if ( var_7 > 0 ) var_6 -- ;
else var_5 ++ ;
}
}
}
return var_2 ;
}
| 4 | 0<SEP>3<SEP>1<SEP>2 |
1,090 | <gouthampradhan>string_LongestPalindrome_1.java | public int longestPalindrome(String s) {
Map<Character, Integer> map = new HashMap<>();
for (char c : s.toCharArray()) {
map.putIfAbsent(c, 0);
int count = map.get(c);
map.put(c, count + 1);
}
int max = 0;
boolean odd = false;
for (char c : map.keySet()) {
int count = map.get(c);
max += count;
if ((count % 2) != 0) {
max--;
odd = true;
}
}
if (odd) max++;
return max;
} | public int sample_funcname ( String var_0 ) {
Map < Character , Integer > var_1 = new HashMap < > ( ) ;
for ( char var_2 : var_0 . toCharArray ( ) ) {
var_1 . putIfAbsent ( var_2 , 0 ) ;
int var_3 = var_1 . get ( var_2 ) ;
var_1 . put ( var_2 , var_3 + 1 ) ;
}
int var_4 = 0 ;
boolean var_5 = false ;
for ( char var_2 : var_1 . keySet ( ) ) {
int var_3 = var_1 . get ( var_2 ) ;
var_4 += var_3 ;
if ( ( var_3 % 2 ) != 0 ) {
var_4 -- ;
var_5 = true ;
}
}
if ( var_5 ) var_4 ++ ;
return var_4 ;
}
| 3 | 2<SEP>0<SEP>1 |
1,091 | <gouthampradhan>binary_search_PowXN_1.java | public double solve(double x, long n) {
if (n == 1) return x;
double val = solve(x, n / 2);
return val * val * ((n % 2) == 0 ? 1 : x);
} | public double sample_funcname ( double x , long n ) {
if ( n == 1 ) return x ;
double val = solve ( x , n / 2 ) ;
return val * val * ( ( n % 2 ) == 0 ? 1 : x ) ;
}
| 3 | 1<SEP>0<SEP>2 |
1,092 | <gouthampradhan>array_MinimumTimeDifference_1.java | public int findMinDifference(List<String> timePoints) {
List<Integer> timeInMinutes =
timePoints
.stream()
.map(
t -> {
String[] strings = t.split(":");
return Integer.parseInt(strings[0]) * 60 + Integer.parseInt(strings[1]);
})
.sorted(Integer::compareTo)
.collect(Collectors.toList());
int min = Integer.MAX_VALUE;
for (int i = 1, l = timeInMinutes.size(); i < l; i++) {
int prev = timeInMinutes.get(i - 1);
int curr = timeInMinutes.get(i);
min = Math.min(min, curr - prev);
min = Math.min(min, ((24 * 60) - curr) + prev);
}
int prev = timeInMinutes.get(0);
int curr = timeInMinutes.get(timeInMinutes.size() - 1);
min = Math.min(min, curr - prev);
min = Math.min(min, ((24 * 60) - curr) + prev);
return min;
} | public int sample_funcname ( List < String > var_0 ) {
List < Integer > var_3 = var_0 . stream ( ) . map ( var_1 -> {
String [ ] var_2 = var_1 . split ( ":" ) ;
return Integer . parseInt ( var_2 [ 0 ] ) * 60 + Integer . parseInt ( var_2 [ 1 ] ) ;
}
) . sorted ( Integer :: compareTo ) . collect ( Collectors . toList ( ) ) ;
int min = Integer . MAX_VALUE ;
for ( int var_4 = 1 , var_5 = var_3 . size ( ) ;
var_4 < var_5 ;
var_4 ++ ) {
int var_6 = var_3 . get ( var_4 - 1 ) ;
int var_7 = var_3 . get ( var_4 ) ;
min = Math . min ( min , var_7 - var_6 ) ;
min = Math . min ( min , ( ( 24 * 60 ) - var_7 ) + var_6 ) ;
}
int var_6 = var_3 . get ( 0 ) ;
int var_7 = var_3 . get ( var_3 . size ( ) - 1 ) ;
min = Math . min ( min , var_7 - var_6 ) ;
min = Math . min ( min , ( ( 24 * 60 ) - var_7 ) + var_6 ) ;
return min ;
}
| 5 | 0<SEP>24<SEP>60<SEP>1<SEP><D_QUOTE>:<D_QUOTE> |
1,093 | <gouthampradhan>hashing_ContiguousArray_1.java | public int findMaxLength(int[] nums) {
Map<Integer, Integer> map = new HashMap<>();
int count = 0;
int max = 0;
for (int i = 0; i < nums.length; i++) {
if (nums[i] == 0) {
count--;
} else count++;
if (count == 0) {
max = Math.max(max, i + 1);
} else {
if (map.containsKey(count)) {
int index = map.get(count);
max = Math.max(max, i - index);
} else {
map.put(count, i);
}
}
}
return max;
} | public int sample_funcname ( int [ ] var_0 ) {
Map < Integer , Integer > var_1 = new HashMap < > ( ) ;
int var_2 = 0 ;
int max = 0 ;
for ( int var_3 = 0 ;
var_3 < var_0 . length ;
var_3 ++ ) {
if ( var_0 [ var_3 ] == 0 ) {
var_2 -- ;
}
else var_2 ++ ;
if ( var_2 == 0 ) {
max = Math . max ( max , var_3 + 1 ) ;
}
else {
if ( var_1 . containsKey ( var_2 ) ) {
int var_4 = var_1 . get ( var_2 ) ;
max = Math . max ( max , var_3 - var_4 ) ;
}
else {
var_1 . put ( var_2 , var_3 ) ;
}
}
}
return max ;
}
| 2 | 0<SEP>1 |
1,094 | <gouthampradhan>heap_SlidingWindowMaximum_1.java | public int[] maxSlidingWindow(int[] nums, int k) {
int[] result = new int[nums.length - (k - 1)];
if (nums.length == 0) return new int[0];
Deque<Integer> queue = new ArrayDeque<>();
for (int i = 0, j = 0, l = nums.length; i < l; i++) {
int head = i - (k - 1);
if (head >= 0) {
if (queue.peek() != null && queue.peek() < head) queue.poll();
}
while (queue.peekLast() != null && nums[queue.peekLast()] <= nums[i]) {
queue.pollLast();
}
queue.offer(i);
if (i >= k - 1) result[j++] = nums[queue.peek()];
}
return result;
} | public int [ ] sample_funcname ( int [ ] var_0 , int var_1 ) {
int [ ] var_2 = new int [ var_0 . length - ( var_1 - 1 ) ] ;
if ( var_0 . length == 0 ) return new int [ 0 ] ;
Deque < Integer > var_3 = new ArrayDeque < > ( ) ;
for ( int var_4 = 0 , var_5 = 0 , var_6 = var_0 . length ;
var_4 < var_6 ;
var_4 ++ ) {
int var_7 = var_4 - ( var_1 - 1 ) ;
if ( var_7 >= 0 ) {
if ( var_3 . peek ( ) != null && var_3 . peek ( ) < var_7 ) var_3 . poll ( ) ;
}
while ( var_3 . peekLast ( ) != null && var_0 [ var_3 . peekLast ( ) ] <= var_0 [ var_4 ] ) {
var_3 . pollLast ( ) ;
}
var_3 . offer ( var_4 ) ;
if ( var_4 >= var_1 - 1 ) var_2 [ var_5 ++ ] = var_0 [ var_3 . peek ( ) ] ;
}
return var_2 ;
}
| 2 | 1<SEP>0 |
1,095 | <gouthampradhan>greedy_BrokenCalculator_1.java | public int brokenCalc(int X, int Y) {
if (X == Y) return 0;
else if (Y < X) return X - Y;
else {
int count = 0;
while (Y > X) {
if (Y % 2 == 0) {
Y /= 2;
count++;
} else {
Y += 1;
Y /= 2;
count += 2;
}
}
if (X == Y) return count;
else return count + (X - Y);
}
} | public int sample_funcname ( int var_0 , int var_1 ) {
if ( var_0 == var_1 ) return 0 ;
else if ( var_1 < var_0 ) return var_0 - var_1 ;
else {
int var_2 = 0 ;
while ( var_1 > var_0 ) {
if ( var_1 % 2 == 0 ) {
var_1 /= 2 ;
var_2 ++ ;
}
else {
var_1 += 1 ;
var_1 /= 2 ;
var_2 += 2 ;
}
}
if ( var_0 == var_1 ) return var_2 ;
else return var_2 + ( var_0 - var_1 ) ;
}
}
| 3 | 0<SEP>1<SEP>2 |
1,096 | <gouthampradhan>binary_search_FindPeakElement_1.java | public int findPeakElement(int[] nums) {
if (nums.length == 1) return 0;
if (nums[0] > nums[1]) return 0;
else if (nums[nums.length - 1] > nums[nums.length - 2]) return nums.length - 1;
int l = 0, h = nums.length - 1;
int ans = 0;
while (l <= h) {
int m = l + (h - l) / 2;
if (m - 1 >= 0 && m + 1 < nums.length) {
if (nums[m] > nums[m - 1] && nums[m] > nums[m + 1]) {
return m;
}
}
if (m - 1 >= 0 && nums[m - 1] > nums[m]) {
h = m - 1;
} else {
ans = l;
l = m + 1;
}
}
return ans;
} | public int sample_funcname ( int [ ] var_0 ) {
if ( var_0 . length == 1 ) return 0 ;
if ( var_0 [ 0 ] > var_0 [ 1 ] ) return 0 ;
else if ( var_0 [ var_0 . length - 1 ] > var_0 [ var_0 . length - 2 ] ) return var_0 . length - 1 ;
int var_1 = 0 , var_2 = var_0 . length - 1 ;
int var_3 = 0 ;
while ( var_1 <= var_2 ) {
int var_4 = var_1 + ( var_2 - var_1 ) / 2 ;
if ( var_4 - 1 >= 0 && var_4 + 1 < var_0 . length ) {
if ( var_0 [ var_4 ] > var_0 [ var_4 - 1 ] && var_0 [ var_4 ] > var_0 [ var_4 + 1 ] ) {
return var_4 ;
}
}
if ( var_4 - 1 >= 0 && var_0 [ var_4 - 1 ] > var_0 [ var_4 ] ) {
var_2 = var_4 - 1 ;
}
else {
var_3 = var_1 ;
var_1 = var_4 + 1 ;
}
}
return var_3 ;
}
| 3 | 1<SEP>0<SEP>2 |
1,097 | <gouthampradhan>string_IsomorphicStrings_1.java | public boolean isIsomorphic(String s, String t) {
if (s.length() != t.length()) return false;
Map<Character, Character> first = new HashMap<>();
Map<Character, Character> second = new HashMap<>();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (first.containsKey(c)) {
char secondC = first.get(c);
if (t.charAt(i) != secondC) return false;
} else {
first.put(c, t.charAt(i));
if (second.containsKey(t.charAt(i))) return false;
second.put(t.charAt(i), c);
}
}
return true;
} | public boolean var_0 ( String var_1 , String var_2 ) {
if ( var_1 . length ( ) != var_2 . length ( ) ) return false ;
Map < Character , Character > var_3 = new HashMap < > ( ) ;
Map < Character , Character > var_4 = new HashMap < > ( ) ;
for ( int var_5 = 0 ;
var_5 < var_1 . length ( ) ;
var_5 ++ ) {
char var_6 = var_1 . charAt ( var_5 ) ;
if ( var_3 . containsKey ( var_6 ) ) {
char var_7 = var_3 . get ( var_6 ) ;
if ( var_2 . charAt ( var_5 ) != var_7 ) return false ;
}
else {
var_3 . put ( var_6 , var_2 . charAt ( var_5 ) ) ;
if ( var_4 . containsKey ( var_2 . charAt ( var_5 ) ) ) return false ;
var_4 . put ( var_2 . charAt ( var_5 ) , var_6 ) ;
}
}
return true ;
}
| 1 | 0 |
1,098 | <gouthampradhan>two_pointers_FourSum_1.java | public List<List<Integer>> fourSum(int[] nums, int target) {
List<List<Integer>> result = new ArrayList<>();
if (nums.length < 4) return result;
Arrays.sort(nums);
for (int i = 0; i < nums.length - 3; i++) {
if (i == 0 || nums[i] != nums[i - 1]) {
for (int j = i + 1; j < nums.length - 2; j++) {
if (j == i + 1 || nums[j] != nums[j - 1]) {
int k = j + 1, l = nums.length - 1;
while (k < l) {
if (k != j + 1 && nums[k] == nums[k + 1]) {
k++;
continue;
}
int sum = nums[i] + nums[j] + nums[k] + nums[l];
if (sum == target) {
result.add(Arrays.asList(nums[i], nums[j], nums[k], nums[l]));
k++;
l--;
} else if (sum < target) {
k++;
} else {
l--;
}
}
}
}
}
}
return result;
} | public List < List < Integer >> var_0 ( int [ ] var_1 , int var_2 ) {
List < List < Integer >> var_3 = new ArrayList < > ( ) ;
if ( var_1 . length < 4 ) return var_3 ;
Arrays . sort ( var_1 ) ;
for ( int var_4 = 0 ;
var_4 < var_1 . length - 3 ;
var_4 ++ ) {
if ( var_4 == 0 || var_1 [ var_4 ] != var_1 [ var_4 - 1 ] ) {
for ( int var_5 = var_4 + 1 ;
var_5 < var_1 . length - 2 ;
var_5 ++ ) {
if ( var_5 == var_4 + 1 || var_1 [ var_5 ] != var_1 [ var_5 - 1 ] ) {
int var_6 = var_5 + 1 , var_7 = var_1 . length - 1 ;
while ( var_6 < var_7 ) {
if ( var_6 != var_5 + 1 && var_1 [ var_6 ] == var_1 [ var_6 + 1 ] ) {
var_6 ++ ;
continue ;
}
int var_8 = var_1 [ var_4 ] + var_1 [ var_5 ] + var_1 [ var_6 ] + var_1 [ var_7 ] ;
if ( var_8 == var_2 ) {
var_3 . add ( Arrays . asList ( var_1 [ var_4 ] , var_1 [ var_5 ] , var_1 [ var_6 ] , var_1 [ var_7 ] ) ) ;
var_6 ++ ;
var_7 -- ;
}
else if ( var_8 < var_2 ) {
var_6 ++ ;
}
else {
var_7 -- ;
}
}
}
}
}
}
return var_3 ;
}
| 5 | 4<SEP>2<SEP>0<SEP>1<SEP>3 |
1,099 | <gouthampradhan>dynamic_programming_MinimumCostForTickets_1.java | public int mincostTickets(int[] days, int[] costs) {
int[] min = new int[days.length];
Arrays.fill(min, Integer.MAX_VALUE);
for (int i = days.length - 1; i >= 0; i--) {
for (int j = 0; j < costs.length; j++) {
if (j == 0) {
min[i] = Math.min(min[i], costs[j] + ((i + 1 >= min.length) ? 0 : min[i + 1]));
} else if (j == 1) {
int c = 0;
for (int k = i + 1; k < days.length; k++) {
if (days[k] >= (days[i] + 7)) {
c = min[k];
break;
}
}
min[i] = Math.min(min[i], costs[j] + c);
} else {
int c = 0;
for (int k = i + 1; k < days.length; k++) {
if (days[k] >= (days[i] + 30)) {
c = min[k];
break;
}
}
min[i] = Math.min(min[i], costs[j] + c);
}
}
}
return min[0];
} | public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) {
int [ ] min = new int [ var_0 . length ] ;
Arrays . fill ( min , Integer . MAX_VALUE ) ;
for ( int var_2 = var_0 . length - 1 ;
var_2 >= 0 ;
var_2 -- ) {
for ( int var_3 = 0 ;
var_3 < var_1 . length ;
var_3 ++ ) {
if ( var_3 == 0 ) {
min [ var_2 ] = Math . min ( min [ var_2 ] , var_1 [ var_3 ] + ( ( var_2 + 1 >= min . length ) ? 0 : min [ var_2 + 1 ] ) ) ;
}
else if ( var_3 == 1 ) {
int var_4 = 0 ;
for ( int var_5 = var_2 + 1 ;
var_5 < var_0 . length ;
var_5 ++ ) {
if ( var_0 [ var_5 ] >= ( var_0 [ var_2 ] + 7 ) ) {
var_4 = min [ var_5 ] ;
break ;
}
}
min [ var_2 ] = Math . min ( min [ var_2 ] , var_1 [ var_3 ] + var_4 ) ;
}
else {
int var_4 = 0 ;
for ( int var_5 = var_2 + 1 ;
var_5 < var_0 . length ;
var_5 ++ ) {
if ( var_0 [ var_5 ] >= ( var_0 [ var_2 ] + 30 ) ) {
var_4 = min [ var_5 ] ;
break ;
}
}
min [ var_2 ] = Math . min ( min [ var_2 ] , var_1 [ var_3 ] + var_4 ) ;
}
}
}
return min [ 0 ] ;
}
| 4 | 7<SEP>1<SEP>0<SEP>30 |
1,100 | <gouthampradhan>string_FindTheClosestPalindrome_1.java | private String getLow(String s) {
int n = s.length() - 1;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
sb.append("9");
}
return sb.toString();
} | private String var_0 ( String var_1 ) {
int var_2 = var_1 . length ( ) - 1 ;
StringBuilder var_3 = new StringBuilder ( ) ;
for ( int var_4 = 0 ;
var_4 < var_2 ;
var_4 ++ ) {
var_3 . append ( "9" ) ;
}
return var_3 . toString ( ) ;
}
| 3 | <D_QUOTE>9<D_QUOTE><SEP>1<SEP>0 |
1,101 | <gouthampradhan>dynamic_programming_LengthofLongestFibonacciSubsequence_1.java | public int lenLongestFibSubseq(int[] A) {
if (A.length < 3) return 0;
Map<Integer, Map<Integer, Integer>> indexMap = new HashMap<>();
int max = 0;
for (int i = A.length - 1; i >= 0; i--) {
Map<Integer, Integer> subHashMap = new HashMap<>();
for (int j = 0; j < i; j++) {
int sum = A[i] + A[j];
if (indexMap.containsKey(sum)) {
if (indexMap.get(sum).containsKey(A[i])) {
int value = 1 + indexMap.get(sum).get(A[i]);
subHashMap.put(A[j], value);
max = Math.max(max, value);
} else {
subHashMap.put(A[j], 1);
max = Math.max(max, 1);
}
}
}
indexMap.put(A[i], subHashMap);
}
return max == 0 ? 0 : max + 2;
} | public int sample_funcname ( int [ ] var_0 ) {
if ( var_0 . length < 3 ) return 0 ;
Map < Integer , Map < Integer , Integer >> var_1 = new HashMap < > ( ) ;
int max = 0 ;
for ( int var_2 = var_0 . length - 1 ;
var_2 >= 0 ;
var_2 -- ) {
Map < Integer , Integer > var_3 = new HashMap < > ( ) ;
for ( int var_4 = 0 ;
var_4 < var_2 ;
var_4 ++ ) {
int var_5 = var_0 [ var_2 ] + var_0 [ var_4 ] ;
if ( var_1 . containsKey ( var_5 ) ) {
if ( var_1 . get ( var_5 ) . containsKey ( var_0 [ var_2 ] ) ) {
int var_6 = 1 + var_1 . get ( var_5 ) . get ( var_0 [ var_2 ] ) ;
var_3 . put ( var_0 [ var_4 ] , var_6 ) ;
max = Math . max ( max , var_6 ) ;
}
else {
var_3 . put ( var_0 [ var_4 ] , 1 ) ;
max = Math . max ( max , 1 ) ;
}
}
}
var_1 . put ( var_0 [ var_2 ] , var_3 ) ;
}
return max == 0 ? 0 : max + 2 ;
}
| 4 | 2<SEP>0<SEP>3<SEP>1 |
1,102 | <gouthampradhan>dynamic_programming_PalindromicSubstrings_1.java | public int countSubstrings(String s) {
boolean[][] T = new boolean[s.length()][s.length()];
int count = s.length();
for (int i = 0, j = 0; i < T.length; i++, j++) {
T[i][j] = true;
}
for (int k = 1, col = s.length(); k < col; k++) {
for (int i = 0, j = k; i < col && j < col; i++, j++) {
if (k == 1) {
if (s.charAt(i) == s.charAt(j)) {
T[i][j] = true;
count++;
}
} else {
if (s.charAt(i) == s.charAt(j) && T[i + 1][j - 1]) {
T[i][j] = true;
count++;
}
}
}
}
return count;
} | public int sample_funcname ( String var_0 ) {
boolean [ ] [ ] var_1 = new boolean [ var_0 . length ( ) ] [ var_0 . length ( ) ] ;
int var_2 = var_0 . length ( ) ;
for ( int var_3 = 0 , var_4 = 0 ;
var_3 < var_1 . length ;
var_3 ++ , var_4 ++ ) {
var_1 [ var_3 ] [ var_4 ] = true ;
}
for ( int var_5 = 1 , var_6 = var_0 . length ( ) ;
var_5 < var_6 ;
var_5 ++ ) {
for ( int var_3 = 0 , var_4 = var_5 ;
var_3 < var_6 && var_4 < var_6 ;
var_3 ++ , var_4 ++ ) {
if ( var_5 == 1 ) {
if ( var_0 . charAt ( var_3 ) == var_0 . charAt ( var_4 ) ) {
var_1 [ var_3 ] [ var_4 ] = true ;
var_2 ++ ;
}
}
else {
if ( var_0 . charAt ( var_3 ) == var_0 . charAt ( var_4 ) && var_1 [ var_3 + 1 ] [ var_4 - 1 ] ) {
var_1 [ var_3 ] [ var_4 ] = true ;
var_2 ++ ;
}
}
}
}
return var_2 ;
}
| 2 | 0<SEP>1 |
1,103 | <gouthampradhan>array_KEmptySlots_1.java | public int kEmptySlots(int[] flowers, int k) {
TreeSet<Integer> set = new TreeSet<>();
for (int i = 0; i < flowers.length; i++) {
Integer lowerBound = set.floor(flowers[i]);
Integer upperBound = set.ceiling(flowers[i]);
if (lowerBound != null) {
if ((Math.abs(flowers[i] - lowerBound) + 1) == k) {
return i + 1;
}
}
if (upperBound != null) {
if ((Math.abs(flowers[i] - upperBound) + 1) == k) {
return i + 1;
}
}
set.add(flowers[i]);
}
return -1;
} | public int sample_funcname ( int [ ] var_0 , int var_1 ) {
TreeSet < Integer > var_2 = new TreeSet < > ( ) ;
for ( int var_3 = 0 ;
var_3 < var_0 . length ;
var_3 ++ ) {
Integer var_4 = var_2 . floor ( var_0 [ var_3 ] ) ;
Integer var_5 = var_2 . ceiling ( var_0 [ var_3 ] ) ;
if ( var_4 != null ) {
if ( ( Math . abs ( var_0 [ var_3 ] - var_4 ) + 1 ) == var_1 ) {
return var_3 + 1 ;
}
}
if ( var_5 != null ) {
if ( ( Math . abs ( var_0 [ var_3 ] - var_5 ) + 1 ) == var_1 ) {
return var_3 + 1 ;
}
}
var_2 . add ( var_0 [ var_3 ] ) ;
}
return - 1 ;
}
| 2 | 0<SEP>1 |
1,104 | <gouthampradhan>array_RevealCardsInIncreasingOrder_1.java | public int[] deckRevealedIncreasing(int[] deck) {
Arrays.sort(deck);
ArrayDeque<Integer> queue = new ArrayDeque<>();
for (int i = deck.length - 1; i >= 0; i--) {
queue.offer(deck[i]);
if (i == 0) break;
int temp = queue.pollFirst();
queue.offer(temp);
}
int[] answer = new int[deck.length];
int i = 0;
while (!queue.isEmpty()) {
answer[i++] = queue.pollLast();
}
return answer;
} | public int [ ] sample_funcname ( int [ ] var_0 ) {
Arrays . sort ( var_0 ) ;
ArrayDeque < Integer > var_1 = new ArrayDeque < > ( ) ;
for ( int var_2 = var_0 . length - 1 ;
var_2 >= 0 ;
var_2 -- ) {
var_1 . offer ( var_0 [ var_2 ] ) ;
if ( var_2 == 0 ) break ;
int var_3 = var_1 . pollFirst ( ) ;
var_1 . offer ( var_3 ) ;
}
int [ ] var_4 = new int [ var_0 . length ] ;
int var_2 = 0 ;
while ( ! var_1 . isEmpty ( ) ) {
var_4 [ var_2 ++ ] = var_1 . pollLast ( ) ;
}
return var_4 ;
}
| 2 | 1<SEP>0 |
1,105 | <gouthampradhan>two_pointers_TrappingRainWater_1.java | private int trap(int[] height) {
if (height.length == 0) return 0;
int[] left = new int[height.length];
int[] right = new int[height.length];
int max = 0;
left[0] = 0;
right[height.length - 1] = 0;
int total = 0;
for (int i = 1, l = height.length; i < l; i++) {
left[i] = Math.max(max, height[i - 1]);
max = left[i];
}
max = 0;
for (int i = height.length - 2; i >= 0; i--) {
right[i] = Math.max(max, height[i + 1]);
max = right[i];
}
for (int i = 0, l = height.length; i < l; i++) {
int min = Math.min(left[i], right[i]);
if (min > height[i]) {
total += (min - height[i]);
}
}
return total;
} | private int sample_funcname ( int [ ] var_0 ) {
if ( var_0 . length == 0 ) return 0 ;
int [ ] var_1 = new int [ var_0 . length ] ;
int [ ] var_2 = new int [ var_0 . length ] ;
int max = 0 ;
var_1 [ 0 ] = 0 ;
var_2 [ var_0 . length - 1 ] = 0 ;
int var_3 = 0 ;
for ( int var_4 = 1 , var_5 = var_0 . length ;
var_4 < var_5 ;
var_4 ++ ) {
var_1 [ var_4 ] = Math . max ( max , var_0 [ var_4 - 1 ] ) ;
max = var_1 [ var_4 ] ;
}
max = 0 ;
for ( int var_4 = var_0 . length - 2 ;
var_4 >= 0 ;
var_4 -- ) {
var_2 [ var_4 ] = Math . max ( max , var_0 [ var_4 + 1 ] ) ;
max = var_2 [ var_4 ] ;
}
for ( int var_4 = 0 , var_5 = var_0 . length ;
var_4 < var_5 ;
var_4 ++ ) {
int min = Math . min ( var_1 [ var_4 ] , var_2 [ var_4 ] ) ;
if ( min > var_0 [ var_4 ] ) {
var_3 += ( min - var_0 [ var_4 ] ) ;
}
}
return var_3 ;
}
| 3 | 2<SEP>0<SEP>1 |
1,106 | <gouthampradhan>greedy_BurstBalloons_1.java | public int findMinArrowShots(int[][] points) {
if (points.length == 0) return 0;
Arrays.sort(points, ((o1, o2) -> o1[1] - o2[1]));
int count = 0;
int leftMost = points[0][1];
for (int i = 1; i < points.length; i++) {
if (leftMost < points[i][0]) {
count++;
leftMost = points[i][1];
}
}
return count + 1;
} | public int sample_funcname ( int [ ] [ ] var_0 ) {
if ( var_0 . length == 0 ) return 0 ;
Arrays . sort ( var_0 , ( ( var_1 , var_2 ) -> var_1 [ 1 ] - var_2 [ 1 ] ) ) ;
int var_3 = 0 ;
int var_4 = var_0 [ 0 ] [ 1 ] ;
for ( int var_5 = 1 ;
var_5 < var_0 . length ;
var_5 ++ ) {
if ( var_4 < var_0 [ var_5 ] [ 0 ] ) {
var_3 ++ ;
var_4 = var_0 [ var_5 ] [ 1 ] ;
}
}
return var_3 + 1 ;
}
| 2 | 0<SEP>1 |
1,107 | <gouthampradhan>array_MergeSortedArray_1.java | public void merge(int[] nums1, int m, int[] nums2, int n) {
int i = m + n - 1, j = m - 1, k = n - 1;
while (j >= 0 && k >= 0) nums1[i--] = (nums1[j] > nums2[k]) ? nums1[j--] : nums2[k--];
while (k >= 0) nums1[i--] = nums2[k--];
} | public void var_0 ( int [ ] var_1 , int var_2 , int [ ] var_3 , int var_4 ) {
int var_5 = var_2 + var_4 - 1 , var_6 = var_2 - 1 , var_7 = var_4 - 1 ;
while ( var_6 >= 0 && var_7 >= 0 ) var_1 [ var_5 -- ] = ( var_1 [ var_6 ] > var_3 [ var_7 ] ) ? var_1 [ var_6 -- ] : var_3 [ var_7 -- ] ;
while ( var_7 >= 0 ) var_1 [ var_5 -- ] = var_3 [ var_7 -- ] ;
}
| 2 | 1<SEP>0 |
1,108 | <gouthampradhan>binary_search_SearchForARange_1.java | private int findIndex(int[] nums, int target, boolean isLowerIndex) {
int result = -1;
int s = 0, e = nums.length - 1;
while (s <= e) {
int m = s + (e - s) / 2;
if (nums[m] == target) {
result = m;
if (isLowerIndex)
e = m - 1;
else s = m + 1;
} else if (nums[m] < target) {
s = m + 1;
} else e = m - 1;
}
return result;
} | private int sample_funcname ( int [ ] var_0 , int var_1 , boolean var_2 ) {
int var_3 = - 1 ;
int var_4 = 0 , var_5 = var_0 . length - 1 ;
while ( var_4 <= var_5 ) {
int var_6 = var_4 + ( var_5 - var_4 ) / 2 ;
if ( var_0 [ var_6 ] == var_1 ) {
var_3 = var_6 ;
if ( var_2 ) var_5 = var_6 - 1 ;
else var_4 = var_6 + 1 ;
}
else if ( var_0 [ var_6 ] < var_1 ) {
var_4 = var_6 + 1 ;
}
else var_5 = var_6 - 1 ;
}
return var_3 ;
}
| 3 | 1<SEP>0<SEP>2 |
1,109 | <gouthampradhan>string_CountAndSay_1.java | public String countAndSay(int n) {
String result = "1";
for (int i = 1; i < n; i++) {
int count = 1;
char num = result.charAt(0);
StringBuilder temp = new StringBuilder();
for (int j = 1, l = result.length(); j < l; j++) {
if (result.charAt(j) == num) {
count++;
} else {
temp = temp.append(String.valueOf(count)).append(String.valueOf(num));
num = result.charAt(j);
count = 1;
}
}
temp = temp.append(String.valueOf(count)).append(String.valueOf(num));
result = temp.toString();
}
return result;
} | public String var_0 ( int var_1 ) {
String var_2 = "1" ;
for ( int var_3 = 1 ;
var_3 < var_1 ;
var_3 ++ ) {
int var_4 = 1 ;
char var_5 = var_2 . charAt ( 0 ) ;
StringBuilder var_6 = new StringBuilder ( ) ;
for ( int var_7 = 1 , var_8 = var_2 . length ( ) ;
var_7 < var_8 ;
var_7 ++ ) {
if ( var_2 . charAt ( var_7 ) == var_5 ) {
var_4 ++ ;
}
else {
var_6 = var_6 . append ( String . valueOf ( var_4 ) ) . append ( String . valueOf ( var_5 ) ) ;
var_5 = var_2 . charAt ( var_7 ) ;
var_4 = 1 ;
}
}
var_6 = var_6 . append ( String . valueOf ( var_4 ) ) . append ( String . valueOf ( var_5 ) ) ;
var_2 = var_6 . toString ( ) ;
}
return var_2 ;
}
| 3 | 1<SEP>0<SEP><D_QUOTE>1<D_QUOTE> |
1,110 | <gouthampradhan>hashing_PartitionLabels_1.java | public List<Integer> partitionLabels(String S) {
if (S == null || S.trim().isEmpty()) return new ArrayList<>();
Map<Character, Integer> map = new HashMap<>();
for (int i = S.length() - 1; i >= 0; i--) {
char c = S.charAt(i);
map.putIfAbsent(c, i);
}
List<Integer> result = new ArrayList<>();
int start = 0;
int max = map.get(S.charAt(0));
for (int i = 0; i < S.length(); i++) {
char c = S.charAt(i);
if (map.get(c) > max) {
max = map.get(c);
} else if (i == max) {
result.add(max - start + 1);
if (i < S.length() - 1) {
start = i + 1;
max = map.get(S.charAt(i + 1));
}
}
}
return result;
} | public List < Integer > var_0 ( String var_1 ) {
if ( var_1 == null || var_1 . trim ( ) . isEmpty ( ) ) return new ArrayList < > ( ) ;
Map < Character , Integer > var_2 = new HashMap < > ( ) ;
for ( int var_3 = var_1 . length ( ) - 1 ;
var_3 >= 0 ;
var_3 -- ) {
char var_4 = var_1 . charAt ( var_3 ) ;
var_2 . putIfAbsent ( var_4 , var_3 ) ;
}
List < Integer > var_5 = new ArrayList < > ( ) ;
int var_6 = 0 ;
int var_7 = var_2 . get ( var_1 . charAt ( 0 ) ) ;
for ( int var_3 = 0 ;
var_3 < var_1 . length ( ) ;
var_3 ++ ) {
char var_4 = var_1 . charAt ( var_3 ) ;
if ( var_2 . get ( var_4 ) > var_7 ) {
var_7 = var_2 . get ( var_4 ) ;
}
else if ( var_3 == var_7 ) {
var_5 . add ( var_7 - var_6 + 1 ) ;
if ( var_3 < var_1 . length ( ) - 1 ) {
var_6 = var_3 + 1 ;
var_7 = var_2 . get ( var_1 . charAt ( var_3 + 1 ) ) ;
}
}
}
return var_5 ;
}
| 2 | 1<SEP>0 |
1,111 | <gouthampradhan>two_pointers_RemoveDuplicatesII_1.java | public int removeDuplicates(int[] nums) {
if (nums.length == 0) return 0;
int j = 0;
int count = 1;
for (int i = 1; i < nums.length; i++) {
if (nums[i - 1] == nums[i]) {
count++;
} else {
count = 1;
}
if (count == 1 || count == 2) {
j++;
nums[j] = nums[i];
}
}
return j + 1;
} | public int sample_funcname ( int [ ] var_0 ) {
if ( var_0 . length == 0 ) return 0 ;
int var_1 = 0 ;
int var_2 = 1 ;
for ( int var_3 = 1 ;
var_3 < var_0 . length ;
var_3 ++ ) {
if ( var_0 [ var_3 - 1 ] == var_0 [ var_3 ] ) {
var_2 ++ ;
}
else {
var_2 = 1 ;
}
if ( var_2 == 1 || var_2 == 2 ) {
var_1 ++ ;
var_0 [ var_1 ] = var_0 [ var_3 ] ;
}
}
return var_1 + 1 ;
}
| 3 | 2<SEP>0<SEP>1 |
1,112 | <gouthampradhan>dynamic_programming_DecodeWays_1.java | public int numDecodings(String s) {
if (s == null || s.isEmpty()) return 0;
int[] dp = new int[s.length() + 2];
dp[s.length()] = 1;
dp[s.length() + 1] = 1;
for (int i = s.length() - 1; i >= 0; i--) {
for (int j = i + 1; j < i + 3; j++) {
if (j <= s.length()) {
String subStr = s.substring(i, j);
if (!subStr.startsWith("0")) {
int intVal = Integer.parseInt(subStr);
if (intVal <= 26) {
dp[i] += dp[j];
}
}
}
}
}
return dp[0];
} | public int sample_funcname ( String var_0 ) {
if ( var_0 == null || var_0 . isEmpty ( ) ) return 0 ;
int [ ] var_1 = new int [ var_0 . length ( ) + 2 ] ;
var_1 [ var_0 . length ( ) ] = 1 ;
var_1 [ var_0 . length ( ) + 1 ] = 1 ;
for ( int var_2 = var_0 . length ( ) - 1 ;
var_2 >= 0 ;
var_2 -- ) {
for ( int var_3 = var_2 + 1 ;
var_3 < var_2 + 3 ;
var_3 ++ ) {
if ( var_3 <= var_0 . length ( ) ) {
String var_4 = var_0 . substring ( var_2 , var_3 ) ;
if ( ! var_4 . startsWith ( "0" ) ) {
int var_5 = Integer . parseInt ( var_4 ) ;
if ( var_5 <= 26 ) {
var_1 [ var_2 ] += var_1 [ var_3 ] ;
}
}
}
}
}
return var_1 [ 0 ] ;
}
| 6 | 2<SEP>0<SEP>3<SEP>1<SEP><D_QUOTE>0<D_QUOTE><SEP>26 |
1,113 | <gouthampradhan>string_RotateString_1.java | public boolean rotateString(String A, String B) {
if (A.length() == 1 || A.isEmpty() || B.length() == 1 || B.isEmpty()) {
return A.equals(B);
} else if (A.length() != B.length()) {
return false;
}
for (int i = 0, l = A.length(); i < l; i++) {
char s = A.charAt(0);
A = A.substring(1) + s;
if (A.equals(B)) return true;
}
return false;
} | public boolean var_0 ( String var_1 , String var_2 ) {
if ( var_1 . length ( ) == 1 || var_1 . isEmpty ( ) || var_2 . length ( ) == 1 || var_2 . isEmpty ( ) ) {
return var_1 . equals ( var_2 ) ;
}
else if ( var_1 . length ( ) != var_2 . length ( ) ) {
return false ;
}
for ( int var_3 = 0 , var_4 = var_1 . length ( ) ;
var_3 < var_4 ;
var_3 ++ ) {
char var_5 = var_1 . charAt ( 0 ) ;
var_1 = var_1 . substring ( 1 ) + var_5 ;
if ( var_1 . equals ( var_2 ) ) return true ;
}
return false ;
}
| 2 | 1<SEP>0 |
1,114 | <gouthampradhan>dynamic_programming_CornerRectangles_1.java | public int countCornerRectangles(int[][] grid) {
int[][] count = new int[grid[0].length][grid[0].length];
int result = 0;
for (int[] row : grid) {
for (int i = 0; i < row.length; i++) {
if (row[i] == 1) {
for (int j = i + 1; j < row.length; j++) {
if (row[j] == 1) {
if (count[i][j] > 0) {
result += count[i][j];
}
count[i][j]++;
}
}
}
}
}
return result;
} | public int sample_funcname ( int [ ] [ ] var_0 ) {
int [ ] [ ] var_1 = new int [ var_0 [ 0 ] . length ] [ var_0 [ 0 ] . length ] ;
int var_2 = 0 ;
for ( int [ ] var_3 : var_0 ) {
for ( int var_4 = 0 ;
var_4 < var_3 . length ;
var_4 ++ ) {
if ( var_3 [ var_4 ] == 1 ) {
for ( int var_5 = var_4 + 1 ;
var_5 < var_3 . length ;
var_5 ++ ) {
if ( var_3 [ var_5 ] == 1 ) {
if ( var_1 [ var_4 ] [ var_5 ] > 0 ) {
var_2 += var_1 [ var_4 ] [ var_5 ] ;
}
var_1 [ var_4 ] [ var_5 ] ++ ;
}
}
}
}
}
return var_2 ;
}
| 2 | 0<SEP>1 |
1,115 | <gouthampradhan>dynamic_programming_CombinationSumIV_1.java | private int backtrack(int[] nums, int[] dp, int sum) {
int total = 0;
if (sum < 0) return 0;
if (dp[sum] != -1) return dp[sum];
else {
for (int num : nums) {
total += backtrack(nums, dp, sum - num);
}
}
dp[sum] = total;
return dp[sum];
} | private int sample_funcname ( int [ ] nums , int [ ] dp , int sum ) {
int total = 0 ;
if ( sum < 0 ) return 0 ;
if ( dp [ sum ] != - 1 ) return dp [ sum ] ;
else {
for ( int num : nums ) {
total += backtrack ( nums , dp , sum - num ) ;
}
}
dp [ sum ] = total ;
return dp [ sum ] ;
}
| 2 | 0<SEP>1 |
1,116 | <gouthampradhan>dynamic_programming_BestTimeToBuyAndSellStockIII_1.java | public int maxProfit(int[] prices) {
if (prices.length == 0 || prices.length == 1) return 0;
int[] dp = new int[prices.length];
int min = prices[0];
int max = prices[prices.length - 1];
for (int i = prices.length - 2; i >= 0; i--) {
dp[i] = Math.max(max - prices[i], dp[i + 1]);
max = Math.max(max, prices[i]);
}
max = Integer.MIN_VALUE;
for (int i = 0; i < prices.length; i++) {
max = Math.max(max, prices[i] - min + dp[i]);
min = Math.min(min, prices[i]);
}
return max;
} | public int sample_funcname ( int [ ] var_0 ) {
if ( var_0 . length == 0 || var_0 . length == 1 ) return 0 ;
int [ ] var_1 = new int [ var_0 . length ] ;
int min = var_0 [ 0 ] ;
int max = var_0 [ var_0 . length - 1 ] ;
for ( int var_2 = var_0 . length - 2 ;
var_2 >= 0 ;
var_2 -- ) {
var_1 [ var_2 ] = Math . max ( max - var_0 [ var_2 ] , var_1 [ var_2 + 1 ] ) ;
max = Math . max ( max , var_0 [ var_2 ] ) ;
}
max = Integer . MIN_VALUE ;
for ( int var_2 = 0 ;
var_2 < var_0 . length ;
var_2 ++ ) {
max = Math . max ( max , var_0 [ var_2 ] - min + var_1 [ var_2 ] ) ;
min = Math . min ( min , var_0 [ var_2 ] ) ;
}
return max ;
}
| 3 | 2<SEP>0<SEP>1 |
1,117 | <gouthampradhan>math_CountPrimes_1.java | public int countPrimes(int n) {
if (n == 0 || n == 1 || n == 2) return 0;
else if (n == 3) return 1;
BitSet set = new BitSet();
n = n - 1;
int sqRt = (int) Math.sqrt(n);
int count = n;
for (int i = 2; i <= sqRt; i++) {
if (!set.get(i)) {
for (int j = 2; (i * j) <= n; j++) {
if (!set.get(i * j)) {
count--;
set.set(i * j);
}
}
}
}
return count - 1;
} | public int sample_funcname ( int var_0 ) {
if ( var_0 == 0 || var_0 == 1 || var_0 == 2 ) return 0 ;
else if ( var_0 == 3 ) return 1 ;
BitSet set = new BitSet ( ) ;
var_0 = var_0 - 1 ;
int var_1 = ( int ) Math . sqrt ( var_0 ) ;
int var_2 = var_0 ;
for ( int var_3 = 2 ;
var_3 <= var_1 ;
var_3 ++ ) {
if ( ! set . get ( var_3 ) ) {
for ( int var_4 = 2 ;
( var_3 * var_4 ) <= var_0 ;
var_4 ++ ) {
if ( ! set . get ( var_3 * var_4 ) ) {
var_2 -- ;
set . set ( var_3 * var_4 ) ;
}
}
}
}
return var_2 - 1 ;
}
| 4 | 2<SEP>0<SEP>3<SEP>1 |
1,118 | <gouthampradhan>depth_first_search_CrackingTheSafe_1.java | private int getStates(int n, int k) {
if (n == 0) return 1;
if (n == 1) return k;
int result = 1;
for (int i = 0; i < n; i++) {
result *= k;
}
return result;
} | private int sample_funcname ( int var_0 , int var_1 ) {
if ( var_0 == 0 ) return 1 ;
if ( var_0 == 1 ) return var_1 ;
int var_2 = 1 ;
for ( int var_3 = 0 ;
var_3 < var_0 ;
var_3 ++ ) {
var_2 *= var_1 ;
}
return var_2 ;
}
| 2 | 0<SEP>1 |
1,119 | <gouthampradhan>array_AddToArrayFormOfInteger_1.java | public List<Integer> addToArrayForm(int[] A, int K) {
StringBuilder sb = new StringBuilder();
for (int a : A) {
sb.append(a);
}
BigInteger big = new BigInteger(sb.toString());
BigInteger result = big.add(BigInteger.valueOf(K));
String resultStr = result.toString();
List<Integer> list = new ArrayList<>();
for (char a : resultStr.toCharArray()) {
list.add(Integer.parseInt(String.valueOf(a)));
}
return list;
} | public List < Integer > var_0 ( int [ ] var_1 , int var_2 ) {
StringBuilder var_3 = new StringBuilder ( ) ;
for ( int var_4 : var_1 ) {
var_3 . append ( var_4 ) ;
}
BigInteger var_5 = new BigInteger ( var_3 . toString ( ) ) ;
BigInteger var_6 = var_5 . add ( BigInteger . valueOf ( var_2 ) ) ;
String var_7 = var_6 . toString ( ) ;
List < Integer > var_8 = new ArrayList < > ( ) ;
for ( char var_4 : var_7 . toCharArray ( ) ) {
var_8 . add ( Integer . parseInt ( String . valueOf ( var_4 ) ) ) ;
}
return var_8 ;
}
| 0 | null |
1,120 | <gouthampradhan>dynamic_programming_TossStrangeCoins_1.java | public double probabilityOfHeads(double[] prob, int target) {
double[][] DP = new double[target + 1][prob.length];
DP[0][0] = 1 - prob[0];
DP[1][0] = prob[0];
for (int c = 1; c < prob.length; c++) {
for (int t = 0; t <= target; t++) {
if (t == 0) DP[t][c] = DP[t][c - 1] * (1 - prob[c]);
else DP[t][c] = DP[t][c - 1] * (1 - prob[c]) + DP[t - 1][c - 1] * (prob[c]);
}
}
return DP[target][prob.length - 1];
} | public double sample_funcname ( double [ ] var_0 , int var_1 ) {
double [ ] [ ] var_2 = new double [ var_1 + 1 ] [ var_0 . length ] ;
var_2 [ 0 ] [ 0 ] = 1 - var_0 [ 0 ] ;
var_2 [ 1 ] [ 0 ] = var_0 [ 0 ] ;
for ( int var_3 = 1 ;
var_3 < var_0 . length ;
var_3 ++ ) {
for ( int var_4 = 0 ;
var_4 <= var_1 ;
var_4 ++ ) {
if ( var_4 == 0 ) var_2 [ var_4 ] [ var_3 ] = var_2 [ var_4 ] [ var_3 - 1 ] * ( 1 - var_0 [ var_3 ] ) ;
else var_2 [ var_4 ] [ var_3 ] = var_2 [ var_4 ] [ var_3 - 1 ] * ( 1 - var_0 [ var_3 ] ) + var_2 [ var_4 - 1 ] [ var_3 - 1 ] * ( var_0 [ var_3 ] ) ;
}
}
return var_2 [ var_1 ] [ var_0 . length - 1 ] ;
}
| 2 | 1<SEP>0 |
1,121 | <gouthampradhan>hashing_CustomSortString_1.java | public String customSortString(String S, String T) {
Map<Character, Integer> map = new HashMap<>();
for (int i = 0; i < T.length(); i++) {
if (!map.containsKey(T.charAt(i))) {
map.put(T.charAt(i), 1);
} else {
map.put(T.charAt(i), map.get(T.charAt(i)) + 1);
}
}
StringBuilder result = new StringBuilder();
for (char c : S.toCharArray()) {
if (map.containsKey(c)) {
int count = map.remove(c);
for (int i = 0; i < count; i++) {
result.append(c);
}
}
}
for (char c : map.keySet()) {
int count = map.get(c);
for (int i = 0; i < count; i++) {
result.append(c);
}
}
return result.toString();
} | public String var_0 ( String var_1 , String var_2 ) {
Map < Character , Integer > var_3 = new HashMap < > ( ) ;
for ( int var_4 = 0 ;
var_4 < var_2 . length ( ) ;
var_4 ++ ) {
if ( ! var_3 . containsKey ( var_2 . charAt ( var_4 ) ) ) {
var_3 . put ( var_2 . charAt ( var_4 ) , 1 ) ;
}
else {
var_3 . put ( var_2 . charAt ( var_4 ) , var_3 . get ( var_2 . charAt ( var_4 ) ) + 1 ) ;
}
}
StringBuilder var_5 = new StringBuilder ( ) ;
for ( char var_6 : var_1 . toCharArray ( ) ) {
if ( var_3 . containsKey ( var_6 ) ) {
int var_7 = var_3 . remove ( var_6 ) ;
for ( int var_4 = 0 ;
var_4 < var_7 ;
var_4 ++ ) {
var_5 . append ( var_6 ) ;
}
}
}
for ( char var_6 : var_3 . keySet ( ) ) {
int var_7 = var_3 . get ( var_6 ) ;
for ( int var_4 = 0 ;
var_4 < var_7 ;
var_4 ++ ) {
var_5 . append ( var_6 ) ;
}
}
return var_5 . toString ( ) ;
}
| 2 | 0<SEP>1 |
1,122 | <gouthampradhan>array_ProductOfArrayExceptSelf_1.java | public int[] productExceptSelf(int[] nums) {
int[] result = new int[nums.length];
for (int i = 0, temp = 1, l = nums.length; i < l; i++) {
result[i] = temp;
temp *= nums[i];
}
for (int i = nums.length - 1, temp = 1; i >= 0; i--) {
result[i] = result[i] * temp;
temp *= nums[i];
}
return result;
} | public int [ ] sample_funcname ( int [ ] var_0 ) {
int [ ] var_1 = new int [ var_0 . length ] ;
for ( int var_2 = 0 , var_3 = 1 , var_4 = var_0 . length ;
var_2 < var_4 ;
var_2 ++ ) {
var_1 [ var_2 ] = var_3 ;
var_3 *= var_0 [ var_2 ] ;
}
for ( int var_2 = var_0 . length - 1 , var_3 = 1 ;
var_2 >= 0 ;
var_2 -- ) {
var_1 [ var_2 ] = var_1 [ var_2 ] * var_3 ;
var_3 *= var_0 [ var_2 ] ;
}
return var_1 ;
}
| 2 | 0<SEP>1 |
1,123 | <gouthampradhan>backtracking_LetterCasePermutation_1.java | private void backtrack(String s, List<String> result, int i, String r) {
if (i == s.length()) {
result.add(r);
} else {
if (Character.isAlphabetic(s.charAt(i))) {
backtrack(s, result, i + 1, r + s.charAt(i));
if (Character.isLowerCase(s.charAt(i))) {
backtrack(s, result, i + 1, r + Character.toUpperCase(s.charAt(i)));
} else {
backtrack(s, result, i + 1, r + Character.toLowerCase(s.charAt(i)));
}
} else {
backtrack(s, result, i + 1, r + s.charAt(i));
}
}
} | private void sample_funcname ( String s , List < String > result , int i , String r ) {
if ( i == s . length ( ) ) {
result . add ( r ) ;
}
else {
if ( Character . isAlphabetic ( s . charAt ( i ) ) ) {
backtrack ( s , result , i + 1 , r + s . charAt ( i ) ) ;
if ( Character . isLowerCase ( s . charAt ( i ) ) ) {
backtrack ( s , result , i + 1 , r + Character . toUpperCase ( s . charAt ( i ) ) ) ;
}
else {
backtrack ( s , result , i + 1 , r + Character . toLowerCase ( s . charAt ( i ) ) ) ;
}
}
else {
backtrack ( s , result , i + 1 , r + s . charAt ( i ) ) ;
}
}
}
| 1 | 1 |
1,124 | <gouthampradhan>string_SplitConcatenatedStrings_1.java | private String findMax(String[] strs, int i) {
int c = 1;
StringBuilder sb = new StringBuilder();
for (int j = i, l = strs.length; c < l; j = (j + 1) % l, c++) {
String nextStr = strs[j];
String reverse = new StringBuilder(nextStr).reverse().toString();
String result = nextStr.compareTo(reverse) > 0 ? nextStr : reverse;
sb.append(result);
}
return sb.toString();
} | private String var_0 ( String [ ] var_1 , int var_2 ) {
int var_3 = 1 ;
StringBuilder var_4 = new StringBuilder ( ) ;
for ( int var_5 = var_2 , var_6 = var_1 . length ;
var_3 < var_6 ;
var_5 = ( var_5 + 1 ) % var_6 , var_3 ++ ) {
String var_7 = var_1 [ var_5 ] ;
String reverse = new StringBuilder ( var_7 ) . reverse ( ) . toString ( ) ;
String var_8 = var_7 . compareTo ( reverse ) > 0 ? var_7 : reverse ;
var_4 . append ( var_8 ) ;
}
return var_4 . toString ( ) ;
}
| 2 | 1<SEP>0 |
1,125 | <gouthampradhan>array_CardFilipGame_1.java | public int flipgame(int[] fronts, int[] backs) {
List<Integer> numbers = new ArrayList<>();
for (int i = 0; i < fronts.length; i++) {
numbers.add(fronts[i]);
numbers.add(backs[i]);
}
Collections.sort(numbers);
for (int n : numbers) {
boolean success = true;
for (int i = 0; i < fronts.length; i++) {
if (n == fronts[i] && n == backs[i]) {
success = false;
break;
}
}
if (success) {
return n;
}
}
return 0;
} | public int sample_funcname ( int [ ] var_0 , int [ ] var_1 ) {
List < Integer > var_2 = new ArrayList < > ( ) ;
for ( int var_3 = 0 ;
var_3 < var_0 . length ;
var_3 ++ ) {
var_2 . add ( var_0 [ var_3 ] ) ;
var_2 . add ( var_1 [ var_3 ] ) ;
}
Collections . sort ( var_2 ) ;
for ( int var_4 : var_2 ) {
boolean var_5 = true ;
for ( int var_3 = 0 ;
var_3 < var_0 . length ;
var_3 ++ ) {
if ( var_4 == var_0 [ var_3 ] && var_4 == var_1 [ var_3 ] ) {
var_5 = false ;
break ;
}
}
if ( var_5 ) {
return var_4 ;
}
}
return 0 ;
}
| 1 | 0 |
1,126 | <gouthampradhan>string_MonotoneIncreasingDigits_1.java | public int monotoneIncreasingDigits(int N) {
String s = String.valueOf(N);
if (s.length() == 1) return N;
int p = -1;
int prev = N % 10;
for (int i = s.length() - 2; i >= 0; i--) {
int curr = Integer.parseInt(String.valueOf(s.charAt(i)));
if (curr > prev) {
p = i;
prev = curr - 1;
} else {
prev = curr;
}
}
if (p == -1) return N;
StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
if (i == p) {
int pV = Integer.parseInt(String.valueOf(s.charAt(i)));
result.append(pV - 1);
break;
}
result.append(String.valueOf(s.charAt(i)));
}
for (int i = p + 1; i < s.length(); i++) {
result.append("9");
}
return Integer.parseInt(result.toString());
} | public int sample_funcname ( int var_0 ) {
String var_1 = String . valueOf ( var_0 ) ;
if ( var_1 . length ( ) == 1 ) return var_0 ;
int var_2 = - 1 ;
int var_3 = var_0 % 10 ;
for ( int var_4 = var_1 . length ( ) - 2 ;
var_4 >= 0 ;
var_4 -- ) {
int var_5 = Integer . parseInt ( String . valueOf ( var_1 . charAt ( var_4 ) ) ) ;
if ( var_5 > var_3 ) {
var_2 = var_4 ;
var_3 = var_5 - 1 ;
}
else {
var_3 = var_5 ;
}
}
if ( var_2 == - 1 ) return var_0 ;
StringBuilder var_6 = new StringBuilder ( ) ;
for ( int var_4 = 0 ;
var_4 < var_1 . length ( ) ;
var_4 ++ ) {
if ( var_4 == var_2 ) {
int var_7 = Integer . parseInt ( String . valueOf ( var_1 . charAt ( var_4 ) ) ) ;
var_6 . append ( var_7 - 1 ) ;
break ;
}
var_6 . append ( String . valueOf ( var_1 . charAt ( var_4 ) ) ) ;
}
for ( int var_4 = var_2 + 1 ;
var_4 < var_1 . length ( ) ;
var_4 ++ ) {
var_6 . append ( "9" ) ;
}
return Integer . parseInt ( var_6 . toString ( ) ) ;
}
| 5 | 2<SEP>1<SEP>0<SEP>10<SEP><D_QUOTE>9<D_QUOTE> |
1,127 | <gouthampradhan>backtracking_ExpressionAddOperators_1.java | private void backTrack(
String exp, List<String> list, int curr, String num, int target, long total, long prod) {
if (curr == num.length()) {
if (total == target) {
list.add(exp);
}
} else {
for (int i = curr, l = num.length(); i < l; i++) {
String newNum = num.substring(curr, i + 1);
if (newNum.length() > 1 && newNum.startsWith("0")) {
break;
}
long newNumL = Long.parseLong(newNum);
if (curr == 0) {
backTrack(newNum, list, i + 1, num, target, newNumL, newNumL);
} else {
backTrack(exp + "+" + newNum, list, i + 1, num, target, total + newNumL, newNumL);
backTrack(exp + "-" + newNum, list, i + 1, num, target, total - newNumL, newNumL * -1L);
backTrack(
exp + "*" + newNum,
list,
i + 1,
num,
target,
(total - prod + (prod * newNumL)),
prod * newNumL);
}
}
}
} | private void sample_funcname ( String exp , List < String > list , int curr , String num , int target , long total , long prod ) {
if ( curr == num . length ( ) ) {
if ( total == target ) {
list . add ( exp ) ;
}
}
else {
for ( int i = curr , l = num . length ( ) ;
i < l ;
i ++ ) {
String newNum = num . substring ( curr , i + 1 ) ;
if ( newNum . length ( ) > 1 && newNum . startsWith ( "0" ) ) {
break ;
}
long newNumL = Long . parseLong ( newNum ) ;
if ( curr == 0 ) {
backTrack ( newNum , list , i + 1 , num , target , newNumL , newNumL ) ;
}
else {
backTrack ( exp + "+" + newNum , list , i + 1 , num , target , total + newNumL , newNumL ) ;
backTrack ( exp + "-" + newNum , list , i + 1 , num , target , total - newNumL , newNumL * - 1L ) ;
backTrack ( exp + "*" + newNum , list , i + 1 , num , target , ( total - prod + ( prod * newNumL ) ) , prod * newNumL ) ;
}
}
}
}
| 6 | <D_QUOTE>-<D_QUOTE><SEP>1<SEP>0<SEP><D_QUOTE>+<D_QUOTE><SEP><D_QUOTE>0<D_QUOTE><SEP><D_QUOTE>*<D_QUOTE> |