FastPrepMinimum Deletions to Make Every Letter Count Even
Problems/Minimum Deletions to Make Every Letter Count Even

Minimum Deletions to Make Every Letter Count Even

Marshall Wace logoMarshall Wace● EasyFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The task, examples and bounds match the report at about 99%. The pictured candidate code incorrectly returns zero for a one-letter input; this exercise follows the stated even-count rule.

You may delete any characters from a lowercase string S. Find the minimum number of deletions needed so that every letter remaining in the string occurs an even number of times.

An absent letter has count zero, which is even. The empty string therefore satisfies the condition.

Function

solution(S: String) → int

Examples

Example 1

S = "acbcbba"return = 1

Removing one b leaves every count even.

Example 2

S = "axxaxa"return = 2

Remove one a and one x to make both letter counts even.

Example 3

S = "aaaa"return = 0

The four a characters already have an even count.

Constraints

  • 0 <= S.length <= 200000.
  • S contains only lowercase English letters.

More Marshall Wace Online Assessment questions

  • Count Letters with Ordered Lowercase and Uppercase OccurrencesOA · Seen Oct 2025
  • Maximum Trailing Zeros on a Path with at Most One TurnOA · Seen Oct 2025
  • Shortest Subarray Covering an Integer RangeOA · Seen Oct 2025
  • Maximum Events in a 60-Second WindowOA · Seen Aug 2025
  • Successful Logins from Multiple CountriesOA · Seen Aug 2025
  • Maximize Remaining Item Types After Clearing Consecutive ShelvesOA · Seen Nov 2024
  • Shortest String After Erasing Equal PairsOA · Seen Nov 2024
  • Count Distinct Tags in a Fixed-Radius Circle (Practice Reconstruction)OA · Seen Apr 2024
  • Generate Unique Company Email AddressesOA · Seen Apr 2024
  • Reconstruct a Two-Row Binary MatrixOA · Seen Apr 2024

Similar questions at other companies

  • Count Phrases Formed by Anagram ReplacementWells Fargo · OAWells Fargo interview questions
  • Ransom NoteThe Walt Disney Company · OA · PHONE SCREENThe Walt Disney Company interview questions
  • Count One-Swap Number PairsCapital One · OACapital One interview questions
  • How Many Sentences?Chubb · OAChubb interview questions
  • Perfect SubstringsVisa · OAVisa interview questions
  • Cheating CodemakerJane Street · OAJane Street interview questions
  • Count Equal-Frequency SubsequencesExpedia · OAExpedia interview questions
  • How Many Sentences?Atlassian · OAAtlassian interview questions
  • K-th Non-Repeating Character IndexBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Dictionary Words Formable From LettersGoogle · ONSITE INTERVIEWGoogle interview questions

Interview reports that mention this question

  • Marshall Wace Older Quant Tests: 5 Experiences (Part 3 of 3)
  • Marshall Wace Quant and Coding OA: 19 Experiences (Part 1 of 3)

Marshall Wace interview experiences

  • Marshall Wace Coding Tests: 11 Experiences (Part 2 of 3)
All Marshall Wace interview questionsSee Marshall Wace hiring insights
Saved
class Solution {
    public int solution(String S) {
        // Write your solution here.
    }
}
Checking account…