← EvenUp Interview Insights

EvenUp·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Interviewed for a Software Engineer role at EvenUp and got a string compression coding problem. Pretty standard algorithmic question but the in-place constraint is where people usually trip up.

Questions Asked (1)

Q1

Given an array of characters, compress it in place using run-length encoding: single characters stay as-is, repeated characters get replaced by the character followed by the count as individual digits. Return the new length. You must use constant extra space.

Algorithms & Data Structures
Author's notes

The two-pointer approach is the way to go here.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a two-pointer technique: one pointer reads through the array to identify runs of identical characters, while the other writes the compressed output in place. For each run, write the character and then the count as individual digits, updating the write pointer accordingly. Return the final write pointer as the new length.

Pro tip: Clarify edge cases upfront, such as runs longer than 9 (requiring multiple digits) and single-character runs (no count written). Also, mention that the array beyond the new length is irrelevant, so overwriting is safe.

1. Initialize pointers and variables

Set a read pointer to traverse the array and a write pointer to track the compressed output position. Also, keep a variable to count consecutive identical characters.

2. Iterate and count runs

While the read pointer is within bounds, count how many times the current character repeats consecutively by advancing the read pointer.

3. Write character and count

Write the character at the write pointer, then if the count is greater than 1, convert the count to digits and write each digit individually.

4. Update pointers and continue

After writing, update the write pointer and continue the loop until the read pointer reaches the end of the array.

5. Return new length

The write pointer now indicates the length of the compressed array. Return it as the result.

Key Points to Mention

  • Two-pointer technique for in-place modification
  • Handling counts greater than 9 by writing each digit separately
  • Single characters are written without a count
  • Constant extra space (O(1)) is maintained
  • Time complexity is O(n) where n is the length of the array
  • Edge cases: empty array, all same characters, no repeats

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