codementor on Nostr: Learn: Costs worth knowing by heart Read array[i]: O(1) Search an unsorted array: ...
Learn: Costs worth knowing by heart
Read array[i]: O(1)
Search an unsorted array: O(n)
Sort: O(n log n)
HashSet or Dictionary lookup: O(1) on average
Search a sorted array with binary search: O(log n)
When you state a solution in an interview, say its Big-O with it.
#tip · TIP-005
Published at
2026-10-25 10:37:52 UTCEvent JSON
{
"id": "163b5c9ef78a3a4d8633586f2d94286ada1248e10b98526386889b06bc98d654",
"pubkey": "e68a0856e90d9997b1f721e905249896412dd570399a987b2e8fd5e7fcfe2279",
"created_at": 1792924672,
"kind": 1,
"tags": [
[
"t",
"tip"
]
],
"content": "Learn: Costs worth knowing by heart\n\nRead array[i]: O(1)\nSearch an unsorted array: O(n)\nSort: O(n log n)\nHashSet or Dictionary lookup: O(1) on average\nSearch a sorted array with binary search: O(log n)\n\nWhen you state a solution in an interview, say its Big-O with it.\n\n#tip · TIP-005",
"sig": "93eec19ccfb118a7ca5dca59193583d6697ce6e06a9268f9537f1a64077a780df81b6cdbcc344b67abb655cff9fc295a06bdd799f3751376ad95059d6cd28844"
}