What do you mean by start index? That is not an index. You mean starting value and ending value.
What will happen if there is no 3 or no 11 in your array? What will happen with this array?
[1, 2, 69, 4]
How are you going to find 3 and 11?
What about this array, which does have 3 and 11 in?
[12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
Case 1: if the start & end value (3,7) are not in array {2, 1,8,5,4} output array should be empty {} and the count will be zero
Case 2: if start & end value (3,7) in the given array {2,1,8,7,4,6,11,10,3,5} then the output array should be {3,5,2,1,8,7} and count will be 6 inclusive of start and end value
More things needed clarification.
What should be a result if there is only one match? Example, {1, 2, 3, 4} against start/end 2 and 5?
What is there is more than one match? Example, {1, 2, 5, 1, 3 ,1, 3, 4, 5, 4, 2, 1, 5} against 2 and 5?
What if start and end are the same? Example {1, 2, 3, 2, 1} against 2 and 2?
Topic is getting more interesting, I'm learning something new from you guys. Thank you
Case 1 will be no result found
Case 2 when there is multiple match we can have two result set one with the closest match and the second will be the last value match
Case 3 start and end value can be same
Here is my specification: "How to get the elements between 3 and 11? in the given array [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] ".
Please Ranch Hand's with proper solution or direct them in a right way; instead of giving a reply like this 'Start by writing down on paper which numbers are between start = 7 and end = 5.'
When you wrote down the numbers between start = 5 and end = 5, what did you get? Did you get any at all?
It is not my business to be clear about 3 to 11 in that array. It is your business. If you aren't clear about it, nobody can solve it. You have to tell us what you mean by 3 to 11 because otherwise nobody knows.
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
Gift giving made easy with the permaculture playing cards