Marks :100
: 15 | : 2
You are given a box of crayons with different colours represented by different alphabets. In one operation, you can remove several continuous crayons of the same colour. You may perform this operation several times until the box is empty. Each time you can choose the crayon set. They must be continuous and of the same colours (i.e., set of x crayons, x>=1). After removing them, you will get x*x points.
You are given an integer N where N denotes the total number of crayons in the box. You are also given an array of colours denoting the N colours in the box, where each colour is represented by an English alphabet. ($$$1 \le N \le 60$$$)
Return the maximum points, you can get in the given scenario.
9 abcccbaba
23
Example 1 : colors array == [ a ,b , c , c , c , b , a ,b ,a]
Remove c ( + 9 ) -> [ a , b , b , a , b , a]
Remove a ( + 1 ) -> [ a , b ,b ,b , a ]
Remove b ( + 9 ) -> [ a , a ]
Remove a ( + 4 ) -> []
Ans -> 23
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.