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

add problem and discuss link to existing solutions #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
416 changes: 208 additions & 208 deletions src/solution/mod.rs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/solution/s0001_two_sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/two-sum/
// discuss: https://leetcode.com/problems/two-sum/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

use std::collections::HashMap;
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0002_add_two_numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
pub struct Solution {}
use crate::util::linked_list::{to_list, ListNode};

// problem: https://leetcode.com/problems/add-two-numbers/
// discuss: https://leetcode.com/problems/add-two-numbers/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/longest-substring-without-repeating-characters/
// discuss: https://leetcode.com/problems/longest-substring-without-repeating-characters/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0004_median_of_two_sorted_arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/median-of-two-sorted-arrays/
// discuss: https://leetcode.com/problems/median-of-two-sorted-arrays/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// TODO: nth slice
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0005_longest_palindromic_substring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/longest-palindromic-substring/
// discuss: https://leetcode.com/problems/longest-palindromic-substring/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0006_zigzag_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/zigzag-conversion/
// discuss: https://leetcode.com/problems/zigzag-conversion/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0007_reverse_integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/reverse-integer/
// discuss: https://leetcode.com/problems/reverse-integer/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here
impl Solution {
pub fn reverse(x: i32) -> i32 {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0008_string_to_integer_atoi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/string-to-integer-atoi/
// discuss: https://leetcode.com/problems/string-to-integer-atoi/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0009_palindrome_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/palindrome-number/
// discuss: https://leetcode.com/problems/palindrome-number/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// TODO: not optimal, we only have to revert half of the string
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0010_regular_expression_matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/regular-expression-matching/
// discuss: https://leetcode.com/problems/regular-expression-matching/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// TODO: NFA
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0011_container_with_most_water.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/container-with-most-water/
// discuss: https://leetcode.com/problems/container-with-most-water/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// Brute force: O(N^2)
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0012_integer_to_roman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/integer-to-roman/
// discuss: https://leetcode.com/problems/integer-to-roman/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0013_roman_to_integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/roman-to-integer/
// discuss: https://leetcode.com/problems/roman-to-integer/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0014_longest_common_prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/longest-common-prefix/
// discuss: https://leetcode.com/problems/longest-common-prefix/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

use std::str::Chars;
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0015_3sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/3sum/
// discuss: https://leetcode.com/problems/3sum/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0016_3sum_closest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/3sum-closest/
// discuss: https://leetcode.com/problems/3sum-closest/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0017_letter_combinations_of_a_phone_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/letter-combinations-of-a-phone-number/
// discuss: https://leetcode.com/problems/letter-combinations-of-a-phone-number/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0018_4sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/4sum/
// discuss: https://leetcode.com/problems/4sum/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// TODO: change to faster N^3 solution... maybe
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0019_remove_nth_node_from_end_of_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
pub struct Solution {}
use crate::util::linked_list::{to_list, ListNode};

// problem: https://leetcode.com/problems/remove-nth-node-from-end-of-list/
// discuss: https://leetcode.com/problems/remove-nth-node-from-end-of-list/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// one pass (two pointer runner pattern) cannot make borrow checker happy
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0020_valid_parentheses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/valid-parentheses/
// discuss: https://leetcode.com/problems/valid-parentheses/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0021_merge_two_sorted_lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
pub struct Solution {}
use crate::util::linked_list::{to_list, ListNode};

// problem: https://leetcode.com/problems/merge-two-sorted-lists/
// discuss: https://leetcode.com/problems/merge-two-sorted-lists/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// recursive will be much easier to understand
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0022_generate_parentheses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/generate-parentheses/
// discuss: https://leetcode.com/problems/generate-parentheses/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// DFS
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0023_merge_k_sorted_lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
pub struct Solution {}
use crate::util::linked_list::{to_list, ListNode};

// problem: https://leetcode.com/problems/merge-k-sorted-lists/
// discuss: https://leetcode.com/problems/merge-k-sorted-lists/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here
use std::cmp::Ordering;
use std::collections::BinaryHeap;
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0024_swap_nodes_in_pairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
pub struct Solution {}
use crate::util::linked_list::{to_list, ListNode};

// problem: https://leetcode.com/problems/swap-nodes-in-pairs/
// discuss: https://leetcode.com/problems/swap-nodes-in-pairs/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0025_reverse_nodes_in_k_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
pub struct Solution {}
use crate::util::linked_list::{to_list, ListNode};

// problem: https://leetcode.com/problems/reverse-nodes-in-k-group/
// discuss: https://leetcode.com/problems/reverse-nodes-in-k-group/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0026_remove_duplicates_from_sorted_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/remove-duplicates-from-sorted-array/
// discuss: https://leetcode.com/problems/remove-duplicates-from-sorted-array/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0027_remove_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/remove-element/
// discuss: https://leetcode.com/problems/remove-element/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0028_implement_strstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/implement-strstr/
// discuss: https://leetcode.com/problems/implement-strstr/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0029_divide_two_integers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/divide-two-integers/
// discuss: https://leetcode.com/problems/divide-two-integers/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/substring-with-concatenation-of-all-words/
// discuss: https://leetcode.com/problems/substring-with-concatenation-of-all-words/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here
struct Term {
expect: i32,
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0031_next_permutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/next-permutation/
// discuss: https://leetcode.com/problems/next-permutation/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0032_longest_valid_parentheses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/longest-valid-parentheses/
// discuss: https://leetcode.com/problems/longest-valid-parentheses/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// time: O(N) space: O(1)
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0033_search_in_rotated_sorted_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub struct Solution {}
Consider the given array as ring, each time we split the ring and judge which part is the target belong to, then it's ordinary binary search.
*/

// problem: https://leetcode.com/problems/search-in-rotated-sorted-array/
// discuss: https://leetcode.com/problems/search-in-rotated-sorted-array/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/
// discuss: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// TODO
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0035_search_insert_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/search-insert-position/
// discuss: https://leetcode.com/problems/search-insert-position/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// TODO
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0036_valid_sudoku.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/valid-sudoku/
// discuss: https://leetcode.com/problems/valid-sudoku/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// just brute force
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0037_sudoku_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/sudoku-solver/
// discuss: https://leetcode.com/problems/sudoku-solver/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

// TODO
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0038_count_and_say.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/count-and-say/
// discuss: https://leetcode.com/problems/count-and-say/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

use std::char::from_digit;
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0039_combination_sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/combination-sum/
// discuss: https://leetcode.com/problems/combination-sum/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
3 changes: 3 additions & 0 deletions src/solution/s0040_combination_sum_ii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
*/
pub struct Solution {}

// problem: https://leetcode.com/problems/combination-sum-ii/
// discuss: https://leetcode.com/problems/combination-sum-ii/discuss/?currentPage=1&orderBy=most_votes&query=

// submission codes start here

impl Solution {
Expand Down
Loading