public void moveZeroes(int[] nums) {
int n = nums.length;
int idx = 0;
int count = 0;
for(int i = 0; i < n; i++) {
if(nums[i] == 0) count++;
else nums[idx++] = nums[i];
}
for(int i = n - count; i < n; i++) {
nums[i] = 0;
}
return ;
}
public boolean isSubsequence(String s, String t) {
int sn = s.length();
int tn = t.length();
int si = 0, ti = 0;
while(si < sn && ti < tn) {
if(s.charAt(si) == t.charAt(ti)) {
si++; ti++;
}else {
ti++;
}
}
return si == sn;
}
public int maxArea(int[] height) {
int l = 0, r = height.length - 1;
int ans = 0;
while(l < r) {
int h = Math.min(height[l], height[r]);
ans = Math.max(ans, (r - l) * h);
if(height[l] >= height[r]) r--;
else l++;
}
return ans;
}
public int maxOperations(int[] nums, int k) {
int ans = 0;
int l = 0, r = nums.length - 1;
Arrays.sort(nums);
while(l < r) {
int sum = nums[l] + nums[r];
if(sum > k) r--;
else if(sum < k) l++;
else {
r--; l++; ans++;
}
}
return ans;
}