In the Right Place explainer

Oh, that. I’ll see about that…

I do not know how to explain this without taking into consideration the next puzzle.

You are using minIndex to check if the letter in a particular word follow one another in stringSequence.

Take for example the word 'boo' and the string sequence, 'hullaballoo'.

You will check of b is found in hullaballoo. It is there. In 'hullaballoo' “b” is at index 5.

You call findNextIndex inside the minIndex variable. As minIndex is 0, 5 is greater than 0, so 5+1 is returned. Therefore, minIndex becomes 6.

You continue for o… o is at indices 9 and 10 in hullaballo. 9>= 6, yes, 10 is return.

The next o in "boo", 9 is not >= to 10(I think the code skip that and go for the next index instead of returning false, is that correct @Grasshopper_Ben?)

10 is equal to 10, 11 is returned and the code is finished. true is returned.

You will say that there is no need for adding 1 in that case. But make as if the string sequence was "hullaballo"… if the 9 didn’t change to 10, the code will think that "boo" is a subsequence of "hullaballo" because 9 is equal to 9.

1 Like

let me ask you one question @Grasshopper_Ben Pls tell me how to post our code in a code block pls!

Hello on my first try doing this puzzle i came up with the solution but i got something wrong.
this line pose a problem to me:
for (var index of indices) {

After being confused i looked up the results just to notice i just have to replace indices with array.
Why is array the right answer?

please tell what is wrong in it

Hi Warren,

Thanks for the question, so my explaining might be not clear.

minIndex is a variable where to search for a character in indices. Imagine that you are given a string 'boo' and the string sequence 'balloon', and let’s say that if this string is a subsequence. Or is it? Yes. Let’s see.

The letter 'b' in 'boo' is at index 0 so it’s found in 'balloon', then 0 is equal to 0, so 1 is returned. Next, the letter 'o' in 'boo' is at indices 4 and 5 so it’s also found in 'balloon'. Is 4 greater than 1? Yes. So 5 is returned. So we know that 'boo' is a subsequence of 'balloon'.

Hope this helps!
D :slight_smile:

What was missing… I see output too… doesn’t take me to next level

Hey there, DogeTheMemer28 from Grasshopper here.

In your function, your for loop is iterating through the array indices and not the function’s parameter array. Please see this post here. This might help you.

Hope this helps!

Hello here i am your helper in coding today i am going to paste a screenshot of my sample code hope this helps you who are stuck . I have putted two pictures because the code was big .

I hope this helps . yours Helper in coding

Your explanation is clear, what isn’t, to me, is how you have then opted to pick 4 as the minIndex is this case. Albeit I did solve the puzzle, clearly without understanding the role of minIndex, I ran into problems with the subsequent puzzle.

Hi @NoviceCoder. Doge here. Could you please post a screenshot of your code in Subsequence puzzle?

:slight_smile: :slight_smile: :slight_smile:

I too have same doubt but I sorry i didn’t understand
Can u pls explain it in simple manner

The function declaration uses “array” and “minIndex” as parameters, but the arguments of the function call uses “indices” and “minIndex”. I think for clarity it is better to use different names for the parameters. I tried to change the name of the parameter “minIndex”, but when I did it changed all instances of “minIndex” throughout the code including the import and the argument of the function call. Is there a reason why the parameter has to use the same name as the argument?

Which app do you think is best overall?

You’re missing some hints to explain te code!
I understood the code itself, but I getting trouble to read it!
Why the indices are 3 and 7?
Why the minIndex is 4?
Why don’t tou use a real map with another array in “indices”??

I feel like the app have a good material, with pretty poor explanation! Although all the exercises are pretty good and help a lot with the logic part of coding, I miss some concrete information. For begginers is easier to put all the information on the screen and avoid import values. I know it turns the code area cleaner to focus only on the exercise code, but it confuses the student, since we have to get out the exercise and open the previous one to remember what we have done! And using always random values/strings turns difficult to find a pattern within the code. Static values, for educational purposes, are infinitely better!!

Help me in this code

hey, please i need help on that coz am so slow to understand. firstly where does the array come from and what is minindex? also why shound the function return index+1? please explain that to me like im 5 years old.

Thanks for the explanation, how do you know with which index you should initialize minIndex?

In the puzzle it’s 4. What if we started with 100? Then it wouldn’t return the nextIndex.

Is there a reason why minIndex can’t be initialized with 0?

Thx Ben

Can you plzz use an example to explain me how this code runs step by step
I spent a day but I didn’t understand