[Problem Title] — LeetCode #[Number]

Metadata

Difficulty: Easy / Medium / Hard Date: YYYY-MM-DD Topic Tags: Array, Hash Map, Two Pointers, … Source: Roadmap-FAANG → Buổi XX


1. Problem Statement

Paste problem statement here hoặc link: LeetCode XXX

Input: Output: Constraints:


2. Clarification Questions (Ask in interview!)

Trước khi code, hỏi interviewer

  • Input có thể empty không? Edge case với n = 0?
  • Có negative numbers không?
  • Có duplicates không? Ảnh hưởng gì?
  • Return gì nếu không có answer?
  • Cần in-place hay được tạo array mới?

3. Pattern Recognition

Map problem → pattern

Signal words: ”…” → Pattern: [Two Pointers / Sliding Window / DP / …]


4. Approaches

Approach 1: Brute Force

  • Idea:
  • Time: | Space:
  • Why not: Timeout với

Approach 2: Optimal — [Pattern Name]

  • Idea:
  • Time: | Space:
  • Why this works:

5. Implementation

/**
 * [Problem Name] — LeetCode #XXX
 *
 * Approach: [Brief description]
 * Time: O(...) | Space: O(...)
 */
function solveProblem(/* params */): /* return type */ {
  // Edge cases
  if (/* condition */) return /* base case */;
 
  // Main logic
 
 
}
 
// Test cases
console.assert(solveProblem(/* input */) === /* expected */);
console.assert(solveProblem(/* edge case */) === /* expected */);

6. Complexity Analysis

TimeSpace
Brute force
Optimal

Bottleneck: [Which step dominates?]


7. Edge Cases Tested

  • Empty input
  • Single element
  • All same elements
  • Already sorted / reverse sorted
  • Negative numbers
  • Integer overflow scenario

8. What I Learned

Key Takeaway

[Insight mới, pattern mới, hoặc mistake đã học được]

Mistake made:Correct approach:Next time I see ”…” in the problem, I will think of …


9. Similar Problems

  • — Same pattern
  • — Variant with extra constraint

Added: YYYY-MM-DD | Reviewed: — | Confidence: ⭐⭐⭐