Arrays
Python Array Interview Questions
Arrays are sequences you walk through by position. Most Python interview questions start here, and what is being checked is whether you can state your loop boundaries and your return value without hand-waving.
What array questions ask you to do
Across the questions here, these are the shapes that come up:
- Return the first item that meets a condition
- Move some items to the end without losing the others
- Merge two sorted sequences into one
- Track a running maximum or minimum
- Reverse or rotate part of a sequence
Common mistakes with arrays
The end of a slice is not included, so taking items up to position n gives you n items and position n is the one after. Changing a list while looping over it skips items too, because the position keeps moving forward while the list gets shorter underneath it.