Skip to content

Commit 5552d15

Browse files
committed
add problem and discuss link to existing solutions
1 parent 5baae86 commit 5552d15

File tree

237 files changed

+711
-0
lines changed

Some content is hidden

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

237 files changed

+711
-0
lines changed

src/solution/s0001_two_sum.rs

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
*/
1919
pub struct Solution {}
2020

21+
// problem: https://leetcode.com/problems/two-sum/
22+
// discuss: https://leetcode.com/problems/two-sum/discuss/?currentPage=1&orderBy=most_votes&query=
23+
2124
// submission codes start here
2225

2326
use std::collections::HashMap;

src/solution/s0002_add_two_numbers.rs

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
pub struct Solution {}
2020
use crate::util::linked_list::{to_list, ListNode};
2121

22+
// problem: https://leetcode.com/problems/add-two-numbers/
23+
// discuss: https://leetcode.com/problems/add-two-numbers/discuss/?currentPage=1&orderBy=most_votes&query=
24+
2225
// submission codes start here
2326

2427
impl Solution {

src/solution/s0003_longest_substring_without_repeating_characters.rs

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*/
1313
pub struct Solution {}
1414

15+
// problem: https://leetcode.com/problems/longest-substring-without-repeating-characters/
16+
// discuss: https://leetcode.com/problems/longest-substring-without-repeating-characters/discuss/?currentPage=1&orderBy=most_votes&query=
17+
1518
// submission codes start here
1619

1720
impl Solution {

src/solution/s0004_median_of_two_sorted_arrays.rs

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
*/
2929
pub struct Solution {}
3030

31+
// problem: https://leetcode.com/problems/median-of-two-sorted-arrays/
32+
// discuss: https://leetcode.com/problems/median-of-two-sorted-arrays/discuss/?currentPage=1&orderBy=most_votes&query=
33+
3134
// submission codes start here
3235

3336
// TODO: nth slice

src/solution/s0005_longest_palindromic_substring.rs

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
*/
2222
pub struct Solution {}
2323

24+
// problem: https://leetcode.com/problems/longest-palindromic-substring/
25+
// discuss: https://leetcode.com/problems/longest-palindromic-substring/discuss/?currentPage=1&orderBy=most_votes&query=
26+
2427
// submission codes start here
2528

2629
impl Solution {

src/solution/s0006_zigzag_conversion.rs

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
*/
3939
pub struct Solution {}
4040

41+
// problem: https://leetcode.com/problems/zigzag-conversion/
42+
// discuss: https://leetcode.com/problems/zigzag-conversion/discuss/?currentPage=1&orderBy=most_votes&query=
43+
4144
// submission codes start here
4245

4346
impl Solution {

src/solution/s0007_reverse_integer.rs

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
*/
3131
pub struct Solution {}
3232

33+
// problem: https://leetcode.com/problems/reverse-integer/
34+
// discuss: https://leetcode.com/problems/reverse-integer/discuss/?currentPage=1&orderBy=most_votes&query=
35+
3336
// submission codes start here
3437
impl Solution {
3538
pub fn reverse(x: i32) -> i32 {

src/solution/s0008_string_to_integer_atoi.rs

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
*/
6262
pub struct Solution {}
6363

64+
// problem: https://leetcode.com/problems/string-to-integer-atoi/
65+
// discuss: https://leetcode.com/problems/string-to-integer-atoi/discuss/?currentPage=1&orderBy=most_votes&query=
66+
6467
// submission codes start here
6568

6669
impl Solution {

src/solution/s0009_palindrome_number.rs

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
*/
3434
pub struct Solution {}
3535

36+
// problem: https://leetcode.com/problems/palindrome-number/
37+
// discuss: https://leetcode.com/problems/palindrome-number/discuss/?currentPage=1&orderBy=most_votes&query=
38+
3639
// submission codes start here
3740

3841
// TODO: not optimal, we only have to revert half of the string

src/solution/s0010_regular_expression_matching.rs

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
*/
7070
pub struct Solution {}
7171

72+
// problem: https://leetcode.com/problems/regular-expression-matching/
73+
// discuss: https://leetcode.com/problems/regular-expression-matching/discuss/?currentPage=1&orderBy=most_votes&query=
74+
7275
// submission codes start here
7376

7477
// TODO: NFA

src/solution/s0011_container_with_most_water.rs

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
pub struct Solution {}
2424

25+
// problem: https://leetcode.com/problems/container-with-most-water/
26+
// discuss: https://leetcode.com/problems/container-with-most-water/discuss/?currentPage=1&orderBy=most_votes&query=
27+
2528
// submission codes start here
2629

2730
// Brute force: O(N^2)

src/solution/s0012_integer_to_roman.rs

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
*/
6262
pub struct Solution {}
6363

64+
// problem: https://leetcode.com/problems/integer-to-roman/
65+
// discuss: https://leetcode.com/problems/integer-to-roman/discuss/?currentPage=1&orderBy=most_votes&query=
66+
6467
// submission codes start here
6568

6669
impl Solution {

src/solution/s0013_roman_to_integer.rs

+3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
*/
6262
pub struct Solution {}
6363

64+
// problem: https://leetcode.com/problems/roman-to-integer/
65+
// discuss: https://leetcode.com/problems/roman-to-integer/discuss/?currentPage=1&orderBy=most_votes&query=
66+
6467
// submission codes start here
6568

6669
impl Solution {

src/solution/s0014_longest_common_prefix.rs

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
*/
2828
pub struct Solution {}
2929

30+
// problem: https://leetcode.com/problems/longest-common-prefix/
31+
// discuss: https://leetcode.com/problems/longest-common-prefix/discuss/?currentPage=1&orderBy=most_votes&query=
32+
3033
// submission codes start here
3134

3235
use std::str::Chars;

src/solution/s0015_3sum.rs

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
pub struct Solution {}
2424

25+
// problem: https://leetcode.com/problems/3sum/
26+
// discuss: https://leetcode.com/problems/3sum/discuss/?currentPage=1&orderBy=most_votes&query=
27+
2528
// submission codes start here
2629

2730
impl Solution {

src/solution/s0016_3sum_closest.rs

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
*/
1515
pub struct Solution {}
1616

17+
// problem: https://leetcode.com/problems/3sum-closest/
18+
// discuss: https://leetcode.com/problems/3sum-closest/discuss/?currentPage=1&orderBy=most_votes&query=
19+
1720
// submission codes start here
1821

1922
impl Solution {

src/solution/s0017_letter_combinations_of_a_phone_number.rs

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
*/
2222
pub struct Solution {}
2323

24+
// problem: https://leetcode.com/problems/letter-combinations-of-a-phone-number/
25+
// discuss: https://leetcode.com/problems/letter-combinations-of-a-phone-number/discuss/?currentPage=1&orderBy=most_votes&query=
26+
2427
// submission codes start here
2528

2629
impl Solution {

src/solution/s0018_4sum.rs

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
*/
2424
pub struct Solution {}
2525

26+
// problem: https://leetcode.com/problems/4sum/
27+
// discuss: https://leetcode.com/problems/4sum/discuss/?currentPage=1&orderBy=most_votes&query=
28+
2629
// submission codes start here
2730

2831
// TODO: change to faster N^3 solution... maybe

src/solution/s0019_remove_nth_node_from_end_of_list.rs

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
pub struct Solution {}
2424
use crate::util::linked_list::{to_list, ListNode};
2525

26+
// problem: https://leetcode.com/problems/remove-nth-node-from-end-of-list/
27+
// discuss: https://leetcode.com/problems/remove-nth-node-from-end-of-list/discuss/?currentPage=1&orderBy=most_votes&query=
28+
2629
// submission codes start here
2730

2831
// one pass (two pointer runner pattern) cannot make borrow checker happy

src/solution/s0020_valid_parentheses.rs

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
*/
5151
pub struct Solution {}
5252

53+
// problem: https://leetcode.com/problems/valid-parentheses/
54+
// discuss: https://leetcode.com/problems/valid-parentheses/discuss/?currentPage=1&orderBy=most_votes&query=
55+
5356
// submission codes start here
5457

5558
impl Solution {

src/solution/s0021_merge_two_sorted_lists.rs

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
pub struct Solution {}
1414
use crate::util::linked_list::{to_list, ListNode};
1515

16+
// problem: https://leetcode.com/problems/merge-two-sorted-lists/
17+
// discuss: https://leetcode.com/problems/merge-two-sorted-lists/discuss/?currentPage=1&orderBy=most_votes&query=
18+
1619
// submission codes start here
1720

1821
// recursive will be much easier to understand

src/solution/s0022_generate_parentheses.rs

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
*/
2121
pub struct Solution {}
2222

23+
// problem: https://leetcode.com/problems/generate-parentheses/
24+
// discuss: https://leetcode.com/problems/generate-parentheses/discuss/?currentPage=1&orderBy=most_votes&query=
25+
2326
// submission codes start here
2427

2528
// DFS

src/solution/s0023_merge_k_sorted_lists.rs

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
pub struct Solution {}
2020
use crate::util::linked_list::{to_list, ListNode};
2121

22+
// problem: https://leetcode.com/problems/merge-k-sorted-lists/
23+
// discuss: https://leetcode.com/problems/merge-k-sorted-lists/discuss/?currentPage=1&orderBy=most_votes&query=
24+
2225
// submission codes start here
2326
use std::cmp::Ordering;
2427
use std::collections::BinaryHeap;

src/solution/s0024_swap_nodes_in_pairs.rs

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
pub struct Solution {}
2020
use crate::util::linked_list::{to_list, ListNode};
2121

22+
// problem: https://leetcode.com/problems/swap-nodes-in-pairs/
23+
// discuss: https://leetcode.com/problems/swap-nodes-in-pairs/discuss/?currentPage=1&orderBy=most_votes&query=
24+
2225
// submission codes start here
2326

2427
impl Solution {

src/solution/s0025_reverse_nodes_in_k_group.rs

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
pub struct Solution {}
2828
use crate::util::linked_list::{to_list, ListNode};
2929

30+
// problem: https://leetcode.com/problems/reverse-nodes-in-k-group/
31+
// discuss: https://leetcode.com/problems/reverse-nodes-in-k-group/discuss/?currentPage=1&orderBy=most_votes&query=
32+
3033
// submission codes start here
3134

3235
impl Solution {

src/solution/s0026_remove_duplicates_from_sorted_array.rs

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
*/
4646
pub struct Solution {}
4747

48+
// problem: https://leetcode.com/problems/remove-duplicates-from-sorted-array/
49+
// discuss: https://leetcode.com/problems/remove-duplicates-from-sorted-array/discuss/?currentPage=1&orderBy=most_votes&query=
50+
4851
// submission codes start here
4952

5053
impl Solution {

src/solution/s0027_remove_element.rs

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
*/
5050
pub struct Solution {}
5151

52+
// problem: https://leetcode.com/problems/remove-element/
53+
// discuss: https://leetcode.com/problems/remove-element/discuss/?currentPage=1&orderBy=most_votes&query=
54+
5255
// submission codes start here
5356

5457
impl Solution {

src/solution/s0028_implement_strstr.rs

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
*/
2929
pub struct Solution {}
3030

31+
// problem: https://leetcode.com/problems/implement-strstr/
32+
// discuss: https://leetcode.com/problems/implement-strstr/discuss/?currentPage=1&orderBy=most_votes&query=
33+
3134
// submission codes start here
3235

3336
impl Solution {

src/solution/s0029_divide_two_integers.rs

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
*/
3131
pub struct Solution {}
3232

33+
// problem: https://leetcode.com/problems/divide-two-integers/
34+
// discuss: https://leetcode.com/problems/divide-two-integers/discuss/?currentPage=1&orderBy=most_votes&query=
35+
3336
// submission codes start here
3437

3538
impl Solution {

src/solution/s0030_substring_with_concatenation_of_all_words.rs

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
*/
2727
pub struct Solution {}
2828

29+
// problem: https://leetcode.com/problems/substring-with-concatenation-of-all-words/
30+
// discuss: https://leetcode.com/problems/substring-with-concatenation-of-all-words/discuss/?currentPage=1&orderBy=most_votes&query=
31+
2932
// submission codes start here
3033
struct Term {
3134
expect: i32,

src/solution/s0031_next_permutation.rs

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
*/
1717
pub struct Solution {}
1818

19+
// problem: https://leetcode.com/problems/next-permutation/
20+
// discuss: https://leetcode.com/problems/next-permutation/discuss/?currentPage=1&orderBy=most_votes&query=
21+
1922
// submission codes start here
2023

2124
impl Solution {

src/solution/s0032_longest_valid_parentheses.rs

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
pub struct Solution {}
2424

25+
// problem: https://leetcode.com/problems/longest-valid-parentheses/
26+
// discuss: https://leetcode.com/problems/longest-valid-parentheses/discuss/?currentPage=1&orderBy=most_votes&query=
27+
2528
// submission codes start here
2629

2730
// time: O(N) space: O(1)

src/solution/s0033_search_in_rotated_sorted_array.rs

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ pub struct Solution {}
3737
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.
3838
*/
3939

40+
// problem: https://leetcode.com/problems/search-in-rotated-sorted-array/
41+
// discuss: https://leetcode.com/problems/search-in-rotated-sorted-array/discuss/?currentPage=1&orderBy=most_votes&query=
42+
4043
// submission codes start here
4144

4245
impl Solution {

src/solution/s0034_find_first_and_last_position_of_element_in_sorted_array.rs

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
pub struct Solution {}
2424

25+
// problem: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/
26+
// discuss: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/discuss/?currentPage=1&orderBy=most_votes&query=
27+
2528
// submission codes start here
2629

2730
// TODO

src/solution/s0035_search_insert_position.rs

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
*/
3737
pub struct Solution {}
3838

39+
// problem: https://leetcode.com/problems/search-insert-position/
40+
// discuss: https://leetcode.com/problems/search-insert-position/discuss/?currentPage=1&orderBy=most_votes&query=
41+
3942
// submission codes start here
4043

4144
// TODO

src/solution/s0036_valid_sudoku.rs

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
*/
6565
pub struct Solution {}
6666

67+
// problem: https://leetcode.com/problems/valid-sudoku/
68+
// discuss: https://leetcode.com/problems/valid-sudoku/discuss/?currentPage=1&orderBy=most_votes&query=
69+
6770
// submission codes start here
6871

6972
// just brute force

src/solution/s0037_sudoku_solver.rs

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
*/
3131
pub struct Solution {}
3232

33+
// problem: https://leetcode.com/problems/sudoku-solver/
34+
// discuss: https://leetcode.com/problems/sudoku-solver/discuss/?currentPage=1&orderBy=most_votes&query=
35+
3336
// submission codes start here
3437

3538
// TODO

src/solution/s0038_count_and_say.rs

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
*/
3838
pub struct Solution {}
3939

40+
// problem: https://leetcode.com/problems/count-and-say/
41+
// discuss: https://leetcode.com/problems/count-and-say/discuss/?currentPage=1&orderBy=most_votes&query=
42+
4043
// submission codes start here
4144

4245
use std::char::from_digit;

src/solution/s0039_combination_sum.rs

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
*/
3939
pub struct Solution {}
4040

41+
// problem: https://leetcode.com/problems/combination-sum/
42+
// discuss: https://leetcode.com/problems/combination-sum/discuss/?currentPage=1&orderBy=most_votes&query=
43+
4144
// submission codes start here
4245

4346
impl Solution {

src/solution/s0040_combination_sum_ii.rs

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
*/
4040
pub struct Solution {}
4141

42+
// problem: https://leetcode.com/problems/combination-sum-ii/
43+
// discuss: https://leetcode.com/problems/combination-sum-ii/discuss/?currentPage=1&orderBy=most_votes&query=
44+
4245
// submission codes start here
4346

4447
impl Solution {

0 commit comments

Comments
 (0)