<jupyter_start><jupyter_text>Last Index Of Number QuestionGiven an array of length N and an integer x, you need to find and return the last index of integer x present in the array. Return -1 if it is not present in the array.Last index means - if x is present multiple times in the array, return the index at which x comes last in the array.You should start traversing your array from 0, not from (N - 1).Do this recursively. Indexing in the array starts from 0.Sample Input :    9 8 10 8    8Sample Output :    3<jupyter_code># With Brute Force

arr = [9,8,10,8,3,5,3,3,2,1]
elem = 7
lastIndex = len(arr)

for i in range(0,len(arr)):
    #print((arr[i]))
    if arr[i] == elem:
        lastIndex = i
if lastIndex == len(arr):
    print(-1)
else:
    print(lastIndex)
## With Recursion

def lastIndex(arr,si,x):
    l = len(arr)
    ## Base Case
    if si == l:
        return -1
    ## Use recursion and check the smaller list start from si+1
    smallerListOutput = lastIndex(arr,si+1,x)
    
    if smallerListOutput != -1:
        return smallerListOutput
    else:
        # if we dont get any value from previous call then check if current call == elem
        if arr[si] == x:
            return si
        else:
            return -1
        

print(lastIndex(arr,0,3))<jupyter_output>7
{'fraction_non_alphanumeric': 0.09041731066460587, 'fraction_numerical': 0.025502318392581144, 'mean_word_length': 2.7427745664739884, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '633563', 'license': 'Unlicense', 'n_tokens_mistral': 420, 'n_tokens_neox': 409, 'n_words': 170, 'path': 'Algo and DSA/CodingNijas/1. Recursion/1. Last Index Of Number Question.ipynb', 'repo_name': 'Sourav692/FAANG-Interview-Preparation', 'size': '1294'}