DRW New Grad Software Engineer Interview Experience — A Greedy Deletion Problem on a String of 1s and 2s

DRW·Software Engineer·Aug 2026
HR ScreenNew Gradhard

I got a string greedy problem:

Given a string digits made up only of '1' and '2', which represents a positive integer. You can delete 0 or more characters from it, and after the deletion: the number of remaining '1's must be even; the number of remaining '2's must also be even; and, while satisfying those first two conditions, the final integer should be as large as possible.

Note that you can only delete characters. You cannot change the original relative order of the remaining characters.

For example: 121212 -> 2121, 2121122 -> 221122, 1111 -> 1111.

The constraint is N <= 200000, so it should need a solution of around O(N).

The problem itself isn't that hard. The main thing is how to greedily decide, when a digit appears an odd number of times, which occurrence you should actually delete so that the final number is guaranteed to be the largest. At first I felt like just deleting the first 1 / the last 2 would do it, but you still need to think carefully through the cases for the different arrangements.

Published

Curated and edited by PracHub

Practice the questions from this interview

Discussion

Sign in to join the discussion. The author is notified of every comment.

Loading comments…

Interview at a glance

Company
DRW
Role
Software Engineer
Level
New Grad
Rounds
HR Screen
Difficulty
hard
Interview date
Aug 2026
Questions from this interview
1 question

Real DRW interview experiences

First-hand reports from DRW candidates — the rounds, the questions they were asked, and how it went.

All 11 DRW interview experiences