← Codeium Interview Insights

Codeium·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Codeium software engineer interview with an array/string manipulation problem that looks straightforward until you actually read the tie-breaking rule.

Questions Asked (1)

Q1

Given an array of strings, return the third largest word by length. If words tie on length, prefer the one that appears later in the array.

Algorithms & Data Structures
Author's notes

The base problem is fine, sort by length descending and grab index 2.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the tie-breaking rule and edge cases (e.g., fewer than 3 distinct lengths, duplicates) before coding. Then use a min-heap of size 3 to track the top three words by length, updating based on length and later index. Alternatively, sort the array by length descending and index descending, then pick the third distinct length.

Pro tip: Mention that you can avoid sorting the entire array by using a heap for O(n log 3) time, but also note that sorting is simpler and O(n log n) is acceptable for most interviews. Discuss the trade-off to show depth.

1. Clarify requirements and edge cases

Ask about tie-breaking (later index wins), what 'third largest' means if there are fewer than 3 distinct lengths, and whether duplicates count as separate words.

2. Choose data structure and algorithm

Decide between sorting (O(n log n)) and heap (O(n log k) with k=3). Explain the trade-offs and pick one based on constraints.

3. Implement the solution

If using heap: iterate through words, maintain a min-heap of size 3 based on length and index. If using sorting: sort by length descending, then index descending, and pick the third distinct length.

4. Test with examples

Walk through edge cases: fewer than 3 words, all same length, ties, and ensure the later index is chosen correctly.

5. Analyze complexity and discuss optimizations

State time and space complexity. Mention that the heap approach is more efficient for large arrays if k is small, but sorting is simpler.

Key Points to Mention

  • Tie-breaking rule: later index wins when lengths are equal.
  • Handling fewer than 3 distinct lengths (return null or empty string).
  • Using a min-heap of size 3 to track top three words efficiently.
  • Sorting approach: sort by length descending, then index descending.
  • Time complexity: O(n log 3) for heap vs O(n log n) for sorting.
  • Space complexity: O(1) for heap (since size 3) vs O(n) for sorting (if not in-place).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.