I want to share a coding question which was recently asked by D.E.shaw company as part of recruitment in india.
I don’t remember the exact question but i will tell u the outline.
which was :
In the question there is a girl and she had to cross a series of land mines ,she cannot step on consecutive land mines but she can skip any number of land mines ,if she steps on a land mine then she loses a certain score.
For each land mine there is certain integer denoting the score she loses on stepping that landmine.if she steps on more than one land mines then she loses score which is the sum of those corresponding integers .
inputs are: n-number of land mines
array of n integers denotes scores which she loses on corresponding land mine
we need to output a single integer which is the minimum score she will lose
8 1 4 6 9
I am so confused on seeing the question then I did it by summing up of odd indexed and even indexed numbers and printed the minimum of them but using this approach I am able to pass only 4 testcases out of 13
please help me in solving this and also if there are any similar questions please let me know