Maximum String Operations
Updated
Problem statement
Choose three consecutive characters whose first two are equal and whose third differs, then replace the third with the repeated character. Apply the operation any number of times and return the maximum possible operation count.
Function
getMaximumOperations(s: String) → longExamples
Example 1
s = "accept"return = 3The pair cc can successively absorb e, p, and t.
Example 2
s = "aabaab"return = 2Two differing characters can be changed by the available repeated-a pairs.
Constraints
3 <= s.length <= 200000scontains lowercase English letters.
More Atlassian Online Assessment questions
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024
- Binary Search Tree IteratorOA · Seen Nov 2023
- Binary Tree Level Order TraversalOA · Seen Nov 2023
Similar questions at other companies
- Lexicographically Largest IdentifierAmazon · OA
- Lexicographically Smallest Grid Path with One Letter ChangeInfosys · OAInfosys interview questions
- Longest Repeated Letter Block with Adjacent SwapsIntuit · OAIntuit interview questions
- Binary CircuitAkuna Capital · OAAkuna Capital interview questions
- Minimize Expression with ParenthesesPinterest · OAPinterest interview questions
- Word Wrap with Even JustificationSentry · OA · PHONE SCREENSentry interview questions
- Palindromic StringsNVIDIA · OANVIDIA interview questions
- Get Patch SequenceMorgan Stanley · OAMorgan Stanley interview questions
- Max Number of OperationsSalesforce · OASalesforce interview questions
- Viral Content BalancerTikTok · OATikTok interview questions