Given a sorted array of integers `nums` and an integer `target`, write a function to search for the `target` in `nums`. If the target exists, then return its index. Otherwise, return -1.
{
"nums": [
-1,
0,
3,
5,
9,
12
],
"target": 9
}4{
"nums": [
-1,
0,
3,
5,
9,
12
],
"target": 2
}-1{
"nums": [
5
],
"target": 5
}0Sign in to Run Code and Submit