8000 1 · Ainevsia/Leetcode-Rust@f956f86 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit f956f86

Browse files
committed
1
1 parent 23c2e39 commit f956f86

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

notes/src/day1/lc704.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,13 @@ impl Solution {
126126
}
127127
}
128128

129+
impl Solution {
130+
pub fn search(nums: Vec<i32>, target: i32) -> i32 {
131+
let idx: usize = nums.partition_point(|&x| x < target);
132+
if idx == nums.len() { return -1i32 }
133+
if nums[idx] != target { return -1i32 }
134+
idx as i32
135+
}
136+
}
137+
129138
```

0 commit comments

Comments
 (0)
0