Sponsored
Use these hints if you're stuck. Try solving on your own first.
Note that the distinct part means that every position in the array belongs to only one piece
Note that you can get the piece every position belongs to naively
Solve with full IDE support and test cases