Skip to content

Commit bad6f99

Browse files
committed
fix: compiler error
1 parent 69fb9b8 commit bad6f99

File tree

467 files changed

+15072
-21153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

467 files changed

+15072
-21153
lines changed

Cargo.lock

Lines changed: 940 additions & 896 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[package]
22
name = "leetcode-rust"
33
version = "0.1.0"
4-
authors = ["alei <rayingecho@gmail.com>"]
4+
authors = ["lidongjies <lidongjies@gmail.com>"]
55
edition = "2018"
66

77
[dependencies]
8-
reqwest = "0.9.8"
8+
reqwest = { version = "0.11.11", features = ["json", "blocking"] }
99
serde = "1.0"
1010
serde_json = "1.0"
1111
serde_derive = "1.0"
12-
rand = "0.6.5"
12+
rand = "0.8.5"
1313
regex = "1.3.4"
14-
futures = { version = "0.3.3", features = ["thread-pool"] }
15-
surf = "1.0.3"
14+
futures = { version = "0.3.21", features = ["thread-pool"] }
15+
surf = "2.3.2"
1616

1717
[lib]
1818
doctest = false

src/fetcher.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn get_problem(frontend_question_id: u32) -> Option<Problem> {
2626
return None;
2727
}
2828

29-
let client = reqwest::Client::new();
29+
let client = reqwest::blocking::Client::new();
3030
let resp: RawProblem = client
3131
.post(GRAPHQL_URL)
3232
.json(&Query::question_query(
@@ -97,7 +97,10 @@ pub async fn get_problem_async(problem_stat: StatWithStatus) -> Option<Problem>
9797
}
9898

9999
pub fn get_problems() -> Option<Problems> {
100-
reqwest::get(PROBLEMS_URL).unwrap().json().unwrap()
100+
reqwest::blocking::get(PROBLEMS_URL)
101+
.unwrap()
102+
.json()
103+
.unwrap()
101104
}
102105

103106
#[derive(Serialize, Deserialize)]

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn generate_random_id(except_ids: &[u32]) -> u32 {
152152
use std::fs;
153153
let mut rng = rand::thread_rng();
154154
loop {
155-
let res: u32 = rng.gen_range(1, 1106);
155+
let res: u32 = rng.gen_range(1..1106);
156156
if !except_ids.contains(&res) {
157157
return res;
158158
}

src/problem/p0100_same_tree.rs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* [100] Same Tree
3+
*
4+
* Given the roots of two binary trees p and q, write a function to check if they are the same or not.
5+
* Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.
6+
*
7+
* Example 1:
8+
* <img alt="" src="https://assets.leetcode.com/uploads/2020/12/20/ex1.jpg" style="width: 622px; height: 182px;" />
9+
* Input: p = [1,2,3], q = [1,2,3]
10+
* Output: true
11+
*
12+
* Example 2:
13+
* <img alt="" src="https://assets.leetcode.com/uploads/2020/12/20/ex2.jpg" style="width: 382px; height: 182px;" />
14+
* Input: p = [1,2], q = [1,null,2]
15+
* Output: false
16+
*
17+
* Example 3:
18+
* <img alt="" src="https://assets.leetcode.com/uploads/2020/12/20/ex3.jpg" style="width: 622px; height: 182px;" />
19+
* Input: p = [1,2,1], q = [1,1,2]
20+
* Output: false
21+
*
22+
*
23+
* Constraints:
24+
*
25+
* The number of nodes in both trees is in the range [0, 100].
26+
* -10^4 <= Node.val <= 10^4
27+
*
28+
*/
29+
pub struct Solution {}
30+
use crate::util::tree::{TreeNode, to_tree};
31+
32+
// problem: https://leetcode.com/problems/same-tree/
33+
// discuss: https://leetcode.com/problems/same-tree/discuss/?currentPage=1&orderBy=most_votes&query=
34+
35+
// submission codes start here
36+
37+
// Definition for a binary tree node.
38+
// #[derive(Debug, PartialEq, Eq)]
39+
// pub struct TreeNode {
40+
// pub val: i32,
41+
// pub left: Option<Rc<RefCell<TreeNode>>>,
42+
// pub right: Option<Rc<RefCell<TreeNode>>>,
43+
// }
44+
//
45+
// impl TreeNode {
46+
// #[inline]
47+
// pub fn new(val: i32) -> Self {
48+
// TreeNode {
49+
// val,
50+
// left: None,
51+
// right: None
52+
// }
53+
// }
54+
// }
55+
use std::rc::Rc;
56+
use std::cell::RefCell;
57+
impl Solution {
58+
pub fn is_same_tree(p: Option<Rc<RefCell<TreeNode>>>, q: Option<Rc<RefCell<TreeNode>>>) -> bool {
59+
false
60+
}
61+
}
62+
63+
// submission codes end
64+
65+
#[cfg(test)]
66+
mod tests {
67+
use super::*;
68+
69+
#[test]
70+
fn test_100() {
71+
}
72+
}

src/problem/p0101_symmetric_tree.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* [101] Symmetric Tree
3+
*
4+
* Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
5+
*
6+
* Example 1:
7+
* <img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/symtree1.jpg" style="width: 354px; height: 291px;" />
8+
* Input: root = [1,2,2,3,4,4,3]
9+
* Output: true
10+
*
11+
* Example 2:
12+
* <img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/symtree2.jpg" style="width: 308px; height: 258px;" />
13+
* Input: root = [1,2,2,null,3,null,3]
14+
* Output: false
15+
*
16+
*
17+
* Constraints:
18+
*
19+
* The number of nodes in the tree is in the range [1, 1000].
20+
* -100 <= Node.val <= 100
21+
*
22+
*
23+
* Follow up: Could you solve it both recursively and iteratively?
24+
*/
25+
pub struct Solution {}
26+
use crate::util::tree::{TreeNode, to_tree};
27+
28+
// problem: https://leetcode.com/problems/symmetric-tree/
29+
// discuss: https://leetcode.com/problems/symmetric-tree/discuss/?currentPage=1&orderBy=most_votes&query=
30+
31+
// submission codes start here
32+
33+
// Definition for a binary tree node.
34+
// #[derive(Debug, PartialEq, Eq)]
35+
// pub struct TreeNode {
36+
// pub val: i32,
37+
// pub left: Option<Rc<RefCell<TreeNode>>>,
38+
// pub right: Option<Rc<RefCell<TreeNode>>>,
39+
// }
40+
//
41+
// impl TreeNode {
42+
// #[inline]
43+
// pub fn new(val: i32) -> Self {
44+
// TreeNode {
45+
// val,
46+
// left: None,
47+
// right: None
48+
// }
49+
// }
50+
// }
51+
use std::rc::Rc;
52+
use std::cell::RefCell;
53+
impl Solution {
54+
pub fn is_symmetric(root: Option<Rc<RefCell<TreeNode>>>) -> bool {
55+
false
56+
}
57+
}
58+
59+
// submission codes end
60+
61+
#[cfg(test)]
62+
mod tests {
63+
use super::*;
64+
65+
#[test]
66+
fn test_101() {
67+
}
68+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* [102] Binary Tree Level Order Traversal
3+
*
4+
* Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).
5+
*
6+
* Example 1:
7+
* <img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg" style="width: 277px; height: 302px;" />
8+
* Input: root = [3,9,20,null,null,15,7]
9+
* Output: [[3],[9,20],[15,7]]
10+
*
11+
* Example 2:
12+
*
13+
* Input: root = [1]
14+
* Output: [[1]]
15+
*
16+
* Example 3:
17+
*
18+
* Input: root = []
19+
* Output: []
20+
*
21+
*
22+
* Constraints:
23+
*
24+
* The number of nodes in the tree is in the range [0, 2000].
25+
* -1000 <= Node.val <= 1000
26+
*
27+
*/
28+
pub struct Solution {}
29+
use crate::util::tree::{TreeNode, to_tree};
30+
31+
// problem: https://leetcode.com/problems/binary-tree-level-order-traversal/
32+
// discuss: https://leetcode.com/problems/binary-tree-level-order-traversal/discuss/?currentPage=1&orderBy=most_votes&query=
33+
34+
// submission codes start here
35+
36+
// Definition for a binary tree node.
37+
// #[derive(Debug, PartialEq, Eq)]
38+
// pub struct TreeNode {
39+
// pub val: i32,
40+
// pub left: Option<Rc<RefCell<TreeNode>>>,
41+
// pub right: Option<Rc<RefCell<TreeNode>>>,
42+
// }
43+
//
44+
// impl TreeNode {
45+
// #[inline]
46+
// pub fn new(val: i32) -> Self {
47+
// TreeNode {
48+
// val,
49+
// left: None,
50+
// right: None
51+
// }
52+
// }
53+
// }
54+
use std::rc::Rc;
55+
use std::cell::RefCell;
56+
impl Solution {
57+
pub fn level_order(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<Vec<i32>> {
58+
vec![]
59+
}
60+
}
61+
62+
// submission codes end
63+
64+
#[cfg(test)]
65+
mod tests {
66+
use super::*;
67+
68+
#[test]
69+
fn test_102() {
70+
}
71+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* [103] Binary Tree Zigzag Level Order Traversal
3+
*
4+
* Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between).
5+
*
6+
* Example 1:
7+
* <img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/tree1.jpg" style="width: 277px; height: 302px;" />
8+
* Input: root = [3,9,20,null,null,15,7]
9+
* Output: [[3],[20,9],[15,7]]
10+
*
11+
* Example 2:
12+
*
13+
* Input: root = [1]
14+
* Output: [[1]]
15+
*
16+
* Example 3:
17+
*
18+
* Input: root = []
19+
* Output: []
20+
*
21+
*
22+
* Constraints:
23+
*
24+
* The number of nodes in the tree is in the range [0, 2000].
25+
* -100 <= Node.val <= 100
26+
*
27+
*/
28+
pub struct Solution {}
29+
use crate::util::tree::{TreeNode, to_tree};
30+
31+
// problem: https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
32+
// discuss: https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/discuss/?currentPage=1&orderBy=most_votes&query=
33+
34+
// submission codes start here
35+
36+
// Definition for a binary tree node.
37+
// #[derive(Debug, PartialEq, Eq)]
38+
// pub struct TreeNode {
39+
// pub val: i32,
40+
// pub left: Option<Rc<RefCell<TreeNode>>>,
41+
// pub right: Option<Rc<RefCell<TreeNode>>>,
42+
// }
43+
//
44+
// impl TreeNode {
45+
// #[inline]
46+
// pub fn new(val: i32) -> Self {
47+
// TreeNode {
48+
// val,
49+
// left: None,
50+
// right: None
51+
// }
52+
// }
53+
// }
54+
use std::rc::Rc;
55+
use std::cell::RefCell;
56+
impl Solution {
57+
pub fn zigzag_level_order(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<Vec<i32>> {
58+
vec![]
59+
}
60+
}
61+
62+
// submission codes end
63+
64+
#[cfg(test)]
65+
mod tests {
66+
use super::*;
67+
68+
#[test]
69+
fn test_103() {
70+
}
71+
}

0 commit comments

Comments
 (0)