Palindrome Rearrangement Queries
international master · 2120 · lc hard +32 · failed · 24.8% accepted · 98 likes · top 4%
Description
You are given a 0-indexed string s of even length n.
You are also given a 0-indexed 2D integer array queries, where queries[i] = [ai, bi, ci, di].
For each query i:
- Rearrange characters within s[ai:bi], where 0 <= ai <= bi < n / 2.
- Rearrange characters within s[ci:di], where n / 2 <= ci <= di < n.
Determine whether s can be made a palindrome through these operations.
Each query is answered independently.
Return a 0-indexed boolean array answer where answer[i] is true if the ith query succeeds.
- A substring is a contiguous sequence of characters.
- s[x:y] denotes the substring from index x to y, both inclusive.
Example 1:
Example 2:
Example 3:
Code