From 256c3847fef11d92be01d104fdeca3cc7c26b800 Mon Sep 17 00:00:00 2001 From: Rafat Bin Islam <59219890+rafatbiin@users.noreply.github.com> Date: Mon, 3 Aug 2020 13:25:39 +0600 Subject: [PATCH] contents: add tip on traversing arrays (#171) --- contents/algorithms/array.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contents/algorithms/array.md b/contents/algorithms/array.md index 00d5c1eb..95475bdf 100644 --- a/contents/algorithms/array.md +++ b/contents/algorithms/array.md @@ -13,6 +13,8 @@ For questions where summation or multiplication of a subarray is involved, pre-c If you are given a sequence and the interviewer asks for O(1) space, it might be possible to use the array itself as a hash table. For example, if the array only has values from 1 to N, where N is the length of the array, negate the value at that index (minus one) to indicate presence of that number. +Also O(n) doesn't mean you can only traverse the array once. Sometimes traversing the array more than once can help you solve the problem easily. + ## Arrays are sequences Are there duplicate values in the array, would it affect the answer?