Minimum Deletions for Unequal Adjacent Characters
Updated
Problem statement
You are given an ordered array of printable-ASCII strings. For each string, find the minimum number of character deletions needed so that no two adjacent retained characters are equal. Deletions must preserve the relative order of retained characters.
Return one deletion count per string in input order.
Function
minimumDeletions(strings: String[]) → int[]Examples
Example 1
strings = ["AABAAB", "AAAA", "ABCD"]return = [2, 3, 0]The first string needs one deletion from each AA run, the second keeps one of four equal characters, and the third already satisfies the rule.
Example 2
strings = ["", "a", "aabccddd"]return = [0, 0, 4]Empty and single-character strings need no deletions. The last string deletes one a, one c, and two d characters.
Constraints
- Every input contains only printable ASCII characters.
- The total length of all strings is at most
200000. - Input order is preserved in the returned counts.
More IBM Online Assessment questions
- Missing IntervalsOA · Seen Nov 2026
- Last Object Exit TimeOA · Seen Nov 2026
- Count Peaks and ValleysOA · Seen Nov 2026
- Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
- Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
- Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
- Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
- Tree Pythagorean TriplesOA · Seen Oct 2026
- Minimum Power-of-Two Removal OperationsOA · Seen Oct 2026
- Maximum Compatible Time WindowsOA · Seen Oct 2026
Similar questions at other companies
- Maximum Ones After K OperationsGoldman Sachs · OAGoldman Sachs interview questions
- Minimum Operations to Reduce a Transaction LedgerVisa · OAVisa interview questions
- Prepare NotificationMicrosoft · OAMicrosoft interview questions
- Minimum Changes for Distinct Adjacent CharactersHeadlands Technologies · OAHeadlands Technologies interview questions
- Largest Number With Even Digit FrequenciesDRW · OADRW interview questions
- Crop Text at a Whole-Word BoundaryAmerican Express · OAAmerican Express interview questions
- Minimum Flips for Even Binary RunsJP Morgan Chase · OAJP Morgan Chase interview questions
- Missing WordsVanguard · OAVanguard interview questions
- Digit Changes for a Multiple of 9Nutanix · OANutanix interview questions
- Smallest String After at Most One DeletionLSEG · OALSEG interview questions