Two Sum — Map O(n):
snippetJavaScript
function twoSum(nums, target) { const seen = new Map(); for (let i = 0; i < nums.length; i++) { const comp = target - nums[i]; if (seen.has(comp)) return [seen.get(comp), i]; seen.set(nums[i], i); } return [];}
Valid Parentheses — Stack:
snippetJavaScript
function isValid(s) { const stack = [], pairs = { ')': '(', ']': '[', '}': '{' }; for (const c of s) { if (c in pairs) { if (stack.pop() !== pairs[c]) return false; } else stack.push(c); } return stack.length === 0;}
Reverse Linked List — 3 ponteiros: prev, current, next.
Cycle Detection — Floyd (slow/fast): dois ponteiros, 1 vs 2 passos.
Max Depth Tree — recursão: 1 + max(left, right).