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-14 05:38:00 UTCEvent JSON
{
"id": "1e2e818119e75bfc544ea304303899d69f7c0efbd89802e7358a38d6863c0f96",
"pubkey": "e68a0856e90d9997b1f721e905249896412dd570399a987b2e8fd5e7fcfe2279",
"created_at": 1791956280,
"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": "53c6d5ea6a895da57c308f5f12f6f3ea05785ca3c24956188ac1b2ce2b65f19041458785abbe5fb098364dce4f54608cb8ef3cf983f70c62c1f048837ad95dc6"
}