You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int left = 0;
for (int right = 0; right < n; right++) {
// window expand
while (condition violated) {
left++;
}
// update answer
}
BFS
Queue<int[]> q = new LinkedList<>();
q.offer(start);
visited[start] = true;
while (!q.isEmpty()) {
int cur = q.poll();
}
Two Pointer
int left = 0;
int right = arr.length - 1;
while (left < right) {
int sum = arr[left] + arr[right];
if (sum == target) break;
if (sum < target)
left++;
else
right--;
}