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-26 18:08:16 UTCEvent JSON
{
"id": "11a20e84d69b9a1ec6e0f72d1567532254f32a6f2c21bb93db51e7e80258e9cd",
"pubkey": "e68a0856e90d9997b1f721e905249896412dd570399a987b2e8fd5e7fcfe2279",
"created_at": 1793038096,
"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": "a5b63d7bbeae9bd1518bb2a4a069481100fbd191a5b518f8d31a20d6ae7ca6efd249f3c5334de1882f7e9a536a1f365b6928ea6770c8c4392c2d06a309e0032c"
}