From d6e135c0b53bb0871f1026a76aeff8812d81498e Mon Sep 17 00:00:00 2001 From: songyzh Date: Sun, 2 Feb 2020 13:14:54 +0800 Subject: [PATCH 1/9] separate problems and answers --- .gitignore | 1 + src/{problem.rs => fetcher.rs} | 0 src/lib.rs | 239 +----------------- src/main.rs | 16 +- src/problem/mod.rs | 0 src/solution/mod.rs | 237 +++++++++++++++++ .../s0001_two_sum.rs} | 0 .../s0002_add_two_numbers.rs} | 2 +- .../s0003_longest_substring.rs} | 0 .../s0004_median_of_two_sorted_arrays.rs} | 0 .../s0005_longest_palindromic_substring.rs} | 0 .../s0006_zigzag_conversion.rs} | 0 .../s0007_reverse_integer.rs} | 0 .../s0008_string_to_integer_atoi.rs} | 0 .../s0009_palindrome_number.rs} | 0 .../s0010_regular_expression_matching.rs} | 0 .../s0011_container_with_most_water.rs} | 0 .../s0012_integer_to_roman.rs} | 0 .../s0013_roman_to_integer.rs} | 0 .../s0014_longest_common_prefix.rs} | 0 src/{n0015_3sum.rs => solution/s0015_3sum.rs} | 0 .../s0016_3sum_closest.rs} | 0 ..._letter_combinations_of_a_phone_number.rs} | 0 src/{n0018_4sum.rs => solution/s0018_4sum.rs} | 0 ...s0019_remove_nth_node_from_end_of_list.rs} | 2 +- .../s0020_valid_parentheses.rs} | 0 .../s0021_merge_two_sorted_lists.rs} | 2 +- .../s0022_generate_parentheses.rs} | 0 .../s0023_merge_k_sorted_lists.rs} | 2 +- .../s0024_swap_nodes_in_pairs.rs} | 2 +- .../s0025_reverse_nodes_in_k_group.rs} | 2 +- ...26_remove_duplicates_from_sorted_array.rs} | 0 .../s0027_remove_element.rs} | 0 .../s0028_implement_strstr.rs} | 0 .../s0029_divide_two_integers.rs} | 0 ...string_with_concatenation_of_all_words.rs} | 0 .../s0031_next_permutation.rs} | 0 .../s0032_longest_valid_parentheses.rs} | 0 .../s0033_search_in_rotated_sorted_array.rs} | 0 ...st_position_of_element_in_sorted_array.rs} | 0 .../s0035_search_insert_position.rs} | 0 .../s0036_valid_sudoku.rs} | 0 .../s0037_sudoku_solver.rs} | 0 .../s0038_count_and_say.rs} | 0 .../s0039_combination_sum.rs} | 0 .../s0040_combination_sum_ii.rs} | 0 .../s0041_first_missing_positive.rs} | 0 .../s0042_trapping_rain_water.rs} | 0 .../s0043_multiply_strings.rs} | 0 .../s0044_wildcard_matching.rs} | 0 .../s0045_jump_game_ii.rs} | 0 .../s0046_permutations.rs} | 0 .../s0047_permutations_ii.rs} | 0 .../s0048_rotate_image.rs} | 0 .../s0049_group_anagrams.rs} | 0 .../s0050_powx_n.rs} | 0 .../s0051_n_queens.rs} | 0 .../s0052_n_queens_ii.rs} | 0 .../s0053_maximum_subarray.rs} | 0 .../s0054_spiral_matrix.rs} | 0 .../s0055_jump_game.rs} | 0 .../s0056_merge_intervals.rs} | 0 .../s0057_insert_interval.rs} | 0 .../s0058_length_of_last_word.rs} | 0 .../s0059_spiral_matrix_ii.rs} | 0 .../s0060_permutation_sequence.rs} | 0 .../s0061_rotate_list.rs} | 2 +- .../s0062_unique_paths.rs} | 0 .../s0063_unique_paths_ii.rs} | 0 .../s0064_minimum_path_sum.rs} | 0 .../s0065_valid_number.rs} | 0 .../s0066_plus_one.rs} | 0 .../s0067_add_binary.rs} | 0 .../s0068_text_justification.rs} | 0 .../s0069_sqrtx.rs} | 0 .../s0070_climbing_stairs.rs} | 0 .../s0071_simplify_path.rs} | 0 .../s0072_edit_distance.rs} | 0 .../s0073_set_matrix_zeroes.rs} | 0 .../s0074_search_a_2d_matrix.rs} | 0 .../s0075_sort_colors.rs} | 0 .../s0076_minimum_window_substring.rs} | 0 .../s0077_combinations.rs} | 0 .../s0078_subsets.rs} | 0 .../s0079_word_search.rs} | 0 ...remove_duplicates_from_sorted_array_ii.rs} | 0 ...0081_search_in_rotated_sorted_array_ii.rs} | 0 ..._remove_duplicates_from_sorted_list_ii.rs} | 2 +- ...083_remove_duplicates_from_sorted_list.rs} | 2 +- .../s0084_largest_rectangle_in_histogram.rs} | 0 .../s0085_maximal_rectangle.rs} | 0 .../s0086_partition_list.rs} | 2 +- .../s0087_scramble_string.rs} | 0 .../s0088_merge_sorted_array.rs} | 0 .../s0089_gray_code.rs} | 0 .../s0090_subsets_ii.rs} | 0 .../s0091_decode_ways.rs} | 0 .../s0092_reverse_linked_list_ii.rs} | 2 +- .../s0093_restore_ip_addresses.rs} | 0 .../s0094_binary_tree_inorder_traversal.rs} | 2 +- .../s0095_unique_binary_search_trees_ii.rs} | 2 +- .../s0096_unique_binary_search_trees.rs} | 0 .../s0097_interleaving_string.rs} | 0 .../s0098_validate_binary_search_tree.rs} | 2 +- .../s0099_recover_binary_search_tree.rs} | 2 +- .../s0100_same_tree.rs} | 2 +- .../s0101_symmetric_tree.rs} | 2 +- ...0102_binary_tree_level_order_traversal.rs} | 2 +- ...nary_tree_zigzag_level_order_traversal.rs} | 2 +- .../s0104_maximum_depth_of_binary_tree.rs} | 2 +- ...ee_from_preorder_and_inorder_traversal.rs} | 2 +- ...e_from_inorder_and_postorder_traversal.rs} | 2 +- ...7_binary_tree_level_order_traversal_ii.rs} | 2 +- ...ert_sorted_array_to_binary_search_tree.rs} | 2 +- ...vert_sorted_list_to_binary_search_tree.rs} | 4 +- .../s0110_balanced_binary_tree.rs} | 2 +- .../s0111_minimum_depth_of_binary_tree.rs} | 2 +- .../s0112_path_sum.rs} | 2 +- .../s0113_path_sum_ii.rs} | 2 +- ...114_flatten_binary_tree_to_linked_list.rs} | 2 +- .../s0115_distinct_subsequences.rs} | 0 .../s0118_pascals_triangle.rs} | 0 .../s0119_pascals_triangle_ii.rs} | 0 .../s0120_triangle.rs} | 0 .../s0121_best_time_to_buy_and_sell_stock.rs} | 0 ...122_best_time_to_buy_and_sell_stock_ii.rs} | 0 ...23_best_time_to_buy_and_sell_stock_iii.rs} | 0 .../s0124_binary_tree_maximum_path_sum.rs} | 2 +- .../s0125_valid_palindrome.rs} | 0 .../s0126_word_ladder_ii.rs} | 0 .../s0127_word_ladder.rs} | 0 .../s0128_longest_consecutive_sequence.rs} | 0 .../s0129_sum_root_to_leaf_numbers.rs} | 2 +- .../s0130_surrounded_regions.rs} | 0 .../s0131_palindrome_partitioning.rs} | 0 .../s0132_palindrome_partitioning_ii.rs} | 0 .../s0134_gas_station.rs} | 0 .../s0135_candy.rs} | 0 .../s0136_single_number.rs} | 0 .../s0137_single_number_ii.rs} | 0 .../s0139_word_break.rs} | 0 .../s0140_word_break_ii.rs} | 0 .../s0143_reorder_list.rs} | 2 +- .../s0144_binary_tree_preorder_traversal.rs} | 2 +- .../s0145_binary_tree_postorder_traversal.rs} | 2 +- .../s0146_lru_cache.rs} | 0 .../s0147_insertion_sort_list.rs} | 4 +- .../s0148_sort_list.rs} | 2 +- .../s0149_max_points_on_a_line.rs} | 4 +- ...s0150_evaluate_reverse_polish_notation.rs} | 0 .../s0151_reverse_words_in_a_string.rs} | 0 .../s0152_maximum_product_subarray.rs} | 0 ...3_find_minimum_in_rotated_sorted_array.rs} | 0 ...ind_minimum_in_rotated_sorted_array_ii.rs} | 0 .../s0155_min_stack.rs} | 0 .../s0162_find_peak_element.rs} | 0 .../s0164_maximum_gap.rs} | 0 .../s0165_compare_version_numbers.rs} | 0 .../s0166_fraction_to_recurring_decimal.rs} | 0 ...s0167_two_sum_ii_input_array_is_sorted.rs} | 0 .../s0168_excel_sheet_column_title.rs} | 0 .../s0169_majority_element.rs} | 0 .../s0171_excel_sheet_column_number.rs} | 0 .../s0172_factorial_trailing_zeroes.rs} | 0 .../s0173_binary_search_tree_iterator.rs} | 6 +- .../s0174_dungeon_game.rs} | 0 .../s0179_largest_number.rs} | 0 .../s0187_repeated_dna_sequences.rs} | 0 ...188_best_time_to_buy_and_sell_stock_iv.rs} | 0 .../s0189_rotate_array.rs} | 0 .../s0198_house_robber.rs} | 0 .../s0199_binary_tree_right_side_view.rs} | 2 +- .../s0200_number_of_islands.rs} | 0 .../s0201_bitwise_and_of_numbers_range.rs} | 0 .../s0202_happy_number.rs} | 0 .../s0203_remove_linked_list_elements.rs} | 2 +- .../s0204_count_primes.rs} | 0 .../s0205_isomorphic_strings.rs} | 0 .../s0206_reverse_linked_list.rs} | 2 +- .../s0207_course_schedule.rs} | 0 .../s0208_implement_trie_prefix_tree.rs} | 0 .../s0209_minimum_size_subarray_sum.rs} | 0 .../s0210_course_schedule_ii.rs} | 0 ..._and_search_word_data_structure_design.rs} | 0 .../s0212_word_search_ii.rs} | 0 .../s0213_house_robber_ii.rs} | 0 .../s0214_shortest_palindrome.rs} | 0 .../s0215_kth_largest_element_in_an_array.rs} | 0 .../s0216_combination_sum_iii.rs} | 0 .../s0217_contains_duplicate.rs} | 0 .../s0218_the_skyline_problem.rs} | 0 .../s0219_contains_duplicate_ii.rs} | 0 .../s0220_contains_duplicate_iii.rs} | 0 .../s0221_maximal_square.rs} | 0 .../s0222_count_complete_tree_nodes.rs} | 2 +- .../s0223_rectangle_area.rs} | 0 .../s0224_basic_calculator.rs} | 0 .../s0225_implement_stack_using_queues.rs} | 0 .../s0226_invert_binary_tree.rs} | 2 +- .../s0227_basic_calculator_ii.rs} | 0 .../s0228_summary_ranges.rs} | 0 .../s0229_majority_element_ii.rs} | 0 .../s0230_kth_smallest_element_in_a_bst.rs} | 2 +- .../s0231_power_of_two.rs} | 0 .../s0232_implement_queue_using_stacks.rs} | 0 .../s0233_number_of_digit_one.rs} | 0 .../s0238_product_of_array_except_self.rs} | 0 .../s0239_sliding_window_maximum.rs} | 0 ...0241_different_ways_to_add_parentheses.rs} | 0 .../s0242_valid_anagram.rs} | 0 .../s0257_binary_tree_paths.rs} | 2 +- .../s0258_add_digits.rs} | 0 .../s0260_single_number_iii.rs} | 0 .../s0263_ugly_number.rs} | 0 .../s0264_ugly_number_ii.rs} | 0 .../s0268_missing_number.rs} | 0 .../s0273_integer_to_english_words.rs} | 0 .../s0274_h_index.rs} | 0 .../s0275_h_index_ii.rs} | 0 .../s0279_perfect_squares.rs} | 0 .../s0282_expression_add_operators.rs} | 0 .../s0283_move_zeroes.rs} | 0 .../s0287_find_the_duplicate_number.rs} | 0 .../s0289_game_of_life.rs} | 0 .../s0290_word_pattern.rs} | 0 .../s0292_nim_game.rs} | 0 .../s0295_find_median_from_data_stream.rs} | 0 .../s0299_bulls_and_cows.rs} | 0 .../s0300_longest_increasing_subsequence.rs} | 0 .../s0301_remove_invalid_parentheses.rs} | 0 .../s0303_range_sum_query_immutable.rs} | 0 .../s0304_range_sum_query_2d_immutable.rs} | 0 .../s0306_additive_number.rs} | 0 .../s0307_range_sum_query_mutable.rs} | 0 ...me_to_buy_and_sell_stock_with_cooldown.rs} | 0 .../s0310_minimum_height_trees.rs} | 0 .../s0312_burst_balloons.rs} | 0 .../s0313_super_ugly_number.rs} | 0 .../s0509_fibonacci_number.rs} | 0 .../s0704_binary_search.rs} | 0 .../s0969_pancake_sorting.rs} | 0 .../s1018_binary_prefix_divisible_by_5.rs} | 0 .../s1046_last_stone_weight.rs} | 0 243 files changed, 299 insertions(+), 296 deletions(-) rename src/{problem.rs => fetcher.rs} (100%) create mode 100644 src/problem/mod.rs create mode 100644 src/solution/mod.rs rename src/{n0001_two_sum.rs => solution/s0001_two_sum.rs} (100%) rename src/{n0002_add_two_numbers.rs => solution/s0002_add_two_numbers.rs} (98%) rename src/{n0003_longest_substring.rs => solution/s0003_longest_substring.rs} (100%) rename src/{n0004_median_of_two_sorted_arrays.rs => solution/s0004_median_of_two_sorted_arrays.rs} (100%) rename src/{n0005_longest_palindromic_substring.rs => solution/s0005_longest_palindromic_substring.rs} (100%) rename src/{n0006_zigzag_conversion.rs => solution/s0006_zigzag_conversion.rs} (100%) rename src/{n0007_reverse_integer.rs => solution/s0007_reverse_integer.rs} (100%) rename src/{n0008_string_to_integer_atoi.rs => solution/s0008_string_to_integer_atoi.rs} (100%) rename src/{n0009_palindrome_number.rs => solution/s0009_palindrome_number.rs} (100%) rename src/{n0010_regular_expression_matching.rs => solution/s0010_regular_expression_matching.rs} (100%) rename src/{n0011_container_with_most_water.rs => solution/s0011_container_with_most_water.rs} (100%) rename src/{n0012_integer_to_roman.rs => solution/s0012_integer_to_roman.rs} (100%) rename src/{n0013_roman_to_integer.rs => solution/s0013_roman_to_integer.rs} (100%) rename src/{n0014_longest_common_prefix.rs => solution/s0014_longest_common_prefix.rs} (100%) rename src/{n0015_3sum.rs => solution/s0015_3sum.rs} (100%) rename src/{n0016_3sum_closest.rs => solution/s0016_3sum_closest.rs} (100%) rename src/{n0017_letter_combinations_of_a_phone_number.rs => solution/s0017_letter_combinations_of_a_phone_number.rs} (100%) rename src/{n0018_4sum.rs => solution/s0018_4sum.rs} (100%) rename src/{n0019_remove_nth_node_from_end_of_list.rs => solution/s0019_remove_nth_node_from_end_of_list.rs} (97%) rename src/{n0020_valid_parentheses.rs => solution/s0020_valid_parentheses.rs} (100%) rename src/{n0021_merge_two_sorted_lists.rs => solution/s0021_merge_two_sorted_lists.rs} (97%) rename src/{n0022_generate_parentheses.rs => solution/s0022_generate_parentheses.rs} (100%) rename src/{n0023_merge_k_sorted_lists.rs => solution/s0023_merge_k_sorted_lists.rs} (97%) rename src/{n0024_swap_nodes_in_pairs.rs => solution/s0024_swap_nodes_in_pairs.rs} (97%) rename src/{n0025_reverse_nodes_in_k_group.rs => solution/s0025_reverse_nodes_in_k_group.rs} (98%) rename src/{n0026_remove_duplicates_from_sorted_array.rs => solution/s0026_remove_duplicates_from_sorted_array.rs} (100%) rename src/{n0027_remove_element.rs => solution/s0027_remove_element.rs} (100%) rename src/{n0028_implement_strstr.rs => solution/s0028_implement_strstr.rs} (100%) rename src/{n0029_divide_two_integers.rs => solution/s0029_divide_two_integers.rs} (100%) rename src/{n0030_substring_with_concatenation_of_all_words.rs => solution/s0030_substring_with_concatenation_of_all_words.rs} (100%) rename src/{n0031_next_permutation.rs => solution/s0031_next_permutation.rs} (100%) rename src/{n0032_longest_valid_parentheses.rs => solution/s0032_longest_valid_parentheses.rs} (100%) rename src/{n0033_search_in_rotated_sorted_array.rs => solution/s0033_search_in_rotated_sorted_array.rs} (100%) rename src/{n0034_find_first_and_last_position_of_element_in_sorted_array.rs => solution/s0034_find_first_and_last_position_of_element_in_sorted_array.rs} (100%) rename src/{n0035_search_insert_position.rs => solution/s0035_search_insert_position.rs} (100%) rename src/{n0036_valid_sudoku.rs => solution/s0036_valid_sudoku.rs} (100%) rename src/{n0037_sudoku_solver.rs => solution/s0037_sudoku_solver.rs} (100%) rename src/{n0038_count_and_say.rs => solution/s0038_count_and_say.rs} (100%) rename src/{n0039_combination_sum.rs => solution/s0039_combination_sum.rs} (100%) rename src/{n0040_combination_sum_ii.rs => solution/s0040_combination_sum_ii.rs} (100%) rename src/{n0041_first_missing_positive.rs => solution/s0041_first_missing_positive.rs} (100%) rename src/{n0042_trapping_rain_water.rs => solution/s0042_trapping_rain_water.rs} (100%) rename src/{n0043_multiply_strings.rs => solution/s0043_multiply_strings.rs} (100%) rename src/{n0044_wildcard_matching.rs => solution/s0044_wildcard_matching.rs} (100%) rename src/{n0045_jump_game_ii.rs => solution/s0045_jump_game_ii.rs} (100%) rename src/{n0046_permutations.rs => solution/s0046_permutations.rs} (100%) rename src/{n0047_permutations_ii.rs => solution/s0047_permutations_ii.rs} (100%) rename src/{n0048_rotate_image.rs => solution/s0048_rotate_image.rs} (100%) rename src/{n0049_group_anagrams.rs => solution/s0049_group_anagrams.rs} (100%) rename src/{n0050_powx_n.rs => solution/s0050_powx_n.rs} (100%) rename src/{n0051_n_queens.rs => solution/s0051_n_queens.rs} (100%) rename src/{n0052_n_queens_ii.rs => solution/s0052_n_queens_ii.rs} (100%) rename src/{n0053_maximum_subarray.rs => solution/s0053_maximum_subarray.rs} (100%) rename src/{n0054_spiral_matrix.rs => solution/s0054_spiral_matrix.rs} (100%) rename src/{n0055_jump_game.rs => solution/s0055_jump_game.rs} (100%) rename src/{n0056_merge_intervals.rs => solution/s0056_merge_intervals.rs} (100%) rename src/{n0057_insert_interval.rs => solution/s0057_insert_interval.rs} (100%) rename src/{n0058_length_of_last_word.rs => solution/s0058_length_of_last_word.rs} (100%) rename src/{n0059_spiral_matrix_ii.rs => solution/s0059_spiral_matrix_ii.rs} (100%) rename src/{n0060_permutation_sequence.rs => solution/s0060_permutation_sequence.rs} (100%) rename src/{n0061_rotate_list.rs => solution/s0061_rotate_list.rs} (94%) rename src/{n0062_unique_paths.rs => solution/s0062_unique_paths.rs} (100%) rename src/{n0063_unique_paths_ii.rs => solution/s0063_unique_paths_ii.rs} (100%) rename src/{n0064_minimum_path_sum.rs => solution/s0064_minimum_path_sum.rs} (100%) rename src/{n0065_valid_number.rs => solution/s0065_valid_number.rs} (100%) rename src/{n0066_plus_one.rs => solution/s0066_plus_one.rs} (100%) rename src/{n0067_add_binary.rs => solution/s0067_add_binary.rs} (100%) rename src/{n0068_text_justification.rs => solution/s0068_text_justification.rs} (100%) rename src/{n0069_sqrtx.rs => solution/s0069_sqrtx.rs} (100%) rename src/{n0070_climbing_stairs.rs => solution/s0070_climbing_stairs.rs} (100%) rename src/{n0071_simplify_path.rs => solution/s0071_simplify_path.rs} (100%) rename src/{n0072_edit_distance.rs => solution/s0072_edit_distance.rs} (100%) rename src/{n0073_set_matrix_zeroes.rs => solution/s0073_set_matrix_zeroes.rs} (100%) rename src/{n0074_search_a_2d_matrix.rs => solution/s0074_search_a_2d_matrix.rs} (100%) rename src/{n0075_sort_colors.rs => solution/s0075_sort_colors.rs} (100%) rename src/{n0076_minimum_window_substring.rs => solution/s0076_minimum_window_substring.rs} (100%) rename src/{n0077_combinations.rs => solution/s0077_combinations.rs} (100%) rename src/{n0078_subsets.rs => solution/s0078_subsets.rs} (100%) rename src/{n0079_word_search.rs => solution/s0079_word_search.rs} (100%) rename src/{n0080_remove_duplicates_from_sorted_array_ii.rs => solution/s0080_remove_duplicates_from_sorted_array_ii.rs} (100%) rename src/{n0081_search_in_rotated_sorted_array_ii.rs => solution/s0081_search_in_rotated_sorted_array_ii.rs} (100%) rename src/{n0082_remove_duplicates_from_sorted_list_ii.rs => solution/s0082_remove_duplicates_from_sorted_list_ii.rs} (94%) rename src/{n0083_remove_duplicates_from_sorted_list.rs => solution/s0083_remove_duplicates_from_sorted_list.rs} (94%) rename src/{n0084_largest_rectangle_in_histogram.rs => solution/s0084_largest_rectangle_in_histogram.rs} (100%) rename src/{n0085_maximal_rectangle.rs => solution/s0085_maximal_rectangle.rs} (100%) rename src/{n0086_partition_list.rs => solution/s0086_partition_list.rs} (97%) rename src/{n0087_scramble_string.rs => solution/s0087_scramble_string.rs} (100%) rename src/{n0088_merge_sorted_array.rs => solution/s0088_merge_sorted_array.rs} (100%) rename src/{n0089_gray_code.rs => solution/s0089_gray_code.rs} (100%) rename src/{n0090_subsets_ii.rs => solution/s0090_subsets_ii.rs} (100%) rename src/{n0091_decode_ways.rs => solution/s0091_decode_ways.rs} (100%) rename src/{n0092_reverse_linked_list_ii.rs => solution/s0092_reverse_linked_list_ii.rs} (94%) rename src/{n0093_restore_ip_addresses.rs => solution/s0093_restore_ip_addresses.rs} (100%) rename src/{n0094_binary_tree_inorder_traversal.rs => solution/s0094_binary_tree_inorder_traversal.rs} (96%) rename src/{n0095_unique_binary_search_trees_ii.rs => solution/s0095_unique_binary_search_trees_ii.rs} (97%) rename src/{n0096_unique_binary_search_trees.rs => solution/s0096_unique_binary_search_trees.rs} (100%) rename src/{n0097_interleaving_string.rs => solution/s0097_interleaving_string.rs} (100%) rename src/{n0098_validate_binary_search_tree.rs => solution/s0098_validate_binary_search_tree.rs} (98%) rename src/{n0099_recover_binary_search_tree.rs => solution/s0099_recover_binary_search_tree.rs} (95%) rename src/{n0100_same_tree.rs => solution/s0100_same_tree.rs} (96%) rename src/{n0101_symmetric_tree.rs => solution/s0101_symmetric_tree.rs} (97%) rename src/{n0102_binary_tree_level_order_traversal.rs => solution/s0102_binary_tree_level_order_traversal.rs} (97%) rename src/{n0103_binary_tree_zigzag_level_order_traversal.rs => solution/s0103_binary_tree_zigzag_level_order_traversal.rs} (97%) rename src/{n0104_maximum_depth_of_binary_tree.rs => solution/s0104_maximum_depth_of_binary_tree.rs} (96%) rename src/{n0105_construct_binary_tree_from_preorder_and_inorder_traversal.rs => solution/s0105_construct_binary_tree_from_preorder_and_inorder_traversal.rs} (97%) rename src/{n0106_construct_binary_tree_from_inorder_and_postorder_traversal.rs => solution/s0106_construct_binary_tree_from_inorder_and_postorder_traversal.rs} (97%) rename src/{n0107_binary_tree_level_order_traversal_ii.rs => solution/s0107_binary_tree_level_order_traversal_ii.rs} (97%) rename src/{n0108_convert_sorted_array_to_binary_search_tree.rs => solution/s0108_convert_sorted_array_to_binary_search_tree.rs} (97%) rename src/{n0109_convert_sorted_list_to_binary_search_tree.rs => solution/s0109_convert_sorted_list_to_binary_search_tree.rs} (94%) rename src/{n0110_balanced_binary_tree.rs => solution/s0110_balanced_binary_tree.rs} (93%) rename src/{n0111_minimum_depth_of_binary_tree.rs => solution/s0111_minimum_depth_of_binary_tree.rs} (96%) rename src/{n0112_path_sum.rs => solution/s0112_path_sum.rs} (97%) rename src/{n0113_path_sum_ii.rs => solution/s0113_path_sum_ii.rs} (97%) rename src/{n0114_flatten_binary_tree_to_linked_list.rs => solution/s0114_flatten_binary_tree_to_linked_list.rs} (97%) rename src/{n0115_distinct_subsequences.rs => solution/s0115_distinct_subsequences.rs} (100%) rename src/{n0118_pascals_triangle.rs => solution/s0118_pascals_triangle.rs} (100%) rename src/{n0119_pascals_triangle_ii.rs => solution/s0119_pascals_triangle_ii.rs} (100%) rename src/{n0120_triangle.rs => solution/s0120_triangle.rs} (100%) rename src/{n0121_best_time_to_buy_and_sell_stock.rs => solution/s0121_best_time_to_buy_and_sell_stock.rs} (100%) rename src/{n0122_best_time_to_buy_and_sell_stock_ii.rs => solution/s0122_best_time_to_buy_and_sell_stock_ii.rs} (100%) rename src/{n0123_best_time_to_buy_and_sell_stock_iii.rs => solution/s0123_best_time_to_buy_and_sell_stock_iii.rs} (100%) rename src/{n0124_binary_tree_maximum_path_sum.rs => solution/s0124_binary_tree_maximum_path_sum.rs} (98%) rename src/{n0125_valid_palindrome.rs => solution/s0125_valid_palindrome.rs} (100%) rename src/{n0126_word_ladder_ii.rs => solution/s0126_word_ladder_ii.rs} (100%) rename src/{n0127_word_ladder.rs => solution/s0127_word_ladder.rs} (100%) rename src/{n0128_longest_consecutive_sequence.rs => solution/s0128_longest_consecutive_sequence.rs} (100%) rename src/{n0129_sum_root_to_leaf_numbers.rs => solution/s0129_sum_root_to_leaf_numbers.rs} (97%) rename src/{n0130_surrounded_regions.rs => solution/s0130_surrounded_regions.rs} (100%) rename src/{n0131_palindrome_partitioning.rs => solution/s0131_palindrome_partitioning.rs} (100%) rename src/{n0132_palindrome_partitioning_ii.rs => solution/s0132_palindrome_partitioning_ii.rs} (100%) rename src/{n0134_gas_station.rs => solution/s0134_gas_station.rs} (100%) rename src/{n0135_candy.rs => solution/s0135_candy.rs} (100%) rename src/{n0136_single_number.rs => solution/s0136_single_number.rs} (100%) rename src/{n0137_single_number_ii.rs => solution/s0137_single_number_ii.rs} (100%) rename src/{n0139_word_break.rs => solution/s0139_word_break.rs} (100%) rename src/{n0140_word_break_ii.rs => solution/s0140_word_break_ii.rs} (100%) rename src/{n0143_reorder_list.rs => solution/s0143_reorder_list.rs} (93%) rename src/{n0144_binary_tree_preorder_traversal.rs => solution/s0144_binary_tree_preorder_traversal.rs} (96%) rename src/{n0145_binary_tree_postorder_traversal.rs => solution/s0145_binary_tree_postorder_traversal.rs} (96%) rename src/{n0146_lru_cache.rs => solution/s0146_lru_cache.rs} (100%) rename src/{n0147_insertion_sort_list.rs => solution/s0147_insertion_sort_list.rs} (96%) rename src/{n0148_sort_list.rs => solution/s0148_sort_list.rs} (98%) rename src/{n0149_max_points_on_a_line.rs => solution/s0149_max_points_on_a_line.rs} (95%) rename src/{n0150_evaluate_reverse_polish_notation.rs => solution/s0150_evaluate_reverse_polish_notation.rs} (100%) rename src/{n0151_reverse_words_in_a_string.rs => solution/s0151_reverse_words_in_a_string.rs} (100%) rename src/{n0152_maximum_product_subarray.rs => solution/s0152_maximum_product_subarray.rs} (100%) rename src/{n0153_find_minimum_in_rotated_sorted_array.rs => solution/s0153_find_minimum_in_rotated_sorted_array.rs} (100%) rename src/{n0154_find_minimum_in_rotated_sorted_array_ii.rs => solution/s0154_find_minimum_in_rotated_sorted_array_ii.rs} (100%) rename src/{n0155_min_stack.rs => solution/s0155_min_stack.rs} (100%) rename src/{n0162_find_peak_element.rs => solution/s0162_find_peak_element.rs} (100%) rename src/{n0164_maximum_gap.rs => solution/s0164_maximum_gap.rs} (100%) rename src/{n0165_compare_version_numbers.rs => solution/s0165_compare_version_numbers.rs} (100%) rename src/{n0166_fraction_to_recurring_decimal.rs => solution/s0166_fraction_to_recurring_decimal.rs} (100%) rename src/{n0167_two_sum_ii_input_array_is_sorted.rs => solution/s0167_two_sum_ii_input_array_is_sorted.rs} (100%) rename src/{n0168_excel_sheet_column_title.rs => solution/s0168_excel_sheet_column_title.rs} (100%) rename src/{n0169_majority_element.rs => solution/s0169_majority_element.rs} (100%) rename src/{n0171_excel_sheet_column_number.rs => solution/s0171_excel_sheet_column_number.rs} (100%) rename src/{n0172_factorial_trailing_zeroes.rs => solution/s0172_factorial_trailing_zeroes.rs} (100%) rename src/{n0173_binary_search_tree_iterator.rs => solution/s0173_binary_search_tree_iterator.rs} (94%) rename src/{n0174_dungeon_game.rs => solution/s0174_dungeon_game.rs} (100%) rename src/{n0179_largest_number.rs => solution/s0179_largest_number.rs} (100%) rename src/{n0187_repeated_dna_sequences.rs => solution/s0187_repeated_dna_sequences.rs} (100%) rename src/{n0188_best_time_to_buy_and_sell_stock_iv.rs => solution/s0188_best_time_to_buy_and_sell_stock_iv.rs} (100%) rename src/{n0189_rotate_array.rs => solution/s0189_rotate_array.rs} (100%) rename src/{n0198_house_robber.rs => solution/s0198_house_robber.rs} (100%) rename src/{n0199_binary_tree_right_side_view.rs => solution/s0199_binary_tree_right_side_view.rs} (97%) rename src/{n0200_number_of_islands.rs => solution/s0200_number_of_islands.rs} (100%) rename src/{n0201_bitwise_and_of_numbers_range.rs => solution/s0201_bitwise_and_of_numbers_range.rs} (100%) rename src/{n0202_happy_number.rs => solution/s0202_happy_number.rs} (100%) rename src/{n0203_remove_linked_list_elements.rs => solution/s0203_remove_linked_list_elements.rs} (95%) rename src/{n0204_count_primes.rs => solution/s0204_count_primes.rs} (100%) rename src/{n0205_isomorphic_strings.rs => solution/s0205_isomorphic_strings.rs} (100%) rename src/{n0206_reverse_linked_list.rs => solution/s0206_reverse_linked_list.rs} (94%) rename src/{n0207_course_schedule.rs => solution/s0207_course_schedule.rs} (100%) rename src/{n0208_implement_trie_prefix_tree.rs => solution/s0208_implement_trie_prefix_tree.rs} (100%) rename src/{n0209_minimum_size_subarray_sum.rs => solution/s0209_minimum_size_subarray_sum.rs} (100%) rename src/{n0210_course_schedule_ii.rs => solution/s0210_course_schedule_ii.rs} (100%) rename src/{n0211_add_and_search_word_data_structure_design.rs => solution/s0211_add_and_search_word_data_structure_design.rs} (100%) rename src/{n0212_word_search_ii.rs => solution/s0212_word_search_ii.rs} (100%) rename src/{n0213_house_robber_ii.rs => solution/s0213_house_robber_ii.rs} (100%) rename src/{n0214_shortest_palindrome.rs => solution/s0214_shortest_palindrome.rs} (100%) rename src/{n0215_kth_largest_element_in_an_array.rs => solution/s0215_kth_largest_element_in_an_array.rs} (100%) rename src/{n0216_combination_sum_iii.rs => solution/s0216_combination_sum_iii.rs} (100%) rename src/{n0217_contains_duplicate.rs => solution/s0217_contains_duplicate.rs} (100%) rename src/{n0218_the_skyline_problem.rs => solution/s0218_the_skyline_problem.rs} (100%) rename src/{n0219_contains_duplicate_ii.rs => solution/s0219_contains_duplicate_ii.rs} (100%) rename src/{n0220_contains_duplicate_iii.rs => solution/s0220_contains_duplicate_iii.rs} (100%) rename src/{n0221_maximal_square.rs => solution/s0221_maximal_square.rs} (100%) rename src/{n0222_count_complete_tree_nodes.rs => solution/s0222_count_complete_tree_nodes.rs} (98%) rename src/{n0223_rectangle_area.rs => solution/s0223_rectangle_area.rs} (100%) rename src/{n0224_basic_calculator.rs => solution/s0224_basic_calculator.rs} (100%) rename src/{n0225_implement_stack_using_queues.rs => solution/s0225_implement_stack_using_queues.rs} (100%) rename src/{n0226_invert_binary_tree.rs => solution/s0226_invert_binary_tree.rs} (97%) rename src/{n0227_basic_calculator_ii.rs => solution/s0227_basic_calculator_ii.rs} (100%) rename src/{n0228_summary_ranges.rs => solution/s0228_summary_ranges.rs} (100%) rename src/{n0229_majority_element_ii.rs => solution/s0229_majority_element_ii.rs} (100%) rename src/{n0230_kth_smallest_element_in_a_bst.rs => solution/s0230_kth_smallest_element_in_a_bst.rs} (97%) rename src/{n0231_power_of_two.rs => solution/s0231_power_of_two.rs} (100%) rename src/{n0232_implement_queue_using_stacks.rs => solution/s0232_implement_queue_using_stacks.rs} (100%) rename src/{n0233_number_of_digit_one.rs => solution/s0233_number_of_digit_one.rs} (100%) rename src/{n0238_product_of_array_except_self.rs => solution/s0238_product_of_array_except_self.rs} (100%) rename src/{n0239_sliding_window_maximum.rs => solution/s0239_sliding_window_maximum.rs} (100%) rename src/{n0241_different_ways_to_add_parentheses.rs => solution/s0241_different_ways_to_add_parentheses.rs} (100%) rename src/{n0242_valid_anagram.rs => solution/s0242_valid_anagram.rs} (100%) rename src/{n0257_binary_tree_paths.rs => solution/s0257_binary_tree_paths.rs} (97%) rename src/{n0258_add_digits.rs => solution/s0258_add_digits.rs} (100%) rename src/{n0260_single_number_iii.rs => solution/s0260_single_number_iii.rs} (100%) rename src/{n0263_ugly_number.rs => solution/s0263_ugly_number.rs} (100%) rename src/{n0264_ugly_number_ii.rs => solution/s0264_ugly_number_ii.rs} (100%) rename src/{n0268_missing_number.rs => solution/s0268_missing_number.rs} (100%) rename src/{n0273_integer_to_english_words.rs => solution/s0273_integer_to_english_words.rs} (100%) rename src/{n0274_h_index.rs => solution/s0274_h_index.rs} (100%) rename src/{n0275_h_index_ii.rs => solution/s0275_h_index_ii.rs} (100%) rename src/{n0279_perfect_squares.rs => solution/s0279_perfect_squares.rs} (100%) rename src/{n0282_expression_add_operators.rs => solution/s0282_expression_add_operators.rs} (100%) rename src/{n0283_move_zeroes.rs => solution/s0283_move_zeroes.rs} (100%) rename src/{n0287_find_the_duplicate_number.rs => solution/s0287_find_the_duplicate_number.rs} (100%) rename src/{n0289_game_of_life.rs => solution/s0289_game_of_life.rs} (100%) rename src/{n0290_word_pattern.rs => solution/s0290_word_pattern.rs} (100%) rename src/{n0292_nim_game.rs => solution/s0292_nim_game.rs} (100%) rename src/{n0295_find_median_from_data_stream.rs => solution/s0295_find_median_from_data_stream.rs} (100%) rename src/{n0299_bulls_and_cows.rs => solution/s0299_bulls_and_cows.rs} (100%) rename src/{n0300_longest_increasing_subsequence.rs => solution/s0300_longest_increasing_subsequence.rs} (100%) rename src/{n0301_remove_invalid_parentheses.rs => solution/s0301_remove_invalid_parentheses.rs} (100%) rename src/{n0303_range_sum_query_immutable.rs => solution/s0303_range_sum_query_immutable.rs} (100%) rename src/{n0304_range_sum_query_2d_immutable.rs => solution/s0304_range_sum_query_2d_immutable.rs} (100%) rename src/{n0306_additive_number.rs => solution/s0306_additive_number.rs} (100%) rename src/{n0307_range_sum_query_mutable.rs => solution/s0307_range_sum_query_mutable.rs} (100%) rename src/{n0309_best_time_to_buy_and_sell_stock_with_cooldown.rs => solution/s0309_best_time_to_buy_and_sell_stock_with_cooldown.rs} (100%) rename src/{n0310_minimum_height_trees.rs => solution/s0310_minimum_height_trees.rs} (100%) rename src/{n0312_burst_balloons.rs => solution/s0312_burst_balloons.rs} (100%) rename src/{n0313_super_ugly_number.rs => solution/s0313_super_ugly_number.rs} (100%) rename src/{n0509_fibonacci_number.rs => solution/s0509_fibonacci_number.rs} (100%) rename src/{n0704_binary_search.rs => solution/s0704_binary_search.rs} (100%) rename src/{n0969_pancake_sorting.rs => solution/s0969_pancake_sorting.rs} (100%) rename src/{n1018_binary_prefix_divisible_by_5.rs => solution/s1018_binary_prefix_divisible_by_5.rs} (100%) rename src/{n1046_last_stone_weight.rs => solution/s1046_last_stone_weight.rs} (100%) diff --git a/.gitignore b/.gitignore index 2f7896d1..96ef862d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target/ +.idea/ diff --git a/src/problem.rs b/src/fetcher.rs similarity index 100% rename from src/problem.rs rename to src/fetcher.rs diff --git a/src/lib.rs b/src/lib.rs index 815c1ce0..55b0298f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,240 +1,5 @@ #[macro_use] pub mod util; -mod n0006_zigzag_conversion; -mod n0238_product_of_array_except_self; -mod n0115_distinct_subsequences; -mod n0099_recover_binary_search_tree; -mod n0310_minimum_height_trees; -mod n0128_longest_consecutive_sequence; -mod n0274_h_index; -mod n0241_different_ways_to_add_parentheses; -mod n0024_swap_nodes_in_pairs; -mod n0110_balanced_binary_tree; -mod n0093_restore_ip_addresses; -mod n0076_minimum_window_substring; -mod n0124_binary_tree_maximum_path_sum; -mod n0122_best_time_to_buy_and_sell_stock_ii; -mod n0169_majority_element; -mod n0162_find_peak_element; -mod n0095_unique_binary_search_trees_ii; -mod n0155_min_stack; -mod n0040_combination_sum_ii; -mod n0217_contains_duplicate; -mod n0055_jump_game; -mod n0106_construct_binary_tree_from_inorder_and_postorder_traversal; -mod n0145_binary_tree_postorder_traversal; -mod n0079_word_search; -mod n0969_pancake_sorting; -mod n0042_trapping_rain_water; -mod n0108_convert_sorted_array_to_binary_search_tree; -mod n0083_remove_duplicates_from_sorted_list; -mod n0130_surrounded_regions; -mod n0226_invert_binary_tree; -mod n0027_remove_element; -mod n0188_best_time_to_buy_and_sell_stock_iv; -mod n0204_count_primes; -mod n0268_missing_number; -mod n0214_shortest_palindrome; -mod n0231_power_of_two; -mod n0202_happy_number; -mod n0075_sort_colors; -mod n0066_plus_one; -mod n0028_implement_strstr; -mod n0290_word_pattern; -mod n0048_rotate_image; -mod n0089_gray_code; -mod n0147_insertion_sort_list; -mod n0084_largest_rectangle_in_histogram; -mod n0011_container_with_most_water; -mod n0009_palindrome_number; -mod n0058_length_of_last_word; -mod n0080_remove_duplicates_from_sorted_array_ii; -mod n0030_substring_with_concatenation_of_all_words; -mod n0060_permutation_sequence; -mod n0071_simplify_path; -mod n0038_count_and_say; -mod n0144_binary_tree_preorder_traversal; -mod n0279_perfect_squares; -mod n0304_range_sum_query_2d_immutable; -mod n0292_nim_game; -mod n0264_ugly_number_ii; -mod n0132_palindrome_partitioning_ii; -mod n0019_remove_nth_node_from_end_of_list; -mod n0136_single_number; -mod n0018_4sum; -mod n0220_contains_duplicate_iii; -mod n0299_bulls_and_cows; -mod n0232_implement_queue_using_stacks; -mod n0100_same_tree; -mod n0171_excel_sheet_column_number; -mod n0087_scramble_string; -mod n0704_binary_search; -mod n0219_contains_duplicate_ii; -mod n0086_partition_list; -mod n0082_remove_duplicates_from_sorted_list_ii; -mod n0228_summary_ranges; -mod n0020_valid_parentheses; -mod n0017_letter_combinations_of_a_phone_number; -mod n0312_burst_balloons; -mod n0306_additive_number; -mod n0283_move_zeroes; -mod n1018_binary_prefix_divisible_by_5; -mod n0201_bitwise_and_of_numbers_range; -mod n0109_convert_sorted_list_to_binary_search_tree; -mod n0101_symmetric_tree; -mod n0098_validate_binary_search_tree; -mod n0035_search_insert_position; -mod n0050_powx_n; -mod n0198_house_robber; -mod n0004_median_of_two_sorted_arrays; -mod n0221_maximal_square; -mod n0047_permutations_ii; -mod n0172_factorial_trailing_zeroes; -mod n0054_spiral_matrix; -mod n0053_maximum_subarray; -mod n1046_last_stone_weight; -mod n0146_lru_cache; -mod n0126_word_ladder_ii; -mod n0242_valid_anagram; -mod n0112_path_sum; -mod n0023_merge_k_sorted_lists; -mod n0230_kth_smallest_element_in_a_bst; -mod n0104_maximum_depth_of_binary_tree; -mod n0258_add_digits; -mod n0187_repeated_dna_sequences; -mod n0025_reverse_nodes_in_k_group; -mod n0039_combination_sum; -mod n0107_binary_tree_level_order_traversal_ii; -mod n0091_decode_ways; -mod n0056_merge_intervals; -mod n0065_valid_number; -mod n0016_3sum_closest; -mod n0096_unique_binary_search_trees; -mod n0072_edit_distance; -mod n0044_wildcard_matching; -mod n0239_sliding_window_maximum; -mod n0174_dungeon_game; -mod n0073_set_matrix_zeroes; -mod n0078_subsets; -mod n0037_sudoku_solver; -mod n0033_search_in_rotated_sorted_array; -mod n0002_add_two_numbers; -mod n0313_super_ugly_number; -mod n0068_text_justification; -mod n0064_minimum_path_sum; -mod n0218_the_skyline_problem; -mod n0125_valid_palindrome; -mod n0210_course_schedule_ii; -mod n0143_reorder_list; -mod n0164_maximum_gap; -mod n0097_interleaving_string; -mod n0105_construct_binary_tree_from_preorder_and_inorder_traversal; -mod n0167_two_sum_ii_input_array_is_sorted; -mod n0034_find_first_and_last_position_of_element_in_sorted_array; -mod n0094_binary_tree_inorder_traversal; -mod n0052_n_queens_ii; -mod n0121_best_time_to_buy_and_sell_stock; -mod n0273_integer_to_english_words; -mod n0225_implement_stack_using_queues; -mod n0046_permutations; -mod n0085_maximal_rectangle; -mod n0135_candy; -mod n0113_path_sum_ii; -mod n0029_divide_two_integers; -mod n0260_single_number_iii; -mod n0140_word_break_ii; -mod n0149_max_points_on_a_line; -mod n0213_house_robber_ii; -mod n0222_count_complete_tree_nodes; -mod n0134_gas_station; -mod n0057_insert_interval; -mod n0173_binary_search_tree_iterator; -mod n0077_combinations; -mod n0005_longest_palindromic_substring; -mod n0041_first_missing_positive; -mod n0026_remove_duplicates_from_sorted_array; -mod n0166_fraction_to_recurring_decimal; -mod n0119_pascals_triangle_ii; -mod n0012_integer_to_roman; -mod n0223_rectangle_area; -mod n0229_majority_element_ii; -mod n0061_rotate_list; -mod n0123_best_time_to_buy_and_sell_stock_iii; -mod n0301_remove_invalid_parentheses; -mod n0067_add_binary; -mod n0049_group_anagrams; -mod n0189_rotate_array; -mod n0001_two_sum; -mod n0275_h_index_ii; -mod n0103_binary_tree_zigzag_level_order_traversal; -mod n0137_single_number_ii; -mod n0208_implement_trie_prefix_tree; -mod n0300_longest_increasing_subsequence; -mod n0118_pascals_triangle; -mod n0010_regular_expression_matching; -mod n0013_roman_to_integer; -mod n0209_minimum_size_subarray_sum; -mod n0227_basic_calculator_ii; -mod n0022_generate_parentheses; -mod n0008_string_to_integer_atoi; -mod n0152_maximum_product_subarray; -mod n0014_longest_common_prefix; -mod n0070_climbing_stairs; -mod n0233_number_of_digit_one; -mod n0154_find_minimum_in_rotated_sorted_array_ii; -mod n0127_word_ladder; -mod n0207_course_schedule; -mod n0263_ugly_number; -mod n0295_find_median_from_data_stream; -mod n0148_sort_list; -mod n0257_binary_tree_paths; -mod n0120_triangle; -mod n0309_best_time_to_buy_and_sell_stock_with_cooldown; -mod n0074_search_a_2d_matrix; -mod n0215_kth_largest_element_in_an_array; -mod n0203_remove_linked_list_elements; -mod n0081_search_in_rotated_sorted_array_ii; -mod n0059_spiral_matrix_ii; -mod n0151_reverse_words_in_a_string; -mod n0205_isomorphic_strings; -mod n0179_largest_number; -mod n0168_excel_sheet_column_title; -mod n0007_reverse_integer; -mod n0032_longest_valid_parentheses; -mod n0165_compare_version_numbers; -mod n0031_next_permutation; -mod n0088_merge_sorted_array; -mod n0509_fibonacci_number; -mod n0036_valid_sudoku; -mod n0069_sqrtx; -mod n0211_add_and_search_word_data_structure_design; -mod n0114_flatten_binary_tree_to_linked_list; -mod n0224_basic_calculator; -mod n0045_jump_game_ii; -mod n0051_n_queens; -mod n0212_word_search_ii; -mod n0287_find_the_duplicate_number; -mod n0153_find_minimum_in_rotated_sorted_array; -mod n0289_game_of_life; -mod n0200_number_of_islands; -mod n0015_3sum; -mod n0216_combination_sum_iii; -mod n0043_multiply_strings; -mod n0090_subsets_ii; -mod n0003_longest_substring; -mod n0139_word_break; -mod n0150_evaluate_reverse_polish_notation; -mod n0063_unique_paths_ii; -mod n0062_unique_paths; -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; +pub mod solution; +pub mod problem; diff --git a/src/main.rs b/src/main.rs index 967c5f85..e25be217 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ extern crate serde_derive; #[macro_use] extern crate serde_json; -mod problem; +mod fetcher; use std::env; use std::fs; @@ -45,7 +45,7 @@ fn main() { } } - let problem = problem::get_problem(id).unwrap_or_else(|| { + let problem = fetcher::get_problem(id).unwrap_or_else(|| { panic!( "Error: failed to get problem #{} \ (The problem may be paid-only or may not be exist).", @@ -61,11 +61,11 @@ fn main() { let code = code.unwrap(); let file_name = format!( - "n{:04}_{}", + "p{:04}_{}", problem.question_id, problem.title_slug.replace("-", "_") ); - let file_path = Path::new("./src").join(format!("{}.rs", file_name)); + let file_path = Path::new("./src/problem").join(format!("{}.rs", file_name)); if file_path.exists() { panic!("problem already initialized"); } @@ -91,7 +91,7 @@ fn main() { let mut lib_file = fs::OpenOptions::new() .write(true) .append(true) - .open("./src/lib.rs") + .open("./src/problem/mod.rs") .unwrap(); writeln!(lib_file, "mod {};", file_name); break; @@ -136,13 +136,13 @@ fn parse_extra_use(code: &str) -> String { let mut extra_use_line = String::new(); // a linked-list problem if code.contains("pub struct ListNode") { - extra_use_line.push_str("\nuse super::util::linked_list::{ListNode, to_list};") + extra_use_line.push_str("\nuse crate::util::linked_list::{ListNode, to_list};") } if code.contains("pub struct TreeNode") { - extra_use_line.push_str("\nuse super::util::tree::{TreeNode, to_tree};") + extra_use_line.push_str("\nuse crate::util::tree::{TreeNode, to_tree};") } if code.contains("pub struct Point") { - extra_use_line.push_str("\nuse super::util::point::Point;") + extra_use_line.push_str("\nuse crate::util::point::Point;") } extra_use_line } diff --git a/src/problem/mod.rs b/src/problem/mod.rs new file mode 100644 index 00000000..e69de29b diff --git a/src/solution/mod.rs b/src/solution/mod.rs new file mode 100644 index 00000000..3b079b74 --- /dev/null +++ b/src/solution/mod.rs @@ -0,0 +1,237 @@ +mod s0006_zigzag_conversion; +mod s0238_product_of_array_except_self; +mod s0115_distinct_subsequences; +mod s0099_recover_binary_search_tree; +mod s0310_minimum_height_trees; +mod s0128_longest_consecutive_sequence; +mod s0274_h_index; +mod s0241_different_ways_to_add_parentheses; +mod s0024_swap_nodes_in_pairs; +mod s0110_balanced_binary_tree; +mod s0093_restore_ip_addresses; +mod s0076_minimum_window_substring; +mod s0124_binary_tree_maximum_path_sum; +mod s0122_best_time_to_buy_and_sell_stock_ii; +mod s0169_majority_element; +mod s0162_find_peak_element; +mod s0095_unique_binary_search_trees_ii; +mod s0155_min_stack; +mod s0040_combination_sum_ii; +mod s0217_contains_duplicate; +mod s0055_jump_game; +mod s0106_construct_binary_tree_from_inorder_and_postorder_traversal; +mod s0145_binary_tree_postorder_traversal; +mod s0079_word_search; +mod s0969_pancake_sorting; +mod s0042_trapping_rain_water; +mod s0108_convert_sorted_array_to_binary_search_tree; +mod s0083_remove_duplicates_from_sorted_list; +mod s0130_surrounded_regions; +mod s0226_invert_binary_tree; +mod s0027_remove_element; +mod s0188_best_time_to_buy_and_sell_stock_iv; +mod s0204_count_primes; +mod s0268_missing_number; +mod s0214_shortest_palindrome; +mod s0231_power_of_two; +mod s0202_happy_number; +mod s0075_sort_colors; +mod s0066_plus_one; +mod s0028_implement_strstr; +mod s0290_word_pattern; +mod s0048_rotate_image; +mod s0089_gray_code; +mod s0147_insertion_sort_list; +mod s0084_largest_rectangle_in_histogram; +mod s0011_container_with_most_water; +mod s0009_palindrome_number; +mod s0058_length_of_last_word; +mod s0080_remove_duplicates_from_sorted_array_ii; +mod s0030_substring_with_concatenation_of_all_words; +mod s0060_permutation_sequence; +mod s0071_simplify_path; +mod s0038_count_and_say; +mod s0144_binary_tree_preorder_traversal; +mod s0279_perfect_squares; +mod s0304_range_sum_query_2d_immutable; +mod s0292_nim_game; +mod s0264_ugly_number_ii; +mod s0132_palindrome_partitioning_ii; +mod s0019_remove_nth_node_from_end_of_list; +mod s0136_single_number; +mod s0018_4sum; +mod s0220_contains_duplicate_iii; +mod s0299_bulls_and_cows; +mod s0232_implement_queue_using_stacks; +mod s0100_same_tree; +mod s0171_excel_sheet_column_number; +mod s0087_scramble_string; +mod s0704_binary_search; +mod s0219_contains_duplicate_ii; +mod s0086_partition_list; +mod s0082_remove_duplicates_from_sorted_list_ii; +mod s0228_summary_ranges; +mod s0020_valid_parentheses; +mod s0017_letter_combinations_of_a_phone_number; +mod s0312_burst_balloons; +mod s0306_additive_number; +mod s0283_move_zeroes; +mod s1018_binary_prefix_divisible_by_5; +mod s0201_bitwise_and_of_numbers_range; +mod s0109_convert_sorted_list_to_binary_search_tree; +mod s0101_symmetric_tree; +mod s0098_validate_binary_search_tree; +mod s0035_search_insert_position; +mod s0050_powx_n; +mod s0198_house_robber; +mod s0004_median_of_two_sorted_arrays; +mod s0221_maximal_square; +mod s0047_permutations_ii; +mod s0172_factorial_trailing_zeroes; +mod s0054_spiral_matrix; +mod s0053_maximum_subarray; +mod s1046_last_stone_weight; +mod s0146_lru_cache; +mod s0126_word_ladder_ii; +mod s0242_valid_anagram; +mod s0112_path_sum; +mod s0023_merge_k_sorted_lists; +mod s0230_kth_smallest_element_in_a_bst; +mod s0104_maximum_depth_of_binary_tree; +mod s0258_add_digits; +mod s0187_repeated_dna_sequences; +mod s0025_reverse_nodes_in_k_group; +mod s0039_combination_sum; +mod s0107_binary_tree_level_order_traversal_ii; +mod s0091_decode_ways; +mod s0056_merge_intervals; +mod s0065_valid_number; +mod s0016_3sum_closest; +mod s0096_unique_binary_search_trees; +mod s0072_edit_distance; +mod s0044_wildcard_matching; +mod s0239_sliding_window_maximum; +mod s0174_dungeon_game; +mod s0073_set_matrix_zeroes; +mod s0078_subsets; +mod s0037_sudoku_solver; +mod s0033_search_in_rotated_sorted_array; +mod s0002_add_two_numbers; +mod s0313_super_ugly_number; +mod s0068_text_justification; +mod s0064_minimum_path_sum; +mod s0218_the_skyline_problem; +mod s0125_valid_palindrome; +mod s0210_course_schedule_ii; +mod s0143_reorder_list; +mod s0164_maximum_gap; +mod s0097_interleaving_string; +mod s0105_construct_binary_tree_from_preorder_and_inorder_traversal; +mod s0167_two_sum_ii_input_array_is_sorted; +mod s0034_find_first_and_last_position_of_element_in_sorted_array; +mod s0094_binary_tree_inorder_traversal; +mod s0052_n_queens_ii; +mod s0121_best_time_to_buy_and_sell_stock; +mod s0273_integer_to_english_words; +mod s0225_implement_stack_using_queues; +mod s0046_permutations; +mod s0085_maximal_rectangle; +mod s0135_candy; +mod s0113_path_sum_ii; +mod s0029_divide_two_integers; +mod s0260_single_number_iii; +mod s0140_word_break_ii; +mod s0149_max_points_on_a_line; +mod s0213_house_robber_ii; +mod s0222_count_complete_tree_nodes; +mod s0134_gas_station; +mod s0057_insert_interval; +mod s0173_binary_search_tree_iterator; +mod s0077_combinations; +mod s0005_longest_palindromic_substring; +mod s0041_first_missing_positive; +mod s0026_remove_duplicates_from_sorted_array; +mod s0166_fraction_to_recurring_decimal; +mod s0119_pascals_triangle_ii; +mod s0012_integer_to_roman; +mod s0223_rectangle_area; +mod s0229_majority_element_ii; +mod s0061_rotate_list; +mod s0123_best_time_to_buy_and_sell_stock_iii; +mod s0301_remove_invalid_parentheses; +mod s0067_add_binary; +mod s0049_group_anagrams; +mod s0189_rotate_array; +mod s0001_two_sum; +mod s0275_h_index_ii; +mod s0103_binary_tree_zigzag_level_order_traversal; +mod s0137_single_number_ii; +mod s0208_implement_trie_prefix_tree; +mod s0300_longest_increasing_subsequence; +mod s0118_pascals_triangle; +mod s0010_regular_expression_matching; +mod s0013_roman_to_integer; +mod s0209_minimum_size_subarray_sum; +mod s0227_basic_calculator_ii; +mod s0022_generate_parentheses; +mod s0008_string_to_integer_atoi; +mod s0152_maximum_product_subarray; +mod s0014_longest_common_prefix; +mod s0070_climbing_stairs; +mod s0233_number_of_digit_one; +mod s0154_find_minimum_in_rotated_sorted_array_ii; +mod s0127_word_ladder; +mod s0207_course_schedule; +mod s0263_ugly_number; +mod s0295_find_median_from_data_stream; +mod s0148_sort_list; +mod s0257_binary_tree_paths; +mod s0120_triangle; +mod s0309_best_time_to_buy_and_sell_stock_with_cooldown; +mod s0074_search_a_2d_matrix; +mod s0215_kth_largest_element_in_an_array; +mod s0203_remove_linked_list_elements; +mod s0081_search_in_rotated_sorted_array_ii; +mod s0059_spiral_matrix_ii; +mod s0151_reverse_words_in_a_string; +mod s0205_isomorphic_strings; +mod s0179_largest_number; +mod s0168_excel_sheet_column_title; +mod s0007_reverse_integer; +mod s0032_longest_valid_parentheses; +mod s0165_compare_version_numbers; +mod s0031_next_permutation; +mod s0088_merge_sorted_array; +mod s0509_fibonacci_number; +mod s0036_valid_sudoku; +mod s0069_sqrtx; +mod s0211_add_and_search_word_data_structure_design; +mod s0114_flatten_binary_tree_to_linked_list; +mod s0224_basic_calculator; +mod s0045_jump_game_ii; +mod s0051_n_queens; +mod s0212_word_search_ii; +mod s0287_find_the_duplicate_number; +mod s0153_find_minimum_in_rotated_sorted_array; +mod s0289_game_of_life; +mod s0200_number_of_islands; +mod s0015_3sum; +mod s0216_combination_sum_iii; +mod s0043_multiply_strings; +mod s0090_subsets_ii; +mod s0003_longest_substring; +mod s0139_word_break; +mod s0150_evaluate_reverse_polish_notation; +mod s0063_unique_paths_ii; +mod s0062_unique_paths; +mod s0199_binary_tree_right_side_view; +mod s0282_expression_add_operators; +mod s0021_merge_two_sorted_lists; +mod s0129_sum_root_to_leaf_numbers; +mod s0206_reverse_linked_list; +mod s0131_palindrome_partitioning; +mod s0307_range_sum_query_mutable; +mod s0111_minimum_depth_of_binary_tree; +mod s0092_reverse_linked_list_ii; +mod s0303_range_sum_query_immutable; +mod s0102_binary_tree_level_order_traversal; diff --git a/src/n0001_two_sum.rs b/src/solution/s0001_two_sum.rs similarity index 100% rename from src/n0001_two_sum.rs rename to src/solution/s0001_two_sum.rs diff --git a/src/n0002_add_two_numbers.rs b/src/solution/s0002_add_two_numbers.rs similarity index 98% rename from src/n0002_add_two_numbers.rs rename to src/solution/s0002_add_two_numbers.rs index b7b21b01..5612c3d4 100644 --- a/src/n0002_add_two_numbers.rs +++ b/src/solution/s0002_add_two_numbers.rs @@ -17,7 +17,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0003_longest_substring.rs b/src/solution/s0003_longest_substring.rs similarity index 100% rename from src/n0003_longest_substring.rs rename to src/solution/s0003_longest_substring.rs diff --git a/src/n0004_median_of_two_sorted_arrays.rs b/src/solution/s0004_median_of_two_sorted_arrays.rs similarity index 100% rename from src/n0004_median_of_two_sorted_arrays.rs rename to src/solution/s0004_median_of_two_sorted_arrays.rs diff --git a/src/n0005_longest_palindromic_substring.rs b/src/solution/s0005_longest_palindromic_substring.rs similarity index 100% rename from src/n0005_longest_palindromic_substring.rs rename to src/solution/s0005_longest_palindromic_substring.rs diff --git a/src/n0006_zigzag_conversion.rs b/src/solution/s0006_zigzag_conversion.rs similarity index 100% rename from src/n0006_zigzag_conversion.rs rename to src/solution/s0006_zigzag_conversion.rs diff --git a/src/n0007_reverse_integer.rs b/src/solution/s0007_reverse_integer.rs similarity index 100% rename from src/n0007_reverse_integer.rs rename to src/solution/s0007_reverse_integer.rs diff --git a/src/n0008_string_to_integer_atoi.rs b/src/solution/s0008_string_to_integer_atoi.rs similarity index 100% rename from src/n0008_string_to_integer_atoi.rs rename to src/solution/s0008_string_to_integer_atoi.rs diff --git a/src/n0009_palindrome_number.rs b/src/solution/s0009_palindrome_number.rs similarity index 100% rename from src/n0009_palindrome_number.rs rename to src/solution/s0009_palindrome_number.rs diff --git a/src/n0010_regular_expression_matching.rs b/src/solution/s0010_regular_expression_matching.rs similarity index 100% rename from src/n0010_regular_expression_matching.rs rename to src/solution/s0010_regular_expression_matching.rs diff --git a/src/n0011_container_with_most_water.rs b/src/solution/s0011_container_with_most_water.rs similarity index 100% rename from src/n0011_container_with_most_water.rs rename to src/solution/s0011_container_with_most_water.rs diff --git a/src/n0012_integer_to_roman.rs b/src/solution/s0012_integer_to_roman.rs similarity index 100% rename from src/n0012_integer_to_roman.rs rename to src/solution/s0012_integer_to_roman.rs diff --git a/src/n0013_roman_to_integer.rs b/src/solution/s0013_roman_to_integer.rs similarity index 100% rename from src/n0013_roman_to_integer.rs rename to src/solution/s0013_roman_to_integer.rs diff --git a/src/n0014_longest_common_prefix.rs b/src/solution/s0014_longest_common_prefix.rs similarity index 100% rename from src/n0014_longest_common_prefix.rs rename to src/solution/s0014_longest_common_prefix.rs diff --git a/src/n0015_3sum.rs b/src/solution/s0015_3sum.rs similarity index 100% rename from src/n0015_3sum.rs rename to src/solution/s0015_3sum.rs diff --git a/src/n0016_3sum_closest.rs b/src/solution/s0016_3sum_closest.rs similarity index 100% rename from src/n0016_3sum_closest.rs rename to src/solution/s0016_3sum_closest.rs diff --git a/src/n0017_letter_combinations_of_a_phone_number.rs b/src/solution/s0017_letter_combinations_of_a_phone_number.rs similarity index 100% rename from src/n0017_letter_combinations_of_a_phone_number.rs rename to src/solution/s0017_letter_combinations_of_a_phone_number.rs diff --git a/src/n0018_4sum.rs b/src/solution/s0018_4sum.rs similarity index 100% rename from src/n0018_4sum.rs rename to src/solution/s0018_4sum.rs diff --git a/src/n0019_remove_nth_node_from_end_of_list.rs b/src/solution/s0019_remove_nth_node_from_end_of_list.rs similarity index 97% rename from src/n0019_remove_nth_node_from_end_of_list.rs rename to src/solution/s0019_remove_nth_node_from_end_of_list.rs index a1698a45..b3dac826 100644 --- a/src/n0019_remove_nth_node_from_end_of_list.rs +++ b/src/solution/s0019_remove_nth_node_from_end_of_list.rs @@ -21,7 +21,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0020_valid_parentheses.rs b/src/solution/s0020_valid_parentheses.rs similarity index 100% rename from src/n0020_valid_parentheses.rs rename to src/solution/s0020_valid_parentheses.rs diff --git a/src/n0021_merge_two_sorted_lists.rs b/src/solution/s0021_merge_two_sorted_lists.rs similarity index 97% rename from src/n0021_merge_two_sorted_lists.rs rename to src/solution/s0021_merge_two_sorted_lists.rs index 5a25adf7..c496d8e0 100644 --- a/src/n0021_merge_two_sorted_lists.rs +++ b/src/solution/s0021_merge_two_sorted_lists.rs @@ -11,7 +11,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0022_generate_parentheses.rs b/src/solution/s0022_generate_parentheses.rs similarity index 100% rename from src/n0022_generate_parentheses.rs rename to src/solution/s0022_generate_parentheses.rs diff --git a/src/n0023_merge_k_sorted_lists.rs b/src/solution/s0023_merge_k_sorted_lists.rs similarity index 97% rename from src/n0023_merge_k_sorted_lists.rs rename to src/solution/s0023_merge_k_sorted_lists.rs index 74b95045..c213eb7d 100644 --- a/src/n0023_merge_k_sorted_lists.rs +++ b/src/solution/s0023_merge_k_sorted_lists.rs @@ -17,7 +17,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here use std::cmp::Ordering; diff --git a/src/n0024_swap_nodes_in_pairs.rs b/src/solution/s0024_swap_nodes_in_pairs.rs similarity index 97% rename from src/n0024_swap_nodes_in_pairs.rs rename to src/solution/s0024_swap_nodes_in_pairs.rs index 41e3c6c4..104d6b9e 100644 --- a/src/n0024_swap_nodes_in_pairs.rs +++ b/src/solution/s0024_swap_nodes_in_pairs.rs @@ -17,7 +17,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0025_reverse_nodes_in_k_group.rs b/src/solution/s0025_reverse_nodes_in_k_group.rs similarity index 98% rename from src/n0025_reverse_nodes_in_k_group.rs rename to src/solution/s0025_reverse_nodes_in_k_group.rs index aac987f7..3beb5528 100644 --- a/src/n0025_reverse_nodes_in_k_group.rs +++ b/src/solution/s0025_reverse_nodes_in_k_group.rs @@ -25,7 +25,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0026_remove_duplicates_from_sorted_array.rs b/src/solution/s0026_remove_duplicates_from_sorted_array.rs similarity index 100% rename from src/n0026_remove_duplicates_from_sorted_array.rs rename to src/solution/s0026_remove_duplicates_from_sorted_array.rs diff --git a/src/n0027_remove_element.rs b/src/solution/s0027_remove_element.rs similarity index 100% rename from src/n0027_remove_element.rs rename to src/solution/s0027_remove_element.rs diff --git a/src/n0028_implement_strstr.rs b/src/solution/s0028_implement_strstr.rs similarity index 100% rename from src/n0028_implement_strstr.rs rename to src/solution/s0028_implement_strstr.rs diff --git a/src/n0029_divide_two_integers.rs b/src/solution/s0029_divide_two_integers.rs similarity index 100% rename from src/n0029_divide_two_integers.rs rename to src/solution/s0029_divide_two_integers.rs diff --git a/src/n0030_substring_with_concatenation_of_all_words.rs b/src/solution/s0030_substring_with_concatenation_of_all_words.rs similarity index 100% rename from src/n0030_substring_with_concatenation_of_all_words.rs rename to src/solution/s0030_substring_with_concatenation_of_all_words.rs diff --git a/src/n0031_next_permutation.rs b/src/solution/s0031_next_permutation.rs similarity index 100% rename from src/n0031_next_permutation.rs rename to src/solution/s0031_next_permutation.rs diff --git a/src/n0032_longest_valid_parentheses.rs b/src/solution/s0032_longest_valid_parentheses.rs similarity index 100% rename from src/n0032_longest_valid_parentheses.rs rename to src/solution/s0032_longest_valid_parentheses.rs diff --git a/src/n0033_search_in_rotated_sorted_array.rs b/src/solution/s0033_search_in_rotated_sorted_array.rs similarity index 100% rename from src/n0033_search_in_rotated_sorted_array.rs rename to src/solution/s0033_search_in_rotated_sorted_array.rs diff --git a/src/n0034_find_first_and_last_position_of_element_in_sorted_array.rs b/src/solution/s0034_find_first_and_last_position_of_element_in_sorted_array.rs similarity index 100% rename from src/n0034_find_first_and_last_position_of_element_in_sorted_array.rs rename to src/solution/s0034_find_first_and_last_position_of_element_in_sorted_array.rs diff --git a/src/n0035_search_insert_position.rs b/src/solution/s0035_search_insert_position.rs similarity index 100% rename from src/n0035_search_insert_position.rs rename to src/solution/s0035_search_insert_position.rs diff --git a/src/n0036_valid_sudoku.rs b/src/solution/s0036_valid_sudoku.rs similarity index 100% rename from src/n0036_valid_sudoku.rs rename to src/solution/s0036_valid_sudoku.rs diff --git a/src/n0037_sudoku_solver.rs b/src/solution/s0037_sudoku_solver.rs similarity index 100% rename from src/n0037_sudoku_solver.rs rename to src/solution/s0037_sudoku_solver.rs diff --git a/src/n0038_count_and_say.rs b/src/solution/s0038_count_and_say.rs similarity index 100% rename from src/n0038_count_and_say.rs rename to src/solution/s0038_count_and_say.rs diff --git a/src/n0039_combination_sum.rs b/src/solution/s0039_combination_sum.rs similarity index 100% rename from src/n0039_combination_sum.rs rename to src/solution/s0039_combination_sum.rs diff --git a/src/n0040_combination_sum_ii.rs b/src/solution/s0040_combination_sum_ii.rs similarity index 100% rename from src/n0040_combination_sum_ii.rs rename to src/solution/s0040_combination_sum_ii.rs diff --git a/src/n0041_first_missing_positive.rs b/src/solution/s0041_first_missing_positive.rs similarity index 100% rename from src/n0041_first_missing_positive.rs rename to src/solution/s0041_first_missing_positive.rs diff --git a/src/n0042_trapping_rain_water.rs b/src/solution/s0042_trapping_rain_water.rs similarity index 100% rename from src/n0042_trapping_rain_water.rs rename to src/solution/s0042_trapping_rain_water.rs diff --git a/src/n0043_multiply_strings.rs b/src/solution/s0043_multiply_strings.rs similarity index 100% rename from src/n0043_multiply_strings.rs rename to src/solution/s0043_multiply_strings.rs diff --git a/src/n0044_wildcard_matching.rs b/src/solution/s0044_wildcard_matching.rs similarity index 100% rename from src/n0044_wildcard_matching.rs rename to src/solution/s0044_wildcard_matching.rs diff --git a/src/n0045_jump_game_ii.rs b/src/solution/s0045_jump_game_ii.rs similarity index 100% rename from src/n0045_jump_game_ii.rs rename to src/solution/s0045_jump_game_ii.rs diff --git a/src/n0046_permutations.rs b/src/solution/s0046_permutations.rs similarity index 100% rename from src/n0046_permutations.rs rename to src/solution/s0046_permutations.rs diff --git a/src/n0047_permutations_ii.rs b/src/solution/s0047_permutations_ii.rs similarity index 100% rename from src/n0047_permutations_ii.rs rename to src/solution/s0047_permutations_ii.rs diff --git a/src/n0048_rotate_image.rs b/src/solution/s0048_rotate_image.rs similarity index 100% rename from src/n0048_rotate_image.rs rename to src/solution/s0048_rotate_image.rs diff --git a/src/n0049_group_anagrams.rs b/src/solution/s0049_group_anagrams.rs similarity index 100% rename from src/n0049_group_anagrams.rs rename to src/solution/s0049_group_anagrams.rs diff --git a/src/n0050_powx_n.rs b/src/solution/s0050_powx_n.rs similarity index 100% rename from src/n0050_powx_n.rs rename to src/solution/s0050_powx_n.rs diff --git a/src/n0051_n_queens.rs b/src/solution/s0051_n_queens.rs similarity index 100% rename from src/n0051_n_queens.rs rename to src/solution/s0051_n_queens.rs diff --git a/src/n0052_n_queens_ii.rs b/src/solution/s0052_n_queens_ii.rs similarity index 100% rename from src/n0052_n_queens_ii.rs rename to src/solution/s0052_n_queens_ii.rs diff --git a/src/n0053_maximum_subarray.rs b/src/solution/s0053_maximum_subarray.rs similarity index 100% rename from src/n0053_maximum_subarray.rs rename to src/solution/s0053_maximum_subarray.rs diff --git a/src/n0054_spiral_matrix.rs b/src/solution/s0054_spiral_matrix.rs similarity index 100% rename from src/n0054_spiral_matrix.rs rename to src/solution/s0054_spiral_matrix.rs diff --git a/src/n0055_jump_game.rs b/src/solution/s0055_jump_game.rs similarity index 100% rename from src/n0055_jump_game.rs rename to src/solution/s0055_jump_game.rs diff --git a/src/n0056_merge_intervals.rs b/src/solution/s0056_merge_intervals.rs similarity index 100% rename from src/n0056_merge_intervals.rs rename to src/solution/s0056_merge_intervals.rs diff --git a/src/n0057_insert_interval.rs b/src/solution/s0057_insert_interval.rs similarity index 100% rename from src/n0057_insert_interval.rs rename to src/solution/s0057_insert_interval.rs diff --git a/src/n0058_length_of_last_word.rs b/src/solution/s0058_length_of_last_word.rs similarity index 100% rename from src/n0058_length_of_last_word.rs rename to src/solution/s0058_length_of_last_word.rs diff --git a/src/n0059_spiral_matrix_ii.rs b/src/solution/s0059_spiral_matrix_ii.rs similarity index 100% rename from src/n0059_spiral_matrix_ii.rs rename to src/solution/s0059_spiral_matrix_ii.rs diff --git a/src/n0060_permutation_sequence.rs b/src/solution/s0060_permutation_sequence.rs similarity index 100% rename from src/n0060_permutation_sequence.rs rename to src/solution/s0060_permutation_sequence.rs diff --git a/src/n0061_rotate_list.rs b/src/solution/s0061_rotate_list.rs similarity index 94% rename from src/n0061_rotate_list.rs rename to src/solution/s0061_rotate_list.rs index 08812115..b7723576 100644 --- a/src/n0061_rotate_list.rs +++ b/src/solution/s0061_rotate_list.rs @@ -26,7 +26,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0062_unique_paths.rs b/src/solution/s0062_unique_paths.rs similarity index 100% rename from src/n0062_unique_paths.rs rename to src/solution/s0062_unique_paths.rs diff --git a/src/n0063_unique_paths_ii.rs b/src/solution/s0063_unique_paths_ii.rs similarity index 100% rename from src/n0063_unique_paths_ii.rs rename to src/solution/s0063_unique_paths_ii.rs diff --git a/src/n0064_minimum_path_sum.rs b/src/solution/s0064_minimum_path_sum.rs similarity index 100% rename from src/n0064_minimum_path_sum.rs rename to src/solution/s0064_minimum_path_sum.rs diff --git a/src/n0065_valid_number.rs b/src/solution/s0065_valid_number.rs similarity index 100% rename from src/n0065_valid_number.rs rename to src/solution/s0065_valid_number.rs diff --git a/src/n0066_plus_one.rs b/src/solution/s0066_plus_one.rs similarity index 100% rename from src/n0066_plus_one.rs rename to src/solution/s0066_plus_one.rs diff --git a/src/n0067_add_binary.rs b/src/solution/s0067_add_binary.rs similarity index 100% rename from src/n0067_add_binary.rs rename to src/solution/s0067_add_binary.rs diff --git a/src/n0068_text_justification.rs b/src/solution/s0068_text_justification.rs similarity index 100% rename from src/n0068_text_justification.rs rename to src/solution/s0068_text_justification.rs diff --git a/src/n0069_sqrtx.rs b/src/solution/s0069_sqrtx.rs similarity index 100% rename from src/n0069_sqrtx.rs rename to src/solution/s0069_sqrtx.rs diff --git a/src/n0070_climbing_stairs.rs b/src/solution/s0070_climbing_stairs.rs similarity index 100% rename from src/n0070_climbing_stairs.rs rename to src/solution/s0070_climbing_stairs.rs diff --git a/src/n0071_simplify_path.rs b/src/solution/s0071_simplify_path.rs similarity index 100% rename from src/n0071_simplify_path.rs rename to src/solution/s0071_simplify_path.rs diff --git a/src/n0072_edit_distance.rs b/src/solution/s0072_edit_distance.rs similarity index 100% rename from src/n0072_edit_distance.rs rename to src/solution/s0072_edit_distance.rs diff --git a/src/n0073_set_matrix_zeroes.rs b/src/solution/s0073_set_matrix_zeroes.rs similarity index 100% rename from src/n0073_set_matrix_zeroes.rs rename to src/solution/s0073_set_matrix_zeroes.rs diff --git a/src/n0074_search_a_2d_matrix.rs b/src/solution/s0074_search_a_2d_matrix.rs similarity index 100% rename from src/n0074_search_a_2d_matrix.rs rename to src/solution/s0074_search_a_2d_matrix.rs diff --git a/src/n0075_sort_colors.rs b/src/solution/s0075_sort_colors.rs similarity index 100% rename from src/n0075_sort_colors.rs rename to src/solution/s0075_sort_colors.rs diff --git a/src/n0076_minimum_window_substring.rs b/src/solution/s0076_minimum_window_substring.rs similarity index 100% rename from src/n0076_minimum_window_substring.rs rename to src/solution/s0076_minimum_window_substring.rs diff --git a/src/n0077_combinations.rs b/src/solution/s0077_combinations.rs similarity index 100% rename from src/n0077_combinations.rs rename to src/solution/s0077_combinations.rs diff --git a/src/n0078_subsets.rs b/src/solution/s0078_subsets.rs similarity index 100% rename from src/n0078_subsets.rs rename to src/solution/s0078_subsets.rs diff --git a/src/n0079_word_search.rs b/src/solution/s0079_word_search.rs similarity index 100% rename from src/n0079_word_search.rs rename to src/solution/s0079_word_search.rs diff --git a/src/n0080_remove_duplicates_from_sorted_array_ii.rs b/src/solution/s0080_remove_duplicates_from_sorted_array_ii.rs similarity index 100% rename from src/n0080_remove_duplicates_from_sorted_array_ii.rs rename to src/solution/s0080_remove_duplicates_from_sorted_array_ii.rs diff --git a/src/n0081_search_in_rotated_sorted_array_ii.rs b/src/solution/s0081_search_in_rotated_sorted_array_ii.rs similarity index 100% rename from src/n0081_search_in_rotated_sorted_array_ii.rs rename to src/solution/s0081_search_in_rotated_sorted_array_ii.rs diff --git a/src/n0082_remove_duplicates_from_sorted_list_ii.rs b/src/solution/s0082_remove_duplicates_from_sorted_list_ii.rs similarity index 94% rename from src/n0082_remove_duplicates_from_sorted_list_ii.rs rename to src/solution/s0082_remove_duplicates_from_sorted_list_ii.rs index ff8c8b8b..d04b15f8 100644 --- a/src/n0082_remove_duplicates_from_sorted_list_ii.rs +++ b/src/solution/s0082_remove_duplicates_from_sorted_list_ii.rs @@ -19,7 +19,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0083_remove_duplicates_from_sorted_list.rs b/src/solution/s0083_remove_duplicates_from_sorted_list.rs similarity index 94% rename from src/n0083_remove_duplicates_from_sorted_list.rs rename to src/solution/s0083_remove_duplicates_from_sorted_list.rs index b8fa539f..785cc03f 100644 --- a/src/n0083_remove_duplicates_from_sorted_list.rs +++ b/src/solution/s0083_remove_duplicates_from_sorted_list.rs @@ -19,7 +19,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0084_largest_rectangle_in_histogram.rs b/src/solution/s0084_largest_rectangle_in_histogram.rs similarity index 100% rename from src/n0084_largest_rectangle_in_histogram.rs rename to src/solution/s0084_largest_rectangle_in_histogram.rs diff --git a/src/n0085_maximal_rectangle.rs b/src/solution/s0085_maximal_rectangle.rs similarity index 100% rename from src/n0085_maximal_rectangle.rs rename to src/solution/s0085_maximal_rectangle.rs diff --git a/src/n0086_partition_list.rs b/src/solution/s0086_partition_list.rs similarity index 97% rename from src/n0086_partition_list.rs rename to src/solution/s0086_partition_list.rs index ad03b081..4238586f 100644 --- a/src/n0086_partition_list.rs +++ b/src/solution/s0086_partition_list.rs @@ -14,7 +14,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; impl Solution { pub fn partition(head: Option>, x: i32) -> Option> { diff --git a/src/n0087_scramble_string.rs b/src/solution/s0087_scramble_string.rs similarity index 100% rename from src/n0087_scramble_string.rs rename to src/solution/s0087_scramble_string.rs diff --git a/src/n0088_merge_sorted_array.rs b/src/solution/s0088_merge_sorted_array.rs similarity index 100% rename from src/n0088_merge_sorted_array.rs rename to src/solution/s0088_merge_sorted_array.rs diff --git a/src/n0089_gray_code.rs b/src/solution/s0089_gray_code.rs similarity index 100% rename from src/n0089_gray_code.rs rename to src/solution/s0089_gray_code.rs diff --git a/src/n0090_subsets_ii.rs b/src/solution/s0090_subsets_ii.rs similarity index 100% rename from src/n0090_subsets_ii.rs rename to src/solution/s0090_subsets_ii.rs diff --git a/src/n0091_decode_ways.rs b/src/solution/s0091_decode_ways.rs similarity index 100% rename from src/n0091_decode_ways.rs rename to src/solution/s0091_decode_ways.rs diff --git a/src/n0092_reverse_linked_list_ii.rs b/src/solution/s0092_reverse_linked_list_ii.rs similarity index 94% rename from src/n0092_reverse_linked_list_ii.rs rename to src/solution/s0092_reverse_linked_list_ii.rs index 705a7875..e84035da 100644 --- a/src/n0092_reverse_linked_list_ii.rs +++ b/src/solution/s0092_reverse_linked_list_ii.rs @@ -14,7 +14,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0093_restore_ip_addresses.rs b/src/solution/s0093_restore_ip_addresses.rs similarity index 100% rename from src/n0093_restore_ip_addresses.rs rename to src/solution/s0093_restore_ip_addresses.rs diff --git a/src/n0094_binary_tree_inorder_traversal.rs b/src/solution/s0094_binary_tree_inorder_traversal.rs similarity index 96% rename from src/n0094_binary_tree_inorder_traversal.rs rename to src/solution/s0094_binary_tree_inorder_traversal.rs index c40cd1c8..d4d2ea2a 100644 --- a/src/n0094_binary_tree_inorder_traversal.rs +++ b/src/solution/s0094_binary_tree_inorder_traversal.rs @@ -22,7 +22,7 @@ pub struct Solution {} // submission codes start here -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; use std::cell::RefCell; use std::rc::Rc; impl Solution { diff --git a/src/n0095_unique_binary_search_trees_ii.rs b/src/solution/s0095_unique_binary_search_trees_ii.rs similarity index 97% rename from src/n0095_unique_binary_search_trees_ii.rs rename to src/solution/s0095_unique_binary_search_trees_ii.rs index 3ab366e4..ffdc763b 100644 --- a/src/n0095_unique_binary_search_trees_ii.rs +++ b/src/solution/s0095_unique_binary_search_trees_ii.rs @@ -48,7 +48,7 @@ pub struct Solution {} / \ 2 4 */ -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; use std::cell::RefCell; use std::rc::Rc; impl Solution { diff --git a/src/n0096_unique_binary_search_trees.rs b/src/solution/s0096_unique_binary_search_trees.rs similarity index 100% rename from src/n0096_unique_binary_search_trees.rs rename to src/solution/s0096_unique_binary_search_trees.rs diff --git a/src/n0097_interleaving_string.rs b/src/solution/s0097_interleaving_string.rs similarity index 100% rename from src/n0097_interleaving_string.rs rename to src/solution/s0097_interleaving_string.rs diff --git a/src/n0098_validate_binary_search_tree.rs b/src/solution/s0098_validate_binary_search_tree.rs similarity index 98% rename from src/n0098_validate_binary_search_tree.rs rename to src/solution/s0098_validate_binary_search_tree.rs index fcb359ee..7f55a47e 100644 --- a/src/n0098_validate_binary_search_tree.rs +++ b/src/solution/s0098_validate_binary_search_tree.rs @@ -40,7 +40,7 @@ pub struct Solution {} // submission codes start here // Definition for a binary tree node. -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; use std::cell::RefCell; use std::rc::Rc; diff --git a/src/n0099_recover_binary_search_tree.rs b/src/solution/s0099_recover_binary_search_tree.rs similarity index 95% rename from src/n0099_recover_binary_search_tree.rs rename to src/solution/s0099_recover_binary_search_tree.rs index 8bc39b3d..3b92da04 100644 --- a/src/n0099_recover_binary_search_tree.rs +++ b/src/solution/s0099_recover_binary_search_tree.rs @@ -55,7 +55,7 @@ */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0100_same_tree.rs b/src/solution/s0100_same_tree.rs similarity index 96% rename from src/n0100_same_tree.rs rename to src/solution/s0100_same_tree.rs index 51b7ad79..f1ca1972 100644 --- a/src/n0100_same_tree.rs +++ b/src/solution/s0100_same_tree.rs @@ -44,7 +44,7 @@ */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here use std::cell::RefCell; use std::rc::Rc; diff --git a/src/n0101_symmetric_tree.rs b/src/solution/s0101_symmetric_tree.rs similarity index 97% rename from src/n0101_symmetric_tree.rs rename to src/solution/s0101_symmetric_tree.rs index d341ff34..c62962d2 100644 --- a/src/n0101_symmetric_tree.rs +++ b/src/solution/s0101_symmetric_tree.rs @@ -30,7 +30,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0102_binary_tree_level_order_traversal.rs b/src/solution/s0102_binary_tree_level_order_traversal.rs similarity index 97% rename from src/n0102_binary_tree_level_order_traversal.rs rename to src/solution/s0102_binary_tree_level_order_traversal.rs index 6fdabf6e..42f782a5 100644 --- a/src/n0102_binary_tree_level_order_traversal.rs +++ b/src/solution/s0102_binary_tree_level_order_traversal.rs @@ -26,7 +26,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0103_binary_tree_zigzag_level_order_traversal.rs b/src/solution/s0103_binary_tree_zigzag_level_order_traversal.rs similarity index 97% rename from src/n0103_binary_tree_zigzag_level_order_traversal.rs rename to src/solution/s0103_binary_tree_zigzag_level_order_traversal.rs index ce31b6b8..96476fda 100644 --- a/src/n0103_binary_tree_zigzag_level_order_traversal.rs +++ b/src/solution/s0103_binary_tree_zigzag_level_order_traversal.rs @@ -26,7 +26,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0104_maximum_depth_of_binary_tree.rs b/src/solution/s0104_maximum_depth_of_binary_tree.rs similarity index 96% rename from src/n0104_maximum_depth_of_binary_tree.rs rename to src/solution/s0104_maximum_depth_of_binary_tree.rs index c5faf233..6d2f18e6 100644 --- a/src/n0104_maximum_depth_of_binary_tree.rs +++ b/src/solution/s0104_maximum_depth_of_binary_tree.rs @@ -22,7 +22,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0105_construct_binary_tree_from_preorder_and_inorder_traversal.rs b/src/solution/s0105_construct_binary_tree_from_preorder_and_inorder_traversal.rs similarity index 97% rename from src/n0105_construct_binary_tree_from_preorder_and_inorder_traversal.rs rename to src/solution/s0105_construct_binary_tree_from_preorder_and_inorder_traversal.rs index 611725de..e271faa5 100644 --- a/src/n0105_construct_binary_tree_from_preorder_and_inorder_traversal.rs +++ b/src/solution/s0105_construct_binary_tree_from_preorder_and_inorder_traversal.rs @@ -23,7 +23,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0106_construct_binary_tree_from_inorder_and_postorder_traversal.rs b/src/solution/s0106_construct_binary_tree_from_inorder_and_postorder_traversal.rs similarity index 97% rename from src/n0106_construct_binary_tree_from_inorder_and_postorder_traversal.rs rename to src/solution/s0106_construct_binary_tree_from_inorder_and_postorder_traversal.rs index 7d3e820c..63c469be 100644 --- a/src/n0106_construct_binary_tree_from_inorder_and_postorder_traversal.rs +++ b/src/solution/s0106_construct_binary_tree_from_inorder_and_postorder_traversal.rs @@ -24,7 +24,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0107_binary_tree_level_order_traversal_ii.rs b/src/solution/s0107_binary_tree_level_order_traversal_ii.rs similarity index 97% rename from src/n0107_binary_tree_level_order_traversal_ii.rs rename to src/solution/s0107_binary_tree_level_order_traversal_ii.rs index 42855964..f77229a6 100644 --- a/src/n0107_binary_tree_level_order_traversal_ii.rs +++ b/src/solution/s0107_binary_tree_level_order_traversal_ii.rs @@ -26,7 +26,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0108_convert_sorted_array_to_binary_search_tree.rs b/src/solution/s0108_convert_sorted_array_to_binary_search_tree.rs similarity index 97% rename from src/n0108_convert_sorted_array_to_binary_search_tree.rs rename to src/solution/s0108_convert_sorted_array_to_binary_search_tree.rs index 4da33781..67e4b2ac 100644 --- a/src/n0108_convert_sorted_array_to_binary_search_tree.rs +++ b/src/solution/s0108_convert_sorted_array_to_binary_search_tree.rs @@ -21,7 +21,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0109_convert_sorted_list_to_binary_search_tree.rs b/src/solution/s0109_convert_sorted_list_to_binary_search_tree.rs similarity index 94% rename from src/n0109_convert_sorted_list_to_binary_search_tree.rs rename to src/solution/s0109_convert_sorted_list_to_binary_search_tree.rs index 072c6eac..6bb37b0e 100644 --- a/src/n0109_convert_sorted_list_to_binary_search_tree.rs +++ b/src/solution/s0109_convert_sorted_list_to_binary_search_tree.rs @@ -21,8 +21,8 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; -use super::util::tree::{to_tree, TreeNode}; +use crate::util::linked_list::{to_list, ListNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0110_balanced_binary_tree.rs b/src/solution/s0110_balanced_binary_tree.rs similarity index 93% rename from src/n0110_balanced_binary_tree.rs rename to src/solution/s0110_balanced_binary_tree.rs index 68e1b2ad..bb067d02 100644 --- a/src/n0110_balanced_binary_tree.rs +++ b/src/solution/s0110_balanced_binary_tree.rs @@ -40,7 +40,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0111_minimum_depth_of_binary_tree.rs b/src/solution/s0111_minimum_depth_of_binary_tree.rs similarity index 96% rename from src/n0111_minimum_depth_of_binary_tree.rs rename to src/solution/s0111_minimum_depth_of_binary_tree.rs index f537c316..1efb759d 100644 --- a/src/n0111_minimum_depth_of_binary_tree.rs +++ b/src/solution/s0111_minimum_depth_of_binary_tree.rs @@ -22,7 +22,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0112_path_sum.rs b/src/solution/s0112_path_sum.rs similarity index 97% rename from src/n0112_path_sum.rs rename to src/solution/s0112_path_sum.rs index 72e34da0..2f036b21 100644 --- a/src/n0112_path_sum.rs +++ b/src/solution/s0112_path_sum.rs @@ -23,7 +23,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0113_path_sum_ii.rs b/src/solution/s0113_path_sum_ii.rs similarity index 97% rename from src/n0113_path_sum_ii.rs rename to src/solution/s0113_path_sum_ii.rs index c9914e08..d567e693 100644 --- a/src/n0113_path_sum_ii.rs +++ b/src/solution/s0113_path_sum_ii.rs @@ -30,7 +30,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0114_flatten_binary_tree_to_linked_list.rs b/src/solution/s0114_flatten_binary_tree_to_linked_list.rs similarity index 97% rename from src/n0114_flatten_binary_tree_to_linked_list.rs rename to src/solution/s0114_flatten_binary_tree_to_linked_list.rs index 2b46cd42..9661e9e7 100644 --- a/src/n0114_flatten_binary_tree_to_linked_list.rs +++ b/src/solution/s0114_flatten_binary_tree_to_linked_list.rs @@ -31,7 +31,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0115_distinct_subsequences.rs b/src/solution/s0115_distinct_subsequences.rs similarity index 100% rename from src/n0115_distinct_subsequences.rs rename to src/solution/s0115_distinct_subsequences.rs diff --git a/src/n0118_pascals_triangle.rs b/src/solution/s0118_pascals_triangle.rs similarity index 100% rename from src/n0118_pascals_triangle.rs rename to src/solution/s0118_pascals_triangle.rs diff --git a/src/n0119_pascals_triangle_ii.rs b/src/solution/s0119_pascals_triangle_ii.rs similarity index 100% rename from src/n0119_pascals_triangle_ii.rs rename to src/solution/s0119_pascals_triangle_ii.rs diff --git a/src/n0120_triangle.rs b/src/solution/s0120_triangle.rs similarity index 100% rename from src/n0120_triangle.rs rename to src/solution/s0120_triangle.rs diff --git a/src/n0121_best_time_to_buy_and_sell_stock.rs b/src/solution/s0121_best_time_to_buy_and_sell_stock.rs similarity index 100% rename from src/n0121_best_time_to_buy_and_sell_stock.rs rename to src/solution/s0121_best_time_to_buy_and_sell_stock.rs diff --git a/src/n0122_best_time_to_buy_and_sell_stock_ii.rs b/src/solution/s0122_best_time_to_buy_and_sell_stock_ii.rs similarity index 100% rename from src/n0122_best_time_to_buy_and_sell_stock_ii.rs rename to src/solution/s0122_best_time_to_buy_and_sell_stock_ii.rs diff --git a/src/n0123_best_time_to_buy_and_sell_stock_iii.rs b/src/solution/s0123_best_time_to_buy_and_sell_stock_iii.rs similarity index 100% rename from src/n0123_best_time_to_buy_and_sell_stock_iii.rs rename to src/solution/s0123_best_time_to_buy_and_sell_stock_iii.rs diff --git a/src/n0124_binary_tree_maximum_path_sum.rs b/src/solution/s0124_binary_tree_maximum_path_sum.rs similarity index 98% rename from src/n0124_binary_tree_maximum_path_sum.rs rename to src/solution/s0124_binary_tree_maximum_path_sum.rs index 5517d18f..f76f3178 100644 --- a/src/n0124_binary_tree_maximum_path_sum.rs +++ b/src/solution/s0124_binary_tree_maximum_path_sum.rs @@ -33,7 +33,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0125_valid_palindrome.rs b/src/solution/s0125_valid_palindrome.rs similarity index 100% rename from src/n0125_valid_palindrome.rs rename to src/solution/s0125_valid_palindrome.rs diff --git a/src/n0126_word_ladder_ii.rs b/src/solution/s0126_word_ladder_ii.rs similarity index 100% rename from src/n0126_word_ladder_ii.rs rename to src/solution/s0126_word_ladder_ii.rs diff --git a/src/n0127_word_ladder.rs b/src/solution/s0127_word_ladder.rs similarity index 100% rename from src/n0127_word_ladder.rs rename to src/solution/s0127_word_ladder.rs diff --git a/src/n0128_longest_consecutive_sequence.rs b/src/solution/s0128_longest_consecutive_sequence.rs similarity index 100% rename from src/n0128_longest_consecutive_sequence.rs rename to src/solution/s0128_longest_consecutive_sequence.rs diff --git a/src/n0129_sum_root_to_leaf_numbers.rs b/src/solution/s0129_sum_root_to_leaf_numbers.rs similarity index 97% rename from src/n0129_sum_root_to_leaf_numbers.rs rename to src/solution/s0129_sum_root_to_leaf_numbers.rs index 5e423c34..c52dc94c 100644 --- a/src/n0129_sum_root_to_leaf_numbers.rs +++ b/src/solution/s0129_sum_root_to_leaf_numbers.rs @@ -40,7 +40,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0130_surrounded_regions.rs b/src/solution/s0130_surrounded_regions.rs similarity index 100% rename from src/n0130_surrounded_regions.rs rename to src/solution/s0130_surrounded_regions.rs diff --git a/src/n0131_palindrome_partitioning.rs b/src/solution/s0131_palindrome_partitioning.rs similarity index 100% rename from src/n0131_palindrome_partitioning.rs rename to src/solution/s0131_palindrome_partitioning.rs diff --git a/src/n0132_palindrome_partitioning_ii.rs b/src/solution/s0132_palindrome_partitioning_ii.rs similarity index 100% rename from src/n0132_palindrome_partitioning_ii.rs rename to src/solution/s0132_palindrome_partitioning_ii.rs diff --git a/src/n0134_gas_station.rs b/src/solution/s0134_gas_station.rs similarity index 100% rename from src/n0134_gas_station.rs rename to src/solution/s0134_gas_station.rs diff --git a/src/n0135_candy.rs b/src/solution/s0135_candy.rs similarity index 100% rename from src/n0135_candy.rs rename to src/solution/s0135_candy.rs diff --git a/src/n0136_single_number.rs b/src/solution/s0136_single_number.rs similarity index 100% rename from src/n0136_single_number.rs rename to src/solution/s0136_single_number.rs diff --git a/src/n0137_single_number_ii.rs b/src/solution/s0137_single_number_ii.rs similarity index 100% rename from src/n0137_single_number_ii.rs rename to src/solution/s0137_single_number_ii.rs diff --git a/src/n0139_word_break.rs b/src/solution/s0139_word_break.rs similarity index 100% rename from src/n0139_word_break.rs rename to src/solution/s0139_word_break.rs diff --git a/src/n0140_word_break_ii.rs b/src/solution/s0140_word_break_ii.rs similarity index 100% rename from src/n0140_word_break_ii.rs rename to src/solution/s0140_word_break_ii.rs diff --git a/src/n0143_reorder_list.rs b/src/solution/s0143_reorder_list.rs similarity index 93% rename from src/n0143_reorder_list.rs rename to src/solution/s0143_reorder_list.rs index 169c44d1..06ec32af 100644 --- a/src/n0143_reorder_list.rs +++ b/src/solution/s0143_reorder_list.rs @@ -19,7 +19,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0144_binary_tree_preorder_traversal.rs b/src/solution/s0144_binary_tree_preorder_traversal.rs similarity index 96% rename from src/n0144_binary_tree_preorder_traversal.rs rename to src/solution/s0144_binary_tree_preorder_traversal.rs index 951014c6..02ed1f7a 100644 --- a/src/n0144_binary_tree_preorder_traversal.rs +++ b/src/solution/s0144_binary_tree_preorder_traversal.rs @@ -20,7 +20,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0145_binary_tree_postorder_traversal.rs b/src/solution/s0145_binary_tree_postorder_traversal.rs similarity index 96% rename from src/n0145_binary_tree_postorder_traversal.rs rename to src/solution/s0145_binary_tree_postorder_traversal.rs index 66495658..2670b5bd 100644 --- a/src/n0145_binary_tree_postorder_traversal.rs +++ b/src/solution/s0145_binary_tree_postorder_traversal.rs @@ -20,7 +20,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0146_lru_cache.rs b/src/solution/s0146_lru_cache.rs similarity index 100% rename from src/n0146_lru_cache.rs rename to src/solution/s0146_lru_cache.rs diff --git a/src/n0147_insertion_sort_list.rs b/src/solution/s0147_insertion_sort_list.rs similarity index 96% rename from src/n0147_insertion_sort_list.rs rename to src/solution/s0147_insertion_sort_list.rs index edcd0787..cdcd2d69 100644 --- a/src/n0147_insertion_sort_list.rs +++ b/src/solution/s0147_insertion_sort_list.rs @@ -9,7 +9,7 @@ *
* A graphical example of insertion sort. The partial sorted list (black) initially contains only the first element in the list.
* With each iteration one element (red) is removed from the input data and inserted in-place into the sorted list

- * + * * *
    *
@@ -39,7 +39,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0148_sort_list.rs b/src/solution/s0148_sort_list.rs similarity index 98% rename from src/n0148_sort_list.rs rename to src/solution/s0148_sort_list.rs index 5fd6a8a2..4bc8ac17 100644 --- a/src/n0148_sort_list.rs +++ b/src/solution/s0148_sort_list.rs @@ -18,7 +18,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0149_max_points_on_a_line.rs b/src/solution/s0149_max_points_on_a_line.rs similarity index 95% rename from src/n0149_max_points_on_a_line.rs rename to src/solution/s0149_max_points_on_a_line.rs index dff94777..c2faf93b 100644 --- a/src/n0149_max_points_on_a_line.rs +++ b/src/solution/s0149_max_points_on_a_line.rs @@ -13,7 +13,7 @@ * | * | o * | o - * | o + * | o * +-------------> * 0 1 2 3 4 * @@ -36,7 +36,7 @@ * */ pub struct Solution {} -use super::util::point::Point; +use crate::util::point::Point; /* 要回顾下高中数学:已知两点, 求解一般式: diff --git a/src/n0150_evaluate_reverse_polish_notation.rs b/src/solution/s0150_evaluate_reverse_polish_notation.rs similarity index 100% rename from src/n0150_evaluate_reverse_polish_notation.rs rename to src/solution/s0150_evaluate_reverse_polish_notation.rs diff --git a/src/n0151_reverse_words_in_a_string.rs b/src/solution/s0151_reverse_words_in_a_string.rs similarity index 100% rename from src/n0151_reverse_words_in_a_string.rs rename to src/solution/s0151_reverse_words_in_a_string.rs diff --git a/src/n0152_maximum_product_subarray.rs b/src/solution/s0152_maximum_product_subarray.rs similarity index 100% rename from src/n0152_maximum_product_subarray.rs rename to src/solution/s0152_maximum_product_subarray.rs diff --git a/src/n0153_find_minimum_in_rotated_sorted_array.rs b/src/solution/s0153_find_minimum_in_rotated_sorted_array.rs similarity index 100% rename from src/n0153_find_minimum_in_rotated_sorted_array.rs rename to src/solution/s0153_find_minimum_in_rotated_sorted_array.rs diff --git a/src/n0154_find_minimum_in_rotated_sorted_array_ii.rs b/src/solution/s0154_find_minimum_in_rotated_sorted_array_ii.rs similarity index 100% rename from src/n0154_find_minimum_in_rotated_sorted_array_ii.rs rename to src/solution/s0154_find_minimum_in_rotated_sorted_array_ii.rs diff --git a/src/n0155_min_stack.rs b/src/solution/s0155_min_stack.rs similarity index 100% rename from src/n0155_min_stack.rs rename to src/solution/s0155_min_stack.rs diff --git a/src/n0162_find_peak_element.rs b/src/solution/s0162_find_peak_element.rs similarity index 100% rename from src/n0162_find_peak_element.rs rename to src/solution/s0162_find_peak_element.rs diff --git a/src/n0164_maximum_gap.rs b/src/solution/s0164_maximum_gap.rs similarity index 100% rename from src/n0164_maximum_gap.rs rename to src/solution/s0164_maximum_gap.rs diff --git a/src/n0165_compare_version_numbers.rs b/src/solution/s0165_compare_version_numbers.rs similarity index 100% rename from src/n0165_compare_version_numbers.rs rename to src/solution/s0165_compare_version_numbers.rs diff --git a/src/n0166_fraction_to_recurring_decimal.rs b/src/solution/s0166_fraction_to_recurring_decimal.rs similarity index 100% rename from src/n0166_fraction_to_recurring_decimal.rs rename to src/solution/s0166_fraction_to_recurring_decimal.rs diff --git a/src/n0167_two_sum_ii_input_array_is_sorted.rs b/src/solution/s0167_two_sum_ii_input_array_is_sorted.rs similarity index 100% rename from src/n0167_two_sum_ii_input_array_is_sorted.rs rename to src/solution/s0167_two_sum_ii_input_array_is_sorted.rs diff --git a/src/n0168_excel_sheet_column_title.rs b/src/solution/s0168_excel_sheet_column_title.rs similarity index 100% rename from src/n0168_excel_sheet_column_title.rs rename to src/solution/s0168_excel_sheet_column_title.rs diff --git a/src/n0169_majority_element.rs b/src/solution/s0169_majority_element.rs similarity index 100% rename from src/n0169_majority_element.rs rename to src/solution/s0169_majority_element.rs diff --git a/src/n0171_excel_sheet_column_number.rs b/src/solution/s0171_excel_sheet_column_number.rs similarity index 100% rename from src/n0171_excel_sheet_column_number.rs rename to src/solution/s0171_excel_sheet_column_number.rs diff --git a/src/n0172_factorial_trailing_zeroes.rs b/src/solution/s0172_factorial_trailing_zeroes.rs similarity index 100% rename from src/n0172_factorial_trailing_zeroes.rs rename to src/solution/s0172_factorial_trailing_zeroes.rs diff --git a/src/n0173_binary_search_tree_iterator.rs b/src/solution/s0173_binary_search_tree_iterator.rs similarity index 94% rename from src/n0173_binary_search_tree_iterator.rs rename to src/solution/s0173_binary_search_tree_iterator.rs index 582e922a..caef4724 100644 --- a/src/n0173_binary_search_tree_iterator.rs +++ b/src/solution/s0173_binary_search_tree_iterator.rs @@ -5,7 +5,7 @@ * * Calling next() will return the next smallest number in the BST. * - * + * * * * @@ -27,7 +27,7 @@ * iterator.hasNext(); // return false * * - * + * * * Note: * @@ -38,7 +38,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; use std::cell::RefCell; use std::rc::Rc; diff --git a/src/n0174_dungeon_game.rs b/src/solution/s0174_dungeon_game.rs similarity index 100% rename from src/n0174_dungeon_game.rs rename to src/solution/s0174_dungeon_game.rs diff --git a/src/n0179_largest_number.rs b/src/solution/s0179_largest_number.rs similarity index 100% rename from src/n0179_largest_number.rs rename to src/solution/s0179_largest_number.rs diff --git a/src/n0187_repeated_dna_sequences.rs b/src/solution/s0187_repeated_dna_sequences.rs similarity index 100% rename from src/n0187_repeated_dna_sequences.rs rename to src/solution/s0187_repeated_dna_sequences.rs diff --git a/src/n0188_best_time_to_buy_and_sell_stock_iv.rs b/src/solution/s0188_best_time_to_buy_and_sell_stock_iv.rs similarity index 100% rename from src/n0188_best_time_to_buy_and_sell_stock_iv.rs rename to src/solution/s0188_best_time_to_buy_and_sell_stock_iv.rs diff --git a/src/n0189_rotate_array.rs b/src/solution/s0189_rotate_array.rs similarity index 100% rename from src/n0189_rotate_array.rs rename to src/solution/s0189_rotate_array.rs diff --git a/src/n0198_house_robber.rs b/src/solution/s0198_house_robber.rs similarity index 100% rename from src/n0198_house_robber.rs rename to src/solution/s0198_house_robber.rs diff --git a/src/n0199_binary_tree_right_side_view.rs b/src/solution/s0199_binary_tree_right_side_view.rs similarity index 97% rename from src/n0199_binary_tree_right_side_view.rs rename to src/solution/s0199_binary_tree_right_side_view.rs index 403a3404..c580970c 100644 --- a/src/n0199_binary_tree_right_side_view.rs +++ b/src/solution/s0199_binary_tree_right_side_view.rs @@ -18,7 +18,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0200_number_of_islands.rs b/src/solution/s0200_number_of_islands.rs similarity index 100% rename from src/n0200_number_of_islands.rs rename to src/solution/s0200_number_of_islands.rs diff --git a/src/n0201_bitwise_and_of_numbers_range.rs b/src/solution/s0201_bitwise_and_of_numbers_range.rs similarity index 100% rename from src/n0201_bitwise_and_of_numbers_range.rs rename to src/solution/s0201_bitwise_and_of_numbers_range.rs diff --git a/src/n0202_happy_number.rs b/src/solution/s0202_happy_number.rs similarity index 100% rename from src/n0202_happy_number.rs rename to src/solution/s0202_happy_number.rs diff --git a/src/n0203_remove_linked_list_elements.rs b/src/solution/s0203_remove_linked_list_elements.rs similarity index 95% rename from src/n0203_remove_linked_list_elements.rs rename to src/solution/s0203_remove_linked_list_elements.rs index 290923d6..f8d9bc43 100644 --- a/src/n0203_remove_linked_list_elements.rs +++ b/src/solution/s0203_remove_linked_list_elements.rs @@ -12,7 +12,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0204_count_primes.rs b/src/solution/s0204_count_primes.rs similarity index 100% rename from src/n0204_count_primes.rs rename to src/solution/s0204_count_primes.rs diff --git a/src/n0205_isomorphic_strings.rs b/src/solution/s0205_isomorphic_strings.rs similarity index 100% rename from src/n0205_isomorphic_strings.rs rename to src/solution/s0205_isomorphic_strings.rs diff --git a/src/n0206_reverse_linked_list.rs b/src/solution/s0206_reverse_linked_list.rs similarity index 94% rename from src/n0206_reverse_linked_list.rs rename to src/solution/s0206_reverse_linked_list.rs index bdbe34e4..4689f415 100644 --- a/src/n0206_reverse_linked_list.rs +++ b/src/solution/s0206_reverse_linked_list.rs @@ -16,7 +16,7 @@ * */ pub struct Solution {} -use super::util::linked_list::{to_list, ListNode}; +use crate::util::linked_list::{to_list, ListNode}; // submission codes start here diff --git a/src/n0207_course_schedule.rs b/src/solution/s0207_course_schedule.rs similarity index 100% rename from src/n0207_course_schedule.rs rename to src/solution/s0207_course_schedule.rs diff --git a/src/n0208_implement_trie_prefix_tree.rs b/src/solution/s0208_implement_trie_prefix_tree.rs similarity index 100% rename from src/n0208_implement_trie_prefix_tree.rs rename to src/solution/s0208_implement_trie_prefix_tree.rs diff --git a/src/n0209_minimum_size_subarray_sum.rs b/src/solution/s0209_minimum_size_subarray_sum.rs similarity index 100% rename from src/n0209_minimum_size_subarray_sum.rs rename to src/solution/s0209_minimum_size_subarray_sum.rs diff --git a/src/n0210_course_schedule_ii.rs b/src/solution/s0210_course_schedule_ii.rs similarity index 100% rename from src/n0210_course_schedule_ii.rs rename to src/solution/s0210_course_schedule_ii.rs diff --git a/src/n0211_add_and_search_word_data_structure_design.rs b/src/solution/s0211_add_and_search_word_data_structure_design.rs similarity index 100% rename from src/n0211_add_and_search_word_data_structure_design.rs rename to src/solution/s0211_add_and_search_word_data_structure_design.rs diff --git a/src/n0212_word_search_ii.rs b/src/solution/s0212_word_search_ii.rs similarity index 100% rename from src/n0212_word_search_ii.rs rename to src/solution/s0212_word_search_ii.rs diff --git a/src/n0213_house_robber_ii.rs b/src/solution/s0213_house_robber_ii.rs similarity index 100% rename from src/n0213_house_robber_ii.rs rename to src/solution/s0213_house_robber_ii.rs diff --git a/src/n0214_shortest_palindrome.rs b/src/solution/s0214_shortest_palindrome.rs similarity index 100% rename from src/n0214_shortest_palindrome.rs rename to src/solution/s0214_shortest_palindrome.rs diff --git a/src/n0215_kth_largest_element_in_an_array.rs b/src/solution/s0215_kth_largest_element_in_an_array.rs similarity index 100% rename from src/n0215_kth_largest_element_in_an_array.rs rename to src/solution/s0215_kth_largest_element_in_an_array.rs diff --git a/src/n0216_combination_sum_iii.rs b/src/solution/s0216_combination_sum_iii.rs similarity index 100% rename from src/n0216_combination_sum_iii.rs rename to src/solution/s0216_combination_sum_iii.rs diff --git a/src/n0217_contains_duplicate.rs b/src/solution/s0217_contains_duplicate.rs similarity index 100% rename from src/n0217_contains_duplicate.rs rename to src/solution/s0217_contains_duplicate.rs diff --git a/src/n0218_the_skyline_problem.rs b/src/solution/s0218_the_skyline_problem.rs similarity index 100% rename from src/n0218_the_skyline_problem.rs rename to src/solution/s0218_the_skyline_problem.rs diff --git a/src/n0219_contains_duplicate_ii.rs b/src/solution/s0219_contains_duplicate_ii.rs similarity index 100% rename from src/n0219_contains_duplicate_ii.rs rename to src/solution/s0219_contains_duplicate_ii.rs diff --git a/src/n0220_contains_duplicate_iii.rs b/src/solution/s0220_contains_duplicate_iii.rs similarity index 100% rename from src/n0220_contains_duplicate_iii.rs rename to src/solution/s0220_contains_duplicate_iii.rs diff --git a/src/n0221_maximal_square.rs b/src/solution/s0221_maximal_square.rs similarity index 100% rename from src/n0221_maximal_square.rs rename to src/solution/s0221_maximal_square.rs diff --git a/src/n0222_count_complete_tree_nodes.rs b/src/solution/s0222_count_complete_tree_nodes.rs similarity index 98% rename from src/n0222_count_complete_tree_nodes.rs rename to src/solution/s0222_count_complete_tree_nodes.rs index c511399d..189fb3dd 100644 --- a/src/n0222_count_complete_tree_nodes.rs +++ b/src/solution/s0222_count_complete_tree_nodes.rs @@ -22,7 +22,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0223_rectangle_area.rs b/src/solution/s0223_rectangle_area.rs similarity index 100% rename from src/n0223_rectangle_area.rs rename to src/solution/s0223_rectangle_area.rs diff --git a/src/n0224_basic_calculator.rs b/src/solution/s0224_basic_calculator.rs similarity index 100% rename from src/n0224_basic_calculator.rs rename to src/solution/s0224_basic_calculator.rs diff --git a/src/n0225_implement_stack_using_queues.rs b/src/solution/s0225_implement_stack_using_queues.rs similarity index 100% rename from src/n0225_implement_stack_using_queues.rs rename to src/solution/s0225_implement_stack_using_queues.rs diff --git a/src/n0226_invert_binary_tree.rs b/src/solution/s0226_invert_binary_tree.rs similarity index 97% rename from src/n0226_invert_binary_tree.rs rename to src/solution/s0226_invert_binary_tree.rs index 29e2a953..30bd001a 100644 --- a/src/n0226_invert_binary_tree.rs +++ b/src/solution/s0226_invert_binary_tree.rs @@ -30,7 +30,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0227_basic_calculator_ii.rs b/src/solution/s0227_basic_calculator_ii.rs similarity index 100% rename from src/n0227_basic_calculator_ii.rs rename to src/solution/s0227_basic_calculator_ii.rs diff --git a/src/n0228_summary_ranges.rs b/src/solution/s0228_summary_ranges.rs similarity index 100% rename from src/n0228_summary_ranges.rs rename to src/solution/s0228_summary_ranges.rs diff --git a/src/n0229_majority_element_ii.rs b/src/solution/s0229_majority_element_ii.rs similarity index 100% rename from src/n0229_majority_element_ii.rs rename to src/solution/s0229_majority_element_ii.rs diff --git a/src/n0230_kth_smallest_element_in_a_bst.rs b/src/solution/s0230_kth_smallest_element_in_a_bst.rs similarity index 97% rename from src/n0230_kth_smallest_element_in_a_bst.rs rename to src/solution/s0230_kth_smallest_element_in_a_bst.rs index 65de4484..fe14721f 100644 --- a/src/n0230_kth_smallest_element_in_a_bst.rs +++ b/src/solution/s0230_kth_smallest_element_in_a_bst.rs @@ -36,7 +36,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0231_power_of_two.rs b/src/solution/s0231_power_of_two.rs similarity index 100% rename from src/n0231_power_of_two.rs rename to src/solution/s0231_power_of_two.rs diff --git a/src/n0232_implement_queue_using_stacks.rs b/src/solution/s0232_implement_queue_using_stacks.rs similarity index 100% rename from src/n0232_implement_queue_using_stacks.rs rename to src/solution/s0232_implement_queue_using_stacks.rs diff --git a/src/n0233_number_of_digit_one.rs b/src/solution/s0233_number_of_digit_one.rs similarity index 100% rename from src/n0233_number_of_digit_one.rs rename to src/solution/s0233_number_of_digit_one.rs diff --git a/src/n0238_product_of_array_except_self.rs b/src/solution/s0238_product_of_array_except_self.rs similarity index 100% rename from src/n0238_product_of_array_except_self.rs rename to src/solution/s0238_product_of_array_except_self.rs diff --git a/src/n0239_sliding_window_maximum.rs b/src/solution/s0239_sliding_window_maximum.rs similarity index 100% rename from src/n0239_sliding_window_maximum.rs rename to src/solution/s0239_sliding_window_maximum.rs diff --git a/src/n0241_different_ways_to_add_parentheses.rs b/src/solution/s0241_different_ways_to_add_parentheses.rs similarity index 100% rename from src/n0241_different_ways_to_add_parentheses.rs rename to src/solution/s0241_different_ways_to_add_parentheses.rs diff --git a/src/n0242_valid_anagram.rs b/src/solution/s0242_valid_anagram.rs similarity index 100% rename from src/n0242_valid_anagram.rs rename to src/solution/s0242_valid_anagram.rs diff --git a/src/n0257_binary_tree_paths.rs b/src/solution/s0257_binary_tree_paths.rs similarity index 97% rename from src/n0257_binary_tree_paths.rs rename to src/solution/s0257_binary_tree_paths.rs index ef5254c9..c5d6d336 100644 --- a/src/n0257_binary_tree_paths.rs +++ b/src/solution/s0257_binary_tree_paths.rs @@ -22,7 +22,7 @@ * */ pub struct Solution {} -use super::util::tree::{to_tree, TreeNode}; +use crate::util::tree::{to_tree, TreeNode}; // submission codes start here diff --git a/src/n0258_add_digits.rs b/src/solution/s0258_add_digits.rs similarity index 100% rename from src/n0258_add_digits.rs rename to src/solution/s0258_add_digits.rs diff --git a/src/n0260_single_number_iii.rs b/src/solution/s0260_single_number_iii.rs similarity index 100% rename from src/n0260_single_number_iii.rs rename to src/solution/s0260_single_number_iii.rs diff --git a/src/n0263_ugly_number.rs b/src/solution/s0263_ugly_number.rs similarity index 100% rename from src/n0263_ugly_number.rs rename to src/solution/s0263_ugly_number.rs diff --git a/src/n0264_ugly_number_ii.rs b/src/solution/s0264_ugly_number_ii.rs similarity index 100% rename from src/n0264_ugly_number_ii.rs rename to src/solution/s0264_ugly_number_ii.rs diff --git a/src/n0268_missing_number.rs b/src/solution/s0268_missing_number.rs similarity index 100% rename from src/n0268_missing_number.rs rename to src/solution/s0268_missing_number.rs diff --git a/src/n0273_integer_to_english_words.rs b/src/solution/s0273_integer_to_english_words.rs similarity index 100% rename from src/n0273_integer_to_english_words.rs rename to src/solution/s0273_integer_to_english_words.rs diff --git a/src/n0274_h_index.rs b/src/solution/s0274_h_index.rs similarity index 100% rename from src/n0274_h_index.rs rename to src/solution/s0274_h_index.rs diff --git a/src/n0275_h_index_ii.rs b/src/solution/s0275_h_index_ii.rs similarity index 100% rename from src/n0275_h_index_ii.rs rename to src/solution/s0275_h_index_ii.rs diff --git a/src/n0279_perfect_squares.rs b/src/solution/s0279_perfect_squares.rs similarity index 100% rename from src/n0279_perfect_squares.rs rename to src/solution/s0279_perfect_squares.rs diff --git a/src/n0282_expression_add_operators.rs b/src/solution/s0282_expression_add_operators.rs similarity index 100% rename from src/n0282_expression_add_operators.rs rename to src/solution/s0282_expression_add_operators.rs diff --git a/src/n0283_move_zeroes.rs b/src/solution/s0283_move_zeroes.rs similarity index 100% rename from src/n0283_move_zeroes.rs rename to src/solution/s0283_move_zeroes.rs diff --git a/src/n0287_find_the_duplicate_number.rs b/src/solution/s0287_find_the_duplicate_number.rs similarity index 100% rename from src/n0287_find_the_duplicate_number.rs rename to src/solution/s0287_find_the_duplicate_number.rs diff --git a/src/n0289_game_of_life.rs b/src/solution/s0289_game_of_life.rs similarity index 100% rename from src/n0289_game_of_life.rs rename to src/solution/s0289_game_of_life.rs diff --git a/src/n0290_word_pattern.rs b/src/solution/s0290_word_pattern.rs similarity index 100% rename from src/n0290_word_pattern.rs rename to src/solution/s0290_word_pattern.rs diff --git a/src/n0292_nim_game.rs b/src/solution/s0292_nim_game.rs similarity index 100% rename from src/n0292_nim_game.rs rename to src/solution/s0292_nim_game.rs diff --git a/src/n0295_find_median_from_data_stream.rs b/src/solution/s0295_find_median_from_data_stream.rs similarity index 100% rename from src/n0295_find_median_from_data_stream.rs rename to src/solution/s0295_find_median_from_data_stream.rs diff --git a/src/n0299_bulls_and_cows.rs b/src/solution/s0299_bulls_and_cows.rs similarity index 100% rename from src/n0299_bulls_and_cows.rs rename to src/solution/s0299_bulls_and_cows.rs diff --git a/src/n0300_longest_increasing_subsequence.rs b/src/solution/s0300_longest_increasing_subsequence.rs similarity index 100% rename from src/n0300_longest_increasing_subsequence.rs rename to src/solution/s0300_longest_increasing_subsequence.rs diff --git a/src/n0301_remove_invalid_parentheses.rs b/src/solution/s0301_remove_invalid_parentheses.rs similarity index 100% rename from src/n0301_remove_invalid_parentheses.rs rename to src/solution/s0301_remove_invalid_parentheses.rs diff --git a/src/n0303_range_sum_query_immutable.rs b/src/solution/s0303_range_sum_query_immutable.rs similarity index 100% rename from src/n0303_range_sum_query_immutable.rs rename to src/solution/s0303_range_sum_query_immutable.rs diff --git a/src/n0304_range_sum_query_2d_immutable.rs b/src/solution/s0304_range_sum_query_2d_immutable.rs similarity index 100% rename from src/n0304_range_sum_query_2d_immutable.rs rename to src/solution/s0304_range_sum_query_2d_immutable.rs diff --git a/src/n0306_additive_number.rs b/src/solution/s0306_additive_number.rs similarity index 100% rename from src/n0306_additive_number.rs rename to src/solution/s0306_additive_number.rs diff --git a/src/n0307_range_sum_query_mutable.rs b/src/solution/s0307_range_sum_query_mutable.rs similarity index 100% rename from src/n0307_range_sum_query_mutable.rs rename to src/solution/s0307_range_sum_query_mutable.rs diff --git a/src/n0309_best_time_to_buy_and_sell_stock_with_cooldown.rs b/src/solution/s0309_best_time_to_buy_and_sell_stock_with_cooldown.rs similarity index 100% rename from src/n0309_best_time_to_buy_and_sell_stock_with_cooldown.rs rename to src/solution/s0309_best_time_to_buy_and_sell_stock_with_cooldown.rs diff --git a/src/n0310_minimum_height_trees.rs b/src/solution/s0310_minimum_height_trees.rs similarity index 100% rename from src/n0310_minimum_height_trees.rs rename to src/solution/s0310_minimum_height_trees.rs diff --git a/src/n0312_burst_balloons.rs b/src/solution/s0312_burst_balloons.rs similarity index 100% rename from src/n0312_burst_balloons.rs rename to src/solution/s0312_burst_balloons.rs diff --git a/src/n0313_super_ugly_number.rs b/src/solution/s0313_super_ugly_number.rs similarity index 100% rename from src/n0313_super_ugly_number.rs rename to src/solution/s0313_super_ugly_number.rs diff --git a/src/n0509_fibonacci_number.rs b/src/solution/s0509_fibonacci_number.rs similarity index 100% rename from src/n0509_fibonacci_number.rs rename to src/solution/s0509_fibonacci_number.rs diff --git a/src/n0704_binary_search.rs b/src/solution/s0704_binary_search.rs similarity index 100% rename from src/n0704_binary_search.rs rename to src/solution/s0704_binary_search.rs diff --git a/src/n0969_pancake_sorting.rs b/src/solution/s0969_pancake_sorting.rs similarity index 100% rename from src/n0969_pancake_sorting.rs rename to src/solution/s0969_pancake_sorting.rs diff --git a/src/n1018_binary_prefix_divisible_by_5.rs b/src/solution/s1018_binary_prefix_divisible_by_5.rs similarity index 100% rename from src/n1018_binary_prefix_divisible_by_5.rs rename to src/solution/s1018_binary_prefix_divisible_by_5.rs diff --git a/src/n1046_last_stone_weight.rs b/src/solution/s1046_last_stone_weight.rs similarity index 100% rename from src/n1046_last_stone_weight.rs rename to src/solution/s1046_last_stone_weight.rs From 01ce862f8526b43ee73bd1c51df25bc4e4344947 Mon Sep 17 00:00:00 2001 From: songyzh Date: Sun, 2 Feb 2020 18:33:22 +0800 Subject: [PATCH 2/9] fix --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e25be217..ccd0c491 100644 --- a/src/main.rs +++ b/src/main.rs @@ -116,7 +116,7 @@ fn generate_random_id(except_ids: &[u32]) -> u32 { } fn get_solved_ids() -> Vec { - let paths = fs::read_dir("./src").unwrap(); + let paths = fs::read_dir("./src/problem").unwrap(); let mut solved_ids = Vec::new(); for path in paths { From 360a3f47895a049679128b4c0b2c96e31e444f8c Mon Sep 17 00:00:00 2001 From: songyzh Date: Sun, 2 Feb 2020 18:35:23 +0800 Subject: [PATCH 3/9] fix --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ccd0c491..3533f9d5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,7 +37,7 @@ fn main() { .unwrap_or_else(|_| panic!("not a number: {}", id_arg)); if solved_ids.contains(&id) { println!( - "The problem you chose is invalid (the problem may have been solved \ + "The problem you chose is invalid (the problem may have been downloaded \ or may have no rust version)." ); continue; From f90c44eef14a18986851d26af39ceccaad17718b Mon Sep 17 00:00:00 2001 From: songyzh Date: Sun, 2 Feb 2020 18:36:04 +0800 Subject: [PATCH 4/9] fix --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3533f9d5..3501fe34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,7 +37,7 @@ fn main() { .unwrap_or_else(|_| panic!("not a number: {}", id_arg)); if solved_ids.contains(&id) { println!( - "The problem you chose is invalid (the problem may have been downloaded \ + "The problem you chose is invalid (the problem may have been initialized \ or may have no rust version)." ); continue; From 9f05e1fb83c1ba3f6976f587ce617c225bf2eb5b Mon Sep 17 00:00:00 2001 From: songyzh Date: Sun, 2 Feb 2020 20:37:35 +0800 Subject: [PATCH 5/9] add option to solve problem --- Cargo.lock | 19 ++++++------ Cargo.toml | 1 + src/main.rs | 88 +++++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 80 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d542a78d..69f4ab42 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -448,6 +448,7 @@ name = "leetcode-rust" version = "0.1.0" dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.21 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", @@ -681,7 +682,7 @@ dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -849,18 +850,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex" -version = "1.3.1" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "regex-syntax" -version = "0.6.12" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1071,7 +1072,7 @@ dependencies = [ [[package]] name = "thread_local" -version = "0.3.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1454,8 +1455,8 @@ dependencies = [ "checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" -"checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" +"checksum regex 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "322cf97724bea3ee221b78fe25ac9c46114ebb51747ad5babd51a2fc6a8235a8" +"checksum regex-syntax 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "b28dfe3fe9badec5dbf0a79a9cccad2cfc2ab5484bdb3e44cbd1ae8b3ba2be06" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum reqwest 0.9.21 (registry+https://github.com/rust-lang/crates.io-index)" = "02b7e953e14c6f3102b7e8d1f1ee3abf5ecee80b427f5565c9389835cecae95c" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" @@ -1478,7 +1479,7 @@ dependencies = [ "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" "checksum synstructure 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "02353edf96d6e4dc81aea2d8490a7e9db177bf8acb0e951c24940bf866cb313f" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" "checksum tokio-buf 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" diff --git a/Cargo.toml b/Cargo.toml index c414242f..f6b7c1c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ serde = "1.0" serde_json = "1.0" serde_derive = "1.0" rand = "0.6.5" +regex = "1.3.4" [lib] doctest = false diff --git a/src/main.rs b/src/main.rs index 3501fe34..9c3fd6d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,10 +5,12 @@ extern crate serde_json; mod fetcher; +use regex::Regex; use std::env; use std::fs; +use std::fs::File; use std::io; -use std::io::Write; +use std::io::{BufRead, Write}; use std::path::Path; /// main() helps to generate the submission template .rs @@ -18,30 +20,44 @@ fn main() { loop { println!("Please enter a frontend problem id, or \"random\" to generate a random one."); let mut is_random = false; + let mut is_solving = false; let mut id: u32 = 0; let mut id_arg = String::new(); io::stdin() .read_line(&mut id_arg) .expect("Failed to read line"); let id_arg = id_arg.trim(); - match id_arg { - "random" => { - println!("You select random mode."); - id = generate_random_id(&solved_ids); - is_random = true; - println!("Generate random problem: {}", &id); - } - _ => { - id = id_arg - .parse::() - .unwrap_or_else(|_| panic!("not a number: {}", id_arg)); - if solved_ids.contains(&id) { - println!( - "The problem you chose is invalid (the problem may have been initialized \ - or may have no rust version)." - ); - continue; - } + + let random_pattern = Regex::new(r"^random$").unwrap(); + let solving_pattern = Regex::new(r"^solve (\d+)$").unwrap(); + + if random_pattern.is_match(id_arg) { + println!("You select random mode."); + id = generate_random_id(&solved_ids); + is_random = true; + println!("Generate random problem: {}", &id); + } else if solving_pattern.is_match(id_arg) { + // solve a problem + // move it from problem/ to solution/ + is_solving = true; + id = solving_pattern + .captures(id_arg) + .unwrap() + .get(1) + .unwrap() + .as_str() + .parse() + .unwrap(); + } else { + id = id_arg + .parse::() + .unwrap_or_else(|_| panic!("not a number: {}", id_arg)); + if solved_ids.contains(&id) { + println!( + "The problem you chose is invalid (the problem may have been initialized \ + or may have no rust version)." + ); + continue; } } @@ -66,6 +82,40 @@ fn main() { problem.title_slug.replace("-", "_") ); let file_path = Path::new("./src/problem").join(format!("{}.rs", file_name)); + if is_solving { + // check problem/ existence + if !file_path.exists() { + panic!("problem does not exist"); + } + // check solution/ no existence + let solution_name = format!( + "s{:04}_{}", + problem.question_id, + problem.title_slug.replace("-", "_") + ); + let solution_path = Path::new("./src/solution").join(format!("{}.rs", solution_name)); + if solution_path.exists() { + panic!("solution exists"); + } + // rename/move file + fs::rename(file_path, solution_path).unwrap(); + // remove from problem/mod.rs + let mod_file = "./src/problem/mod.rs"; + let target_line = format!("mod {};", file_name); + let lines: Vec = io::BufReader::new(File::open(mod_file).unwrap()) + .lines() + .map(|x| x.unwrap()) + .filter(|x| *x != target_line) + .collect(); + fs::write(mod_file, lines.join("\n")); + // insert into solution/mod.rs + let mut lib_file = fs::OpenOptions::new() + .append(true) + .open("./src/solution/mod.rs") + .unwrap(); + writeln!(lib_file, "mod {};", solution_name); + break; + } if file_path.exists() { panic!("problem already initialized"); } From 0d72e628b6c6b11cc5edca9725e3d505fcc7c355 Mon Sep 17 00:00:00 2001 From: songyzh Date: Tue, 4 Feb 2020 10:57:03 +0800 Subject: [PATCH 6/9] add a message to explain the solve $i command --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 9c3fd6d7..f58192c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,7 @@ fn main() { println!("Welcome to leetcode-rust system."); let mut solved_ids = get_solved_ids(); loop { - println!("Please enter a frontend problem id, or \"random\" to generate a random one."); + println!("Please enter a frontend problem id, or \"random\" to generate a random one, or \"solve $i\" to move problem to solution/"); let mut is_random = false; let mut is_solving = false; let mut id: u32 = 0; From 125c64c39b035d4cab2687d9bc2977749c8b0a59 Mon Sep 17 00:00:00 2001 From: songyzh Date: Tue, 4 Feb 2020 11:06:16 +0800 Subject: [PATCH 7/9] clarify error message --- src/main.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index f58192c0..87c333fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,10 +53,7 @@ fn main() { .parse::() .unwrap_or_else(|_| panic!("not a number: {}", id_arg)); if solved_ids.contains(&id) { - println!( - "The problem you chose is invalid (the problem may have been initialized \ - or may have no rust version)." - ); + println!("The problem you chose has been initialized in problem/"); continue; } } From 76edb8c5fb172de61a1e308d279e9b877ad32c5f Mon Sep 17 00:00:00 2001 From: songyzh Date: Tue, 4 Feb 2020 11:24:08 +0800 Subject: [PATCH 8/9] refactor get_solved_ids() according to current logic --- src/main.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index 87c333fc..545c2d22 100644 --- a/src/main.rs +++ b/src/main.rs @@ -163,20 +163,12 @@ fn generate_random_id(except_ids: &[u32]) -> u32 { } fn get_solved_ids() -> Vec { - let paths = fs::read_dir("./src/problem").unwrap(); - let mut solved_ids = Vec::new(); - - for path in paths { - let path = path.unwrap().path(); - let s = path.to_str().unwrap(); - if !s.starts_with('n') { - continue; - } - let id = &s[7..11]; - let id = id.parse::().unwrap(); - solved_ids.push(id); - } - solved_ids + let content = fs::read_to_string("./src/problem/mod.rs").unwrap(); + let id_pattern = Regex::new(r"p(\d{4})_").unwrap(); + id_pattern + .captures_iter(&content) + .map(|x| x.get(1).unwrap().as_str().parse().unwrap()) + .collect() } fn parse_extra_use(code: &str) -> String { From 695f53a684264b19f0d2e94541fdb18cc1f37628 Mon Sep 17 00:00:00 2001 From: songyzh Date: Tue, 4 Feb 2020 11:28:00 +0800 Subject: [PATCH 9/9] clarify var and fn name --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 545c2d22..cf5d251b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ use std::path::Path; /// main() helps to generate the submission template .rs fn main() { println!("Welcome to leetcode-rust system."); - let mut solved_ids = get_solved_ids(); + let mut initialized_ids = get_initialized_ids(); loop { println!("Please enter a frontend problem id, or \"random\" to generate a random one, or \"solve $i\" to move problem to solution/"); let mut is_random = false; @@ -33,7 +33,7 @@ fn main() { if random_pattern.is_match(id_arg) { println!("You select random mode."); - id = generate_random_id(&solved_ids); + id = generate_random_id(&initialized_ids); is_random = true; println!("Generate random problem: {}", &id); } else if solving_pattern.is_match(id_arg) { @@ -52,7 +52,7 @@ fn main() { id = id_arg .parse::() .unwrap_or_else(|_| panic!("not a number: {}", id_arg)); - if solved_ids.contains(&id) { + if initialized_ids.contains(&id) { println!("The problem you chose has been initialized in problem/"); continue; } @@ -68,7 +68,7 @@ fn main() { let code = problem.code_definition.iter().find(|&d| d.value == "rust"); if code.is_none() { println!("Problem {} has no rust version.", &id); - solved_ids.push(problem.question_id); + initialized_ids.push(problem.question_id); continue; } let code = code.unwrap(); @@ -162,7 +162,7 @@ fn generate_random_id(except_ids: &[u32]) -> u32 { } } -fn get_solved_ids() -> Vec { +fn get_initialized_ids() -> Vec { let content = fs::read_to_string("./src/problem/mod.rs").unwrap(); let id_pattern = Regex::new(r"p(\d{4})_").unwrap(); id_pattern