← Convoy Interview Insights

Convoy·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Convoy coding interview for a software engineer role, one question but they really dug into it with a bunch of follow-ups that I wasn't fully ready for.

Questions Asked (1)

Q1

Given an array of characters, compress it in place using run-length encoding. Write the character followed by its run count as individual digit characters, skipping the count when a run is just one character. Return the new length using O(1) extra space.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The base problem wasn't too bad once I realized I needed two pointers, one for reading and one for writing.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a two-pointer technique: one pointer reads the array to identify runs, and another writes the compressed characters in place. For each run, write the character, then if the count is greater than 1, write each digit of the count as a separate character. Return the write pointer as the new length.

Pro tip: Clarify that the input array is mutable and that we can overwrite characters we've already read, since the write pointer never exceeds the read pointer. Also, handle edge cases like empty array and runs longer than 9 by writing multiple digits.

1. Understand the problem and constraints

Restate the problem: compress the array in place using run-length encoding, skipping count for single characters, and return the new length. Emphasize O(1) extra space, so we must modify the array directly.

2. Design the two-pointer approach

Use a read pointer to scan runs and a write pointer to overwrite the array. For each run, write the character and then the count digits if count > 1.

3. Handle digit conversion and edge cases

Convert the count to individual digit characters (e.g., 12 becomes '1' and '2'). Consider edge cases: empty array, single character, runs of length 1, and runs longer than 9.

4. Implement and test with examples

Walk through a concrete example like ['a','a','b','b','c','c','c'] to show the in-place modification and verify the returned length. Discuss time and space complexity: O(n) time, O(1) space.

Key Points to Mention

  • Two-pointer technique for in-place modification
  • Time complexity O(n) and space complexity O(1)
  • Handling counts greater than 9 by writing multiple digits
  • Skipping the count when the run length is 1
  • Edge cases: empty array, all same characters, no consecutive duplicates
  • Ensuring the write pointer never overtakes the read pointer

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