Problem · String
Count Case-Insensitive Triplets
Learn this problemProblem statement
Given a string text consisting of uppercase and lowercase English letters, count all triplets of consecutive characters for which the first and last characters are the same when compared case-insensitively.
Note: You are not expected to provide the most optimal solution, but a solution with time complexity no worse than O(text.length^2) will fit within the execution time limit.
Function
solution(text: String) → intExamples
Example 1
text = "aXA"return = 1The only triplet is "aXA". Its first and last characters are equal when compared case-insensitively, so the answer is 1.
Example 2
text = ""return = 0An empty string has no triplet of consecutive characters, so the answer is 0.
Constraints
textcontains only uppercase and lowercase English letters.textmay be empty.
More Tiktok problems
- Count Access Code PairsOA · Seen Aug 2026
- Distribution Center Package AllocationOA · Seen Aug 2026
- Linear Warehouse Drone DeliveryOA · Seen Aug 2026
- Optimize TikTok Reels ViewingOA · Seen Aug 2026
- Can Reach the Exit with TeleportsOA · Seen Jul 2026
- Check Monotonic TriplesOA · Seen Jul 2026
- Shift Every K-th ConsonantOA · Seen Jul 2026
- Count Key ChangesOA · Seen Jul 2026