Second and third largest Numbers in an array using Python
- Input: [2, 14, 5, 53, 26, 33, 53, 33, 12]
- Output: 33 (second largest), 26 (third largest)
-
Assumption: Input contains at least two or three numbers.
- Interviewer: Find second largest number.
- Quick code using list sorted() and set()
- Interviewer: Rewrite without sorted() and set().
- Interviewer: Rewrite the code to find the third largest.
- Interviewer: Why did you use pass instead of continue ?
- Me: pass
- Interviewer: What? My question is: why did you use pass?
- Me: I said pass, which means move to the next question!
- Interviewer: 🤓