Sponsored
Use these hints if you're stuck. Try solving on your own first.
Try to think of the most basic dp which is n^2 now optimize it
Think of any range query data structure to optimize
Solve with full IDE support and test cases