Minimum Removals for a Nice Array
Updated
Problem statement
An array is nice when removing exactly one of its elements leaves a strictly increasing array.
Given an array of positive integers nums, delete the minimum number of elements, without reordering the remaining elements, so that the remaining array is nice. Return that minimum number.
The remaining nice array must contain at least two elements.
Function
minimumRemovalsForNice(nums: int[]) → intExamples
Example 1
nums = [4,1,2,3]return = 0The whole array is already nice because deleting 4 leaves 1, 2, 3.
Example 2
nums = [5,4,3,2,1]return = 3The values only go down, so no two of them are in strictly increasing order. In other words, the longest strictly increasing subsequence has length 1. A nice array must be strictly increasing after one removal. Here that leaves room for only one element, so a nice array can keep at most two. You keep two of the five values and delete the other three.
Constraints
2 <= nums.length <= 2000001 <= nums[i] <= 10^9- Deleting an element preserves the relative order of all remaining elements.
More Adobe interview questions
- Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Lowest Common Ancestor Only When Both Targets ExistONSITE INTERVIEW · Seen Aug 2026
- Lowest Common Ancestor with Parent PointersONSITE INTERVIEW · Seen Aug 2026
- Next and Previous Lexicographic PermutationONSITE INTERVIEW · Seen Aug 2026
- Asteroid CollisionONSITE INTERVIEW · Seen Aug 2026
- Farthest Affordable Shop per QueryONSITE INTERVIEW · Seen Aug 2026
- Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Trie: Add and Search WordsONSITE INTERVIEW · Seen Jul 2026
- Base Unit ConversionsOA · Seen Nov 2026
- Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
Similar questions at other companies
- Longest Increasing SubsequenceAmazon · ONSITE INTERVIEW
- Longest Increasing SubsequenceMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Longest Increasing SubsequenceExpedia · ONSITE INTERVIEWExpedia interview questions
- Minimum Cost for TicketsRoku · ONSITE INTERVIEWRoku interview questions
- Longest Increasing SubsequencePeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
- Maximum Total Length of Non-Overlapping IntervalsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
- Russian Doll EnvelopesGoogle · ONSITE INTERVIEWGoogle interview questions
- Russian Doll EnvelopesInMobi · ONSITE INTERVIEWInMobi interview questions
- Russian Doll EnvelopesAirbnb · ONSITE INTERVIEWAirbnb interview questions
- Longest Increasing SubsequenceByteDance · PHONE SCREENByteDance interview questions
Interview reports that mention this question
Adobe interview experiences
- Adobe New Grad OA: Unit Conversion and Code Review: 1 Experience
- Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
- Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
- Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
- Adobe New Grad MTS Interview Questions: 7 Experiences