Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 23a0241

Browse files
committed
fix
1 parent 70467d4 commit 23a0241

File tree

4 files changed

+11
-70
lines changed

4 files changed

+11
-70
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ mod n0199_binary_tree_right_side_view;
231231
mod n0282_expression_add_operators;
232232
mod n0021_merge_two_sorted_lists;
233233
mod n0129_sum_root_to_leaf_numbers;
234-
mod n0206_reverse_linked_list;
235234
mod n0131_palindrome_partitioning;
236235
mod n0307_range_sum_query_mutable;
237236
mod n0111_minimum_depth_of_binary_tree;
238237
mod n0092_reverse_linked_list_ii;
239238
mod n0303_range_sum_query_immutable;
240239
mod n0102_binary_tree_level_order_traversal;
240+
mod n0206_reverse_linked_list;

src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ fn parse_extra_use(code: &str) -> String {
150150

151151
fn insert_return_in_code(return_type: &str, code: &str) -> String {
152152
match return_type {
153-
"ListNode" => {
154-
let re = Regex::new(r"\{\n +\n +}").unwrap();
155-
re.replace(code, format!("{{\n{:8}Some(Box::new(ListNode::new(0)))\n{:4}}}")).to_string()
153+
"ListNode" => {
154+
let re = Regex::new(r"\{[ \n]+}").unwrap();
155+
re.replace(&code, "{\n Some(Box::new(ListNode::new(0)))\n }").to_string()
156156
},
157-
_ => code
157+
_ => code.to_string()
158158
}
159159
}
160160

src/n0206_reverse_linked_list.rs

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/problem.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ extern crate reqwest;
22
extern crate serde_json;
33

44
use std::fmt::{Display, Error, Formatter};
5+
use serde_json::Value;
56

67
const PROBLEMS_URL: &str = "https://leetcode.com/api/problems/algorithms/";
78
const GRAPHQL_URL: &str = "https://leetcode.com/graphql";
@@ -43,7 +44,10 @@ pub fn get_problem(frontend_question_id: u32) -> Option<Problem> {
4344
sample_test_case: resp.data.question.sample_test_case,
4445
difficulty: problem.difficulty.to_string(),
4546
question_id: problem.stat.frontend_question_id,
46-
return_type: serde_json::from_str(&resp.data.question.meta_data.return_info.type_name).unwrap(),
47+
return_type: {
48+
let v: Value = serde_json::from_str(&resp.data.question.meta_data).unwrap();
49+
v["return"]["type"].to_string().as_str().replace("\"", "").to_string()
50+
},
4751
});
4852
}
4953
}
@@ -113,21 +117,7 @@ struct Question {
113117
#[serde(rename = "sampleTestCase")]
114118
sample_test_case: String,
115119
#[serde(rename = "metaData")]
116-
meta_data: MetaData,
117-
}
118-
119-
#[derive(Debug, Serialize, Deserialize)]
120-
struct MetaData {
121-
name:String,
122-
params: String,
123-
return_info: ReturnInfo,
124-
}
125-
126-
#[derive(Debug, Serialize, Deserialize)]
127-
struct ReturnInfo {
128-
#[serde(rename = "type")]
129-
type_name: String,
130-
params: String,
120+
meta_data: String,
131121
}
132122

133123
#[derive(Debug, Serialize, Deserialize)]

0 commit comments

Comments
 (0)