NeetCodeIO

Arrays are one of the most common interview topics.


Here are four to patterns that are a must know.


๐Ÿญ. ๐—ž๐—ฎ๐—ฑ๐—ฎ๐—ป๐—ฒ'๐˜€ ๐—”๐—น๐—ด๐—ผ๐—ฟ๐—ถ๐˜๐—ต๐—บ - An efficient algorithm used to find the maximum subarray sum.


๐Ÿฎ. ๐—ง๐˜„๐—ผ ๐—ฃ๐—ผ๐—ถ๐—ป๐˜๐—ฒ๐—ฟ๐˜€ - Use two pointers, e.g. left and right, typically starting at different positions, e.g., start and end of an array, and move them based on specific conditions to solve the problem.


๐Ÿฏ. ๐—ฆ๐—น๐—ถ๐—ฑ๐—ถ๐—ป๐—ด ๐—ช๐—ถ๐—ป๐—ฑ๐—ผ๐˜„ - Expand the window by adding elements from the right until the constraint is broken. Shrink the window by removing elements from the left. Repeat until a valid window is found.


๐Ÿฐ. ๐—ฃ๐—ฟ๐—ฒ๐—ณ๐—ถ๐˜… ๐—ฆ๐˜‚๐—บ - Used to calculate the running sum of a subarray efficiently.

โ€”

Preparing for coding interviews? Check out neetcode.io/

9 months ago (edited) | [YT] | 1,379



@rdubb77

Honestly most interviews should just stick to arrays since they are the most important data structure. But some just make things needlessly hard to weed people out and thatโ€™s just a dick move.

9 months ago | 13

@moralized

I would say that two pointers also includes algorithms where you have a pointer in one array and a pointer in another array, and you calculate something at each entry as they slide along to the end.

9 months ago | 5

@technicallytechnical1

W

9 months ago | 1

@Zooiest

Any algorithm on a collection can technically be implemented in O(1) time if you just always loop through the entire range of indexes that your iteration data type supports

9 months ago | 0

@araneuskyuro

Thanks man, love your content

9 months ago | 0

@karribalasubramanyam5463

What tools do you use to create this GIF..? Great Content BTW

9 months ago (edited) | 1

@Garg478

How is MaxSum=5 in Cadane's algo, second iteration. It should be 4 right? Might be a typo

9 months ago | 1