CLEAR MIND GO Framework Examples

You’ve read my blog on how to tackle any coding question in Indian placement tests using the CLEAR MIND GO framework. If you haven’t read it, I strongly recommend checking it out before diving into these examples. That blog gives you the full step-by-step method to tackle any coding question. You can read it here.

So in this blog, I’ll walk you through 5 real coding questions and show you step by step how to use the framework. The goal? You’ll see that solving coding problems isn’t about “IIT-level IQ” — it’s about having a system.

Example 1: Two Sum Problem

Question: Find two numbers in an array that add up to a given target.

CLEAR MIND GO in action:

  • C: Read carefully — we need indices of 2 numbers, not just “yes/no.”

  • L: Example [2,7,11,15], target = 9 → output = [0,1].

  • E: Don’t scream HashMap yet.

  • A: n ≤ 10⁵, so brute-force O(n²) might fail.

  • R: Input: array + target. Output: indices of 2 elements.

  • M: Make your own: [3,4,5], target = 7 → output = [0,1].

  • I: Edge case: no pair exists? Empty array?

  • N: Naive = try all pairs → O(n²).

  • D: For 10⁵ → too slow.

  • G: Use HashMap to store complements.

  • O: Optimized to O(n). Done.

Example 2: Reverse a String

Question: Given “smoothcampus”, output “supmachtooms.”

CLEAR MIND GO in action:

  • C: Just reverse the whole string, nothing fancy.

  • L: Example is straightforward → input = “abc”, output = “cba.”

  • E: Don’t think about stacks yet.

  • A: Constraints small (n ≤ 10³).

  • R: Input = string. Output = reversed string.

  • M: Own example: “a” → “a.”

  • I: Edge case = empty string.

  • N: Naive = swap characters from ends.

  • D: O(n). Fine.

  • G: DSA not required, just array/string.

  • O: Done.

Example 3: Maximum Subarray (Kadane’s Problem)

Question: Find the contiguous subarray with the maximum sum.

CLEAR MIND GO in action:

  • C: Don’t confuse “subarray” with “subsequence.”

  • L: Example: [-2,1,-3,4,-1,2,1,-5,4] → max sum = 6 (subarray [4,-1,2,1]).

  • E: Don’t panic with DP yet.

  • A: n ≤ 10⁵, brute force O(n²) may fail.

  • R: Input = array. Output = max sum.

  • M: Own example: [1,2,3] → 6.

  • I: Edge case: all negatives → pick max element.

  • N: Naive = try all subarrays O(n²).

  • D: Too slow.

  • G: Use running sum + DP (Kadane’s algorithm).

  • O: O(n). Perfect.

Example 4: Valid Parentheses

Question: Check if parentheses string is valid.

CLEAR MIND GO in action:

  • C: Valid = every opening has a matching closing, order matters.

  • L: Example: “()[]{}” → true. “(]” → false.

  • E: Don’t instantly think regex.

  • A: n ≤ 10³.

  • R: Input = string. Output = boolean.

  • M: Own example: “(()” → false.

  • I: Edge case: empty string → valid.

  • N: Naive = simulate checking manually.

  • D: O(n). Fine.

  • G: Stack is best here.

  • O: Push/pop → O(n).

Example 5: Find Missing Number

Question: Array of n containing numbers 0 to n, find missing number.

CLEAR MIND GO in action:

  • C: Don’t confuse with duplicates. Only 1 number is missing.

  • L: Example: [3,0,1] → output = 2.

  • E: Don’t jump to HashSet yet.

  • A: n ≤ 10⁵.

  • R: Input = array. Output = integer missing.

  • M: Own example: [0,1,2,4] → output = 3.

  • I: Edge case: missing 0 or n.

  • N: Naive = check all numbers O(n²).

  • D: Too slow.

  • G: Use sum formula or XOR trick.

  • O: O(n). Done.

Scroll to Top