Education + Jobs Hiring Website - 2026
0 like 0 dislike
151 views
in Online Assessments by (150 points) | 151 views

1 Answer

0 like 0 dislike
Best answer

Media.net | SDE Intern | DSA Round | Rejected

Round: Online Interview (DSA)
Duration: 60 min


Question

Given an integer array a, in one operation you can pick 3 consecutive elements that form an Arithmetic Progression and remove them. After removal, the left and right parts join, so new elements can become adjacent.

Perform any number of operations. Return the minimum possible length of the array.

Example

Input: a = [1, 5, 6, 7, 4, 7]
Output: 0

Explanation:
[1, 5, 6, 7, 4, 7] → remove (5, 6, 7) → [1, 4, 7]
[1, 4, 7] → remove (1, 4, 7) → []


How it went

  • Started with brute force: take / not-take recursion + memoization.
  • The interviewer pushed for optimization. The catch is that removals can nest: elements far apart become adjacent after inner removals, so a simple index-based DP doesn't capture it.
  • The intended solution was Interval DP, but I couldn't come up with it on the spot.

Verdict: Rejected

Saw a comment once saying "if they ask you this, they don't want to hire you" and now I get it

ago by Expert (147,790 points)

Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .