The Online coding test has 3 questions :
Ques 1: A binary string is given and an integer x. We have to count number of substrings having atleast x 1's. (50 marks)
Sample : 1010
output : 2
Sample: 111011
output : 3constraints : 1<=len(string)<=10^5
My approach was to use 2 pointers but it gives tle to last two cases.
Ques 2 : An array of n integers is given . Every time we are deleting 4 numbers (x,y,z,w) from it such that x>=y>=z>=w. Our task is to calculate max weight which is obtained by adding 2nd minimum element in each step. n is a multiple of 4.
output the ans modulo 10^9+7 (75 marks)
Sample : [1,3,1,5,4,3,1,4]
output : 5constraints : 1<=n<=10^5, 1<=a[i]<=10^9
My approach : It is a simple one. just sort them and put one from start and other 3 from last.
Ques 3 : same as
https://leetcode.com/problems/odd-even-jump/ (100 marks)