An Interesting Problem

Revision en3, by AjaySabarish, 2020-07-19 16:09:04

Given an Array, find the maximum difference between the sum of elements in odd indices and even indices. To achieve this you can delete any number of elements from the array,after deleting the elements,the array will be re-numbered.

Example : 1 4 8 2 6

Upon deleting 1,4.

New array 8 2 6

Answer is 8+6-2 = 12.

Constraints : 1<=N<=1e5

Can anyone please help me solve this problem?

Tags #greedy, #dynamic programming

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English AjaySabarish 2020-07-19 16:09:59 0 (published)
en3 English AjaySabarish 2020-07-19 16:09:04 2 Tiny change: 'eleting 1,2.\n\nNew a' -> 'eleting 1,4.\n\nNew a' (saved to drafts)
en2 English AjaySabarish 2020-07-19 16:03:52 2 Tiny change: 'ay 8 2 6\nAnswer i' -> 'ay 8 2 6\n\nAnswer i'
en1 English AjaySabarish 2020-07-19 16:03:26 419 Initial revision (published)