Question: A second example, a call like this searchInLastN ( nums , 2 , 7 ) would check positions [ 8 ] and [ 9 ]

A second example, a call like this searchInLastN (nums,2,7) would check positions [8] and [9] and return -1(not found) as the value 7 is not in the last 2 positions.
1 searchInLastw(nums,2,7)-1
This should work for arrays of any size. You can assume that the array size is larger than the value in lastN.
Examples:
searchInLastN ({9,18,3,17,12,10,7,5,3,15},3,5)7
searchInLastN ({9,18,3,17,12,10,7,5,3,15},2,7)-1
searchInLastN ({9,18,3,17,12,10,7,5,3,15},10,9)0
searchInLastN ({9,18,3,17,12,10,7,5,3,15},10,3)2
 A second example, a call like this searchInLastN (nums,2,7) would check

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!