This is a verified interview question from De-shaw. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Delete Longest Subarray - De Shaw OA NIT Bhopal" covers key patterns like Arrays.
"You are given an array of integers. In a single operation, you can choose the longest contiguous subarray consisting of identical elements and delete it. If there are multiple subarrays of the same maximum length, you must delete the leftmost one. After a subarray is deleted, the remaining elements on the left and right side (if any) are concatenated together. This means previously separated elements might become adjacent and form a new, longer contiguous subarray of identical elements. Return the total number of operations required to completely empty the array. ### Input Format - The first line contains an integer n, representing the size of the array. - The second line contains n space-separated integers representing the array elements. ### Output Format Print a single integer representing the total number of deletion operations required to empty the array."
Join thousands of developers practicing for De-shaw.