Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
songyzh committed Feb 2, 2020
commit 23a0241186392082ef835ccc85779c7db5a5e3e6
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ mod n0199_binary_tree_right_side_view;
mod n0282_expression_add_operators;
mod n0021_merge_two_sorted_lists;
mod n0129_sum_root_to_leaf_numbers;
mod n0206_reverse_linked_list;
mod n0131_palindrome_partitioning;
mod n0307_range_sum_query_mutable;
mod n0111_minimum_depth_of_binary_tree;
mod n0092_reverse_linked_list_ii;
mod n0303_range_sum_query_immutable;
mod n0102_binary_tree_level_order_traversal;
mod n0206_reverse_linked_list;
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ fn parse_extra_use(code: &str) -> String {

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

Expand Down
49 changes: 0 additions & 49 deletions src/n0206_reverse_linked_list.rs

This file was deleted.

22 changes: 6 additions & 16 deletions src/problem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extern crate reqwest;
extern crate serde_json;

use std::fmt::{Display, Error, Formatter};
use serde_json::Value;

const PROBLEMS_URL: &str = "https://leetcode.com/api/problems/algorithms/";
const GRAPHQL_URL: &str = "https://leetcode.com/graphql";
Expand Down Expand Up @@ -43,7 +44,10 @@ pub fn get_problem(frontend_question_id: u32) -> Option<Problem> {
sample_test_case: resp.data.question.sample_test_case,
difficulty: problem.difficulty.to_string(),
question_id: problem.stat.frontend_question_id,
return_type: serde_json::from_str(&resp.data.question.meta_data.return_info.type_name).unwrap(),
return_type: {
let v: Value = serde_json::from_str(&resp.data.question.meta_data).unwrap();
v["return"]["type"].to_string().as_str().replace("\"", "").to_string()
},
});
}
}
Expand Down Expand Up @@ -113,21 +117,7 @@ struct Question {
#[serde(rename = "sampleTestCase")]
sample_test_case: String,
#[serde(rename = "metaData")]
meta_data: MetaData,
}

#[derive(Debug, Serialize, Deserialize)]
struct MetaData {
name:String,
params: String,
return_info: ReturnInfo,
}

#[derive(Debug, Serialize, Deserialize)]
struct ReturnInfo {
#[serde(rename = "type")]
type_name: String,
params: String,
meta_data: String,
}

#[derive(Debug, Serialize, Deserialize)]
Expand Down