FastPrepMinimum Deletions Before Rearranging into a Palindrome
Problems/Minimum Deletions Before Rearranging into a Palindrome

Minimum Deletions Before Rearranging into a Palindrome

Marshall Wace logoMarshall Wace● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Marshall Wace phone screen. The report gives the goal of fewest deletions and says you may rearrange the letters. We chose the alphabet, the limits and the answer for an empty string. Our version is about 95% the same as the reported question.

Given a string S, remove as few characters as possible so that the remaining characters can be rearranged into a palindrome.

The remaining characters may be put in any order. Return the minimum number of deletions. An empty string is a palindrome.

Function

solution(S: String) → int

Examples

Example 1

S = "aabbc"return = 0

No deletion is needed: rearrange the characters into abcba.

Example 2

S = "abc"return = 2

Each letter has an odd count. Keep any one letter and delete the other two.

Example 3

S = "aaabbb"return = 1

Delete one a, then rearrange aabbb into abbba.

Example 4

S = ""return = 0

The empty string already satisfies the condition.

Constraints

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

More Marshall Wace interview questions

  • Maximum Sum with at Most Three Two-Element TilesPHONE SCREEN · Seen Sep 2025
  • Minimum Full Glasses for an Exact Water VolumePHONE SCREEN · Seen Sep 2025
  • Smallest Absolute Difference Between Two Array ElementsPHONE SCREEN · Seen Sep 2025
  • Maximum Frog Separation with One Upward Jump (Practice Reconstruction)PHONE SCREEN · Seen Jul 2023
  • Smallest Larger Integer with Twice the Digit SumPHONE SCREEN · Seen Jul 2023
  • Count Squares of Any OrientationPHONE SCREEN · Seen Oct 2019
  • 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

Similar questions at other companies

  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • First Letter to Appear TwiceCisco · PHONE SCREENCisco interview questions
  • Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Portfolio Valuation, Part 1Stripe · PHONE SCREENStripe interview questions
  • Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
  • Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
  • Known Words Matching Phone DigitsLinkedIn · PHONE SCREENLinkedIn interview questions
  • First Non-Repeated CharacterDell Technologies · PHONE SCREENDell Technologies interview questions
  • Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
  • First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions

Interview reports that mention this question

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

Marshall Wace interview experiences

  • Marshall Wace Older Quant Tests: 5 Experiences (Part 3 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…