Number of partitions of the array

Правка en1, от loverBoUy, 2022-09-21 14:06:53

Given an array. find the number of subsegments in which you can divide an array such that in the sum array of every subsegment, no two adjacent elements have the same parity;

see the test case for better understanding;

given array= [1 2 2 1] subsegment = [[1],[2,2],[1]] = [[1],[4],[1]] valid 1,2,2,1 = [6] valid [[1],[2,2,1]]= [5] not valid hence answer is 2.

please share your approach.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский loverBoUy 2022-09-21 14:11:54 6 Tiny change: '2,2,1]]= [5] not vali' -> '2,2,1]]= [[1],[5]] not vali'
en3 Английский loverBoUy 2022-09-21 14:10:36 60
en2 Английский loverBoUy 2022-09-21 14:08:40 3
en1 Английский loverBoUy 2022-09-21 14:06:53 480 Initial revision (published)