De Shaw OA Intern Problems

Правка en1, от Don_quixxote, 2025-07-16 08:21:06
Problem 1

Given a binary string find no. of subsequence of length 3 such that no two adjacent characters are same(101, 010). N <= 1e5

Problem 2

Given an array we want to make it non-decreasing by doing following operation one at a time :- - you can shift 1 from a[i] to a[i+1], after that a[i]->a[i]-1 and a[i+1]->a[i+1]+1 (if i+1<n) - you can shift 1 from a[i] to a[i-1], after that a[i]->a[i]-1 and a[i-1]->a[i-1]+1 (if i-1>=0) Calculate minimum moves required to make it non-decreasing. N <= 250. a[i] <= 1e9 Example: a[] = [5 3 2 3 3 3] -> [4 4 2 3 3 3] -> [4 3 3 3 3 3], output is 2

Problem 3

Given an array a[] find no. of array b, such that 1 <= b[i] <= a[i], and no two adjacent element of b are same(b[i] != b[i+1]). Print it modulo (1e9+7) since ans is large. N <= 1e5 a[i] <= 1e6 Example: a[] = [2 3] b[] = [1 2], [1 3], [2 1], [2 3], output is 4

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Don_quixxote 2025-07-16 09:16:45 4 Tiny change: 'ke it non-decreasing b' -> 'ke it non-increasing b'
en1 Английский Don_quixxote 2025-07-16 08:21:06 988 Initial revision (published)