Given an array where each element is at most `k` positions away from its sorted position (often k=1), find the index of a given target element. If the element is not present, return -1.
{
"nums": [
10,
3,
40,
20,
50,
80,
70
],
"target": 40
}2{
"nums": [
10,
3,
40,
20,
50,
80,
70
],
"target": 90
}-1{
"nums": [
5,
10,
30,
20,
40
],
"target": 20
}3Sign in to Run Code and Submit