4 ms·
When attempting a problem that has an obvious brute force solution ask yourself why the brute force solution is wasteful. "It is wasteful because if I've alread
by 3pt14159 14y ago
When attempting a problem that has an obvious brute force solution ask yourself why the brute force solution is wasteful. "It is wasteful because if I've already compared element A and element B, and I've already compared element B and element C then in some cases I shouldn't need to compare element C and element A." Is the type of thinking you should be having. This will lead you towards the right data structures and algorithms. Also, understanding sets and set theory really helps too.