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 18:07:53 UTCEvent JSON
{
"id": "2e97c24081d2ee18900c59a74286cafed30cf5851ba059a3e5ebeb363c834e95",
"pubkey": "e68a0856e90d9997b1f721e905249896412dd570399a987b2e8fd5e7fcfe2279",
"created_at": 1792951673,
"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": "f9fe4b7f2a6de037f8c4e96e2d797cda03d70a9cafbf1755dec9cc37cf8e1bbd56cd8ec78a35abf1a8180fc859ae33e423f2d6c054fd4ca1915c6c86961553b2"
}