DSA interview question
A weather station uploads the day's temperature readings as an array, and the dashboard shows the maximum temperature. It's the simplest array problem there is, which is exactly why it appears in first rounds: the interviewer wants to see a single clean pass, a correct starting value (a real element, not 0, since temperatures can be negative), and the judgement not to sort the whole array just to read one value.
Example: [1, 8, 7, 56, 90] → 90.
int largestElement(const vector<int>& a); // a is non-empty
Input a | Output | Explanation |
|---|---|---|
[1, 8, 7, 56, 90] | 90 | |
[5, 5, 5] | 5 | All equal |
[-3, -1, -7] | -1 | Starting from 0 would wrongly return 0 |
[10] | 10 | Single element |
[2147483647, -5] | 2147483647 | INT_MAX is handled |
(Confirm: the array has at least one element; values can be negative.)
max start at?"On Practick another engineer interviews you live for 60 minutes on a question from this bank. They have the full interviewer guide beside the call: the expected answer to every follow-up, hints to give if you stall, and a scoring rubric. You get the model solution once the session settles. It is free: interview someone for an hour and you have earned your own.
Book a free mock interviewAll 474 dsa interview questions
DSA mock interviews · System design interview questions · Free mock interview practice · Browse interviewers · Sign in