An Interesting Problem

Правка en3, от 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?

Теги #greedy, #dynamic programming

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский AjaySabarish 2020-07-19 16:09:59 0 (published)
en3 Английский 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 Английский AjaySabarish 2020-07-19 16:03:52 2 Tiny change: 'ay 8 2 6\nAnswer i' -> 'ay 8 2 6\n\nAnswer i'
en1 Английский AjaySabarish 2020-07-19 16:03:26 419 Initial revision (published)