Zum Inhalt springen

I solved LeetCode #1 Two Sum the “wrong” way in Java, why ?

Hey folks,

I just uploaded a 4-minute live-coding clip where I tackle LeetCode’s Two Sum in plain Java—no HashMap, just brute-force nested loops.

Before you scroll past thinking “old news”, here’s why you might want to peek:

Watch time-complexity hurt in real time. My IDE timer goes from 0 ms to >2 s when the input hits 10 000 numbers.

The curiosity gap: one one-line refactor later (next episode) cuts ~50 million comparisons. Seeing the “pain point” first makes the fix unforgettable.

No voice-over, no filler. Pure keystrokes + console output, so you can benchmark yourself or use it as a timing drill.

Video 4 min ➜ https://www.youtube.com/watch?v=vtfJ9wWqv14

What I’m up to next

I’m graduating next month in *Systems Analysis & Development* and started this channel to sharpen Java + English.

Plan: refactor the same problem with

  1. HashMap (O(n))

  2. Two-pointer on sorted array

  3. Java Streams vs imperative timing.

Question for you: What visual aid or metric would make future clips more useful—unit tests, JVM heap stats, or something else?

submitted by /u/BottleOld8406
[link] [comments]

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert