> For example, I've seen people write code which relies heavily on design patterns but then that same code uses an O(n^2) nested loop to find items that are common between two arrays. There is a simple 'pattern' you can use to store the items of the first array in a Set or HashMap and then finding common items is O(n) because Set and HashMap lookups are O(1)... Very useful pattern but I don't believe it has a name. I use it literally ALL the time. The idea of storing intermediate state in some kind of HashMap is a game-changer IMO but there's no name for that pattern of coding.Isn't this called 'dynamic programming'? It's actually a habit people should pick up when grinding leetcode.
viraptor|2 months ago
salutis|2 months ago
arethuza|2 months ago
zelphirkalt|2 months ago