adaptatron's blog

By adaptatron, 9 hours ago, In English

Given an array, you can select any subarray of length 3, say $$$[a, b, c]$$$. Then, if $$$a + c \gt b$$$, you can delete this triplet, and replace it with $$$(a + c - b)$$$.

Can you achieve an array of length 1 by doing these operations optimally? Then, solve a harder version: How many subarrays can be trimmed to length 1 after doing these operations?

I created a video talking about the ideas and intuition used in this problem

  • Vote: I like it
  • +8
  • Vote: I do not like it