 Welcome back to channel. So today we are the coding interview questions that I have recently encountered in Hackerrank exam So this was about the question. So this was asked as part of mind tree hackerrank questions So basically here we need to iterate the array in a circular fashion and find out What is the shortest way to reach our target? So so I have already Created the array. So this was the question So I'm taking the second example So the one is it will start from first position and the target So the output should be how it travels in a backward So at the first position it found a and it started traversing the back So it found in the second position if it would have traversed in the forward a way One two three three steps. So three let's say greater than two. So two is the output here So how I like exactly what solution I gave that day. I am going to discuss about that thing So I have already so this was the Method that was given by Hackerrank itself. So I need to provide the solution. So firstly I want the length So we have length word com so This will capture like what how many Steps it takes when we are traversing in the forward direction and similarly that Back word com this would our whole how many steps you have traveled in the back So basically I have given the solution using while loop and after What is that So they can debate on the solution but I am Giving the solution which I have given in that Exam and I was qualified This was the solution exact solution what I gave that day I Target string is at the given point star position itself then I I don't need to traverse anywhere. So that is Zero would be the solution. And if it here doesn't find then I'll go While so basically I have used increase the count and made phone so this will bring the phone but to iterate in a circular fashion I need to implement this also position and need to have one check the position has to reach 0 so basically why this check is if at all I am reaching the end of the string suppose I have started from here so in this case 0 1 2 so if at all I am starting from here so 1 2 3 and the target would have been a so as I have reached the end of the array so I will again start from 0 for that thing I have traversed in this way so similarly for reverse traversing I have used one more while loop so let me see how I have used that one so it was similarly first I will make form equal to form then I will change the polarization as well again while so mostly I can copy paste this so here I was traversing in the forward direction now I will traverse in the reverse direction that means here it would be minus minus and if it is here less than 0 then go to the last and backward now returning how I have written that day the solution given that day and I was even qualified by exam and apart from this there were 25 different multiple choice questions so let us print so here so I have given 2 so 1 0 1 2 fff is the target so 1 2 3 I am traversing the forward direction I need 3 steps to reach that target if it all I am traversing the backward direction 1 2 3 then also I need 3 so basically the output should be 3 only both are the border directions I am getting the same so let us wait what happened what I have learned is the exception let us out of one here array position that was yeah length should be minus 1 okay let me try now yeah 3 so let me change the input so let me give the same input a so what will happen 0 1 so if I traverse in the first forward direction 1 2 3 3rd if I traverse in the reverse 1 2 so the answer should be 2 yeah so if you can see we got the desired output so this was the solution that was given by me on that day and I was qualified for the next round the solution can be debatable here while to use two file while lobes we can do the same in the one while I agree but on that day in that situation I got this idea and it was success so that's it for this video and if you haven't subscribed please do subscribe and share this video so that it might be helpful to someone who is looking for similar kind of videos and thanks for watching