Skip to content

Instantly share code, notes, and snippets.

View Upasna20's full-sized avatar

Upasna Singh Upasna20

View GitHub Profile
@Upasna20
Upasna20 / codingPractices.md
Last active April 21, 2026 19:44
I need to actively try to use these practices to avoid the common errors i have been making in case based questions.

Here is a breakdown of where your implementation leaked and how to tighten your methodology from a first-principles perspective.

1. Enforce Mutually Exclusive Control Flow (MECE)

Your biggest structural bug was letting states bleed into each other because of stacked if statements instead of if / else if / else chains.

When you are mapping out a problem, especially in DP or backtracking, every branch must be Mutually Exclusive and Collectively Exhaustive (MECE).

  • Mutually Exclusive: If a string is "*1", it cannot simultaneously be treated as a normal two-digit number. Only one path should mathematically be allowed to execute.
  • Collectively Exhaustive: You must cover every possible permutation (which is why forgetting the "two normal digits" scenario was a fatal error).

How to improve: Before touching the keyboard, draw out the decision tree on paper. Think of it like a strict state machine. If you enter State A, you cannot fall through to State B. Map the if/else boundaries a