Skip to content

Commit 1737474

Browse files
committedFeb 27, 2019
Skip some boring problems
1 parent 07f74d0 commit 1737474

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed
 

‎src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,5 @@ mod n0135_candy;
136136
mod n0136_single_number;
137137
mod n0137_single_number_ii;
138138
mod n0139_word_break;
139+
mod n0140_word_break_ii;
140+
mod n0143_reorder_list;

‎src/n0140_word_break_ii.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/**
2+
* [140] Word Break II
3+
*
4+
* Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences.
5+
*
6+
* Note:
7+
*
8+
*
9+
* The same word in the dictionary may be reused multiple times in the segmentation.
10+
* You may assume the dictionary does not contain duplicate words.
11+
*
12+
*
13+
* Example 1:
14+
*
15+
*
16+
* Input:
17+
* s = "catsanddog"
18+
* wordDict = ["cat", "cats", "and", "sand", "dog"]
19+
* Output:
20+
* [
21+
* "cats and dog",
22+
* "cat sand dog"
23+
* ]
24+
*
25+
*
26+
* Example 2:
27+
*
28+
*
29+
* Input:
30+
* s = "pineapplepenapple"
31+
* wordDict = ["apple", "pen", "applepen", "pine", "pineapple"]
32+
* Output:
33+
* [
34+
* "pine apple pen apple",
35+
* "pineapple pen apple",
36+
* "pine applepen apple"
37+
* ]
38+
* Explanation: Note that you are allowed to reuse a dictionary word.
39+
*
40+
*
41+
* Example 3:
42+
*
43+
*
44+
* Input:
45+
* s = "catsandog"
46+
* wordDict = ["cats", "dog", "sand", "and", "cat"]
47+
* Output:
48+
* []
49+
*
50+
*/
51+
pub struct Solution {}
52+
53+
// submission codes start here
54+
55+
impl Solution {
56+
pub fn word_break(s: String, word_dict: Vec<String>) -> Vec<String> {
57+
vec![]
58+
}
59+
}
60+
61+
// submission codes end
62+
63+
#[cfg(test)]
64+
mod tests {
65+
use super::*;
66+
67+
#[test]
68+
fn test_140() {
69+
}
70+
}

‎src/n0143_reorder_list.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* [143] Reorder List
3+
*
4+
* Given a singly linked list L: L0&rarr;L1&rarr;&hellip;&rarr;Ln-1&rarr;Ln,<br />
5+
* reorder it to: L0&rarr;Ln&rarr;L1&rarr;Ln-1&rarr;L2&rarr;Ln-2&rarr;&hellip;
6+
*
7+
* You may not modify the values in the list's nodes, only nodes itself may be changed.
8+
*
9+
* Example 1:
10+
*
11+
*
12+
* Given 1->2->3->4, reorder it to 1->4->2->3.
13+
*
14+
* Example 2:
15+
*
16+
*
17+
* Given 1->2->3->4->5, reorder it to 1->5->2->4->3.
18+
*
19+
*
20+
*/
21+
pub struct Solution {}
22+
use super::util::linked_list::{ListNode, to_list};
23+
24+
// submission codes start here
25+
26+
/*
27+
1->2->3->4->5
28+
29+
1->2->3<-4<-5
30+
31+
1->5->2->4->3
32+
*/
33+
impl Solution {
34+
pub fn reorder_list(head: &mut Option<Box<ListNode>>) {
35+
// TODO
36+
}
37+
}
38+
39+
// submission codes end
40+
41+
#[cfg(test)]
42+
mod tests {
43+
use super::*;
44+
45+
#[test]
46+
fn test_143() {
47+
}
48+
}

0 commit comments

Comments
 (0)
Please sign in to comment.