InterviewLegend

OA Strings, Digits & Running Balances

Alex Chen40 min readGuide updated
In this lesson
  • Pick the right digits to delete from a string of 1s and 2s, and explain why
  • Write the short May 2026 OA tasks quickly and cleanly: no triple letters, password rules and card fees
  • Build the smallest string with exact letter counts by checking, at each step, that the rest can still be placed

DRW's developer assessment runs on Codility. It's timed, usually three problems in about two hours, and DRW's own prep article says the problems are scored on both correctness and performance. Several candidates add that you only see basic examples, so the edge cases are yours to test. The newest full set, from an October 2026 intern assessment, has its own lesson.

This lesson covers the rest of the 2026 problems, newest first. A new-grad coding screen in August 2026 asked for the largest number you can keep from a string of 1s and 2s once both digit counts are even, and the same write-up was also posted for March 2026. Question listings from a May 2026 data engineer intern assessment add three shorter tasks: a string with no letter three times in a row, a password check and a year-end balance with monthly card fees. After those comes a 2023 problem that builds the smallest string from exact letter counts.

The DRW angle
Performance is graded, so state the bound before you code. The 1s and 2s screen allowed strings of 200,000 digits and expected O(N). A quadratic delete-and-compare loop passes the visible examples and then times out on the hidden ones.

What these DRW OA questions have in common

None of the five needs a clever data structure. Each is a single pass that makes a local choice, and the hard part is being sure the choice is safe. Which 1 do you delete? When can you place an "a" without trapping yourself later? Which months still owe the fee? Codility shows few examples, so write the awkward cases yourself before you submit: the empty string, a string that's already fine, and an input where the answer is "nothing works".

Say the rule out loud before you type it, then test the rule on a case built to break it. For the 1s and 2s problem, that means trying every possible 1 to delete on a short string and checking that your pick wins. For the letter-count problem, it means a count that's too large to place at all.

Asked in 2026

Largest number from 1s and 2s with even counts

This one comes from a new-grad software engineer coding screen in August 2026, and the same write-up was also posted for March 2026. It gave two examples and a bound of 200,000 digits with O(N) expected. The candidate said the hard part was choosing which occurrence to delete when a count is odd. That choice is the problem, so most of the walkthrough is about it.

1

Largest Number From 1s and 2s With Even Counts

MediumCommonly asked
Problem
You get digits, a string made only of the characters "1" and "2". Delete zero or more characters, keeping the rest in order, so that the number of 1s left is even and the number of 2s left is even.

Return the remaining string that reads as the largest number. Zero is even, so an empty string is a valid answer when nothing better exists. The string can hold up to 200,000 digits, so aim for O(N).
Inputdigits = "121212"Output"2121"

Three 1s and three 2s, so one of each must go. Dropping the first 1 lets a 2 lead, then the last 2 goes.

How this uses the pattern

Delete exactly one 1 if the 1s are odd and exactly one 2 if the 2s are odd. Take the first 1 and the last 2.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Largest Number From 1s and 2s With Even Counts

Loading...
Click "Run" to execute your code
The DRW angle
The bound is the hint. With 200,000 digits you can't try every deletion and compare the results, so you need a rule that picks the right digit in one scan, and you need to defend it. In a live screen, expect to be asked why the first 1 and why the last 2. A crisp answer is about place value: a deletion changes the number starting at the spot where it happens, so you want gains early and losses late.
Take it further
Do it without deleting from the middle of a list. Each del shifts the tail, which is fine twice but not in a loop. Find both indexes first in one pass, then build the answer by skipping them. Then try the same rule on a string with three digit values and see which part of the argument still holds.

Delete the fewest letters so none appears three times in a row

This one is listed for a May 2026 data engineer intern assessment. The listing gives only a one-line outline, so the wording below is something like what was asked. The shape is clear: a lowercase string, the fewest deletions so no three identical letters sit next to each other, and the order of the rest kept.

2

Delete the Fewest Letters So None Appears Three Times in a Row

EasySometimes asked
Problem
You get text, a string of lowercase letters. Delete as few characters as possible so that no letter appears three or more times in a row. The characters you keep stay in their original order.

Return the string that remains.
Inputtext = "bookkkeeper"Output"bookkeeper"

The run of three k letters loses one. Every other run is two letters or shorter.

How this uses the pattern

Build the answer one character at a time. Skip a character when the last two kept characters already equal it.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Delete the Fewest Letters So None Appears Three Times in a Row

Loading...
Click "Run" to execute your code
The DRW angle
There's little to it, so finish it quickly and correctly and save the clock for the rest of the set. Building a new string as you go is cleaner than deleting from the input while you walk it, which shifts indexes under your loop. Mention why greedy is optimal in one sentence: each run of length L must lose at least L minus 2 letters, and keeping two per run does exactly that.
Take it further
Any limit k, and report the count. A natural variant allows at most k in a row and asks how many deletions you need. Track the current run length instead of looking back two places, and count the characters you skip.

Validate a password against explicit rules

Another task from that May 2026 assessment checks a password against a list of rules: a length, a digit, a lowercase letter, an uppercase letter, a special character from a given set, and no spaces. The listing names those checks but not the exact length or the exact symbols, so here both are inputs. Read the real prompt closely for those two values, since they're where submissions fail.

3

Validate a Password Against Explicit Rules

EasySometimes asked
Problem
Write is_valid_password(password, min_length, specials). A password is valid when all of these hold. Its length is at least min_length. There is at least one digit, one lowercase letter and one uppercase letter. At least one character comes from the string specials, and no character is a space.

Other characters are allowed and simply don't count toward any rule. Return true if the password is valid and false otherwise.
Inputpassword = "Tr4de!ng"min_length = 8specials = "!@#$%^&*"Outputtrue
How this uses the pattern

Check the length and the space rule first, then scan once with a flag for each kind of character you need.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Validate a Password Against Explicit Rules

Loading...
Click "Run" to execute your code
The DRW angle
Nothing here is algorithmic. Points get lost in the reading. Check "at least" against "more than" for the length, and an exact special set against "anything that isn't a letter or digit". Then write the tests the prompt doesn't show: one password per rule that fails only that rule. Six short tests are quick to write and catch the off-by-one mistakes before the hidden tests do.
Take it further
Say which rules failed. A friendlier checker returns the names of the rules a password breaks, so a sign-up form can show them all at once. Keep the same checks but collect a name for each one that fails, in a fixed order.

Year-end balance with monthly card fees

The third task from that assessment computes an account's balance at the end of 2020 after every transaction and twelve monthly card-fee decisions. A month's fee is waived only when that month meets both a count of card payments and an amount spent. The listing gives that outline without the numbers, so the fee and both thresholds are inputs here, and a card payment is any negative amount.

4

Year-End Balance With Monthly Card Fees

EasySometimes asked
Problem
An account starts 2020 at 0. You get two lists of the same length, amounts and dates. Transaction i adds amounts[i] to the balance on dates[i], a string like "2020-03-15". A negative amount is a card payment and a positive one is money coming in. The lists are in no particular order.

At the end of each of the twelve months the bank charges fee. It waives the fee for a month when that month has at least min_payments card payments and those payments add up to at least min_spend (as a positive total).

Return the balance at the end of the year.
Inputamounts = [500, -40, -25, -60, 200]dates = ["2020-03-02", "2020-03-09", "2020-03-15", "2020-03-28", "2020-07-01"]fee = 4min_payments = 3min_spend = 100Output531

The transactions sum to 575. March has three payments totalling 125, so its fee is waived. The other eleven months cost 44.

How this uses the pattern

Sum every amount. Separately, count the card payments and their total for each month, then subtract the fee for each month that misses either threshold.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Year-End Balance With Monthly Card Fees

Loading...
Click "Run" to execute your code
The DRW angle
The sums are trivial. The rules around them are where people slip. Both thresholds must hold for a waiver. A month with no transactions at all still owes its fee, which a loop over transactions alone never visits. Incoming money doesn't count toward the payment total. Parse the month from the date string directly instead of reaching for a date library, and say so as you do it.
Take it further
Show the balance month by month. A statement view wants all twelve month-end balances. Sort the transactions by date, or bucket them by month, and walk the months in order, adding that month's amounts and then taking the fee if it isn't waived.

Older problems (2023)

This one is older than a year, so treat it as practice for the shape. In a July 2023 software developer intern assessment on Codility, three problems in 150 minutes, the second asked for the smallest string that uses exact counts of a, b and c with no letter three times in a row. The candidate called it a harder version of the longest happy string problem and didn't finish it. An undated question-bank listing has a close cousin with upper limits on each letter and a fixed length, worked below as the follow-up.

Smallest string with exact letter counts and no three in a row

5

Smallest String With Exact Letter Counts and No Three in a Row

HardRarely asked
Problem
You get three counts, a, b and c. Build a string that uses exactly a copies of "a", b copies of "b" and c copies of "c", and never has the same letter three times in a row.

Among all such strings, return the one that comes first in dictionary order. If no such string exists, return an empty string.
Inputa = 1b = 2c = 3Output"abcbcc"

Starting with a is safe. Then b, but a second b would leave three c letters and nothing to split them.

How this uses the pattern

Fill positions left to right. At each one, try a, then b, then c, and take the first letter that keeps the rest of the counts placeable.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Smallest String With Exact Letter Counts and No Three in a Row

Loading...
Click "Run" to execute your code
The DRW angle
The longest-happy-string greedy always places the most plentiful letter, and here that's wrong twice over. You must use every letter, and dictionary order wants a's early even when c is the plentiful one. The fix is a feasibility check you can run in constant time. A letter with m copies left among T remaining needs the others as separators, which works out to 3m at most 2T + 2. Derive that on paper before you code.
Take it further
At most these counts, fixed length. The undated listing gives upper limits on a, b and c and asks for the smallest string of length n. The greedy stays the same. Only the feasibility check changes, since you now choose how many of each letter to use.

Common questions

What questions are on the DRW OA?

Custom problems written for the test, mostly greedy, string and simulation work. In 2026 that means the four 2026 problems on this page plus the October set in The DRW Online Assessment. That set asked you to change up to three elements to shrink max minus min, find the longest substring with equal letter counts, and defer the fewest expenses so a balance never goes negative.

How hard is the DRW online assessment?

It varies by cycle. The October 2026 intern set was described as pretty easy, a July 2026 intern report called all three problems medium, and a 2025 report says the prompts are long to read. Only basic examples are shown, so the hidden tests decide the score. DRW grades correctness and performance, so an answer that's right but quadratic can still lose points on large inputs.

Which language should I use?

Most reports say language of choice on Codility. One July 2026 intern report says the hardest of three problems had to be written in C++, so check the invite. Python is fine for all five problems here, since each one is a single linear pass.

Key Takeaways

  • ✓DRW grades OA code on correctness and performance. State the O(N) bound before you write a line.
  • ✓For 1s and 2s, delete the first 1 and the last 2. Defend each choice with place value.
  • ✓The May 2026 tasks reward exact reading: both waiver thresholds, the exact special set, quiet months still pay.
  • ✓For exact letter counts, try letters smallest first and keep one only if 3m stays at most 2T + 2.
DRW interview guide

Know what DRW asks before you walk in.

29 coding · 3 system design · 18 behavioral questions

Get Premium$49 a year · Instant access
Or start freeNo card.

Get their questions first.

The DRW Online Assessment (Codility)Had your DRW interview?How we research

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.