You are given the head pointer of a singly linked list.
null
/ throw an error).
Constraints: Aim for time and extra space.
Given a string s (ASCII letters only), remove every contiguous length-3 substring s[i..i+2] that matches the pattern:
s[i] == s[i+2]
(exact same character), and
s[i]
and
s[i+1]
have
different letter cases
(one uppercase, one lowercase).
After removals, the remaining parts are concatenated.
Example
"AaADbDEeEbcvQv"
"bc"
Clarify whether removals are single pass or repeated until no more matches; design your solution accordingly.
Constraints: .
A worker works 7 days and is paid one gold bar total. The bar can be broken into pieces with at most two breaks.