You are given an array of n unsigned 8-bit integers (uint8_t) and a key. Your task is to:
Do not use standard library functions. Use only loop and index logic.
Example-1
Input: n = 5, arr = [10 20 30 40 50], key = 30
Output: 2
Example-2
Input: n = 4, arr = [5 8 12 9], key = 7
Output: -1
Example-3
Input: n = 6, arr = [1 1 2 3 1 4], key = 1
Output: 0
Input
5 10 20 30 40 50 30
Expected Output
2