Learn
Arrays — Easy
Linear scans, two-pass tricks, basic counting. The first set of array problems every interviewer expects you to do without thinking.
C++JavaScriptPythonJava
Lessons
- 01Largest elementScan the array, remember the biggest value you've seen so far.C++JavaScriptPython
- 02Second largest elementOne pass, two variables. Watch out for duplicates of the maximum.C++JavaScriptPython
- 03Check if an array is sortedCompare adjacent pairs. The moment you find one out of order, you can stop.C++JavaScriptPython
- 04Remove duplicates from a sorted arrayTwo pointers in one pass. The classic in-place de-dup pattern.C++JavaScriptPython
- 05Left rotate by oneSave the first element, shift everything left, drop it at the end.C++JavaScriptPython
- 06Move zeros to endTwo pointers again: one walks the array, one tracks where the next non-zero goes.C++JavaScriptPython