File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 2
2
leetcode by rust
3
3
4
4
### 题目
5
+
6
+ - [ 746. 使用最小花费爬楼梯]
7
+ - [src](https://github.com/rustors/leetcode/blob/main/src/bin/check-if-n-and-its-double-exist.rs)
8
+ - [leetcode](https://leetcode-cn.com/problems/check-if-n-and-its-double-exist/)
9
+
5
10
- 1008:前序遍历构造二叉搜索树
6
- - [ src] ( https://github.com/rustors/leetcode/blob/main/src/bin/construct-binary-search-tree-from-preorder-traversal.rs )
7
- - [ leetcode] ( https://leetcode-cn.com/problems/construct-binary-search-tree-from-preorder-traversal/ )
11
+ - [ src] ( https://github.com/rustors/leetcode/blob/main/src/bin/construct-binary-search-tree-from-preorder-traversal.rs )
12
+ - [leetcode](https://leetcode-cn.com/problems/construct-binary-search-tree-from-preorder-traversal/)
8
13
Original file line number Diff line number Diff line change
1
+ fn main ( ) { }
2
+
3
+ struct Solution ;
4
+
5
+ impl Solution {
6
+ pub fn check_if_exist ( arr : Vec < i32 > ) -> bool {
7
+ let mut map = std:: collections:: HashMap :: < i32 , usize > :: new ( ) ;
8
+
9
+ for ( index, value) in arr. iter ( ) . enumerate ( ) {
10
+ map. insert ( * value, index) ;
11
+ }
12
+
13
+ for ( index, value) in arr. iter ( ) . map ( |x| x * 2 ) . enumerate ( ) {
14
+ if let Some ( i) = map. get ( & value) {
15
+ if * i != index {
16
+ return true ;
17
+ }
18
+ }
19
+ }
20
+
21
+ false
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments