Process
- Read the problem carefully
- Made sure I knew what the input and output should be. Checked for any weird cases like empty lists or missing keys.
- Used the right tools
- For lists,
.stream()
,.map()
, and.collect()
handled transformations easily. - For maps,
.containsKey()
,.put()
, and.remove()
were all I needed.
- For lists,
- Planned before writing code
- Thought through the logic first instead of jumping in and fixing later.
- Example: In
mapBully
, I knew"b"
should take"a"
‘s value while"a"
became empty, so I wrote that directly.
- Wrote the code and tested in small steps
- Kept it simple at first, then added edge case handling.
What Worked
- Recognizing patterns – Most problems followed similar logic (modify lists, update maps).
- Using Java Streams – Made list modifications quick and clean.
- Handling maps efficiently – Used .containsKey() to avoid unnecessary conditions.
- Fixing small parts first – Debugging one issue at a time instead of rewriting everything.
What Didn’t Work
- Forgetting edge cases – Ignoring empty inputs or missing keys led to bugs.
- Overcomplicating solutions – Some problems could be solved in one line, but I made them harder.
- Relying on the first try – Some logic worked for basic cases but failed on edge cases.
Tries Taken
- Simple ones (lists, basic maps): Usually done in 1-2 tries.
- More complex ones (maps with conditions): Took 3-5 tries, mostly fixing edge cases.