Company: Devrev_13nov

Difficulty: medium

Problem Statement

Problem Description Picture a tube packed with beads of different colors, each color written as a distinct letter of the alphabet. In one move you may pop out a run of consecutive beads that all share one color. Keep repeating this until the tube is empty. Each move must target a contiguous run of same-colored beads (a run of x beads, x >= 1), and popping that run earns you x*x points. You're given an integer N, the total number of beads in the tube, along with an array colors holding the N bead colors, each written as a letter of the English alphabet. Work out the highest total score achievable. Function Description Complete the solve() function. This function takes the following 2 arguments and returns the answer. Parameters N: Represents the total beads in the tube. colors[]: Represents the array of colors of beads in the tube. Each color is represented by an English alphabet. Input Format Note: Use this input format if you are testing against custom input or writing code in a la

More Devrev_13nov OA questionsInterview experiences