Segment tree is an advance data struture which can solve several Leetcode questions.
Segment tree is basically a binary tree, ; it can be implemented by using binary tree, but most frequently its array representation way. This question needs the segment tree with max; and a method which searchs the 1st basket not less than target & then updates it.
Palindrome question is quite often asked. This question can be solved basically by using counting. It's important to know the 2-letter strings xy & yx can be paired.
The key observation: palindrome strings of even lengths have all letters even occurrences, palindrome strings of odd lengths have all letters even occurrences but except one letter with odd occurrence.