next is called with n, iterate over the encoding array starting from the current index.n, subtract the count from n and move to the next element (increment the index by 2).n, subtract n from the count and return the value at the current index + 1.n elements, return -1.