← Wells Fargo Interview Insights
I knew mapToLong and max were the right tools but I second-guessed myself on whether OptionalLong.empty() would come back automatically for an empty stream.
Use the Stream API's mapToLong to extract salaries, then call max() which returns an OptionalLong. This handles empty lists gracefully by returning an empty OptionalLong, and avoids explicit loops or mutable state.
Pro tip: Mention that max() on an empty stream returns OptionalLong.empty(), so no extra null checks are needed. Also, consider parallelization for large datasets, but note that it may not always improve performance due to overhead.
Clarify that the method should return an OptionalLong, empty if the list is empty, and that no explicit loops or external mutable state are allowed.
Use mapToLong to convert each Employee to its salary, then call max() to find the highest value.
Rely on max() returning OptionalLong.empty() for an empty stream, so no additional checks are needed.
Discuss whether to use parallelStream() for large lists, and mention that it may not always be beneficial due to overhead.
Implement the method succinctly, ensuring it is functional and easy to understand.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.