codementor on Nostr: Learn: Brute force first, then improve If you don't see the best solution right away, ...
Learn: Brute force first, then improve
If you don't see the best solution right away, say the simple one first, with its Big-O. For example: "Check every pair: O(n²)."
Then ask yourself what work is repeated. A HashSet, sorting, or two pointers often removes it. A working slow answer beats an unfinished fast one.
#tip · TIP-003
Published at
2026-10-14 06:38:00 UTCEvent JSON
{
"id": "1705a518c58f8275ec4e100e0694eb48838f9bf38f6e9e54f3e072504b332361",
"pubkey": "e68a0856e90d9997b1f721e905249896412dd570399a987b2e8fd5e7fcfe2279",
"created_at": 1791959880,
"kind": 1,
"tags": [
[
"t",
"tip"
]
],
"content": "Learn: Brute force first, then improve\n\nIf you don't see the best solution right away, say the simple one first, with its Big-O. For example: \"Check every pair: O(n²).\"\n\nThen ask yourself what work is repeated. A HashSet, sorting, or two pointers often removes it. A working slow answer beats an unfinished fast one.\n\n#tip · TIP-003",
"sig": "6dfd4cb9476733f9d5e2ce45b9290d4c80c8eaee125f5ecbb89ea974098ce3cf43d09a6a6fed4a0450fe9560843b95d3706303ee2d0e039b56784e1bf6d0c4be"
}