From 6dc689f3a08fa3f584e9533649991a3f08c0ea6f Mon Sep 17 00:00:00 2001 From: bt3gl <138340846+bt3gl-google@users.noreply.github.com> Date: Sun, 30 Jul 2023 12:26:33 -0700 Subject: [PATCH] Update hash_map_array.py --- arrays_and_strings/hash_map_array.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arrays_and_strings/hash_map_array.py b/arrays_and_strings/hash_map_array.py index 533065f..343e4e2 100644 --- a/arrays_and_strings/hash_map_array.py +++ b/arrays_and_strings/hash_map_array.py @@ -41,4 +41,7 @@ class Bucket: def remove(self, key): for i, k in enumerate(self.bucket): if key == k[0]: + # del is an O(n) operation, as we would copy all the i: elements + # to make it O(1) we could swap the element we want to remove + # with the last element in the bucket del self.bucket[i]