├── .cargo └── config.toml ├── .clippy.toml ├── .github └── workflows │ ├── c++.yml │ ├── coverage.yml │ ├── progress.yml │ └── rust.yml ├── .gitignore ├── .rustfmt.toml ├── Cargo.toml ├── Notes.md ├── README.md ├── c++ ├── .clang-format ├── .clang-tidy ├── .gitignore ├── CMakeLists.txt ├── include │ └── leet-code │ │ ├── data-structures │ │ ├── list-node.h │ │ └── tree-node-with-next-right-pointer.h │ │ ├── problem-0116-populating-next-right-pointers-in-each-node │ │ ├── iterative.h │ │ └── recursive.h │ │ ├── problem-0117-populating-next-right-pointers-in-each-node-ii │ │ └── iterative.h │ │ ├── problem-0237-delete-node-in-a-linked-list │ │ └── modify-this.h │ │ ├── problem-0321-create-maximum-number │ │ ├── dynamic-programming.h │ │ └── greedy.h │ │ ├── problem-0373-find-k-pairs-with-smallest-sums │ │ ├── bfs-2.h │ │ └── bfs.h │ │ ├── problem-0378-kth-smallest-element-in-a-sorted-matrix │ │ ├── bfs-2.h │ │ ├── binary-search-2.h │ │ ├── binary-search-3.h │ │ └── binary-search.h │ │ ├── problem-0386-lexicographical-numbers │ │ └── iterative-dfs.h │ │ ├── problem-0402-remove-k-digits │ │ ├── greedy-2.h │ │ └── greedy.h │ │ ├── problem-0406-queue-reconstruction-by-height │ │ ├── binary-search-tree.h │ │ ├── fenwick-tree.h │ │ └── insertion.h │ │ └── problem-0436-find-right-interval │ │ ├── sort-and-merge.h │ │ └── sort-and-scan.h └── tests │ └── leet-code │ ├── problem-0116-populating-next-right-pointers-in-each-node │ ├── iterative.cpp │ ├── recursive.cpp │ └── tests.h │ ├── problem-0117-populating-next-right-pointers-in-each-node-ii │ ├── iterative.cpp │ └── tests.h │ ├── problem-0237-delete-node-in-a-linked-list │ ├── modify-this.cpp │ └── tests.h │ ├── problem-0321-create-maximum-number │ ├── dynamic-programming.cpp │ ├── greedy.cpp │ └── tests.h │ ├── problem-0373-find-k-pairs-with-smallest-sums │ ├── bfs-2.cpp │ ├── bfs.cpp │ └── tests.h │ ├── problem-0378-kth-smallest-element-in-a-sorted-matrix │ ├── bfs-2.cpp │ ├── binary-search-2.cpp │ ├── binary-search-3.cpp │ ├── binary-search.cpp │ └── tests.h │ ├── problem-0386-lexicographical-numbers │ ├── iterative-dfs.cpp │ └── tests.h │ ├── problem-0402-remove-k-digits │ ├── greedy-2.cpp │ ├── greedy.cpp │ └── tests.h │ ├── problem-0406-queue-reconstruction-by-height │ ├── binary-search-tree.cpp │ ├── fenwick-tree.cpp │ ├── insertion.cpp │ └── tests.h │ ├── problem-0436-find-right-interval │ ├── sort-and-merge.cpp │ ├── sort-and-scan.cpp │ └── tests.h │ ├── test-utilities.cpp │ └── test-utilities.h ├── rust-toolchain.toml ├── src ├── data_structures.rs ├── lib.rs ├── problem_0001_two_sum │ ├── index_map.rs │ ├── mod.rs │ ├── sort_then_bidirectional_search.rs │ └── sort_then_bidirectional_search_2.rs ├── problem_0002_add_two_numbers │ ├── mod.rs │ └── simple.rs ├── problem_0003_longest_substring_without_repeating_characters │ ├── mod.rs │ ├── sliding_window.rs │ ├── sliding_window_2.rs │ └── sliding_window_3.rs ├── problem_0004_median_of_two_sorted_arrays │ ├── binary_search.rs │ └── mod.rs ├── problem_0005_longest_palindromic_substring │ ├── brute_force.rs │ └── mod.rs ├── problem_0006_zigzag_conversion │ ├── brute_force.rs │ └── mod.rs ├── problem_0007_reverse_integer │ ├── brute_force.rs │ └── mod.rs ├── problem_0008_string_to_integer_atoi │ ├── brute_force.rs │ └── mod.rs ├── problem_0009_palindrome_number │ ├── brute_force.rs │ ├── brute_force_unsafe.rs │ ├── mod.rs │ └── reverse_half.rs ├── problem_0010_regular_expression_matching │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0011_container_with_most_water │ ├── mod.rs │ └── two_pointers.rs ├── problem_0012_integer_to_roman │ ├── generic.rs │ ├── mod.rs │ ├── specialized_1.rs │ └── specialized_2.rs ├── problem_0013_roman_to_integer │ ├── mod.rs │ ├── parsing.rs │ └── parsing_2.rs ├── problem_0014_longest_common_prefix │ ├── brute_force.rs │ └── mod.rs ├── problem_0015_3sum │ ├── mod.rs │ ├── sort_then_two_sum.rs │ └── sort_then_two_sum_short.rs ├── problem_0016_3sum_closest │ ├── mod.rs │ └── two_pointers.rs ├── problem_0017_letter_combinations_of_a_phone_number │ ├── backtracking.rs │ └── mod.rs ├── problem_0018_4sum │ ├── mod.rs │ └── reduce_to_three_sum.rs ├── problem_0019_remove_nth_node_from_end_of_list │ ├── measure_length.rs │ └── mod.rs ├── problem_0020_valid_parentheses │ ├── mod.rs │ ├── stack.rs │ └── stack_2.rs ├── problem_0021_merge_two_sorted_lists │ ├── mod.rs │ ├── zip.rs │ └── zip_2.rs ├── problem_0022_generate_parentheses │ ├── backtracking.rs │ ├── backtracking_2.rs │ ├── backtracking_3.rs │ └── mod.rs ├── problem_0023_merge_k_sorted_lists │ ├── heap.rs │ └── mod.rs ├── problem_0024_swap_nodes_in_pairs │ ├── mod.rs │ └── obvious.rs ├── problem_0025_reverse_nodes_in_k_group │ ├── mod.rs │ ├── reverse_group.rs │ └── reverse_group_2.rs ├── problem_0026_remove_duplicates_from_sorted_array │ ├── cheating.rs │ ├── mod.rs │ └── sequential_processing.rs ├── problem_0027_remove_element │ ├── cheating.rs │ ├── mod.rs │ ├── sequential_processing.rs │ └── sequential_processing_2.rs ├── problem_0028_find_the_index_of_the_first_occurrence_in_a_string │ ├── cheating.rs │ ├── kmp.rs │ ├── mod.rs │ └── naive.rs ├── problem_0029_divide_two_integers │ ├── exponential_check.rs │ └── mod.rs ├── problem_0030_substring_with_concatenation_of_all_words │ ├── brute_force.rs │ ├── interleaving_sliding_window_sets.rs │ ├── mod.rs │ └── sliding_window_sets.rs ├── problem_0031_next_permutation │ ├── find_last_inversion.rs │ └── mod.rs ├── problem_0032_longest_valid_parentheses │ ├── bidirectional_scan.rs │ ├── dynamic_programming.rs │ ├── mod.rs │ └── stack.rs ├── problem_0033_search_in_rotated_sorted_array │ ├── binary_search.rs │ ├── binary_search_2.rs │ └── mod.rs ├── problem_0034_find_first_and_last_position_of_element_in_sorted_array │ ├── binary_search.rs │ ├── binary_search_2.rs │ └── mod.rs ├── problem_0035_search_insert_position │ ├── binary_search.rs │ ├── binary_search_2.rs │ ├── binary_search_fast.rs │ ├── binary_search_fast_2.rs │ ├── binary_search_recursive.rs │ └── mod.rs ├── problem_0036_valid_sudoku │ ├── mod.rs │ ├── naive.rs │ └── single_pass.rs ├── problem_0037_sudoku_solver │ ├── backtracking_1.rs │ ├── backtracking_2.rs │ └── mod.rs ├── problem_0038_count_and_say │ ├── iterative.rs │ └── mod.rs ├── problem_0039_combination_sum │ ├── backtracking.rs │ └── mod.rs ├── problem_0040_combination_sum_ii │ ├── backtracking.rs │ ├── backtracking_2.rs │ ├── backtracking_3.rs │ └── mod.rs ├── problem_0041_first_missing_positive │ ├── mod.rs │ └── pigeonhole.rs ├── problem_0042_trapping_rain_water │ ├── maximum_on_both_sides.rs │ ├── mod.rs │ ├── stack.rs │ ├── two_pointers.rs │ └── two_pointers_2.rs ├── problem_0043_multiply_strings │ ├── mod.rs │ └── naive.rs ├── problem_0044_wildcard_matching │ ├── match_by_chunks.rs │ └── mod.rs ├── problem_0045_jump_game_ii │ ├── bfs.rs │ ├── bfs_single_loop.rs │ ├── bfs_with_tricks.rs │ └── mod.rs ├── problem_0046_permutations │ ├── backtracking_1.rs │ ├── backtracking_2.rs │ ├── backtracking_3.rs │ ├── heap.rs │ └── mod.rs ├── problem_0047_permutations_ii │ ├── backtracking_1.rs │ ├── backtracking_2.rs │ ├── backtracking_3.rs │ ├── mod.rs │ └── next_permutations.rs ├── problem_0048_rotate_image │ ├── mod.rs │ ├── naive.rs │ └── reverse_then_transpose.rs ├── problem_0049_group_anagrams │ ├── mod.rs │ └── sort_word.rs ├── problem_0050_powx_n │ ├── mod.rs │ └── recurse_on_half.rs ├── problem_0051_n_queens │ ├── backtracking.rs │ └── mod.rs ├── problem_0052_n_queens_ii │ ├── backtracking.rs │ └── mod.rs ├── problem_0053_maximum_subarray │ ├── divide_and_conquer.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0054_spiral_matrix │ ├── level_by_level.rs │ ├── mod.rs │ └── rotate_matrix.rs ├── problem_0055_jump_game │ ├── greedy.rs │ └── mod.rs ├── problem_0056_merge_intervals │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_0057_insert_interval │ ├── binary_search.rs │ ├── binary_search_2.rs │ ├── binary_search_3.rs │ └── mod.rs ├── problem_0058_length_of_last_word │ ├── manual_reversed_iteration.rs │ ├── mod.rs │ └── reversed_iteration.rs ├── problem_0059_spiral_matrix_ii │ ├── layer_by_layer.rs │ └── mod.rs ├── problem_0060_permutation_sequence │ ├── iterative.rs │ └── mod.rs ├── problem_0061_rotate_list │ ├── measure_length.rs │ └── mod.rs ├── problem_0062_unique_paths │ ├── binomial.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0063_unique_paths_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0064_minimum_path_sum │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0065_valid_number │ ├── dfa.rs │ └── mod.rs ├── problem_0066_plus_one │ ├── clever.rs │ └── mod.rs ├── problem_0067_add_binary │ ├── mod.rs │ └── naive.rs ├── problem_0068_text_justification │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0069_sqrtx │ ├── binary_search.rs │ ├── fast_binary_search.rs │ ├── mod.rs │ ├── newtons_method.rs │ ├── newtons_method_with_f32.rs │ ├── newtons_method_with_f64.rs │ ├── smart_newtons_method.rs │ └── smarter_newtons_method.rs ├── problem_0070_climbing_stairs │ ├── dynamic_programming.rs │ ├── fast_fibonacci_iterative.rs │ ├── fast_fibonacci_recursive.rs │ └── mod.rs ├── problem_0071_simplify_path │ ├── mod.rs │ └── stack.rs ├── problem_0072_edit_distance │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0073_set_matrix_zeroes │ ├── mod.rs │ ├── two_passes.rs │ └── two_passes_2.rs ├── problem_0074_search_a_2d_matrix │ ├── binary_search.rs │ └── mod.rs ├── problem_0075_sort_colors │ ├── counting_sort.rs │ └── mod.rs ├── problem_0076_minimum_window_substring │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_0077_combinations │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0078_subsets │ ├── iterative.rs │ ├── iterative_2.rs │ ├── mod.rs │ ├── partial_iterative.rs │ └── recursive.rs ├── problem_0079_word_search │ ├── mod.rs │ └── recursive.rs ├── problem_0080_remove_duplicates_from_sorted_array_ii │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0081_search_in_rotated_sorted_array_ii │ ├── binary_search.rs │ └── mod.rs ├── problem_0082_remove_duplicates_from_sorted_list_ii │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0083_remove_duplicates_from_sorted_list │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0084_largest_rectangle_in_histogram │ ├── mod.rs │ ├── stack.rs │ └── stack_2.rs ├── problem_0085_maximal_rectangle │ ├── dynamic_programming.rs │ ├── mod.rs │ └── use_largest_rectangle_in_histogram.rs ├── problem_0086_partition_list │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0087_scramble_string │ ├── dynamic_programming.rs │ ├── memoized_recursive.rs │ └── mod.rs ├── problem_0088_merge_sorted_array │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0089_gray_code │ ├── bit_manipulation.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0090_subsets_ii │ ├── iterative.rs │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_0091_decode_ways │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_0092_reverse_linked_list_ii │ ├── iterative.rs │ └── mod.rs ├── problem_0093_restore_ip_addresses │ ├── iterative.rs │ └── mod.rs ├── problem_0094_binary_tree_inorder_traversal │ ├── iterative.rs │ ├── mod.rs │ ├── morris_traversal.rs │ ├── morris_traversal_keep_structure.rs │ ├── partial_iterative.rs │ └── recursive.rs ├── problem_0095_unique_binary_search_trees_ii │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_0096_unique_binary_search_trees │ ├── catalan_number.rs │ ├── catalan_number_2.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0097_interleaving_string │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0098_validate_binary_search_tree │ ├── mod.rs │ ├── recursive.rs │ ├── recursive_2.rs │ └── recursive_3.rs ├── problem_0099_recover_binary_search_tree │ ├── mod.rs │ └── morris_traversal.rs ├── problem_0100_same_tree │ ├── cheating.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0101_symmetric_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0102_binary_tree_level_order_traversal │ ├── iterative.rs │ └── mod.rs ├── problem_0103_binary_tree_zigzag_level_order_traversal │ ├── iterative.rs │ └── mod.rs ├── problem_0104_maximum_depth_of_binary_tree │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0105_construct_binary_tree_from_preorder_and_inorder_traversal │ ├── mod.rs │ ├── recursive.rs │ ├── recursive_cached.rs │ ├── recursive_smart.rs │ └── recursive_smart_2.rs ├── problem_0106_construct_binary_tree_from_inorder_and_postorder_traversal │ ├── mod.rs │ ├── recursive.rs │ ├── recursive_cached.rs │ ├── recursive_smart.rs │ └── recursive_smart_2.rs ├── problem_0107_binary_tree_level_order_traversal_ii │ ├── iterative.rs │ └── mod.rs ├── problem_0108_convert_sorted_array_to_binary_search_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0109_convert_sorted_list_to_binary_search_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0110_balanced_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0111_minimum_depth_of_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0112_path_sum │ ├── iterative.rs │ └── mod.rs ├── problem_0113_path_sum_ii │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0114_flatten_binary_tree_to_linked_list │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0115_distinct_subsequences │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0118_pascals_triangle │ ├── iterative.rs │ └── mod.rs ├── problem_0119_pascals_triangle_ii │ ├── iterative.rs │ └── mod.rs ├── problem_0120_triangle │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_0121_best_time_to_buy_and_sell_stock │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0122_best_time_to_buy_and_sell_stock_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0123_best_time_to_buy_and_sell_stock_iii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0124_binary_tree_maximum_path_sum │ ├── mod.rs │ └── recursive.rs ├── problem_0125_valid_palindrome │ ├── bidirectional_search.rs │ └── mod.rs ├── problem_0126_word_ladder_ii │ ├── bidirectional_search.rs │ └── mod.rs ├── problem_0127_word_ladder │ ├── bfs.rs │ ├── bidirectional_bfs.rs │ ├── mod.rs │ └── naive_bfs.rs ├── problem_0128_longest_consecutive_sequence │ ├── hash_set.rs │ └── mod.rs ├── problem_0129_sum_root_to_leaf_numbers │ ├── mod.rs │ └── recursive.rs ├── problem_0130_surrounded_regions │ ├── bfs.rs │ ├── bfs_2.rs │ └── mod.rs ├── problem_0131_palindrome_partitioning │ ├── find_all_palindromes.rs │ └── mod.rs ├── problem_0132_palindrome_partitioning_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0134_gas_station │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_0135_candy │ ├── mod.rs │ └── tail_recursive.rs ├── problem_0136_single_number │ ├── mod.rs │ └── reduce_xor.rs ├── problem_0137_single_number_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0139_word_break │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0140_word_break_ii │ ├── dynamic_programming.rs │ ├── memoized_recursive.rs │ └── mod.rs ├── problem_0143_reorder_list │ ├── iterative.rs │ └── mod.rs ├── problem_0144_binary_tree_preorder_traversal │ ├── iterative.rs │ ├── mod.rs │ ├── partial_iterative.rs │ └── recursive.rs ├── problem_0145_binary_tree_postorder_traversal │ ├── iterative.rs │ ├── iterative_2.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0146_lru_cache │ ├── map_to_doubly_linked_list.rs │ ├── map_to_doubly_linked_list_2.rs │ ├── map_to_doubly_linked_list_3.rs │ └── mod.rs ├── problem_0147_insertion_sort_list │ ├── iterative.rs │ └── mod.rs ├── problem_0148_sort_list │ ├── merge_sort.rs │ └── mod.rs ├── problem_0149_max_points_on_a_line │ ├── brute_force.rs │ └── mod.rs ├── problem_0150_evaluate_reverse_polish_notation │ ├── mod.rs │ └── stack.rs ├── problem_0151_reverse_words_in_a_string │ ├── cheating.rs │ └── mod.rs ├── problem_0152_maximum_product_subarray │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0153_find_minimum_in_rotated_sorted_array │ ├── binary_search.rs │ └── mod.rs ├── problem_0154_find_minimum_in_rotated_sorted_array_ii │ ├── binary_search.rs │ └── mod.rs ├── problem_0155_min_stack │ ├── mod.rs │ └── one_stack.rs ├── problem_0162_find_peak_element │ ├── binary_search.rs │ └── mod.rs ├── problem_0164_maximum_gap │ ├── buckets_and_pigeonhole.rs │ ├── comparison_sort.rs │ ├── mod.rs │ └── radix_sort.rs ├── problem_0165_compare_version_numbers │ ├── iterator.rs │ └── mod.rs ├── problem_0166_fraction_to_recurring_decimal │ ├── hash_map.rs │ └── mod.rs ├── problem_0167_two_sum_ii_input_array_is_sorted │ ├── bidirectional_search.rs │ └── mod.rs ├── problem_0168_excel_sheet_column_title │ ├── iterative.rs │ └── mod.rs ├── problem_0169_majority_element │ ├── boyer_moore_majority_vote.rs │ └── mod.rs ├── problem_0171_excel_sheet_column_number │ ├── iterative.rs │ └── mod.rs ├── problem_0172_factorial_trailing_zeroes │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0173_binary_search_tree_iterator │ ├── iterative.rs │ └── mod.rs ├── problem_0174_dungeon_game │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0179_largest_number │ ├── mod.rs │ ├── sorting_1.rs │ └── sorting_2.rs ├── problem_0187_repeated_dna_sequences │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_0188_best_time_to_buy_and_sell_stock_iv │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0189_rotate_array │ ├── cheating.rs │ ├── cyclic_replacements.rs │ ├── mod.rs │ └── triple_reverses.rs ├── problem_0190_reverse_bits │ ├── cheating.rs │ ├── divide_and_conquer.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0191_number_of_1_bits │ ├── cheating.rs │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0198_house_robber │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_0199_binary_tree_right_side_view │ ├── bfs.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0200_number_of_islands │ ├── bfs.rs │ ├── dfs.rs │ ├── mod.rs │ └── recursive_dfs.rs ├── problem_0201_bitwise_and_of_numbers_range │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0202_happy_number │ ├── hash_set.rs │ ├── mod.rs │ └── two_runners.rs ├── problem_0203_remove_linked_list_elements │ ├── iterative.rs │ ├── mod.rs │ └── tail_recursive.rs ├── problem_0204_count_primes │ ├── mod.rs │ └── sieve.rs ├── problem_0205_isomorphic_strings │ ├── direct_address_table.rs │ ├── hash_map.rs │ └── mod.rs ├── problem_0206_reverse_linked_list │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0207_course_schedule │ ├── bfs.rs │ ├── iterative_dfs.rs │ ├── iterative_dfs_2.rs │ ├── iterative_dfs_3.rs │ ├── mod.rs │ ├── recursive_dfs.rs │ ├── recursive_dfs_2.rs │ └── recursive_dfs_3.rs ├── problem_0208_implement_trie_prefix_tree │ ├── canonical.rs │ └── mod.rs ├── problem_0209_minimum_size_subarray_sum │ ├── mod.rs │ ├── sliding_window.rs │ └── tail_recursive_sliding_window.rs ├── problem_0210_course_schedule_ii │ ├── in_degrees.rs │ ├── in_degrees_2.rs │ ├── iterative_dfs.rs │ ├── iterative_dfs_2.rs │ ├── mod.rs │ ├── recursive_dfs.rs │ └── recursive_dfs_2.rs ├── problem_0211_design_add_and_search_words_data_structure │ ├── mod.rs │ └── trie.rs ├── problem_0212_word_search_ii │ ├── mod.rs │ └── trie_dfs.rs ├── problem_0213_house_robber_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0214_shortest_palindrome │ ├── brute_force.rs │ ├── kmp.rs │ └── mod.rs ├── problem_0215_kth_largest_element_in_an_array │ ├── mod.rs │ ├── quick_select.rs │ └── randomized_quick_select.rs ├── problem_0216_combination_sum_iii │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_0217_contains_duplicate │ ├── hash_set.rs │ └── mod.rs ├── problem_0218_the_skyline_problem │ ├── divide_and_conquer.rs │ ├── mod.rs │ ├── ordered_map.rs │ └── priority_queue.rs ├── problem_0219_contains_duplicate_ii │ ├── index_map.rs │ ├── mod.rs │ └── sliding_window_hash_set.rs ├── problem_0220_contains_duplicate_iii │ ├── mod.rs │ ├── sliding_window_buckets.rs │ └── sliding_window_ordered_set.rs ├── problem_0221_maximal_square │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_0222_count_complete_tree_nodes │ ├── mod.rs │ └── recursive.rs ├── problem_0223_rectangle_area │ ├── mod.rs │ └── normalize.rs ├── problem_0224_basic_calculator │ ├── mod.rs │ ├── recursive_descent.rs │ └── stack.rs ├── problem_0225_implement_stack_using_queues │ ├── mod.rs │ ├── slow_pop.rs │ └── slow_push.rs ├── problem_0226_invert_binary_tree │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_0227_basic_calculator_ii │ ├── iterative.rs │ ├── mod.rs │ ├── recursive_descent.rs │ └── stack.rs ├── problem_0228_summary_ranges │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0229_majority_element_ii │ ├── boyer_moore_majority_vote.rs │ └── mod.rs ├── problem_0230_kth_smallest_element_in_a_bst │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0231_power_of_two │ ├── bit_manipulation.rs │ ├── division.rs │ ├── enumeration.rs │ └── mod.rs ├── problem_0232_implement_queue_using_stacks │ ├── double_ended_stack.rs │ └── mod.rs ├── problem_0233_number_of_digit_one │ ├── iterative.rs │ ├── iterative_2.rs │ ├── iterative_3.rs │ └── mod.rs ├── problem_0234_palindrome_linked_list │ ├── iterative.rs │ └── mod.rs ├── problem_0235_lowest_common_ancestor_of_a_binary_search_tree │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0236_lowest_common_ancestor_of_a_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0238_product_of_array_except_self │ ├── mod.rs │ └── two_passes.rs ├── problem_0239_sliding_window_maximum │ ├── deque.rs │ ├── deque_2.rs │ └── mod.rs ├── problem_0240_search_a_2d_matrix_ii │ ├── eliminate_row_or_column.rs │ ├── eliminate_row_or_column_2.rs │ └── mod.rs ├── problem_0241_different_ways_to_add_parentheses │ ├── backtracking.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0242_valid_anagram │ ├── direct_address_table.rs │ └── mod.rs ├── problem_0257_binary_tree_paths │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_0258_add_digits │ ├── formula.rs │ └── mod.rs ├── problem_0260_single_number_iii │ ├── mod.rs │ └── partition_by_bit.rs ├── problem_0263_ugly_number │ ├── brute_force.rs │ └── mod.rs ├── problem_0264_ugly_number_ii │ ├── dynamic_programming.rs │ ├── dynamic_programming_short.rs │ └── mod.rs ├── problem_0268_missing_number │ ├── mod.rs │ ├── pigeonhole.rs │ ├── reduce_sum.rs │ └── reduce_xor.rs ├── problem_0273_integer_to_english_words │ ├── group_by_thousands.rs │ └── mod.rs ├── problem_0274_h_index │ ├── counting_sort.rs │ └── mod.rs ├── problem_0275_h_index_ii │ ├── binary_search.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0278_first_bad_version │ ├── binary_search.rs │ └── mod.rs ├── problem_0279_perfect_squares │ ├── bfs.rs │ ├── bfs_2.rs │ └── mod.rs ├── problem_0282_expression_add_operators │ ├── backtracking.rs │ ├── backtracking_2.rs │ └── mod.rs ├── problem_0283_move_zeroes │ ├── iterative.rs │ └── mod.rs ├── problem_0287_find_the_duplicate_number │ ├── cycle_detection.rs │ └── mod.rs ├── problem_0289_game_of_life │ ├── mod.rs │ └── two_passes.rs ├── problem_0290_word_pattern │ ├── hash_map.rs │ ├── index_hash_map.rs │ └── mod.rs ├── problem_0292_nim_game │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0295_find_median_from_data_stream │ ├── mod.rs │ └── two_heaps.rs ├── problem_0297_serialize_and_deserialize_binary_tree │ ├── level_order_traversal.rs │ ├── mod.rs │ └── preorder_traversal.rs ├── problem_0299_bulls_and_cows │ ├── iterative.rs │ └── mod.rs ├── problem_0300_longest_increasing_subsequence │ ├── dynamic_programming_fast.rs │ ├── dynamic_programming_slow.rs │ └── mod.rs ├── problem_0301_remove_invalid_parentheses │ ├── backtracking.rs │ ├── backtracking_2.rs │ └── mod.rs ├── problem_0303_range_sum_query_immutable │ ├── cumulative_sum.rs │ ├── cumulative_sum_2.rs │ └── mod.rs ├── problem_0304_range_sum_query_2d_immutable │ ├── cumulative_sum.rs │ └── mod.rs ├── problem_0306_additive_number │ ├── brute_force.rs │ └── mod.rs ├── problem_0307_range_sum_query_mutable │ ├── fenwick_tree.rs │ ├── mod.rs │ ├── segment_tree.rs │ └── segment_tree_2.rs ├── problem_0309_best_time_to_buy_and_sell_stock_with_cooldown │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0310_minimum_height_trees │ ├── bfs.rs │ ├── bfs_2.rs │ └── mod.rs ├── problem_0312_burst_balloons │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0313_super_ugly_number │ ├── dynamic_programming.rs │ ├── dynamic_programming_binary_heap.rs │ └── mod.rs ├── problem_0315_count_of_smaller_numbers_after_self │ ├── fenwick_tree.rs │ ├── merge_sort.rs │ └── mod.rs ├── problem_0316_remove_duplicate_letters │ ├── mod.rs │ └── stack.rs ├── problem_0318_maximum_product_of_word_lengths │ ├── bit_mask.rs │ └── mod.rs ├── problem_0319_bulb_switcher │ ├── mathematical.rs │ └── mod.rs ├── problem_0321_create_maximum_number │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ ├── greedy.rs │ └── mod.rs ├── problem_0322_coin_change │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_0324_wiggle_sort_ii │ ├── find_median.rs │ └── mod.rs ├── problem_0326_power_of_three │ ├── division.rs │ └── mod.rs ├── problem_0327_count_of_range_sum │ ├── merge_sort.rs │ └── mod.rs ├── problem_0328_odd_even_linked_list │ ├── iterative.rs │ └── mod.rs ├── problem_0329_longest_increasing_path_in_a_matrix │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0330_patching_array │ ├── greedy.rs │ └── mod.rs ├── problem_0331_verify_preorder_serialization_of_a_binary_tree │ ├── iterative.rs │ ├── iterative_2.rs │ ├── iterative_3.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0332_reconstruct_itinerary │ ├── dfs.rs │ ├── dfs_2.rs │ ├── dfs_3.rs │ └── mod.rs ├── problem_0334_increasing_triplet_subsequence │ ├── iterative.rs │ ├── iterative_2.rs │ ├── iterative_3.rs │ └── mod.rs ├── problem_0335_self_crossing │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0336_palindrome_pairs │ ├── b_tree_map.rs │ ├── hash_map.rs │ ├── mod.rs │ └── trie.rs ├── problem_0337_house_robber_iii │ ├── mod.rs │ └── recursive.rs ├── problem_0338_counting_bits │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_0341_flatten_nested_list_iterator │ ├── mod.rs │ ├── stack.rs │ └── stack_2.rs ├── problem_0342_power_of_four │ ├── bit_mask.rs │ └── mod.rs ├── problem_0343_integer_break │ ├── mathematical.rs │ └── mod.rs ├── problem_0344_reverse_string │ ├── cheating.rs │ ├── indices.rs │ ├── iterator.rs │ └── mod.rs ├── problem_0345_reverse_vowels_of_a_string │ ├── iterator.rs │ ├── iterator_2.rs │ └── mod.rs ├── problem_0347_top_k_frequent_elements │ ├── mod.rs │ └── quick_select.rs ├── problem_0349_intersection_of_two_arrays │ ├── cheating.rs │ ├── mod.rs │ ├── single_set.rs │ └── two_sets.rs ├── problem_0350_intersection_of_two_arrays_ii │ ├── mod.rs │ └── single_map.rs ├── problem_0352_data_stream_as_disjoint_intervals │ ├── mod.rs │ ├── ordered_map.rs │ └── union_find.rs ├── problem_0354_russian_doll_envelopes │ ├── longest_increasing_subsequence.rs │ └── mod.rs ├── problem_0355_design_twitter │ ├── binary_heap.rs │ ├── binary_heap_2.rs │ └── mod.rs ├── problem_0357_count_numbers_with_unique_digits │ ├── mathematical.rs │ ├── mod.rs │ └── precomputed.rs ├── problem_0363_max_sum_of_rectangle_no_larger_than_k │ ├── mod.rs │ └── reduce_to_subarray_sum.rs ├── problem_0365_water_and_jug_problem │ ├── mathematical.rs │ └── mod.rs ├── problem_0367_valid_perfect_square │ ├── binary_search.rs │ ├── mod.rs │ └── newtons_method.rs ├── problem_0368_largest_divisible_subset │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0371_sum_of_two_integers │ ├── mod.rs │ └── sum_and_carry.rs ├── problem_0372_super_pow │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0373_find_k_pairs_with_smallest_sums │ ├── bfs.rs │ └── mod.rs ├── problem_0374_guess_number_higher_or_lower │ ├── binary_search.rs │ └── mod.rs ├── problem_0375_guess_number_higher_or_lower_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0376_wiggle_subsequence │ ├── greedy.rs │ └── mod.rs ├── problem_0377_combination_sum_iv │ ├── dynamic_programming.rs │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_0378_kth_smallest_element_in_a_sorted_matrix │ ├── bfs.rs │ ├── bfs_2.rs │ ├── binary_search.rs │ ├── binary_search_2.rs │ ├── binary_search_3.rs │ ├── divide_and_conquer.rs │ └── mod.rs ├── problem_0383_ransom_note │ ├── direct_address_table.rs │ ├── hash_map.rs │ └── mod.rs ├── problem_0385_mini_parser │ ├── mod.rs │ └── recursive.rs ├── problem_0386_lexicographical_numbers │ ├── dfs.rs │ ├── iterative_dfs.rs │ └── mod.rs ├── problem_0387_first_unique_character_in_a_string │ ├── iterative.rs │ └── mod.rs ├── problem_0388_longest_absolute_file_path │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0389_find_the_difference │ ├── mod.rs │ └── reduce_xor.rs ├── problem_0390_elimination_game │ ├── mathematical.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0391_perfect_rectangle │ ├── count_corners.rs │ └── mod.rs ├── problem_0392_is_subsequence │ ├── greedy.rs │ └── mod.rs ├── problem_0393_utf_8_validation │ ├── iterative.rs │ └── mod.rs ├── problem_0394_decode_string │ ├── mod.rs │ ├── recursive.rs │ ├── stack.rs │ └── stack_2.rs ├── problem_0395_longest_substring_with_at_least_k_repeating_characters │ ├── divide_and_conquer.rs │ ├── mod.rs │ └── sliding_window.rs ├── problem_0396_rotate_function │ ├── iterative.rs │ └── mod.rs ├── problem_0397_integer_replacement │ ├── dynamic_programming.rs │ ├── greedy.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0399_evaluate_division │ ├── bfs.rs │ └── mod.rs ├── problem_0400_nth_digit │ ├── binary_search.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0401_binary_watch │ ├── backtracking.rs │ └── mod.rs ├── problem_0402_remove_k_digits │ ├── greedy.rs │ ├── greedy_2.rs │ ├── mod.rs │ └── stack.rs ├── problem_0403_frog_jump │ ├── bfs.rs │ ├── dfs.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0404_sum_of_left_leaves │ ├── mod.rs │ └── recursive.rs ├── problem_0405_convert_a_number_to_hexadecimal │ ├── cheating.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0406_queue_reconstruction_by_height │ ├── binary_search_tree.rs │ ├── fenwick_tree.rs │ ├── insertion.rs │ ├── insertion_2.rs │ └── mod.rs ├── problem_0407_trapping_rain_water_ii │ ├── bfs.rs │ └── mod.rs ├── problem_0409_longest_palindrome │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0410_split_array_largest_sum │ ├── binary_search.rs │ └── mod.rs ├── problem_0412_fizz_buzz │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0413_arithmetic_slices │ ├── clever_iterative.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0414_third_maximum_number │ ├── iterative.rs │ └── mod.rs ├── problem_0415_add_strings │ ├── implicit_carry.rs │ ├── implicit_carry_2.rs │ ├── mod.rs │ └── naive.rs ├── problem_0416_partition_equal_subset_sum │ ├── knapsack.rs │ └── mod.rs ├── problem_0417_pacific_atlantic_water_flow │ ├── bfs.rs │ └── mod.rs ├── problem_0419_battleships_in_a_board │ ├── count_heads.rs │ └── mod.rs ├── problem_0420_strong_password_checker │ ├── greedy.rs │ └── mod.rs ├── problem_0421_maximum_xor_of_two_numbers_in_an_array │ ├── hash_map.rs │ ├── mod.rs │ └── trie.rs ├── problem_0423_reconstruct_original_digits_from_english │ ├── mod.rs │ └── solve_equations.rs ├── problem_0424_longest_repeating_character_replacement │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_0432_all_oone_data_structure │ ├── doubly_linked_list.rs │ └── mod.rs ├── problem_0433_minimum_genetic_mutation │ ├── bidirectional_bfs.rs │ └── mod.rs ├── problem_0434_number_of_segments_in_a_string │ ├── cheating.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0435_non_overlapping_intervals │ ├── greedy.rs │ └── mod.rs ├── problem_0436_find_right_interval │ ├── mod.rs │ ├── sort_and_merge.rs │ └── sort_and_scan.rs ├── problem_0437_path_sum_iii │ ├── mod.rs │ └── recursive.rs ├── problem_0438_find_all_anagrams_in_a_string │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_0440_k_th_smallest_in_lexicographical_order │ ├── mod.rs │ └── tree_preorder_traversal.rs ├── problem_0441_arranging_coins │ ├── mod.rs │ ├── newtons_method.rs │ ├── smart_newtons_method.rs │ └── smarter_newtons_method.rs ├── problem_0442_find_all_duplicates_in_an_array │ ├── highest_bit_as_marker.rs │ ├── mod.rs │ └── pigeonhole.rs ├── problem_0443_string_compression │ ├── iterative.rs │ └── mod.rs ├── problem_0445_add_two_numbers_ii │ ├── mod.rs │ └── reverse_output.rs ├── problem_0446_arithmetic_slices_ii_subsequence │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0447_number_of_boomerangs │ ├── group_by_circles.rs │ └── mod.rs ├── problem_0448_find_all_numbers_disappeared_in_an_array │ ├── highest_bit_as_marker.rs │ ├── mod.rs │ └── pigeonhole.rs ├── problem_0449_serialize_and_deserialize_bst │ ├── mod.rs │ └── preorder_traversal.rs ├── problem_0450_delete_node_in_a_bst │ ├── lift_right_min.rs │ └── mod.rs ├── problem_0451_sort_characters_by_frequency │ ├── mod.rs │ └── sort_counts.rs ├── problem_0452_minimum_number_of_arrows_to_burst_balloons │ ├── greedy.rs │ └── mod.rs ├── problem_0453_minimum_moves_to_equal_array_elements │ ├── iterative.rs │ └── mod.rs ├── problem_0454_4sum_ii │ ├── mod.rs │ └── reduce_to_two_sum.rs ├── problem_0455_assign_cookies │ ├── greedy.rs │ └── mod.rs ├── problem_0456_132_pattern │ ├── mod.rs │ ├── stack.rs │ └── stack_2.rs ├── problem_0457_circular_array_loop │ ├── iterative.rs │ └── mod.rs ├── problem_0458_poor_pigs │ ├── mathematical.rs │ └── mod.rs ├── problem_0459_repeated_substring_pattern │ ├── bidirectional_search.rs │ └── mod.rs ├── problem_0460_lfu_cache │ ├── map_to_nested_linked_lists.rs │ └── mod.rs ├── problem_0461_hamming_distance │ ├── mod.rs │ └── xor.rs ├── problem_0462_minimum_moves_to_equal_array_elements_ii │ ├── median.rs │ └── mod.rs ├── problem_0463_island_perimeter │ ├── brute_force.rs │ └── mod.rs ├── problem_0464_can_i_win │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_0466_count_the_repetitions │ ├── find_repeated_pattern.rs │ └── mod.rs ├── problem_0467_unique_substrings_in_wraparound_string │ ├── brute_force.rs │ └── mod.rs ├── problem_0468_validate_ip_address │ ├── check_one_by_one.rs │ └── mod.rs ├── problem_0472_concatenated_words │ ├── mod.rs │ └── trie_and_dynamic_programming.rs ├── problem_0473_matchsticks_to_square │ ├── backtracking.rs │ └── mod.rs ├── problem_0474_ones_and_zeroes │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0475_heaters │ ├── iterative.rs │ └── mod.rs ├── problem_0476_number_complement │ ├── bit_manipulation.rs │ ├── bit_manipulation_2.rs │ ├── bit_manipulation_3.rs │ └── mod.rs ├── problem_0477_total_hamming_distance │ ├── iterative.rs │ └── mod.rs ├── problem_0479_largest_palindrome_product │ ├── iterative.rs │ └── mod.rs ├── problem_0480_sliding_window_median │ ├── mod.rs │ ├── two_binary_heaps.rs │ └── two_sets.rs ├── problem_0481_magical_string │ ├── deque.rs │ ├── generator.rs │ ├── mod.rs │ ├── state_machine.rs │ └── state_machine_2.rs ├── problem_0482_license_key_formatting │ ├── iterative.rs │ └── mod.rs ├── problem_0483_smallest_good_base │ ├── iterative.rs │ └── mod.rs ├── problem_0485_max_consecutive_ones │ ├── iterative.rs │ ├── iterative_2.rs │ ├── iterative_3.rs │ ├── mod.rs │ └── tail_recursive.rs ├── problem_0486_predict_the_winner │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0488_zuma_game │ ├── bfs.rs │ └── mod.rs ├── problem_0491_non_decreasing_subsequences │ ├── mod.rs │ └── recursive.rs ├── problem_0492_construct_the_rectangle │ ├── iterative.rs │ └── mod.rs ├── problem_0493_reverse_pairs │ ├── divide_and_conquer.rs │ └── mod.rs ├── problem_0494_target_sum │ ├── dynamic_programming.rs │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_0495_teemo_attacking │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0496_next_greater_element_i │ ├── hash_map_and_stack.rs │ └── mod.rs ├── problem_0498_diagonal_traverse │ ├── iterative.rs │ └── mod.rs ├── problem_0500_keyboard_row │ ├── iterative.rs │ └── mod.rs ├── problem_0501_find_mode_in_binary_search_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0502_ipo │ ├── greedy.rs │ └── mod.rs ├── problem_0503_next_greater_element_ii │ ├── mod.rs │ └── stack.rs ├── problem_0504_base_7 │ ├── iterative.rs │ └── mod.rs ├── problem_0506_relative_ranks │ ├── mod.rs │ └── sort_indices.rs ├── problem_0507_perfect_number │ ├── cheating.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0508_most_frequent_subtree_sum │ ├── mod.rs │ └── recursive.rs ├── problem_0509_fibonacci_number │ ├── dynamic_programming.rs │ ├── fast_iterative.rs │ ├── fast_recursive.rs │ ├── mod.rs │ └── unsafe_math.rs ├── problem_0513_find_bottom_left_tree_value │ ├── bfs.rs │ ├── bfs_2.rs │ └── mod.rs ├── problem_0514_freedom_trail │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0515_find_largest_value_in_each_tree_row │ ├── bfs.rs │ └── mod.rs ├── problem_0516_longest_palindromic_subsequence │ ├── dynamic_programming.rs │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_0517_super_washing_machines │ ├── iterative.rs │ └── mod.rs ├── problem_0518_coin_change_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0520_detect_capital │ ├── iterative.rs │ ├── mod.rs │ └── pattern_matching.rs ├── problem_0521_longest_uncommon_subsequence_i │ ├── mod.rs │ └── standard.rs ├── problem_0522_longest_uncommon_subsequence_ii │ ├── mod.rs │ └── trie.rs ├── problem_0523_continuous_subarray_sum │ ├── mod.rs │ └── modular_arithmetic.rs ├── problem_0524_longest_word_in_dictionary_through_deleting │ ├── mod.rs │ └── trie.rs ├── problem_0525_contiguous_array │ ├── iterative.rs │ └── mod.rs ├── problem_0526_beautiful_arrangement │ ├── backtracking.rs │ └── mod.rs ├── problem_0529_minesweeper │ ├── bfs.rs │ └── mod.rs ├── problem_0530_minimum_absolute_difference_in_bst │ ├── mod.rs │ └── recursive.rs ├── problem_0532_k_diff_pairs_in_an_array │ ├── hash_set.rs │ └── mod.rs ├── problem_0535_encode_and_decode_tinyurl │ ├── hash_maps.rs │ ├── hash_maps_online_hack.rs │ └── mod.rs ├── problem_0537_complex_number_multiplication │ ├── mod.rs │ └── parsing.rs ├── problem_0538_convert_bst_to_greater_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0539_minimum_time_difference │ ├── iterative.rs │ └── mod.rs ├── problem_0540_single_element_in_a_sorted_array │ ├── binary_search.rs │ ├── binary_search_2.rs │ └── mod.rs ├── problem_0541_reverse_string_ii │ ├── mod.rs │ └── reverse_by_chunks.rs ├── problem_0542_01_matrix │ ├── bfs.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0543_diameter_of_binary_tree │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_0546_remove_boxes │ ├── dynamic_programming.rs │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_0547_number_of_provinces │ ├── bfs.rs │ └── mod.rs ├── problem_0551_student_attendance_record_i │ ├── iterative.rs │ ├── mod.rs │ ├── state_machine.rs │ └── state_machine_2.rs ├── problem_0552_student_attendance_record_ii │ ├── dynamic_programming.rs │ ├── matrix_multiplication.rs │ └── mod.rs ├── problem_0553_optimal_division │ ├── dynamic_programming.rs │ ├── mathematical.rs │ └── mod.rs ├── problem_0554_brick_wall │ ├── hash_map.rs │ └── mod.rs ├── problem_0556_next_greater_element_iii │ ├── mod.rs │ └── next_permutation.rs ├── problem_0557_reverse_words_in_a_string_iii │ ├── iterative.rs │ └── mod.rs ├── problem_0560_subarray_sum_equals_k │ ├── mod.rs │ └── prefix_sum.rs ├── problem_0561_array_partition │ ├── mod.rs │ └── sorting.rs ├── problem_0563_binary_tree_tilt │ ├── mod.rs │ └── recursive.rs ├── problem_0564_find_the_closest_palindrome │ ├── brute_force.rs │ └── mod.rs ├── problem_0565_array_nesting │ ├── iterative.rs │ └── mod.rs ├── problem_0566_reshape_the_matrix │ ├── iterative.rs │ └── mod.rs ├── problem_0567_permutation_in_string │ ├── mod.rs │ └── sliding_window.rs ├── problem_0572_subtree_of_another_tree │ ├── hash_map.rs │ ├── hashing.rs │ └── mod.rs ├── problem_0575_distribute_candies │ ├── hash_set.rs │ └── mod.rs ├── problem_0576_out_of_boundary_paths │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0581_shortest_unsorted_continuous_subarray │ ├── iterative.rs │ └── mod.rs ├── problem_0583_delete_operation_for_two_strings │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0587_erect_the_fence │ ├── grahams_scan.rs │ └── mod.rs ├── problem_0591_tag_validator │ ├── mod.rs │ ├── recursive_descent.rs │ └── recursive_descent_2.rs ├── problem_0592_fraction_addition_and_subtraction │ ├── iterative.rs │ └── mod.rs ├── problem_0593_valid_square │ ├── mathematical.rs │ └── mod.rs ├── problem_0594_longest_harmonious_subsequence │ ├── iterative.rs │ └── mod.rs ├── problem_0598_range_addition_ii │ ├── iterative.rs │ └── mod.rs ├── problem_0599_minimum_index_sum_of_two_lists │ ├── index_map.rs │ └── mod.rs ├── problem_0600_non_negative_integers_without_consecutive_ones │ ├── mathematical.rs │ ├── mathematical_2.rs │ └── mod.rs ├── problem_0605_can_place_flowers │ ├── iterative.rs │ └── mod.rs ├── problem_0606_construct_string_from_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0609_find_duplicate_file_in_system │ ├── hash_map.rs │ └── mod.rs ├── problem_0611_valid_triangle_number │ ├── mod.rs │ └── sort_then_binary_search.rs ├── problem_0617_merge_two_binary_trees │ ├── mod.rs │ └── recursive.rs ├── problem_0621_task_scheduler │ ├── greedy.rs │ ├── mathematical.rs │ └── mod.rs ├── problem_0622_design_circular_queue │ ├── head_and_tail.rs │ ├── mod.rs │ └── start_and_length.rs ├── problem_0623_add_one_row_to_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0628_maximum_product_of_three_numbers │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0629_k_inverse_pairs_array │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0630_course_schedule_iii │ ├── binary_heap.rs │ └── mod.rs ├── problem_0632_smallest_range_covering_elements_from_k_lists │ ├── binary_heap.rs │ ├── mod.rs │ └── sliding_window.rs ├── problem_0633_sum_of_square_numbers │ ├── brute_force.rs │ ├── mod.rs │ └── two_pointers.rs ├── problem_0636_exclusive_time_of_functions │ ├── mod.rs │ └── stack.rs ├── problem_0637_average_of_levels_in_binary_tree │ ├── bfs.rs │ └── mod.rs ├── problem_0638_shopping_offers │ ├── memoized_dynamic_programming.rs │ ├── memoized_dynamic_programming_2.rs │ ├── memoized_dynamic_programming_3.rs │ └── mod.rs ├── problem_0639_decode_ways_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0640_solve_the_equation │ ├── iterative.rs │ └── mod.rs ├── problem_0641_design_circular_deque │ ├── head_and_tail.rs │ ├── mod.rs │ └── start_and_length.rs ├── problem_0643_maximum_average_subarray_i │ ├── mod.rs │ └── sliding_window.rs ├── problem_0645_set_mismatch │ ├── highest_bit_as_marker.rs │ ├── mod.rs │ └── partition_by_bit.rs ├── problem_0646_maximum_length_of_pair_chain │ ├── greedy.rs │ └── mod.rs ├── problem_0647_palindromic_substrings │ ├── brute_force.rs │ └── mod.rs ├── problem_0648_replace_words │ ├── mod.rs │ └── trie.rs ├── problem_0649_dota2_senate │ ├── greedy.rs │ └── mod.rs ├── problem_0650_2_keys_keyboard │ ├── bfs.rs │ ├── mod.rs │ └── prime_factorization.rs ├── problem_0652_find_duplicate_subtrees │ ├── cached_hash_values.rs │ ├── hash_map.rs │ └── mod.rs ├── problem_0653_two_sum_iv_input_is_a_bst │ ├── bst_iterator.rs │ └── mod.rs ├── problem_0654_maximum_binary_tree │ ├── mod.rs │ └── stack.rs ├── problem_0655_print_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0657_robot_return_to_origin │ ├── iterative.rs │ └── mod.rs ├── problem_0658_find_k_closest_elements │ ├── binary_search.rs │ └── mod.rs ├── problem_0659_split_array_into_consecutive_subsequences │ ├── check_by_chunks.rs │ ├── mod.rs │ ├── two_binary_heaps.rs │ └── two_optimized_binary_heaps.rs ├── problem_0661_image_smoother │ ├── brute_force.rs │ └── mod.rs ├── problem_0662_maximum_width_of_binary_tree │ ├── bfs.rs │ └── mod.rs ├── problem_0664_strange_printer │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0665_non_decreasing_array │ ├── iterative.rs │ └── mod.rs ├── problem_0667_beautiful_arrangement_ii │ ├── mod.rs │ └── stack.rs ├── problem_0668_kth_smallest_number_in_multiplication_table │ ├── binary_search.rs │ └── mod.rs ├── problem_0669_trim_a_binary_search_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0670_maximum_swap │ ├── iterative.rs │ └── mod.rs ├── problem_0671_second_minimum_node_in_a_binary_tree │ ├── mod.rs │ └── specialized_recursive.rs ├── problem_0672_bulb_switcher_ii │ ├── brute_force.rs │ ├── enumerate.rs │ └── mod.rs ├── problem_0673_number_of_longest_increasing_subsequence │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0674_longest_continuous_increasing_subsequence │ ├── iterative.rs │ └── mod.rs ├── problem_0675_cut_off_trees_for_golf_event │ ├── bfs.rs │ └── mod.rs ├── problem_0676_implement_magic_dictionary │ ├── hash_map.rs │ ├── hash_map_2.rs │ ├── mod.rs │ ├── trie.rs │ ├── trie_2.rs │ └── trie_3.rs ├── problem_0677_map_sum_pairs │ ├── mod.rs │ └── trie.rs ├── problem_0678_valid_parenthesis_string │ ├── mod.rs │ └── stack.rs ├── problem_0679_24_game │ ├── backtracking.rs │ └── mod.rs ├── problem_0680_valid_palindrome_ii │ ├── iterative.rs │ └── mod.rs ├── problem_0682_baseball_game │ ├── mod.rs │ └── stack.rs ├── problem_0684_redundant_connection │ ├── mod.rs │ └── union_find.rs ├── problem_0685_redundant_connection_ii │ ├── mod.rs │ └── union_find.rs ├── problem_0686_repeated_string_match │ ├── mod.rs │ └── search_substring.rs ├── problem_0687_longest_univalue_path │ ├── mod.rs │ └── recursive.rs ├── problem_0688_knight_probability_in_chessboard │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0689_maximum_sum_of_3_non_overlapping_subarrays │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0691_stickers_to_spell_word │ ├── bfs.rs │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_0692_top_k_frequent_words │ ├── mod.rs │ └── quick_select.rs ├── problem_0693_binary_number_with_alternating_bits │ ├── count_leading_zeros.rs │ ├── mod.rs │ └── xor_with_shifting.rs ├── problem_0695_max_area_of_island │ ├── bfs.rs │ └── mod.rs ├── problem_0696_count_binary_substrings │ ├── iterative.rs │ └── mod.rs ├── problem_0697_degree_of_an_array │ ├── hash_map.rs │ └── mod.rs ├── problem_0698_partition_to_k_equal_sum_subsets │ ├── backtracking.rs │ └── mod.rs ├── problem_0699_falling_squares │ ├── btree_map.rs │ ├── mod.rs │ └── segment_tree.rs ├── problem_0700_search_in_a_binary_search_tree │ ├── iterative.rs │ └── mod.rs ├── problem_0701_insert_into_a_binary_search_tree │ ├── iterative.rs │ └── mod.rs ├── problem_0703_kth_largest_element_in_a_stream │ ├── binary_heap.rs │ └── mod.rs ├── problem_0704_binary_search │ ├── canonical.rs │ ├── cheating.rs │ ├── fast.rs │ ├── fast_2.rs │ ├── mod.rs │ ├── three_way.rs │ └── three_way_fast.rs ├── problem_0705_design_hashset │ ├── mod.rs │ └── store_by_buckets.rs ├── problem_0706_design_hashmap │ ├── mod.rs │ └── store_by_buckets.rs ├── problem_0707_design_linked_list │ ├── doubly_linked_list.rs │ └── mod.rs ├── problem_0709_to_lower_case │ ├── cheating.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0712_minimum_ascii_delete_sum_for_two_strings │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0713_subarray_product_less_than_k │ ├── mod.rs │ └── sliding_window.rs ├── problem_0714_best_time_to_buy_and_sell_stock_with_transaction_fee │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0715_range_module │ ├── btree_map.rs │ └── mod.rs ├── problem_0717_1_bit_and_2_bit_characters │ ├── iterative.rs │ └── mod.rs ├── problem_0718_maximum_length_of_repeated_subarray │ ├── binary_search.rs │ └── mod.rs ├── problem_0719_find_k_th_smallest_pair_distance │ ├── binary_search.rs │ └── mod.rs ├── problem_0720_longest_word_in_dictionary │ ├── mod.rs │ └── trie.rs ├── problem_0721_accounts_merge │ ├── iterative_dfs.rs │ └── mod.rs ├── problem_0722_remove_comments │ ├── iterative.rs │ └── mod.rs ├── problem_0724_find_pivot_index │ ├── iterative.rs │ └── mod.rs ├── problem_0725_split_linked_list_in_parts │ ├── mod.rs │ └── two_passes.rs ├── problem_0726_number_of_atoms │ ├── mod.rs │ └── right_to_left_recursive_descent.rs ├── problem_0728_self_dividing_numbers │ ├── brute_force.rs │ ├── brute_force_2.rs │ └── mod.rs ├── problem_0729_my_calendar_i │ ├── btree_map.rs │ └── mod.rs ├── problem_0730_count_different_palindromic_subsequences │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0731_my_calendar_ii │ ├── mod.rs │ └── sweep_line.rs ├── problem_0732_my_calendar_iii │ ├── mod.rs │ └── sweep_line.rs ├── problem_0733_flood_fill │ ├── bfs.rs │ └── mod.rs ├── problem_0735_asteroid_collision │ ├── mod.rs │ └── stack.rs ├── problem_0736_parse_lisp_expression │ ├── mod.rs │ └── recursive_descent.rs ├── problem_0738_monotone_increasing_digits │ ├── iterative.rs │ └── mod.rs ├── problem_0739_daily_temperatures │ ├── mod.rs │ └── stack.rs ├── problem_0740_delete_and_earn │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0741_cherry_pickup │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0743_network_delay_time │ ├── dijkstra.rs │ ├── dijkstra_2.rs │ └── mod.rs ├── problem_0744_find_smallest_letter_greater_than_target │ ├── binary_search.rs │ └── mod.rs ├── problem_0745_prefix_and_suffix_search │ ├── mod.rs │ ├── trie_with_enumerated_suffixes.rs │ └── two_tries.rs ├── problem_0746_min_cost_climbing_stairs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0747_largest_number_at_least_twice_of_others │ ├── greedy.rs │ └── mod.rs ├── problem_0748_shortest_completing_word │ ├── iterative.rs │ └── mod.rs ├── problem_0749_contain_virus │ ├── bfs.rs │ ├── bfs_2.rs │ ├── bfs_3.rs │ └── mod.rs ├── problem_0752_open_the_lock │ ├── bfs.rs │ ├── bfs_2.rs │ ├── bidirectional_bfs.rs │ └── mod.rs ├── problem_0753_cracking_the_safe │ ├── dfs.rs │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_0754_reach_a_number │ ├── mathematical.rs │ └── mod.rs ├── problem_0756_pyramid_transition_matrix │ ├── block_by_block_backtracking.rs │ ├── cached_layer_by_layer_backtracking.rs │ ├── layer_by_layer_backtracking.rs │ └── mod.rs ├── problem_0757_set_intersection_size_at_least_two │ ├── greedy.rs │ └── mod.rs ├── problem_0761_special_binary_string │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_0762_prime_number_of_set_bits_in_binary_representation │ ├── brute_force.rs │ ├── combinations.rs │ └── mod.rs ├── problem_0763_partition_labels │ ├── greedy.rs │ ├── merge_intervals.rs │ └── mod.rs ├── problem_0764_largest_plus_sign │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0765_couples_holding_hands │ ├── find_cycles.rs │ └── mod.rs ├── problem_0766_toeplitz_matrix │ ├── iterative.rs │ └── mod.rs ├── problem_0767_reorganize_string │ ├── buckets.rs │ ├── even_odd.rs │ └── mod.rs ├── problem_0768_max_chunks_to_make_sorted_ii │ ├── iterative.rs │ └── mod.rs ├── problem_0769_max_chunks_to_make_sorted │ ├── greedy.rs │ └── mod.rs ├── problem_0770_basic_calculator_iv │ ├── mod.rs │ └── recursive.rs ├── problem_0771_jewels_and_stones │ ├── brute_force.rs │ └── mod.rs ├── problem_0773_sliding_puzzle │ ├── bidirectional_bfs.rs │ └── mod.rs ├── problem_0775_global_and_local_inversions │ ├── iterative.rs │ ├── iterative_2.rs │ ├── iterative_3.rs │ └── mod.rs ├── problem_0777_swap_adjacent_in_lr_string │ ├── iterative.rs │ └── mod.rs ├── problem_0778_swim_in_rising_water │ ├── bfs.rs │ ├── bidirectional_bfs.rs │ └── mod.rs ├── problem_0779_k_th_symbol_in_grammar │ ├── mathematical.rs │ └── mod.rs ├── problem_0780_reaching_points │ ├── mathematical.rs │ └── mod.rs ├── problem_0781_rabbits_in_forest │ ├── buckets.rs │ └── mod.rs ├── problem_0782_transform_to_chessboard │ ├── iterative.rs │ └── mod.rs ├── problem_0783_minimum_distance_between_bst_nodes │ ├── mod.rs │ └── recursive.rs ├── problem_0784_letter_case_permutation │ ├── backtracking.rs │ └── mod.rs ├── problem_0785_is_graph_bipartite │ ├── bfs.rs │ └── mod.rs ├── problem_0786_k_th_smallest_prime_fraction │ ├── divide_and_conquer.rs │ └── mod.rs ├── problem_0787_cheapest_flights_within_k_stops │ ├── bfs.rs │ ├── dijkstra.rs │ └── mod.rs ├── problem_0788_rotated_digits │ ├── iterative.rs │ └── mod.rs ├── problem_0789_escape_the_ghosts │ ├── mathematical.rs │ └── mod.rs ├── problem_0790_domino_and_tromino_tiling │ ├── dynamic_programming.rs │ ├── matrix_multiplication.rs │ └── mod.rs ├── problem_0791_custom_sort_string │ ├── counting_sort.rs │ └── mod.rs ├── problem_0792_number_of_matching_subsequences │ ├── buckets.rs │ ├── mod.rs │ ├── trie.rs │ └── trie_2.rs ├── problem_0793_preimage_size_of_factorial_zeroes_function │ ├── binary_search.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0794_valid_tic_tac_toe_state │ ├── brute_force.rs │ └── mod.rs ├── problem_0795_number_of_subarrays_with_bounded_maximum │ ├── iterative.rs │ └── mod.rs ├── problem_0796_rotate_string │ ├── find_in_repeated_string.rs │ └── mod.rs ├── problem_0797_all_paths_from_source_to_target │ ├── dfs.rs │ └── mod.rs ├── problem_0798_smallest_rotation_with_highest_score │ ├── count_interval_intersections.rs │ └── mod.rs ├── problem_0799_champagne_tower │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0801_minimum_swaps_to_make_sequences_increasing │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0802_find_eventual_safe_states │ ├── cycle_detection.rs │ └── mod.rs ├── problem_0803_bricks_falling_when_hit │ ├── mod.rs │ └── reverse_time_and_union_find.rs ├── problem_0804_unique_morse_code_words │ ├── hash_set.rs │ └── mod.rs ├── problem_0805_split_array_with_same_average │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_0806_number_of_lines_to_write_string │ ├── iterative.rs │ └── mod.rs ├── problem_0807_max_increase_to_keep_city_skyline │ ├── iterative.rs │ └── mod.rs ├── problem_0808_soup_servings │ ├── bounded_memoized_dynamic_programming.rs │ └── mod.rs ├── problem_0809_expressive_words │ ├── iterative.rs │ └── mod.rs ├── problem_0810_chalkboard_xor_game │ ├── iterative.rs │ └── mod.rs ├── problem_0811_subdomain_visit_count │ ├── hash_map.rs │ └── mod.rs ├── problem_0812_largest_triangle_area │ ├── brute_force.rs │ ├── convex_hull.rs │ └── mod.rs ├── problem_0813_largest_sum_of_averages │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0814_binary_tree_pruning │ ├── mod.rs │ └── recursive.rs ├── problem_0815_bus_routes │ ├── bidirectional_bfs.rs │ ├── bidirectional_bfs_2.rs │ └── mod.rs ├── problem_0816_ambiguous_coordinates │ ├── brute_force.rs │ └── mod.rs ├── problem_0817_linked_list_components │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0818_race_car │ ├── bfs.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0819_most_common_word │ ├── hash_map.rs │ ├── hash_map_2.rs │ └── mod.rs ├── problem_0820_short_encoding_of_words │ ├── mod.rs │ ├── trie.rs │ ├── trie_2.rs │ └── trie_3.rs ├── problem_0821_shortest_distance_to_a_character │ ├── iterative.rs │ └── mod.rs ├── problem_0822_card_flipping_game │ ├── iterative.rs │ └── mod.rs ├── problem_0823_binary_trees_with_factors │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0824_goat_latin │ ├── iterative.rs │ └── mod.rs ├── problem_0825_friends_of_appropriate_ages │ ├── iterative.rs │ └── mod.rs ├── problem_0826_most_profit_assigning_work │ ├── iterative.rs │ └── mod.rs ├── problem_0827_making_a_large_island │ ├── bfs.rs │ └── mod.rs ├── problem_0828_count_unique_characters_of_all_substrings_of_a_given_string │ ├── dynamic_programming.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0829_consecutive_numbers_sum │ ├── brute_force.rs │ └── mod.rs ├── problem_0830_positions_of_large_groups │ ├── iterative.rs │ └── mod.rs ├── problem_0831_masking_personal_information │ ├── iterative.rs │ └── mod.rs ├── problem_0832_flipping_an_image │ ├── mod.rs │ └── naive.rs ├── problem_0833_find_and_replace_in_string │ ├── iterative.rs │ └── mod.rs ├── problem_0834_sum_of_distances_in_tree │ ├── dfs.rs │ └── mod.rs ├── problem_0835_image_overlap │ ├── brute_force.rs │ └── mod.rs ├── problem_0836_rectangle_overlap │ ├── mod.rs │ └── reduce_to_line_overlap.rs ├── problem_0837_new_21_game │ ├── dynamic_programming.rs │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_0838_push_dominoes │ ├── iterative.rs │ └── mod.rs ├── problem_0839_similar_string_groups │ ├── bfs.rs │ └── mod.rs ├── problem_0840_magic_squares_in_grid │ ├── brute_force.rs │ └── mod.rs ├── problem_0841_keys_and_rooms │ ├── bfs.rs │ └── mod.rs ├── problem_0842_split_array_into_fibonacci_sequence │ ├── brute_force.rs │ └── mod.rs ├── problem_0843_guess_the_word │ ├── brute_force.rs │ ├── brute_force_2.rs │ ├── brute_force_3.rs │ └── mod.rs ├── problem_0844_backspace_string_compare │ ├── mod.rs │ ├── reversed_iterator.rs │ └── stack.rs ├── problem_0845_longest_mountain_in_array │ ├── iterative.rs │ └── mod.rs ├── problem_0846_hand_of_straights │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0847_shortest_path_visiting_all_nodes │ ├── bfs.rs │ └── mod.rs ├── problem_0848_shifting_letters │ ├── iterative.rs │ └── mod.rs ├── problem_0849_maximize_distance_to_closest_person │ ├── iterative.rs │ └── mod.rs ├── problem_0850_rectangle_area_ii │ ├── mod.rs │ └── sweep_line_with_segment_tree.rs ├── problem_0851_loud_and_rich │ ├── dfs.rs │ ├── dfs_2.rs │ └── mod.rs ├── problem_0852_peak_index_in_a_mountain_array │ ├── binary_search.rs │ ├── iterative.rs │ └── mod.rs ├── problem_0853_car_fleet │ ├── iterative.rs │ └── mod.rs ├── problem_0854_k_similar_strings │ ├── bfs.rs │ └── mod.rs ├── problem_0855_exam_room │ ├── binary_heap.rs │ └── mod.rs ├── problem_0856_score_of_parentheses │ ├── iterative.rs │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_0857_minimum_cost_to_hire_k_workers │ ├── binary_heap.rs │ └── mod.rs ├── problem_0858_mirror_reflection │ ├── mathematical.rs │ ├── mathematical_2.rs │ └── mod.rs ├── problem_0859_buddy_strings │ ├── brute_force.rs │ └── mod.rs ├── problem_0860_lemonade_change │ ├── iterative.rs │ └── mod.rs ├── problem_0861_score_after_flipping_matrix │ ├── iterative.rs │ └── mod.rs ├── problem_0862_shortest_subarray_with_sum_at_least_k │ ├── mod.rs │ └── sliding_window.rs ├── problem_0863_all_nodes_distance_k_in_binary_tree │ ├── bfs.rs │ └── mod.rs ├── problem_0863_projection_area_of_3d_shapes │ ├── iterative.rs │ └── mod.rs ├── problem_0864_shortest_path_to_get_all_keys │ ├── bfs.rs │ └── mod.rs ├── problem_0865_smallest_subtree_with_all_the_deepest_nodes │ ├── mod.rs │ └── recursive.rs ├── problem_0866_prime_palindrome │ ├── brute_force.rs │ └── mod.rs ├── problem_0867_transpose_matrix │ ├── brute_force.rs │ └── mod.rs ├── problem_0868_binary_gap │ ├── iterative.rs │ └── mod.rs ├── problem_0869_reordered_power_of_2 │ ├── brute_force.rs │ └── mod.rs ├── problem_0870_advantage_shuffle │ ├── mod.rs │ └── sort_and_merge.rs ├── problem_0871_minimum_number_of_refueling_stops │ ├── greedy.rs │ └── mod.rs ├── problem_0872_leaf_similar_trees │ ├── iterator.rs │ └── mod.rs ├── problem_0873_length_of_longest_fibonacci_subsequence │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_0874_walking_robot_simulation │ ├── iterative.rs │ └── mod.rs ├── problem_0875_koko_eating_bananas │ ├── binary_search.rs │ └── mod.rs ├── problem_0876_middle_of_the_linked_list │ ├── iterative.rs │ └── mod.rs ├── problem_0877_stone_game │ ├── dynamic_programming.rs │ ├── mathematical.rs │ └── mod.rs ├── problem_0878_nth_magical_number │ ├── binary_search.rs │ ├── mathematical.rs │ └── mod.rs ├── problem_0879_profitable_schemes │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0880_decoded_string_at_index │ ├── iterative.rs │ └── mod.rs ├── problem_0881_boats_to_save_people │ ├── mod.rs │ ├── two_pointers.rs │ └── two_pointers_2.rs ├── problem_0882_reachable_nodes_in_subdivided_graph │ ├── dijkstra.rs │ └── mod.rs ├── problem_0883_projection_area_of_3d_shapes │ ├── iterative.rs │ └── mod.rs ├── problem_0884_uncommon_words_from_two_sentences │ ├── hash_map.rs │ └── mod.rs ├── problem_0885_spiral_matrix_iii │ ├── iterative.rs │ └── mod.rs ├── problem_0886_possible_bipartition │ ├── bfs.rs │ └── mod.rs ├── problem_0887_super_egg_drop │ ├── binary_search.rs │ └── mod.rs ├── problem_0888_fair_candy_swap │ ├── iterative.rs │ └── mod.rs ├── problem_0889_construct_binary_tree_from_preorder_and_postorder_traversal │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_0890_find_and_replace_pattern │ ├── iterative.rs │ └── mod.rs ├── problem_0891_sum_of_subsequence_widths │ ├── count_add_and_sub_separately.rs │ └── mod.rs ├── problem_0892_surface_area_of_3d_shapes │ ├── iterative.rs │ └── mod.rs ├── problem_0893_groups_of_special_equivalent_strings │ ├── hash_set.rs │ └── mod.rs ├── problem_0894_all_possible_full_binary_trees │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0895_maximum_frequency_stack │ ├── mod.rs │ └── stack_of_stacks.rs ├── problem_0896_monotonic_array │ ├── iterative.rs │ └── mod.rs ├── problem_0897_increasing_order_search_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0898_bitwise_ors_of_subarrays │ ├── iterative.rs │ └── mod.rs ├── problem_0899_orderly_queue │ ├── duval.rs │ └── mod.rs ├── problem_0900_rle_iterator │ ├── iterative.rs │ └── mod.rs ├── problem_0901_online_stock_span │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_0902_numbers_at_most_n_given_digit_set │ ├── iterative.rs │ └── mod.rs ├── problem_0903_valid_permutations_for_di_sequence │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0904_fruit_into_baskets │ ├── iterative.rs │ └── mod.rs ├── problem_0905_sort_array_by_parity │ ├── iterative.rs │ └── mod.rs ├── problem_0906_super_palindromes │ ├── brute_force.rs │ └── mod.rs ├── problem_0907_sum_of_subarray_minimums │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_0908_smallest_range_i │ ├── iterative.rs │ └── mod.rs ├── problem_0909_snakes_and_ladders │ ├── bfs.rs │ └── mod.rs ├── problem_0910_smallest_range_ii │ ├── iterative.rs │ └── mod.rs ├── problem_0911_online_election │ ├── mod.rs │ └── precompute.rs ├── problem_0912_sort_an_array │ ├── cheating.rs │ ├── cheating_unstable.rs │ ├── counting_sort_and_unstable_sort_hybrid.rs │ ├── heap_sort.rs │ ├── merge_sort.rs │ ├── mod.rs │ ├── quick_sort.rs │ ├── quick_sort_with_three_way_partition.rs │ └── radix_sort.rs ├── problem_0913_cat_and_mouse │ ├── minimax_queue.rs │ ├── minimax_stack.rs │ └── mod.rs ├── problem_0914_x_of_a_kind_in_a_deck_of_cards │ ├── gcd.rs │ └── mod.rs ├── problem_0915_partition_array_into_disjoint_intervals │ ├── iterative.rs │ └── mod.rs ├── problem_0916_word_subsets │ ├── iterative.rs │ └── mod.rs ├── problem_0917_reverse_only_letters │ ├── iterative.rs │ └── mod.rs ├── problem_0918_maximum_sum_circular_subarray │ ├── iterative.rs │ └── mod.rs ├── problem_0919_complete_binary_tree_inserter │ ├── mod.rs │ └── queue.rs ├── problem_0920_number_of_music_playlists │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0921_minimum_add_to_make_parentheses_valid │ ├── mod.rs │ └── stack.rs ├── problem_0922_sort_array_by_parity_ii │ ├── iterative.rs │ └── mod.rs ├── problem_0923_3sum_with_multiplicity │ ├── combinations.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0924_minimize_malware_spread │ ├── bfs.rs │ └── mod.rs ├── problem_0925_long_pressed_name │ ├── iterative.rs │ ├── iterative_2.rs │ ├── iterator.rs │ └── mod.rs ├── problem_0926_flip_string_to_monotone_increasing │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_0927_three_equal_parts │ ├── iterative.rs │ └── mod.rs ├── problem_0928_minimize_malware_spread_ii │ ├── bfs.rs │ └── mod.rs ├── problem_0929_unique_email_addresses │ ├── iterative.rs │ └── mod.rs ├── problem_0930_binary_subarrays_with_sum │ ├── mod.rs │ └── sliding_window.rs ├── problem_0931_minimum_falling_path_sum │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0932_beautiful_array │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0933_number_of_recent_calls │ ├── mod.rs │ └── queue.rs ├── problem_0934_shortest_bridge │ ├── bfs.rs │ └── mod.rs ├── problem_0935_knight_dialer │ ├── dynamic_programming.rs │ ├── matrix_multiplication.rs │ └── mod.rs ├── problem_0936_stamping_the_sequence │ ├── greedy.rs │ └── mod.rs ├── problem_0937_reorder_data_in_log_files │ ├── mod.rs │ └── partition_and_sort.rs ├── problem_0938_range_sum_of_bst │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_0939_minimum_area_rectangle │ ├── merge_by_columns.rs │ └── mod.rs ├── problem_0940_distinct_subsequences_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0941_valid_mountain_array │ ├── iterative.rs │ └── mod.rs ├── problem_0942_di_string_match │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0943_find_the_shortest_superstring │ ├── kmp_and_held_karp.rs │ └── mod.rs ├── problem_0944_delete_columns_to_make_sorted │ ├── brute_force.rs │ └── mod.rs ├── problem_0945_minimum_increment_to_make_array_unique │ ├── greedy.rs │ └── mod.rs ├── problem_0946_validate_stack_sequences │ ├── mod.rs │ └── simulation.rs ├── problem_0947_most_stones_removed_with_same_row_or_column │ ├── connected_components.rs │ ├── connected_components_2.rs │ └── mod.rs ├── problem_0948_bag_of_tokens │ ├── greedy.rs │ └── mod.rs ├── problem_0949_largest_time_for_given_digits │ ├── brute_force.rs │ └── mod.rs ├── problem_0950_reveal_cards_in_increasing_order │ ├── mod.rs │ └── recursive.rs ├── problem_0951_flip_equivalent_binary_trees │ ├── mod.rs │ └── recursive.rs ├── problem_0952_largest_component_size_by_common_factor │ ├── mod.rs │ └── union_find.rs ├── problem_0953_verifying_an_alien_dictionary │ ├── iterative.rs │ └── mod.rs ├── problem_0954_array_of_doubled_pairs │ ├── iterative.rs │ └── mod.rs ├── problem_0955_delete_columns_to_make_sorted_ii │ ├── greedy.rs │ └── mod.rs ├── problem_0956_tallest_billboard │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0957_prison_cells_after_n_days │ ├── find_cycle.rs │ └── mod.rs ├── problem_0958_check_completeness_of_a_binary_tree │ ├── bfs.rs │ └── mod.rs ├── problem_0959_regions_cut_by_slashes │ ├── bfs.rs │ └── mod.rs ├── problem_0960_delete_columns_to_make_sorted_iii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0961_n_repeated_element_in_size_2n_array │ ├── iterative.rs │ └── mod.rs ├── problem_0962_maximum_width_ramp │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_0963_minimum_area_rectangle_ii │ ├── brute_force.rs │ ├── brute_force_2.rs │ ├── brute_force_3.rs │ └── mod.rs ├── problem_0964_least_operators_to_express_number │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0965_univalued_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0966_vowel_spellchecker │ ├── iterative.rs │ └── mod.rs ├── problem_0967_numbers_with_same_consecutive_differences │ ├── dfs.rs │ └── mod.rs ├── problem_0968_binary_tree_cameras │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0969_pancake_sorting │ ├── iterative.rs │ └── mod.rs ├── problem_0970_powerful_integers │ ├── brute_force.rs │ └── mod.rs ├── problem_0971_flip_binary_tree_to_match_preorder_traversal │ ├── mod.rs │ └── recursive.rs ├── problem_0972_equal_rational_numbers │ ├── convert_to_fraction.rs │ └── mod.rs ├── problem_0973_k_closest_points_to_origin │ ├── mod.rs │ └── quick_select.rs ├── problem_0974_subarray_sums_divisible_by_k │ ├── iterative.rs │ └── mod.rs ├── problem_0975_odd_even_jump │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_0976_largest_perimeter_triangle │ ├── greedy.rs │ └── mod.rs ├── problem_0977_squares_of_a_sorted_array │ ├── merge.rs │ └── mod.rs ├── problem_0978_longest_turbulent_subarray │ ├── flip_every_second_order.rs │ └── mod.rs ├── problem_0979_distribute_coins_in_binary_tree │ ├── count_edge_flow.rs │ └── mod.rs ├── problem_0980_unique_paths_iii │ ├── backtracking.rs │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_0981_time_based_key_value_store │ ├── binary_search.rs │ ├── binary_search_2.rs │ └── mod.rs ├── problem_0982_triples_with_bitwise_and_equal_to_zero │ ├── iterative.rs │ └── mod.rs ├── problem_0983_minimum_cost_for_tickets │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_0984_string_without_aaa_or_bbb │ ├── greedy.rs │ └── mod.rs ├── problem_0985_sum_of_even_numbers_after_queries │ ├── iterative.rs │ └── mod.rs ├── problem_0986_interval_list_intersections │ ├── iterative.rs │ └── mod.rs ├── problem_0987_vertical_order_traversal_of_a_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_0988_smallest_string_starting_from_leaf │ ├── bottom_up.rs │ └── mod.rs ├── problem_0989_add_to_array_form_of_integer │ ├── iterative.rs │ └── mod.rs ├── problem_0990_satisfiability_of_equality_equations │ ├── bfs.rs │ └── mod.rs ├── problem_0991_broken_calculator │ ├── greedy.rs │ └── mod.rs ├── problem_0992_subarrays_with_k_different_integers │ ├── mod.rs │ └── sliding_window.rs ├── problem_0993_cousins_in_binary_tree │ ├── bfs.rs │ └── mod.rs ├── problem_0994_rotting_oranges │ ├── bfs.rs │ └── mod.rs ├── problem_0995_minimum_number_of_k_consecutive_bit_flips │ ├── greedy_sliding_window.rs │ ├── greedy_sliding_window_inplace.rs │ └── mod.rs ├── problem_0996_number_of_squareful_arrays │ ├── backtracking.rs │ └── mod.rs ├── problem_0997_find_the_town_judge │ ├── iterative.rs │ └── mod.rs ├── problem_0998_maximum_binary_tree_ii │ ├── iterative.rs │ └── mod.rs ├── problem_0999_available_captures_for_rook │ ├── brute_force.rs │ └── mod.rs ├── problem_1000_minimum_cost_to_merge_stones │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1001_grid_illumination │ ├── iterative.rs │ └── mod.rs ├── problem_1002_find_common_characters │ ├── iterative.rs │ └── mod.rs ├── problem_1003_check_if_word_is_valid_after_substitutions │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_1004_max_consecutive_ones_iii │ ├── mod.rs │ └── sliding_window.rs ├── problem_1005_maximize_sum_of_array_after_k_negations │ ├── greedy.rs │ └── mod.rs ├── problem_1006_clumsy_factorial │ ├── iterative.rs │ └── mod.rs ├── problem_1007_minimum_domino_rotations_for_equal_row │ ├── find_major_element.rs │ └── mod.rs ├── problem_1008_construct_binary_search_tree_from_preorder_traversal │ ├── mod.rs │ └── recursive.rs ├── problem_1009_complement_of_base_10_integer │ ├── bit_manipulation.rs │ ├── bit_manipulation_2.rs │ ├── bit_manipulation_3.rs │ └── mod.rs ├── problem_1010_pairs_of_songs_with_total_durations_divisible_by_60 │ ├── mod.rs │ └── modular_arithmetic.rs ├── problem_1011_capacity_to_ship_packages_within_d_days │ ├── binary_search.rs │ └── mod.rs ├── problem_1012_numbers_with_repeated_digits │ ├── iterative.rs │ └── mod.rs ├── problem_1013_partition_array_into_three_parts_with_equal_sum │ ├── iterative.rs │ └── mod.rs ├── problem_1014_best_sightseeing_pair │ ├── iterative.rs │ └── mod.rs ├── problem_1015_smallest_integer_divisible_by_k │ ├── find_cycle.rs │ └── mod.rs ├── problem_1016_binary_string_with_substrings_representing_1_to_n │ ├── brute_force.rs │ └── mod.rs ├── problem_1017_convert_to_base_2 │ ├── iterative.rs │ ├── iterative_2.rs │ ├── iterative_3.rs │ └── mod.rs ├── problem_1018_binary_prefix_divisible_by_5 │ ├── mod.rs │ └── modular_arithmetic.rs ├── problem_1019_next_greater_node_in_linked_list │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_1020_number_of_enclaves │ ├── bfs.rs │ └── mod.rs ├── problem_1021_remove_outermost_parentheses │ ├── iterative.rs │ └── mod.rs ├── problem_1022_sum_of_root_to_leaf_binary_numbers │ ├── mod.rs │ └── recursive.rs ├── problem_1023_camelcase_matching │ ├── iterative.rs │ └── mod.rs ├── problem_1024_video_stitching │ ├── greedy.rs │ └── mod.rs ├── problem_1025_divisor_game │ ├── mathematical.rs │ └── mod.rs ├── problem_1026_maximum_difference_between_node_and_ancestor │ ├── mod.rs │ └── recursive.rs ├── problem_1027_longest_arithmetic_subsequence │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1028_recover_a_tree_from_preorder_traversal │ ├── mod.rs │ ├── recursive.rs │ └── stack.rs ├── problem_1029_two_city_scheduling │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1030_matrix_cells_in_distance_order │ ├── bfs.rs │ └── mod.rs ├── problem_1031_maximum_sum_of_two_non_overlapping_subarrays │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1032_stream_of_characters │ ├── dfa.rs │ └── mod.rs ├── problem_1033_moving_stones_until_consecutive │ ├── greedy.rs │ └── mod.rs ├── problem_1034_coloring_a_border │ ├── bfs.rs │ └── mod.rs ├── problem_1035_uncrossed_lines │ ├── longest_common_subsequence.rs │ └── mod.rs ├── problem_1036_escape_a_large_maze │ ├── bfs.rs │ └── mod.rs ├── problem_1037_valid_boomerang │ ├── check_gradient.rs │ └── mod.rs ├── problem_1038_binary_search_tree_to_greater_sum_tree │ ├── mod.rs │ └── recursive.rs ├── problem_1039_minimum_score_triangulation_of_polygon │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1040_moving_stones_until_consecutive_ii │ ├── iterative.rs │ └── mod.rs ├── problem_1041_robot_bounded_in_circle │ ├── mathematical.rs │ └── mod.rs ├── problem_1042_flower_planting_with_no_adjacent │ ├── greedy.rs │ └── mod.rs ├── problem_1043_partition_array_for_maximum_sum │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1044_longest_duplicate_substring │ ├── binary_search_and_rolling_hash.rs │ └── mod.rs ├── problem_1046_last_stone_weight │ ├── brute_force_with_binary_heap.rs │ └── mod.rs ├── problem_1047_remove_all_adjacent_duplicates_in_string │ ├── greedy.rs │ └── mod.rs ├── problem_1048_longest_string_chain │ ├── dfs.rs │ └── mod.rs ├── problem_1049_last_stone_weight_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1051_height_checker │ ├── counting_sort.rs │ └── mod.rs ├── problem_1052_grumpy_bookstore_owner │ ├── mod.rs │ └── sliding_window.rs ├── problem_1053_previous_permutation_with_one_swap │ ├── iterative.rs │ └── mod.rs ├── problem_1054_distant_barcodes │ ├── even_odd.rs │ └── mod.rs ├── problem_1061_lexicographically_smallest_equivalent_string │ ├── dfs.rs │ ├── mod.rs │ └── union_find.rs ├── problem_1071_greatest_common_divisor_of_strings │ ├── even_odd.rs │ └── mod.rs ├── problem_1072_flip_columns_for_maximum_number_of_equal_rows │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_1073_adding_two_negabinary_numbers │ ├── iterative.rs │ └── mod.rs ├── problem_1074_number_of_submatrices_that_sum_to_target │ ├── iterative.rs │ └── mod.rs ├── problem_1078_occurrences_after_bigram │ ├── iterative.rs │ └── mod.rs ├── problem_1079_letter_tile_possibilities │ ├── brute_force.rs │ ├── mathematical.rs │ └── mod.rs ├── problem_1080_insufficient_nodes_in_root_to_leaf_paths │ ├── mod.rs │ └── recursive.rs ├── problem_1081_smallest_subsequence_of_distinct_characters │ ├── mod.rs │ └── stack.rs ├── problem_1089_duplicate_zeros │ ├── count_zeros.rs │ └── mod.rs ├── problem_1090_largest_values_from_labels │ ├── greedy.rs │ └── mod.rs ├── problem_1091_shortest_path_in_binary_matrix │ ├── bfs.rs │ └── mod.rs ├── problem_1092_shortest_common_supersequence │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1093_statistics_from_a_large_sample │ ├── iterative.rs │ └── mod.rs ├── problem_1094_car_pooling │ ├── binary_heap.rs │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1095_find_in_mountain_array │ ├── binary_search.rs │ └── mod.rs ├── problem_1096_brace_expansion_ii │ ├── mod.rs │ └── parse_and_expand.rs ├── problem_1103_distribute_candies_to_people │ ├── brute_force.rs │ └── mod.rs ├── problem_1104_path_in_zigzag_labelled_binary_tree │ ├── iterative.rs │ └── mod.rs ├── problem_1105_filling_bookcase_shelves │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1106_parsing_a_boolean_expression │ ├── mod.rs │ ├── recursive_descent.rs │ └── recursive_descent_2.rs ├── problem_1108_defanging_an_ip_address │ ├── brute_force.rs │ └── mod.rs ├── problem_1109_corporate_flight_bookings │ ├── iterative.rs │ └── mod.rs ├── problem_1110_delete_nodes_and_return_forest │ ├── mod.rs │ └── recursive.rs ├── problem_1111_maximum_nesting_depth_of_two_valid_parentheses_strings │ ├── greedy.rs │ ├── group_by_even_odd.rs │ └── mod.rs ├── problem_1122_relative_sort_array │ ├── hash_map.rs │ └── mod.rs ├── problem_1123_lowest_common_ancestor_of_deepest_leaves │ ├── mod.rs │ └── recursive.rs ├── problem_1124_longest_well_performing_interval │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_1125_smallest_sufficient_team │ ├── bfs.rs │ └── mod.rs ├── problem_1128_number_of_equivalent_domino_pairs │ ├── iterative.rs │ └── mod.rs ├── problem_1129_shortest_path_with_alternating_colors │ ├── bfs.rs │ └── mod.rs ├── problem_1130_minimum_cost_tree_from_leaf_values │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_1131_maximum_of_absolute_value_expression │ ├── iterative.rs │ └── mod.rs ├── problem_1137_n_th_tribonacci_number │ ├── matrix_multiplication.rs │ └── mod.rs ├── problem_1138_alphabet_board_path │ ├── iterative.rs │ └── mod.rs ├── problem_1139_largest_1_bordered_square │ ├── iterative.rs │ └── mod.rs ├── problem_1140_stone_game_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1143_longest_common_subsequence │ ├── dynamic_programming_1.rs │ ├── dynamic_programming_2.rs │ ├── memoized_dynamic_programming_1.rs │ ├── memoized_dynamic_programming_2.rs │ └── mod.rs ├── problem_1144_decrease_elements_to_make_array_zigzag │ ├── iterative.rs │ └── mod.rs ├── problem_1145_binary_tree_coloring_game │ ├── mod.rs │ └── recursive.rs ├── problem_1146_snapshot_array │ ├── binary_search.rs │ └── mod.rs ├── problem_1147_longest_chunked_palindrome_decomposition │ ├── greedy_with_rolling_hash.rs │ └── mod.rs ├── problem_1154_day_of_the_year │ ├── mod.rs │ └── pre_computed_sums.rs ├── problem_1155_number_of_dice_rolls_with_target_sum │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1156_swap_for_longest_repeated_character_substring │ ├── iterative.rs │ └── mod.rs ├── problem_1157_online_majority_element_in_subarray │ ├── mod.rs │ └── segment_tree_and_binary_search.rs ├── problem_1160_find_words_that_can_be_formed_by_characters │ ├── iterative.rs │ └── mod.rs ├── problem_1161_maximum_level_sum_of_a_binary_tree │ ├── bfs.rs │ └── mod.rs ├── problem_1162_as_far_from_land_as_possible │ ├── bfs.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1163_last_substring_in_lexicographical_order │ ├── iterative.rs │ └── mod.rs ├── problem_1169_invalid_transactions │ ├── mod.rs │ └── sliding_window.rs ├── problem_1170_compare_strings_by_frequency_of_the_smallest_character │ ├── binary_search.rs │ ├── cumulative_sum.rs │ └── mod.rs ├── problem_1171_remove_zero_sum_consecutive_nodes_from_linked_list │ ├── greedy.rs │ └── mod.rs ├── problem_1172_dinner_plate_stacks │ ├── heap.rs │ └── mod.rs ├── problem_1175_prime_arrangements │ ├── mod.rs │ ├── on_the_fly.rs │ └── pre_computed.rs ├── problem_1177_can_make_palindrome_from_substring │ ├── iterative.rs │ └── mod.rs ├── problem_1178_number_of_valid_words_for_each_puzzle │ ├── mod.rs │ └── trie.rs ├── problem_1184_distance_between_bus_stops │ ├── iterative.rs │ └── mod.rs ├── problem_1185_day_of_the_week │ ├── mod.rs │ └── sakamoto_s_methods.rs ├── problem_1186_maximum_subarray_sum_with_one_deletion │ ├── iterative.rs │ └── mod.rs ├── problem_1187_make_array_strictly_increasing │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1189_maximum_number_of_balloons │ ├── count_letters.rs │ └── mod.rs ├── problem_1190_reverse_substrings_between_each_pair_of_parentheses │ ├── mod.rs │ └── two_passes.rs ├── problem_1191_k_concatenation_maximum_sum │ ├── mathematical.rs │ └── mod.rs ├── problem_1192_critical_connections_in_a_network │ ├── dfs.rs │ ├── dfs_2.rs │ └── mod.rs ├── problem_1200_minimum_absolute_difference │ ├── mod.rs │ └── sort_and_check.rs ├── problem_1201_ugly_number_iii │ ├── binary_search.rs │ ├── binary_search_2.rs │ └── mod.rs ├── problem_1202_smallest_string_with_swaps │ ├── connected_components.rs │ └── mod.rs ├── problem_1203_sort_items_by_groups_respecting_dependencies │ ├── mod.rs │ └── topological_sorting.rs ├── problem_1206_design_skiplist │ ├── mod.rs │ ├── vanilla.rs │ ├── vanilla_low_memory.rs │ └── vanilla_rand.rs ├── problem_1207_unique_number_of_occurrences │ ├── hash_map_and_hash_set.rs │ └── mod.rs ├── problem_1208_get_equal_substrings_within_budget │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_1209_remove_all_adjacent_duplicates_in_string_ii │ ├── mod.rs │ └── stack.rs ├── problem_1210_minimum_moves_to_reach_target_with_rotations │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1217_minimum_cost_to_move_chips_to_the_same_position │ ├── mathematical.rs │ ├── mathematical_2.rs │ └── mod.rs ├── problem_1218_longest_arithmetic_subsequence_of_given_difference │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1219_path_with_maximum_gold │ ├── backtracking.rs │ └── mod.rs ├── problem_1220_count_vowels_permutation │ ├── matrix_multiplication.rs │ └── mod.rs ├── problem_1221_split_a_string_in_balanced_strings │ ├── greedy.rs │ └── mod.rs ├── problem_1222_queens_that_can_attack_the_king │ ├── iterative.rs │ └── mod.rs ├── problem_1223_dice_roll_simulation │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1224_maximum_equal_frequency │ ├── iterative.rs │ └── mod.rs ├── problem_1227_airplane_seat_assignment_probability │ ├── mathematical.rs │ └── mod.rs ├── problem_1232_check_if_it_is_a_straight_line │ ├── check_gradient.rs │ └── mod.rs ├── problem_1233_remove_sub_folders_from_the_filesystem │ ├── dfs.rs │ └── mod.rs ├── problem_1234_replace_the_substring_for_balanced_string │ ├── mod.rs │ └── sliding_window.rs ├── problem_1235_maximum_profit_in_job_scheduling │ ├── iterative.rs │ └── mod.rs ├── problem_1237_find_positive_integer_solution_for_a_given_equation │ ├── iterative.rs │ └── mod.rs ├── problem_1238_circular_permutation_in_binary_representation │ ├── gray_code.rs │ └── mod.rs ├── problem_1239_maximum_length_of_a_concatenated_string_with_unique_characters │ ├── dfs.rs │ └── mod.rs ├── problem_1240_tiling_a_rectangle_with_the_fewest_squares │ ├── backtracking.rs │ └── mod.rs ├── problem_1247_minimum_swaps_to_make_strings_equal │ ├── greedy.rs │ └── mod.rs ├── problem_1248_count_number_of_nice_subarrays │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_1249_minimum_remove_to_make_valid_parentheses │ ├── mod.rs │ └── stack.rs ├── problem_1250_check_if_it_is_a_good_array │ ├── iterative.rs │ └── mod.rs ├── problem_1252_cells_with_odd_values_in_a_matrix │ ├── mathematical.rs │ └── mod.rs ├── problem_1253_reconstruct_a_2_row_binary_matrix │ ├── greedy.rs │ └── mod.rs ├── problem_1254_number_of_closed_islands │ ├── bfs.rs │ └── mod.rs ├── problem_1255_maximum_score_words_formed_by_letters │ ├── brute_force.rs │ └── mod.rs ├── problem_1260_shift_2d_grid │ ├── array_rotation.rs │ └── mod.rs ├── problem_1261_find_elements_in_a_contaminated_binary_tree │ ├── iterative.rs │ └── mod.rs ├── problem_1262_greatest_sum_divisible_by_three │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ ├── dynamic_programming_3.rs │ ├── dynamic_programming_4.rs │ └── mod.rs ├── problem_1263_minimum_moves_to_move_a_box_to_their_target_location │ ├── bfs.rs │ └── mod.rs ├── problem_1266_minimum_time_visiting_all_points │ ├── greedy.rs │ └── mod.rs ├── problem_1267_count_servers_that_communicate │ ├── iterative.rs │ └── mod.rs ├── problem_1268_search_suggestions_system │ ├── mod.rs │ └── trie.rs ├── problem_1269_number_of_ways_to_stay_in_the_same_place_after_some_steps │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1275_find_winner_on_a_tic_tac_toe_game │ ├── brute_force.rs │ └── mod.rs ├── problem_1276_number_of_burgers_with_no_waste_of_ingredients │ ├── mathematical.rs │ └── mod.rs ├── problem_1277_count_square_submatrices_with_all_ones │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1278_palindrome_partitioning_iii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1281_subtract_the_product_and_sum_of_digits_of_an_integer │ ├── iterative.rs │ └── mod.rs ├── problem_1282_group_the_people_given_the_group_size_they_belong_to │ ├── iterative.rs │ └── mod.rs ├── problem_1283_find_the_smallest_divisor_given_a_threshold │ ├── binary_search.rs │ └── mod.rs ├── problem_1284_minimum_number_of_flips_to_convert_binary_matrix_to_zero_matrix │ ├── bfs.rs │ └── mod.rs ├── problem_1286_iterator_for_combination │ ├── iterative.rs │ └── mod.rs ├── problem_1287_element_appearing_more_than_25_in_sorted_array │ ├── iterative.rs │ └── mod.rs ├── problem_1288_remove_covered_intervals │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_1289_minimum_falling_path_sum_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1290_convert_binary_number_in_a_linked_list_to_integer │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1291_sequential_digits │ ├── binary_search.rs │ ├── iterative.rs │ └── mod.rs ├── problem_1292_maximum_side_length_of_a_square_with_sum_less_than_or_equal_to_threshold │ ├── cumulative_sum.rs │ └── mod.rs ├── problem_1293_shortest_path_in_a_grid_with_obstacles_elimination │ ├── bfs.rs │ └── mod.rs ├── problem_1295_find_numbers_with_even_number_of_digits │ ├── iterative.rs │ └── mod.rs ├── problem_1296_divide_array_in_sets_of_k_consecutive_numbers │ ├── iterative.rs │ └── mod.rs ├── problem_1297_maximum_number_of_occurrences_of_a_substring │ ├── mod.rs │ └── sliding_window.rs ├── problem_1298_maximum_candies_you_can_get_from_boxes │ ├── dfs.rs │ └── mod.rs ├── problem_1299_replace_elements_with_greatest_element_on_right_side │ ├── iterative.rs │ └── mod.rs ├── problem_1300_sum_of_mutated_array_closest_to_target │ ├── iterative.rs │ └── mod.rs ├── problem_1301_number_of_paths_with_max_score │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1302_deepest_leaves_sum │ ├── bfs.rs │ └── mod.rs ├── problem_1304_find_n_unique_integers_sum_up_to_zero │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1305_all_elements_in_two_binary_search_trees │ ├── merge_iterators.rs │ └── mod.rs ├── problem_1306_jump_game_iii │ ├── bfs.rs │ └── mod.rs ├── problem_1307_verbal_arithmetic_puzzle │ ├── brute_force.rs │ ├── dfs.rs │ └── mod.rs ├── problem_1309_decrypt_string_from_alphabet_to_integer_mapping │ ├── iterative.rs │ └── mod.rs ├── problem_1310_xor_queries_of_a_subarray │ ├── iterative.rs │ └── mod.rs ├── problem_1311_get_watched_videos_by_your_friends │ ├── bfs.rs │ └── mod.rs ├── problem_1312_minimum_insertion_steps_to_make_a_string_palindrome │ ├── dynamic_programming.rs │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_1313_decompress_run_length_encoded_list │ ├── iterative.rs │ └── mod.rs ├── problem_1314_matrix_block_sum │ ├── cumulative_sum.rs │ └── mod.rs ├── problem_1315_sum_of_nodes_with_even_valued_grandparent │ ├── mod.rs │ ├── recursive.rs │ └── recursive_2.rs ├── problem_1316_distinct_echo_substrings │ ├── mod.rs │ └── sliding.rs ├── problem_1317_convert_integer_to_the_sum_of_two_no_zero_integers │ ├── iterative.rs │ └── mod.rs ├── problem_1318_minimum_flips_to_make_a_or_b_equal_to_c │ ├── bit_manipulation.rs │ └── mod.rs ├── problem_1319_number_of_operations_to_make_network_connected │ ├── bfs.rs │ └── mod.rs ├── problem_1320_minimum_distance_to_type_a_word_using_two_fingers │ ├── dijkstras_algorithm.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1323_maximum_69_number │ ├── iterative.rs │ └── mod.rs ├── problem_1324_print_words_vertically │ ├── iterative.rs │ └── mod.rs ├── problem_1325_delete_leaves_with_a_given_value │ ├── mod.rs │ └── recursive.rs ├── problem_1326_minimum_number_of_taps_to_open_to_water_a_garden │ ├── greedy.rs │ └── mod.rs ├── problem_1328_break_a_palindrome │ ├── greedy.rs │ └── mod.rs ├── problem_1329_sort_the_matrix_diagonally │ ├── brute_force.rs │ └── mod.rs ├── problem_1330_reverse_subarray_to_maximize_array_value │ ├── mathematical.rs │ └── mod.rs ├── problem_1331_rank_transform_of_an_array │ ├── hash_map.rs │ └── mod.rs ├── problem_1332_remove_palindromic_subsequences │ ├── iterative.rs │ └── mod.rs ├── problem_1333_filter_restaurants_by_vegan_friendly_price_and_distance │ ├── iterative.rs │ └── mod.rs ├── problem_1334_find_the_city_with_the_smallest_number_of_neighbors_at_a_threshold_distance │ ├── floyd_warshall_algorithm.rs │ └── mod.rs ├── problem_1335_minimum_difficulty_of_a_job_schedule │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1337_the_k_weakest_rows_in_a_matrix │ ├── binary_heap.rs │ ├── mod.rs │ └── quick_select.rs ├── problem_1338_reduce_array_size_to_the_half │ ├── greedy.rs │ └── mod.rs ├── problem_1339_maximum_product_of_splitted_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_1340_jump_game_v │ ├── dfs.rs │ └── mod.rs ├── problem_1342_number_of_steps_to_reduce_a_number_to_zero │ ├── brute_force.rs │ ├── brute_force_2.rs │ └── mod.rs ├── problem_1343_number_of_sub_arrays_of_size_k_and_average_greater_than_or_equal_to_threshold │ ├── iterative.rs │ └── mod.rs ├── problem_1344_angle_between_hands_of_a_clock │ ├── mathematical.rs │ └── mod.rs ├── problem_1345_jump_game_iv │ ├── bfs.rs │ └── mod.rs ├── problem_1346_check_if_n_and_its_double_exist │ ├── hash_set.rs │ └── mod.rs ├── problem_1347_minimum_number_of_steps_to_make_two_strings_anagram │ ├── iterative.rs │ └── mod.rs ├── problem_1348_tweet_counts_per_frequency │ ├── iterative.rs │ └── mod.rs ├── problem_1349_maximum_students_taking_exam │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1351_count_negative_numbers_in_a_sorted_matrix │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1352_product_of_the_last_k_numbers │ ├── cumulative_product.rs │ └── mod.rs ├── problem_1353_maximum_number_of_events_that_can_be_attended │ ├── greedy_binary_heap.rs │ └── mod.rs ├── problem_1354_construct_target_array_with_multiple_sums │ ├── mod.rs │ └── restore_original_state.rs ├── problem_1356_sort_integers_by_the_number_of_1_bits │ ├── cheating.rs │ └── mod.rs ├── problem_1357_apply_discount_every_n_orders │ ├── mod.rs │ └── standard.rs ├── problem_1358_number_of_substrings_containing_all_three_characters │ ├── mod.rs │ └── sliding_window.rs ├── problem_1359_count_all_valid_pickup_and_delivery_options │ ├── mathematical.rs │ └── mod.rs ├── problem_1360_number_of_days_between_two_dates │ ├── mathematical.rs │ └── mod.rs ├── problem_1361_validate_binary_tree_nodes │ ├── dfs.rs │ └── mod.rs ├── problem_1362_closest_divisors │ ├── iterative.rs │ └── mod.rs ├── problem_1363_largest_multiple_of_three │ ├── greedy.rs │ └── mod.rs ├── problem_1365_how_many_numbers_are_smaller_than_the_current_number │ ├── hash_map.rs │ └── mod.rs ├── problem_1366_rank_teams_by_votes │ ├── iterative.rs │ └── mod.rs ├── problem_1367_linked_list_in_binary_tree │ ├── kmp.rs │ ├── kmp_2.rs │ └── mod.rs ├── problem_1368_minimum_cost_to_make_at_least_one_valid_path_in_a_grid │ ├── bfs.rs │ └── mod.rs ├── problem_1370_increasing_decreasing_string │ ├── iterative.rs │ └── mod.rs ├── problem_1371_find_the_longest_substring_containing_vowels_in_even_counts │ ├── iterative.rs │ └── mod.rs ├── problem_1372_longest_zigzag_path_in_a_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_1373_maximum_sum_bst_in_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_1374_generate_a_string_with_characters_that_have_odd_counts │ ├── iterative.rs │ └── mod.rs ├── problem_1375_number_of_times_binary_string_is_prefix_aligned │ ├── iterative.rs │ └── mod.rs ├── problem_1376_time_needed_to_inform_all_employees │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_1377_frog_position_after_t_seconds │ ├── dfs.rs │ └── mod.rs ├── problem_1380_lucky_numbers_in_a_matrix │ ├── mathematical.rs │ └── mod.rs ├── problem_1381_design_a_stack_with_increment_operation │ ├── lazy.rs │ └── mod.rs ├── problem_1382_balance_a_binary_search_tree │ ├── iterator.rs │ ├── mod.rs │ └── rebuild_from_scratch.rs ├── problem_1383_maximum_performance_of_a_team │ ├── binary_heap.rs │ └── mod.rs ├── problem_1385_find_the_distance_value_between_two_arrays │ ├── binary_search.rs │ ├── buckets.rs │ └── mod.rs ├── problem_1386_cinema_seat_allocation │ ├── iterative.rs │ └── mod.rs ├── problem_1387_sort_integers_by_the_power_value │ ├── mod.rs │ └── quick_select_and_memoized_dynamic_programming.rs ├── problem_1388_pizza_with_3n_slices │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1389_create_target_array_in_the_given_order │ ├── brute_force.rs │ ├── merge_sort.rs │ └── mod.rs ├── problem_1390_four_divisors │ ├── brute_force.rs │ └── mod.rs ├── problem_1391_check_if_there_is_a_valid_path_in_a_grid │ ├── iterative.rs │ └── mod.rs ├── problem_1392_longest_happy_prefix │ ├── iterative.rs │ └── mod.rs ├── problem_1394_find_lucky_integer_in_an_array │ ├── brute_force.rs │ └── mod.rs ├── problem_1395_count_number_of_teams │ ├── merge_sort.rs │ └── mod.rs ├── problem_1396_design_underground_system │ ├── mod.rs │ └── standard.rs ├── problem_1397_find_all_good_strings │ ├── memoized_dynamic_programming_with_kmp.rs │ └── mod.rs ├── problem_1399_count_largest_group │ ├── brute_force.rs │ └── mod.rs ├── problem_1400_construct_k_palindrome_strings │ ├── mathematical.rs │ └── mod.rs ├── problem_1401_circle_and_rectangle_overlapping │ ├── mathematical.rs │ └── mod.rs ├── problem_1402_reducing_dishes │ ├── greedy.rs │ ├── greedy_binary_heap.rs │ └── mod.rs ├── problem_1403_minimum_subsequence_in_non_increasing_order │ ├── greedy_binary_heap.rs │ └── mod.rs ├── problem_1404_number_of_steps_to_reduce_a_number_in_binary_representation_to_one │ ├── iterative.rs │ └── mod.rs ├── problem_1405_longest_happy_string │ ├── greedy.rs │ └── mod.rs ├── problem_1406_stone_game_iii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1408_string_matching_in_an_array │ ├── brute_force.rs │ └── mod.rs ├── problem_1409_queries_on_a_permutation_with_key │ ├── fenwick_tree.rs │ └── mod.rs ├── problem_1410_html_entity_parser │ ├── look_ahead.rs │ ├── mod.rs │ ├── state_machine.rs │ └── state_machine_2.rs ├── problem_1411_number_of_ways_to_paint_n_3_grid │ ├── dynamic_programming.rs │ ├── matrix_multiplication.rs │ └── mod.rs ├── problem_1413_minimum_value_to_get_positive_step_by_step_sum │ ├── iterative.rs │ └── mod.rs ├── problem_1414_find_the_minimum_number_of_fibonacci_numbers_whose_sum_is_k │ ├── greedy.rs │ └── mod.rs ├── problem_1415_the_k_th_lexicographical_string_of_all_happy_strings_of_length_n │ ├── mathematical.rs │ └── mod.rs ├── problem_1416_restore_the_array │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1417_reformat_the_string │ ├── iterative.rs │ └── mod.rs ├── problem_1418_display_table_of_food_orders_in_a_restaurant │ ├── hash_map.rs │ └── mod.rs ├── problem_1419_minimum_number_of_frogs_croaking │ ├── iterative.rs │ └── mod.rs ├── problem_1420_build_array_where_you_can_find_the_maximum_exactly_k_comparisons │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1422_maximum_score_after_splitting_a_string │ ├── iterative.rs │ └── mod.rs ├── problem_1423_maximum_points_you_can_obtain_from_cards │ ├── mod.rs │ └── sliding_window.rs ├── problem_1424_diagonal_traverse_ii │ ├── bfs.rs │ ├── bfs_2.rs │ └── mod.rs ├── problem_1425_constrained_subsequence_sum │ ├── mod.rs │ └── sliding_window_maximum.rs ├── problem_1431_kids_with_the_greatest_number_of_candies │ ├── iterative.rs │ └── mod.rs ├── problem_1432_max_difference_you_can_get_from_changing_an_integer │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_1433_check_if_a_string_can_break_another_string │ ├── compare_count.rs │ ├── mod.rs │ └── sort_and_compare.rs ├── problem_1434_number_of_ways_to_wear_different_hats_to_each_other │ ├── dynamic_programming.rs │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_1436_destination_city │ ├── hash_set.rs │ └── mod.rs ├── problem_1437_check_if_all_1s_are_at_least_length_k_places_away │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1438_longest_continuous_subarray_with_absolute_diff_less_than_or_equal_to_limit │ ├── mod.rs │ └── monotonic_stacks.rs ├── problem_1439_find_the_kth_smallest_sum_of_a_matrix_with_sorted_rows │ ├── binary_heap.rs │ └── mod.rs ├── problem_1441_build_an_array_with_stack_operations │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1442_count_triplets_that_can_form_two_arrays_of_equal_xor │ ├── iterative.rs │ └── mod.rs ├── problem_1443_minimum_time_to_collect_all_apples_in_a_tree │ ├── dfs.rs │ └── mod.rs ├── problem_1444_number_of_ways_of_cutting_a_pizza │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1446_consecutive_characters │ ├── iterative.rs │ └── mod.rs ├── problem_1447_simplified_fractions │ ├── brute_force.rs │ └── mod.rs ├── problem_1448_count_good_nodes_in_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_1449_form_largest_integer_with_digits_that_add_up_to_target │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1450_number_of_students_doing_homework_at_a_given_time │ ├── iterative.rs │ └── mod.rs ├── problem_1451_rearrange_words_in_a_sentence │ ├── iterative.rs │ └── mod.rs ├── problem_1452_people_whose_list_of_favorite_companies_is_not_a_subset_of_another_list │ ├── hash_set.rs │ └── mod.rs ├── problem_1453_maximum_number_of_darts_inside_of_a_circular_dartboard │ ├── angular_sweep.rs │ └── mod.rs ├── problem_1455_check_if_a_word_occurs_as_a_prefix_of_any_word_in_a_sentence │ ├── iterative.rs │ └── mod.rs ├── problem_1456_maximum_number_of_vowels_in_a_substring_of_given_length │ ├── mod.rs │ └── sliding_window.rs ├── problem_1457_pseudo_palindromic_paths_in_a_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_1458_max_dot_product_of_two_subsequences │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1460_make_two_arrays_equal_by_reversing_subarrays │ ├── iterative.rs │ └── mod.rs ├── problem_1461_check_if_a_string_contains_all_binary_codes_of_size_k │ ├── iterative.rs │ └── mod.rs ├── problem_1462_course_schedule_iv │ ├── floyd_warshall.rs │ ├── iterative_dfs.rs │ ├── mod.rs │ └── recursive_dfs.rs ├── problem_1463_cherry_pickup_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1464_maximum_product_of_two_elements_in_an_array │ ├── iterative.rs │ └── mod.rs ├── problem_1465_maximum_area_of_a_piece_of_cake_after_horizontal_and_vertical_cuts │ ├── greedy.rs │ └── mod.rs ├── problem_1466_reorder_routes_to_make_all_paths_lead_to_the_city_zero │ ├── dfs.rs │ └── mod.rs ├── problem_1467_probability_of_a_two_boxes_having_the_same_number_of_distinct_balls │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1470_shuffle_the_array │ ├── mod.rs │ └── reuse_upper_bits.rs ├── problem_1471_the_k_strongest_values_in_an_array │ ├── mod.rs │ └── quick_select.rs ├── problem_1472_design_browser_history │ ├── mod.rs │ └── stack.rs ├── problem_1473_paint_house_iii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1475_final_prices_with_a_special_discount_in_a_shop │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_1476_subrectangle_queries │ ├── mod.rs │ └── stack_updates.rs ├── problem_1477_find_two_non_overlapping_sub_arrays_each_with_target_sum │ ├── cached_sliding_window.rs │ ├── mod.rs │ └── sliding_window.rs ├── problem_1478_allocate_mailboxes │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1480_running_sum_of_1d_array │ ├── iterative.rs │ └── mod.rs ├── problem_1481_least_number_of_unique_integers_after_k_removals │ ├── greedy.rs │ └── mod.rs ├── problem_1482_minimum_number_of_days_to_make_m_bouquets │ ├── binary_search.rs │ ├── binary_search_2.rs │ └── mod.rs ├── problem_1483_kth_ancestor_of_a_tree_node │ ├── binary_lifting.rs │ └── mod.rs ├── problem_1486_xor_operation_in_an_array │ ├── bit_manipulation.rs │ └── mod.rs ├── problem_1487_making_file_names_unique │ ├── hash_map.rs │ └── mod.rs ├── problem_1488_avoid_flood_in_the_city │ ├── binary_heap.rs │ ├── btree_set.rs │ └── mod.rs ├── problem_1489_find_critical_and_pseudo_critical_edges_in_minimum_spanning_tree │ ├── kruskal.rs │ └── mod.rs ├── problem_1491_average_salary_excluding_the_minimum_and_maximum_salary │ ├── iterative.rs │ └── mod.rs ├── problem_1492_the_kth_factor_of_n │ ├── iterative.rs │ └── mod.rs ├── problem_1493_longest_subarray_of_1s_after_deleting_one_element │ ├── mod.rs │ └── sliding_window.rs ├── problem_1494_parallel_courses_ii │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_1496_path_crossing │ ├── hash_set.rs │ └── mod.rs ├── problem_1497_check_if_array_pairs_are_divisible_by_k │ ├── buckets.rs │ └── mod.rs ├── problem_1498_number_of_subsequences_that_satisfy_the_given_sum_condition │ ├── mod.rs │ └── two_pointers.rs ├── problem_1499_max_value_of_equation │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_1502_can_make_arithmetic_progression_from_sequence │ ├── mod.rs │ └── pigeonhole.rs ├── problem_1503_last_moment_before_all_ants_fall_out_of_a_plank │ ├── greedy.rs │ └── mod.rs ├── problem_1504_count_submatrices_with_all_ones │ ├── mod.rs │ ├── monotonic_stack.rs │ ├── monotonic_stack_2.rs │ └── monotonic_stack_3.rs ├── problem_1505_minimum_possible_integer_after_at_most_k_adjacent_swaps_on_digits │ ├── fenwick_tree.rs │ └── mod.rs ├── problem_1507_reformat_date │ ├── mod.rs │ └── parsing.rs ├── problem_1508_range_sum_of_sorted_subarray_sums │ ├── binary_heap.rs │ ├── binary_search.rs │ └── mod.rs ├── problem_1509_minimum_difference_between_largest_and_smallest_value_in_three_moves │ ├── mod.rs │ └── sliding_window.rs ├── problem_1510_stone_game_iv │ ├── memoized_dynamic_programming.rs │ └── mod.rs ├── problem_1512_number_of_good_pairs │ ├── iterative.rs │ └── mod.rs ├── problem_1513_number_of_substrings_with_only_1s │ ├── iterative.rs │ └── mod.rs ├── problem_1514_path_with_maximum_probability │ ├── dijkstra.rs │ ├── dijkstra_2.rs │ └── mod.rs ├── problem_1515_best_position_for_a_service_centre │ ├── geometric_median.rs │ └── mod.rs ├── problem_1518_water_bottles │ ├── mathematical.rs │ └── mod.rs ├── problem_1519_number_of_nodes_in_the_sub_tree_with_the_same_label │ ├── dfs.rs │ └── mod.rs ├── problem_1520_maximum_number_of_non_overlapping_substrings │ ├── mod.rs │ └── sliding_window_and_greedy.rs ├── problem_1521_find_a_value_of_a_mysterious_function_closest_to_target │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_masked.rs ├── problem_1523_count_odd_numbers_in_an_interval_range │ ├── mathematical.rs │ ├── mathematical_2.rs │ └── mod.rs ├── problem_1524_number_of_sub_arrays_with_odd_sum │ ├── iterative.rs │ └── mod.rs ├── problem_1525_number_of_good_ways_to_split_a_string │ ├── iterative.rs │ └── mod.rs ├── problem_1526_minimum_number_of_increments_on_subarrays_to_form_a_target_array │ ├── greedy.rs │ └── mod.rs ├── problem_1528_shuffle_string │ ├── iterative.rs │ └── mod.rs ├── problem_1529_minimum_suffix_flips │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_1530_number_of_good_leaf_nodes_pairs │ ├── mod.rs │ └── recursive.rs ├── problem_1531_string_compression_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1534_count_good_triplets │ ├── brute_force.rs │ ├── brute_force_2.rs │ └── mod.rs ├── problem_1535_find_the_winner_of_an_array_game │ ├── mod.rs │ └── simulation.rs ├── problem_1536_minimum_swaps_to_arrange_a_binary_grid │ ├── greedy.rs │ └── mod.rs ├── problem_1537_get_the_maximum_score │ ├── greedy.rs │ ├── mod.rs │ ├── state_matchine.rs │ └── tail_recursive.rs ├── problem_1539_kth_missing_positive_number │ ├── binary_search.rs │ └── mod.rs ├── problem_1540_can_convert_string_in_k_moves │ ├── buckets.rs │ └── mod.rs ├── problem_1541_minimum_insertions_to_balance_a_parentheses_string │ ├── mod.rs │ └── stack.rs ├── problem_1542_find_longest_awesome_substring │ ├── iterative.rs │ └── mod.rs ├── problem_1544_make_the_string_great │ ├── mod.rs │ └── stack.rs ├── problem_1545_find_kth_bit_in_nth_binary_string │ ├── iterative.rs │ ├── mathematical.rs │ └── mod.rs ├── problem_1546_maximum_number_of_non_overlapping_subarrays_with_sum_equals_target │ ├── greedy.rs │ └── mod.rs ├── problem_1547_minimum_cost_to_cut_a_stick │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_1550_three_consecutive_odds │ ├── iterative.rs │ └── mod.rs ├── problem_1551_minimum_operations_to_make_array_equal │ ├── mathematical.rs │ └── mod.rs ├── problem_1552_magnetic_force_between_two_balls │ ├── binary_search.rs │ └── mod.rs ├── problem_1553_minimum_number_of_days_to_eat_n_oranges │ ├── memoized_dynamic_programming.rs │ ├── memoized_dynamic_programming_2.rs │ ├── memoized_dynamic_programming_3.rs │ └── mod.rs ├── problem_1556_thousand_separator │ ├── iterative.rs │ └── mod.rs ├── problem_1557_minimum_number_of_vertices_to_reach_all_nodes │ ├── find_node_without_incoming_edges.rs │ └── mod.rs ├── problem_1558_minimum_numbers_of_function_calls_to_make_target_array │ ├── count_bits.rs │ └── mod.rs ├── problem_1559_detect_cycles_in_2d_grid │ ├── dfs.rs │ └── mod.rs ├── problem_1560_most_visited_sector_in_a_circular_track │ ├── mathematical.rs │ └── mod.rs ├── problem_1561_maximum_number_of_coins_you_can_get │ ├── greedy.rs │ └── mod.rs ├── problem_1562_find_latest_group_of_size_m │ ├── iterative.rs │ └── mod.rs ├── problem_1563_stone_game_v │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1566_detect_pattern_of_length_m_repeated_k_or_more_times │ ├── iterative.rs │ └── mod.rs ├── problem_1567_maximum_length_of_subarray_with_positive_product │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1568_minimum_number_of_days_to_disconnect_island │ ├── articulation_point.rs │ └── mod.rs ├── problem_1569_number_of_ways_to_reorder_array_to_get_same_bst │ ├── mod.rs │ └── recursive.rs ├── problem_1572_matrix_diagonal_sum │ ├── iterative.rs │ └── mod.rs ├── problem_1573_number_of_ways_to_split_a_string │ ├── iterative.rs │ └── mod.rs ├── problem_1574_shortest_subarray_to_be_removed_to_make_array_sorted │ ├── mod.rs │ └── sliding_window.rs ├── problem_1575_count_all_possible_routes │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1576_replace_all_s_to_avoid_consecutive_repeating_characters │ ├── iterative.rs │ └── mod.rs ├── problem_1577_number_of_ways_where_square_of_number_is_equal_to_product_of_two_numbers │ ├── hash_map.rs │ └── mod.rs ├── problem_1578_minimum_time_to_make_rope_colorful │ ├── greedy.rs │ └── mod.rs ├── problem_1579_remove_max_number_of_edges_to_keep_graph_fully_traversable │ ├── greedy_kruskal.rs │ └── mod.rs ├── problem_1582_special_positions_in_a_binary_matrix │ ├── iterative.rs │ └── mod.rs ├── problem_1583_count_unhappy_friends │ ├── brute_force.rs │ └── mod.rs ├── problem_1584_min_cost_to_connect_all_points │ ├── greedy_kruskal.rs │ ├── greedy_prim.rs │ └── mod.rs ├── problem_1585_check_if_string_is_transformable_with_substring_sort_operations │ ├── iterative.rs │ └── mod.rs ├── problem_1588_sum_of_all_odd_length_subarrays │ ├── mathematical.rs │ └── mod.rs ├── problem_1589_maximum_sum_obtained_of_any_permutation │ ├── greedy.rs │ └── mod.rs ├── problem_1590_make_sum_divisible_by_p │ ├── cumulative_sum.rs │ └── mod.rs ├── problem_1591_strange_printer_ii │ ├── cycle_detection.rs │ └── mod.rs ├── problem_1592_rearrange_spaces_between_words │ ├── iterative.rs │ └── mod.rs ├── problem_1593_split_a_string_into_the_max_number_of_unique_substrings │ ├── backtracking.rs │ └── mod.rs ├── problem_1594_maximum_non_negative_product_in_a_matrix │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1598_crawler_log_folder │ ├── mod.rs │ └── stack.rs ├── problem_1599_maximum_profit_of_operating_a_centennial_wheel │ ├── iterative.rs │ └── mod.rs ├── problem_1600_throne_inheritance │ ├── dfs.rs │ └── mod.rs ├── problem_1603_design_parking_system │ ├── mod.rs │ └── naive.rs ├── problem_1604_alert_using_same_key_card_three_or_more_times_in_a_one_hour_period │ ├── mod.rs │ └── sliding_window.rs ├── problem_1605_find_valid_matrix_given_row_and_column_sums │ ├── iterative.rs │ └── mod.rs ├── problem_1606_find_servers_that_handled_most_number_of_requests │ ├── binary_heap.rs │ └── mod.rs ├── problem_1608_special_array_with_x_elements_greater_than_or_equal_x │ ├── binary_heap.rs │ └── mod.rs ├── problem_1609_even_odd_tree │ ├── mod.rs │ └── recursive.rs ├── problem_1610_maximum_number_of_visible_points │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_1611_minimum_one_bit_operations_to_make_integers_zero │ ├── gray_code.rs │ └── mod.rs ├── problem_1614_maximum_nesting_depth_of_the_parentheses │ ├── mod.rs │ └── stack.rs ├── problem_1615_maximal_network_rank │ ├── brute_force.rs │ └── mod.rs ├── problem_1616_split_two_strings_to_make_palindrome │ ├── greedy.rs │ └── mod.rs ├── problem_1617_count_subtrees_with_max_distance_between_cities │ ├── brute_force.rs │ └── mod.rs ├── problem_1619_mean_of_array_after_removing_some_elements │ ├── mod.rs │ └── quick_select.rs ├── problem_1620_coordinate_with_maximum_network_quality │ ├── brute_force.rs │ └── mod.rs ├── problem_1621_number_of_sets_of_k_non_overlapping_line_segments │ ├── combinations.rs │ └── mod.rs ├── problem_1622_fancy_sequence │ ├── lazy.rs │ ├── mod.rs │ ├── mod_inverse.rs │ └── mod_inverse_2.rs ├── problem_1624_largest_substring_between_two_equal_characters │ ├── iterative.rs │ └── mod.rs ├── problem_1625_lexicographically_smallest_string_after_applying_operations │ ├── group_theory.rs │ └── mod.rs ├── problem_1626_best_team_with_no_conflicts │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1627_graph_connectivity_with_threshold │ ├── mod.rs │ └── union_find.rs ├── problem_1629_slowest_key │ ├── iterative.rs │ └── mod.rs ├── problem_1630_arithmetic_subarrays │ ├── iterative.rs │ └── mod.rs ├── problem_1631_path_with_minimum_effort │ ├── dijkstra.rs │ └── mod.rs ├── problem_1632_rank_transform_of_a_matrix │ ├── mod.rs │ └── union_find.rs ├── problem_1636_sort_array_by_increasing_frequency │ ├── iterative.rs │ └── mod.rs ├── problem_1637_widest_vertical_area_between_two_points_containing_no_points │ ├── greedy.rs │ └── mod.rs ├── problem_1638_count_substrings_that_differ_by_one_character │ ├── iterative.rs │ └── mod.rs ├── problem_1639_number_of_ways_to_form_a_target_string_given_a_dictionary │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_1640_check_array_formation_through_concatenation │ ├── map.rs │ └── mod.rs ├── problem_1641_count_sorted_vowel_strings │ ├── mathematical.rs │ └── mod.rs ├── problem_1642_furthest_building_you_can_reach │ ├── binary_heap.rs │ └── mod.rs ├── problem_1643_kth_smallest_instructions │ ├── combinations.rs │ └── mod.rs ├── problem_1646_get_maximum_in_generated_array │ ├── iterative.rs │ └── mod.rs ├── problem_1647_minimum_deletions_to_make_character_frequencies_unique │ ├── iterative.rs │ └── mod.rs ├── problem_1648_sell_diminishing_valued_colored_balls │ ├── greedy_binary_heap.rs │ └── mod.rs ├── problem_1649_create_sorted_array_through_instructions │ ├── merge_sort.rs │ └── mod.rs ├── problem_1652_defuse_the_bomb │ ├── iterative.rs │ └── mod.rs ├── problem_1653_minimum_deletions_to_make_string_balanced │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_1655_distribute_repeating_integers │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1656_design_an_ordered_stream │ ├── mod.rs │ └── vec_deque.rs ├── problem_1657_determine_if_two_strings_are_close │ ├── iterative.rs │ └── mod.rs ├── problem_1658_minimum_operations_to_reduce_x_to_zero │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_1659_maximize_grid_happiness │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1662_check_if_two_string_arrays_are_equivalent │ ├── flatten_iterator.rs │ └── mod.rs ├── problem_1663_smallest_string_with_a_given_numeric_value │ ├── mathematical.rs │ └── mod.rs ├── problem_1664_ways_to_make_a_fair_array │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1665_minimum_initial_energy_to_finish_tasks │ ├── greedy.rs │ └── mod.rs ├── problem_1668_maximum_repeating_substring │ ├── lazy_kmp.rs │ └── mod.rs ├── problem_1669_merge_in_between_linked_lists │ ├── iterative.rs │ └── mod.rs ├── problem_1670_design_front_middle_back_queue │ ├── mod.rs │ └── two_deques.rs ├── problem_1671_minimum_number_of_removals_to_make_mountain_array │ ├── longest_increasing_subsequence.rs │ └── mod.rs ├── problem_1672_richest_customer_wealth │ ├── iterator.rs │ └── mod.rs ├── problem_1673_find_the_most_competitive_subsequence │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_1674_minimum_moves_to_make_array_complementary │ ├── mod.rs │ └── sweep_line.rs ├── problem_1675_minimize_deviation_in_array │ ├── binary_heap.rs │ └── mod.rs ├── problem_1678_goal_parser_interpretation │ ├── iterative.rs │ └── mod.rs ├── problem_1679_max_number_of_k_sum_pairs │ ├── hash_map.rs │ └── mod.rs ├── problem_1680_concatenation_of_consecutive_binary_numbers │ ├── matrix_multiplication.rs │ └── mod.rs ├── problem_1681_minimum_incompatibility │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1684_count_the_number_of_consistent_strings │ ├── bit_manipulation.rs │ └── mod.rs ├── problem_1685_sum_of_absolute_differences_in_a_sorted_array │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1686_stone_game_vi │ ├── greedy.rs │ └── mod.rs ├── problem_1687_delivering_boxes_from_storage_to_ports │ ├── dynamic_programming_and_sliding_window.rs │ └── mod.rs ├── problem_1688_count_of_matches_in_tournament │ ├── mathematical.rs │ └── mod.rs ├── problem_1689_partitioning_into_minimum_number_of_deci_binary_numbers │ ├── greedy.rs │ └── mod.rs ├── problem_1690_stone_game_vii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1691_maximum_height_by_stacking_cuboids │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1694_reformat_phone_number │ ├── iterative.rs │ └── mod.rs ├── problem_1695_maximum_erasure_value │ ├── cumulative_sum.rs │ ├── mod.rs │ └── sliding_window.rs ├── problem_1696_jump_game_vi │ ├── mod.rs │ └── monotonic_deque.rs ├── problem_1697_checking_existence_of_edge_length_limited_paths │ ├── mod.rs │ └── union_find.rs ├── problem_1700_number_of_students_unable_to_eat_lunch │ ├── mod.rs │ └── simulation.rs ├── problem_1701_average_waiting_time │ ├── greedy.rs │ └── mod.rs ├── problem_1702_maximum_binary_string_after_change │ ├── greedy.rs │ └── mod.rs ├── problem_1703_minimum_adjacent_swaps_for_k_consecutive_ones │ ├── mod.rs │ └── sliding_window.rs ├── problem_1704_determine_if_string_halves_are_alike │ ├── iterative.rs │ └── mod.rs ├── problem_1705_maximum_number_of_eaten_apples │ ├── greedy_binary_heap.rs │ └── mod.rs ├── problem_1706_where_will_the_ball_fall │ ├── iterative.rs │ └── mod.rs ├── problem_1707_maximum_xor_with_an_element_from_array │ ├── mod.rs │ └── trie.rs ├── problem_1710_maximum_units_on_a_truck │ ├── greedy_binary_heap.rs │ ├── greedy_quick_select.rs │ └── mod.rs ├── problem_1711_count_good_meals │ ├── hash_map.rs │ └── mod.rs ├── problem_1712_ways_to_split_array_into_three_subarrays │ ├── mod.rs │ └── sliding_window.rs ├── problem_1713_minimum_operations_to_make_a_subsequence │ ├── longest_increasing_subsequence.rs │ └── mod.rs ├── problem_1716_calculate_money_in_leetcode_bank │ ├── mathematical.rs │ └── mod.rs ├── problem_1717_maximum_score_from_removing_substrings │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_1718_construct_the_lexicographically_largest_valid_sequence │ ├── backtracking.rs │ └── mod.rs ├── problem_1720_decode_xored_array │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1721_swapping_nodes_in_a_linked_list │ ├── iterative.rs │ └── mod.rs ├── problem_1722_minimize_hamming_distance_after_swap_operations │ ├── mod.rs │ └── union_find.rs ├── problem_1723_find_minimum_time_to_finish_all_jobs │ ├── binary_search.rs │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1725_number_of_rectangles_that_can_form_the_largest_square │ ├── iterative.rs │ └── mod.rs ├── problem_1726_tuple_with_same_product │ ├── hash_map.rs │ └── mod.rs ├── problem_1727_largest_submatrix_with_rearrangements │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1728_cat_and_mouse_ii │ ├── bfs.rs │ └── mod.rs ├── problem_1732_find_the_highest_altitude │ ├── iterative.rs │ └── mod.rs ├── problem_1733_minimum_number_of_people_to_teach │ ├── bit_set.rs │ ├── hash_set.rs │ └── mod.rs ├── problem_1734_decode_xored_permutation │ ├── iterative.rs │ └── mod.rs ├── problem_1735_count_ways_to_make_array_with_product │ ├── combinations.rs │ └── mod.rs ├── problem_1736_latest_time_by_replacing_hidden_digits │ ├── brute_force.rs │ └── mod.rs ├── problem_1737_change_minimum_characters_to_satisfy_one_of_three_conditions │ ├── mod.rs │ └── prefix_sum.rs ├── problem_1738_find_kth_largest_xor_coordinate_value │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1739_building_boxes │ ├── mathematical.rs │ └── mod.rs ├── problem_1742_maximum_number_of_balls_in_a_box │ ├── iterative.rs │ └── mod.rs ├── problem_1743_restore_the_array_from_adjacent_pairs │ ├── dfs.rs │ └── mod.rs ├── problem_1744_can_you_eat_your_favorite_candy_on_your_favorite_day │ ├── iterative.rs │ └── mod.rs ├── problem_1745_palindrome_partitioning_iv │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1748_sum_of_unique_elements │ ├── iterative.rs │ ├── iterative_2.rs │ ├── iterative_3.rs │ └── mod.rs ├── problem_1749_maximum_absolute_sum_of_any_subarray │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1750_minimum_length_of_string_after_deleting_similar_ends │ ├── iterative.rs │ └── mod.rs ├── problem_1751_maximum_number_of_events_that_can_be_attended_ii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1752_check_if_array_is_sorted_and_rotated │ ├── iterative.rs │ └── mod.rs ├── problem_1753_maximum_score_from_removing_stones │ ├── greedy.rs │ └── mod.rs ├── problem_1754_largest_merge_of_two_strings │ ├── greedy.rs │ └── mod.rs ├── problem_1755_closest_subsequence_sum │ ├── binary_search.rs │ └── mod.rs ├── problem_1758_minimum_changes_to_make_alternating_binary_string │ ├── dynamic_programming.rs │ ├── iterative.rs │ └── mod.rs ├── problem_1759_count_number_of_homogenous_substrings │ ├── greedy.rs │ └── mod.rs ├── problem_1760_minimum_limit_of_balls_in_a_bag │ ├── binary_search.rs │ └── mod.rs ├── problem_1761_minimum_degree_of_a_connected_trio_in_a_graph │ ├── adjacency_matrix.rs │ ├── hash_set.rs │ └── mod.rs ├── problem_1763_longest_nice_substring │ ├── divide_and_conquer.rs │ └── mod.rs ├── problem_1764_form_array_by_concatenating_subarrays_of_another_array │ ├── kmp.rs │ └── mod.rs ├── problem_1765_map_of_highest_peak │ ├── bfs.rs │ └── mod.rs ├── problem_1766_tree_of_coprimes │ ├── mod.rs │ └── recursive.rs ├── problem_1768_merge_strings_alternately │ ├── iterative.rs │ └── mod.rs ├── problem_1769_minimum_number_of_operations_to_move_all_balls_to_each_box │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1770_maximum_score_from_performing_multiplication_operations │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1771_maximize_palindrome_length_from_subsequences │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1773_count_items_matching_a_rule │ ├── iterative.rs │ └── mod.rs ├── problem_1774_closest_dessert_cost │ ├── binary_search.rs │ └── mod.rs ├── problem_1775_equal_sum_arrays_with_minimum_number_of_operations │ ├── greedy.rs │ └── mod.rs ├── problem_1776_car_fleet_ii │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_1779_find_nearest_point_that_has_the_same_x_or_y_coordinate │ ├── iterative.rs │ └── mod.rs ├── problem_1780_check_if_number_is_a_sum_of_powers_of_three │ ├── mod.rs │ └── ternary_number.rs ├── problem_1781_sum_of_beauty_of_all_substrings │ ├── brute_force.rs │ └── mod.rs ├── problem_1782_count_pairs_of_nodes │ ├── mod.rs │ └── two_pointers.rs ├── problem_1784_check_if_binary_string_has_at_most_one_segment_of_ones │ ├── iterative.rs │ └── mod.rs ├── problem_1785_minimum_elements_to_add_to_form_a_given_sum │ ├── mathematical.rs │ └── mod.rs ├── problem_1786_number_of_restricted_paths_from_first_to_last_node │ ├── dijkstra.rs │ └── mod.rs ├── problem_1787_make_the_xor_of_all_segments_equal_to_zero │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1790_check_if_one_string_swap_can_make_strings_equal │ ├── iterative.rs │ └── mod.rs ├── problem_1791_find_center_of_star_graph │ ├── mathematical.rs │ └── mod.rs ├── problem_1792_maximum_average_pass_ratio │ ├── greedy_binary_heap.rs │ └── mod.rs ├── problem_1793_maximum_score_of_a_good_subarray │ ├── iterative.rs │ └── mod.rs ├── problem_1796_second_largest_digit_in_a_string │ ├── iterative.rs │ └── mod.rs ├── problem_1797_design_authentication_manager │ ├── binary_heap.rs │ ├── binary_heap_2.rs │ └── mod.rs ├── problem_1798_maximum_number_of_consecutive_values_you_can_make │ ├── greedy.rs │ └── mod.rs ├── problem_1799_maximize_score_after_n_operations │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1800_maximum_ascending_subarray_sum │ ├── iterative.rs │ └── mod.rs ├── problem_1801_number_of_orders_in_the_backlog │ ├── binary_heap.rs │ └── mod.rs ├── problem_1802_maximum_value_at_a_given_index_in_a_bounded_array │ ├── mathematical.rs │ └── mod.rs ├── problem_1803_count_pairs_with_xor_in_a_range │ ├── mod.rs │ └── trie.rs ├── problem_1805_number_of_different_integers_in_a_string │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_1806_minimum_number_of_operations_to_reinitialize_a_permutation │ ├── mod.rs │ └── reversed_iteration.rs ├── problem_1807_evaluate_the_bracket_pairs_of_a_string │ ├── iterative.rs │ └── mod.rs ├── problem_1808_maximize_number_of_nice_divisors │ ├── mathematical.rs │ └── mod.rs ├── problem_1812_determine_color_of_a_chessboard_square │ ├── mathematical.rs │ └── mod.rs ├── problem_1813_sentence_similarity_iii │ ├── iterative.rs │ └── mod.rs ├── problem_1814_count_nice_pairs_in_an_array │ ├── hash_map.rs │ └── mod.rs ├── problem_1815_maximum_number_of_groups_getting_fresh_donuts │ ├── greedy_and_dynamic_programming.rs │ └── mod.rs ├── problem_1816_truncate_sentence │ ├── iterative.rs │ └── mod.rs ├── problem_1817_finding_the_users_active_minutes │ ├── hash_map_and_hash_set.rs │ └── mod.rs ├── problem_1818_minimum_absolute_sum_difference │ ├── binary_search.rs │ └── mod.rs ├── problem_1819_number_of_different_subsequences_gcds │ ├── mathematical.rs │ └── mod.rs ├── problem_1822_sign_of_the_product_of_an_array │ ├── iterative.rs │ └── mod.rs ├── problem_1824_minimum_sideway_jumps │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1825_finding_mk_average │ ├── btree_map.rs │ └── mod.rs ├── problem_1827_minimum_operations_to_make_the_array_increasing │ ├── iterative.rs │ └── mod.rs ├── problem_1829_maximum_xor_for_each_query │ ├── iterative.rs │ └── mod.rs ├── problem_1832_check_if_the_sentence_is_pangram │ ├── bit_manipulation.rs │ └── mod.rs ├── problem_1833_maximum_ice_cream_bars │ ├── counting_sort.rs │ └── mod.rs ├── problem_1834_single_threaded_cpu │ ├── binary_heap.rs │ └── mod.rs ├── problem_1835_find_xor_sum_of_all_pairs_bitwise_and │ ├── mathematical.rs │ └── mod.rs ├── problem_1837_sum_of_digits_in_base_k │ ├── iterative.rs │ └── mod.rs ├── problem_1838_frequency_of_the_most_frequent_element │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_1839_longest_substring_of_all_vowels_in_order │ ├── mod.rs │ └── state_machine.rs ├── problem_1840_maximum_building_height │ ├── iterative.rs │ └── mod.rs ├── problem_1844_replace_all_digits_with_characters │ ├── iterative.rs │ └── mod.rs ├── problem_1845_seat_reservation_manager │ ├── binary_heap.rs │ ├── lazy_binary_heap.rs │ └── mod.rs ├── problem_1846_maximum_element_after_decreasing_and_rearranging │ ├── greedy.rs │ └── mod.rs ├── problem_1847_closest_room │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_1848_minimum_distance_to_the_target_element │ ├── iterative.rs │ └── mod.rs ├── problem_1849_splitting_a_string_into_descending_consecutive_values │ ├── backtracking.rs │ └── mod.rs ├── problem_1850_minimum_adjacent_swaps_to_reach_the_kth_smallest_number │ ├── brute_force.rs │ └── mod.rs ├── problem_1851_minimum_interval_to_include_each_query │ ├── binary_heap_and_binary_search.rs │ └── mod.rs ├── problem_1854_maximum_population_year │ ├── iterative.rs │ └── mod.rs ├── problem_1855_maximum_distance_between_a_pair_of_values │ ├── mod.rs │ ├── two_pointers.rs │ └── two_pointers_2.rs ├── problem_1856_maximum_subarray_min_product │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_1857_largest_color_value_in_a_directed_graph │ ├── dfs.rs │ └── mod.rs ├── problem_1859_sorting_the_sentence │ ├── iterative.rs │ └── mod.rs ├── problem_1860_incremental_memory_leak │ ├── mod.rs │ └── simulation.rs ├── problem_1861_rotating_the_box │ ├── iterative.rs │ └── mod.rs ├── problem_1862_sum_of_floored_pairs │ ├── iterative.rs │ └── mod.rs ├── problem_1863_sum_of_all_subset_xor_totals │ ├── iterative.rs │ └── mod.rs ├── problem_1864_minimum_number_of_swaps_to_make_the_binary_string_alternating │ ├── greedy.rs │ └── mod.rs ├── problem_1865_finding_pairs_with_a_certain_sum │ ├── hash_map.rs │ └── mod.rs ├── problem_1866_number_of_ways_to_rearrange_sticks_with_k_sticks_visible │ ├── iterative.rs │ └── mod.rs ├── problem_1869_longer_contiguous_segments_of_ones_than_zeros │ ├── iterative.rs │ └── mod.rs ├── problem_1870_minimum_speed_to_arrive_on_time │ ├── binary_search.rs │ └── mod.rs ├── problem_1871_jump_game_vii │ ├── mod.rs │ └── sliding_window.rs ├── problem_1872_stone_game_viii │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1876_substrings_of_size_three_with_distinct_characters │ ├── iterative.rs │ └── mod.rs ├── problem_1877_minimize_maximum_pair_sum_in_array │ ├── greedy.rs │ └── mod.rs ├── problem_1878_get_biggest_three_rhombus_sums_in_a_grid │ ├── iterative.rs │ └── mod.rs ├── problem_1879_minimum_xor_sum_of_two_arrays │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1880_check_if_word_equals_summation_of_two_words │ ├── greedy.rs │ └── mod.rs ├── problem_1881_maximum_value_after_insertion │ ├── iterative.rs │ └── mod.rs ├── problem_1882_process_tasks_using_servers │ ├── binary_heap.rs │ └── mod.rs ├── problem_1883_minimum_skips_to_arrive_at_meeting_on_time │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1884_egg_drop_with_2_eggs_and_n_floors │ ├── dynamic_programming.rs │ ├── mathematical.rs │ └── mod.rs ├── problem_1886_determine_whether_matrix_can_be_obtained_by_rotation │ ├── brute_force.rs │ └── mod.rs ├── problem_1887_reduction_operations_to_make_the_array_elements_equal │ ├── iterative.rs │ └── mod.rs ├── problem_1888_minimum_number_of_flips_to_make_the_binary_string_alternating │ ├── mod.rs │ └── sliding_window.rs ├── problem_1889_minimum_space_wasted_from_packaging │ ├── mod.rs │ └── prefix_sum.rs ├── problem_1893_check_if_all_the_integers_in_a_range_are_covered │ ├── iterative.rs │ └── mod.rs ├── problem_1894_find_the_student_that_will_replace_the_chalk │ ├── iterative.rs │ └── mod.rs ├── problem_1895_largest_magic_square │ ├── mod.rs │ └── prefix_sum.rs ├── problem_1896_minimum_cost_to_change_the_final_value_of_expression │ ├── mod.rs │ └── recursive.rs ├── problem_1897_redistribute_characters_to_make_all_strings_equal │ ├── iterative.rs │ └── mod.rs ├── problem_1898_maximum_number_of_removable_characters │ ├── binary_search.rs │ └── mod.rs ├── problem_1899_merge_triplets_to_form_target_triplet │ ├── iterative.rs │ ├── iterative_2.rs │ ├── iterative_3.rs │ └── mod.rs ├── problem_1901_find_a_peak_element_ii │ ├── binary_search.rs │ └── mod.rs ├── problem_1903_largest_odd_number_in_string │ ├── greedy.rs │ └── mod.rs ├── problem_1904_the_number_of_full_rounds_you_have_played │ ├── mathematical.rs │ └── mod.rs ├── problem_1905_count_sub_islands │ ├── bfs.rs │ ├── bfs_2.rs │ └── mod.rs ├── problem_1906_minimum_absolute_difference_queries │ ├── mod.rs │ └── prefix_sum.rs ├── problem_1909_remove_one_element_to_make_the_array_strictly_increasing │ ├── iterative.rs │ └── mod.rs ├── problem_1910_remove_all_occurrences_of_a_substring │ ├── kmp.rs │ └── mod.rs ├── problem_1911_maximum_alternating_subsequence_sum │ ├── iterative.rs │ └── mod.rs ├── problem_1912_design_movie_rental_system │ ├── btree_set.rs │ ├── btree_set_2.rs │ └── mod.rs ├── problem_1913_maximum_product_difference_between_two_pairs │ ├── greedy.rs │ └── mod.rs ├── problem_1914_cyclically_rotating_a_grid │ ├── iterative.rs │ └── mod.rs ├── problem_1915_number_of_wonderful_substrings │ ├── mod.rs │ └── prefix_xor.rs ├── problem_1916_count_ways_to_build_rooms_in_an_ant_colony │ ├── mod.rs │ └── recursive_with_mod_inverse.rs ├── problem_1920_build_array_from_permutation │ ├── mod.rs │ └── utilize_higher_bits.rs ├── problem_1921_eliminate_maximum_number_of_monsters │ ├── buckets.rs │ └── mod.rs ├── problem_1922_count_good_numbers │ ├── mathematical.rs │ └── mod.rs ├── problem_1925_count_square_sum_triples │ ├── brute_force.rs │ └── mod.rs ├── problem_1926_nearest_exit_from_entrance_in_maze │ ├── bfs.rs │ └── mod.rs ├── problem_1927_sum_game │ ├── mathematical.rs │ └── mod.rs ├── problem_1928_minimum_cost_to_reach_destination_in_time │ ├── dijkstra.rs │ └── mod.rs ├── problem_1929_concatenation_of_array │ ├── cheating.rs │ └── mod.rs ├── problem_1930_unique_length_3_palindromic_subsequences │ ├── iterative.rs │ └── mod.rs ├── problem_1931_painting_a_grid_with_three_different_colors │ ├── matrix_multiplication.rs │ └── mod.rs ├── problem_1932_merge_bsts_to_create_single_bst │ ├── bfs.rs │ └── mod.rs ├── problem_1935_maximum_number_of_words_you_can_type │ ├── iterative.rs │ └── mod.rs ├── problem_1936_add_minimum_number_of_rungs │ ├── iterative.rs │ └── mod.rs ├── problem_1937_maximum_number_of_points_with_cost │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1938_maximum_genetic_difference_query │ ├── mod.rs │ └── trie.rs ├── problem_1941_check_if_all_characters_have_equal_number_of_occurrences │ ├── iterative.rs │ └── mod.rs ├── problem_1942_the_number_of_the_smallest_unoccupied_chair │ ├── binary_heap.rs │ └── mod.rs ├── problem_1943_describe_the_painting │ ├── iterative.rs │ └── mod.rs ├── problem_1944_number_of_visible_people_in_a_queue │ ├── mod.rs │ └── stack.rs ├── problem_1945_sum_of_digits_of_string_after_convert │ ├── iterative.rs │ └── mod.rs ├── problem_1946_largest_number_after_mutating_substring │ ├── greedy.rs │ └── mod.rs ├── problem_1948_delete_duplicate_folders_in_system │ ├── interning.rs │ └── mod.rs ├── problem_1952_three_divisors │ ├── iterative.rs │ └── mod.rs ├── problem_1953_maximum_number_of_weeks_for_which_you_can_work │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_1954_minimum_garden_perimeter_to_collect_enough_apples │ ├── mod.rs │ ├── newtons_method.rs │ └── newtons_method_2.rs ├── problem_1955_count_number_of_special_subsequences │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1957_delete_characters_to_make_fancy_string │ ├── iterative.rs │ └── mod.rs ├── problem_1958_check_if_move_is_legal │ ├── iterative.rs │ └── mod.rs ├── problem_1959_minimum_total_space_wasted_with_k_resizing_operations │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1961_check_if_string_is_a_prefix_of_array │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1962_remove_stones_to_minimize_the_total │ ├── binary_heap.rs │ └── mod.rs ├── problem_1963_minimum_number_of_swaps_to_make_the_string_balanced │ ├── iterative.rs │ └── mod.rs ├── problem_1964_find_the_longest_valid_obstacle_course_at_each_position │ ├── mod.rs │ └── stack.rs ├── problem_1967_number_of_strings_that_appear_as_substrings_in_word │ ├── brute_force.rs │ └── mod.rs ├── problem_1968_array_with_elements_not_equal_to_average_of_neighbors │ ├── iterative.rs │ └── mod.rs ├── problem_1969_minimum_non_zero_product_of_the_array_elements │ ├── mathematical.rs │ └── mod.rs ├── problem_1970_last_day_where_you_can_still_cross │ ├── mod.rs │ └── union_find.rs ├── problem_1971_find_if_path_exists_in_graph │ ├── bfs.rs │ ├── bidirectional_bfs.rs │ ├── dfs.rs │ ├── mod.rs │ ├── pseudo_dfs.rs │ └── union_find.rs ├── problem_1974_minimum_time_to_type_word_using_special_typewriter │ ├── iterative.rs │ └── mod.rs ├── problem_1975_maximum_matrix_sum │ ├── greedy.rs │ └── mod.rs ├── problem_1976_number_of_ways_to_arrive_at_destination │ ├── dijkstra.rs │ ├── dijkstra_2.rs │ └── mod.rs ├── problem_1977_number_of_ways_to_separate_numbers │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1979_find_greatest_common_divisor_of_array │ ├── iterative.rs │ └── mod.rs ├── problem_1980_find_unique_binary_string │ ├── iterative.rs │ └── mod.rs ├── problem_1981_minimize_the_difference_between_target_and_chosen_elements │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1982_find_array_given_subset_sums │ ├── divide_and_conquer.rs │ └── mod.rs ├── problem_1984_minimum_difference_between_highest_and_lowest_of_k_scores │ ├── mod.rs │ └── sliding_window.rs ├── problem_1985_find_the_kth_largest_integer_in_the_array │ ├── mod.rs │ └── quick_select.rs ├── problem_1986_minimum_number_of_work_sessions_to_finish_the_tasks │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1987_number_of_unique_good_subsequences │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_1991_find_the_middle_index_in_array │ ├── iterative.rs │ └── mod.rs ├── problem_1992_find_all_groups_of_farmland │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1993_operations_on_tree │ ├── iterative.rs │ └── mod.rs ├── problem_1994_the_number_of_good_subsets │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1995_count_special_quadruplets │ ├── hash_map.rs │ └── mod.rs ├── problem_1996_the_number_of_weak_characters_in_the_game │ ├── iterative.rs │ └── mod.rs ├── problem_1997_first_day_where_you_have_been_in_all_the_rooms │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_1998_gcd_sort_of_an_array │ ├── mod.rs │ └── union_find.rs ├── problem_2000_reverse_prefix_of_word │ ├── iterative.rs │ └── mod.rs ├── problem_2001_number_of_pairs_of_interchangeable_rectangles │ ├── hash_map.rs │ ├── hash_map_with_double_bytes.rs │ └── mod.rs ├── problem_2002_maximum_product_of_the_length_of_two_palindromic_subsequences │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2003_smallest_missing_genetic_value_in_each_subtree │ ├── bottom_up.rs │ └── mod.rs ├── problem_2006_count_number_of_pairs_with_absolute_difference_k │ ├── hash_map.rs │ ├── hash_map_2.rs │ └── mod.rs ├── problem_2007_find_original_array_from_doubled_array │ ├── hash_map.rs │ └── mod.rs ├── problem_2008_maximum_earnings_from_taxi │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2009_minimum_number_of_operations_to_make_array_continuous │ ├── iterative.rs │ └── mod.rs ├── problem_2011_final_value_of_variable_after_performing_operations │ ├── iterative.rs │ └── mod.rs ├── problem_2012_sum_of_beauty_in_the_array │ ├── iterative.rs │ └── mod.rs ├── problem_2013_detect_squares │ ├── hash_map.rs │ └── mod.rs ├── problem_2014_longest_subsequence_repeated_k_times │ ├── bfs.rs │ └── mod.rs ├── problem_2016_maximum_difference_between_increasing_elements │ ├── iterative.rs │ └── mod.rs ├── problem_2017_grid_game │ ├── greedy.rs │ └── mod.rs ├── problem_2018_check_if_word_can_be_placed_in_crossword │ ├── iterative.rs │ └── mod.rs ├── problem_2019_the_score_of_students_solving_math_expression │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2022_convert_1d_array_into_2d_array │ ├── iterative.rs │ └── mod.rs ├── problem_2023_number_of_pairs_of_strings_with_concatenation_equal_to_target │ ├── iterative.rs │ └── mod.rs ├── problem_2024_maximize_the_confusion_of_an_exam │ ├── mod.rs │ └── sliding_window.rs ├── problem_2025_maximum_number_of_ways_to_partition_an_array │ ├── mod.rs │ └── prefix_sum.rs ├── problem_2027_minimum_moves_to_convert_string │ ├── iterative.rs │ └── mod.rs ├── problem_2028_find_missing_observations │ ├── iterative.rs │ └── mod.rs ├── problem_2029_stone_game_ix │ ├── mathematical.rs │ └── mod.rs ├── problem_2030_smallest_k_length_subsequence_with_occurrences_of_a_letter │ ├── greedy_stack.rs │ └── mod.rs ├── problem_2032_two_out_of_three │ ├── iterative.rs │ └── mod.rs ├── problem_2033_minimum_operations_to_make_a_uni_value_grid │ ├── median.rs │ └── mod.rs ├── problem_2034_stock_price_fluctuation │ ├── binary_heap_and_hash_map.rs │ └── mod.rs ├── problem_2035_partition_array_into_two_arrays_to_minimize_sum_difference │ ├── meet_in_the_middle.rs │ └── mod.rs ├── problem_2037_minimum_number_of_moves_to_seat_everyone │ ├── iterative.rs │ └── mod.rs ├── problem_2038_remove_colored_pieces_if_both_neighbors_are_the_same_color │ ├── iterative.rs │ └── mod.rs ├── problem_2039_the_time_when_the_network_becomes_idle │ ├── bfs.rs │ └── mod.rs ├── problem_2040_kth_smallest_product_of_two_sorted_arrays │ ├── binary_search.rs │ └── mod.rs ├── problem_2042_check_if_numbers_are_ascending_in_a_sentence │ ├── iterative.rs │ └── mod.rs ├── problem_2043_simple_bank_system │ ├── mod.rs │ └── naive.rs ├── problem_2044_count_number_of_maximum_bitwise_or_subsets │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2045_second_minimum_time_to_reach_destination │ ├── bfs.rs │ └── mod.rs ├── problem_2047_number_of_valid_words_in_a_sentence │ ├── iterative.rs │ └── mod.rs ├── problem_2048_next_greater_numerically_balanced_number │ ├── binary_search.rs │ └── mod.rs ├── problem_2049_count_nodes_with_the_highest_score │ ├── mod.rs │ └── recursive.rs ├── problem_2050_parallel_courses_iii │ ├── iterative.rs │ ├── mod.rs │ └── recursive.rs ├── problem_2053_kth_distinct_string_in_an_array │ ├── hash_map.rs │ └── mod.rs ├── problem_2054_two_best_non_overlapping_events │ ├── iterative.rs │ └── mod.rs ├── problem_2055_plates_between_candles │ ├── mod.rs │ └── prefix_sum.rs ├── problem_2056_number_of_valid_move_combinations_on_chessboard │ ├── brute_force.rs │ └── mod.rs ├── problem_2057_smallest_index_with_equal_value │ ├── iterative.rs │ └── mod.rs ├── problem_2058_find_the_minimum_and_maximum_number_of_nodes_between_critical_points │ ├── iterative.rs │ └── mod.rs ├── problem_2059_minimum_operations_to_convert_number │ ├── bfs.rs │ └── mod.rs ├── problem_2062_count_vowel_substrings_of_a_string │ ├── mod.rs │ └── sliding_window.rs ├── problem_2063_vowels_of_all_substrings │ ├── iterative.rs │ └── mod.rs ├── problem_2064_minimized_maximum_of_products_distributed_to_any_store │ ├── binary_search.rs │ └── mod.rs ├── problem_2065_maximum_path_quality_of_a_graph │ ├── brute_force_dfs.rs │ └── mod.rs ├── problem_2068_check_whether_two_strings_are_almost_equivalent │ ├── iterative.rs │ └── mod.rs ├── problem_2069_walking_robot_simulation_ii │ ├── mod.rs │ └── modular_arithmetic.rs ├── problem_2070_most_beautiful_item_for_each_query │ ├── mod.rs │ └── sort_and_binary_search.rs ├── problem_2071_maximum_number_of_tasks_you_can_assign │ ├── binary_search_and_greedy.rs │ └── mod.rs ├── problem_2073_time_needed_to_buy_tickets │ ├── mod.rs │ └── sliding_window.rs ├── problem_2074_reverse_nodes_in_even_length_groups │ ├── iterative.rs │ └── mod.rs ├── problem_2075_decode_the_slanted_ciphertext │ ├── iterative.rs │ └── mod.rs ├── problem_2076_process_restricted_friend_requests │ ├── mod.rs │ └── union_find.rs ├── problem_2078_two_furthest_houses_with_different_colors │ ├── greedy.rs │ └── mod.rs ├── problem_2079_watering_plants │ ├── iterative.rs │ └── mod.rs ├── problem_2080_range_frequency_queries │ ├── binary_search.rs │ └── mod.rs ├── problem_2081_sum_of_k_mirror_numbers │ ├── cheating.rs │ ├── cheating_2.rs │ └── mod.rs ├── problem_2085_count_common_words_with_one_occurrence │ ├── hash_map.rs │ └── mod.rs ├── problem_2086_minimum_number_of_food_buckets_to_feed_the_hamsters │ ├── mod.rs │ ├── state_machine.rs │ ├── state_machine_2.rs │ └── state_machine_3.rs ├── problem_2087_minimum_cost_homecoming_of_a_robot_in_a_grid │ ├── greedy.rs │ └── mod.rs ├── problem_2088_count_fertile_pyramids_in_a_land │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2089_find_target_indices_after_sorting_array │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_2090_k_radius_subarray_averages │ ├── mod.rs │ └── sliding_window.rs ├── problem_2091_removing_minimum_and_maximum_from_array │ ├── iterative.rs │ └── mod.rs ├── problem_2092_find_all_people_with_secret │ ├── mod.rs │ └── union_find.rs ├── problem_2094_finding_3_digit_even_numbers │ ├── brute_force.rs │ ├── brute_force_2.rs │ └── mod.rs ├── problem_2095_delete_the_middle_node_of_a_linked_list │ ├── iterative.rs │ └── mod.rs ├── problem_2096_step_by_step_directions_from_a_binary_tree_node_to_another │ ├── mod.rs │ └── recursive.rs ├── problem_2097_valid_arrangement_of_pairs │ ├── dfs.rs │ ├── interned_dfs.rs │ ├── interned_dfs_with_stack.rs │ └── mod.rs ├── problem_2099_find_subsequence_of_length_k_with_the_largest_sum │ ├── mod.rs │ └── quick_select.rs ├── problem_2100_find_good_days_to_rob_the_bank │ ├── mod.rs │ └── sliding_window.rs ├── problem_2101_detonate_the_maximum_bombs │ ├── dfs.rs │ └── mod.rs ├── problem_2102_sequentially_ordinal_rank_tracker │ ├── binary_heap.rs │ └── mod.rs ├── problem_2103_rings_and_rods │ ├── iterative.rs │ └── mod.rs ├── problem_2104_sum_of_subarray_ranges │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_2105_watering_plants_ii │ ├── iterative.rs │ └── mod.rs ├── problem_2106_maximum_fruits_harvested_after_at_most_k_steps │ ├── greedy.rs │ └── mod.rs ├── problem_2108_find_first_palindromic_string_in_the_array │ ├── iterative.rs │ └── mod.rs ├── problem_2109_adding_spaces_to_a_string │ ├── iterative.rs │ └── mod.rs ├── problem_2110_number_of_smooth_descent_periods_of_a_stock │ ├── iterative.rs │ └── mod.rs ├── problem_2111_minimum_operations_to_make_the_array_k_increasing │ ├── longest_increasing_subsequence.rs │ ├── longest_increasing_subsequence_2.rs │ └── mod.rs ├── problem_2114_maximum_number_of_words_found_in_sentences │ ├── count_spaces.rs │ └── mod.rs ├── problem_2115_find_all_possible_recipes_from_given_supplies │ ├── bfs.rs │ └── mod.rs ├── problem_2116_check_if_a_parentheses_string_can_be_valid │ ├── mod.rs │ └── two_passes.rs ├── problem_2119_a_number_after_a_double_reversal │ ├── mathematical.rs │ └── mod.rs ├── problem_2120_execution_of_all_suffix_instructions_staying_in_a_grid │ ├── dequeue.rs │ └── mod.rs ├── problem_2121_intervals_between_identical_elements │ ├── iterative.rs │ └── mod.rs ├── problem_2122_recover_the_original_array │ ├── mod.rs │ └── two_pointers.rs ├── problem_2124_check_if_all_as_appears_before_all_bs │ ├── iterative.rs │ └── mod.rs ├── problem_2125_number_of_laser_beams_in_a_bank │ ├── iterative.rs │ └── mod.rs ├── problem_2126_destroying_asteroids │ ├── greedy.rs │ └── mod.rs ├── problem_2127_maximum_employees_to_be_invited_to_a_meeting │ ├── dfs.rs │ └── mod.rs ├── problem_2129_capitalize_the_title │ ├── iterative.rs │ └── mod.rs ├── problem_2130_maximum_twin_sum_of_a_linked_list │ ├── in_place.rs │ ├── mod.rs │ └── reverse_half.rs ├── problem_2131_longest_palindrome_by_concatenating_two_letter_words │ ├── greedy.rs │ └── mod.rs ├── problem_2132_stamping_the_grid │ ├── mod.rs │ └── sliding_window.rs ├── problem_2133_check_if_every_row_and_column_contains_all_numbers │ ├── iterative.rs │ └── mod.rs ├── problem_2134_minimum_swaps_to_group_all_1s_together_ii │ ├── mod.rs │ └── sliding_window.rs ├── problem_2135_count_words_obtained_after_adding_a_letter │ ├── hash_set.rs │ └── mod.rs ├── problem_2136_earliest_possible_day_of_full_bloom │ ├── greedy.rs │ └── mod.rs ├── problem_2138_divide_a_string_into_groups_of_size_k │ ├── iterative.rs │ └── mod.rs ├── problem_2139_minimum_moves_to_reach_target_score │ ├── greedy.rs │ └── mod.rs ├── problem_2140_solving_questions_with_brainpower │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2141_maximum_running_time_of_n_computers │ ├── mod.rs │ └── quick_select_three_way.rs ├── problem_2144_minimum_cost_of_buying_candies_with_discount │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_2145_count_the_hidden_sequences │ ├── iterative.rs │ └── mod.rs ├── problem_2146_k_highest_ranked_items_within_a_price_range │ ├── bfs_and_quick_select.rs │ └── mod.rs ├── problem_2147_number_of_ways_to_divide_a_long_corridor │ ├── iterative.rs │ └── mod.rs ├── problem_2148_count_elements_with_strictly_smaller_and_greater_elements │ ├── iterative.rs │ └── mod.rs ├── problem_2149_rearrange_array_elements_by_sign │ ├── iterative.rs │ └── mod.rs ├── problem_2150_find_all_lonely_numbers_in_the_array │ ├── hash_map.rs │ └── mod.rs ├── problem_2154_keep_multiplying_found_values_by_two │ ├── hash_set.rs │ └── mod.rs ├── problem_2155_all_divisions_with_the_highest_score_of_a_binary_array │ ├── iterative.rs │ └── mod.rs ├── problem_2156_find_substring_with_given_hash_value │ ├── iterative.rs │ └── mod.rs ├── problem_2157_groups_of_strings │ ├── hash_map.rs │ └── mod.rs ├── problem_2160_minimum_sum_of_four_digit_number_after_splitting_digits │ ├── mathematical.rs │ └── mod.rs ├── problem_2161_partition_array_according_to_given_pivot │ ├── iterative.rs │ └── mod.rs ├── problem_2162_minimum_cost_to_set_cooking_time │ ├── mathematical.rs │ └── mod.rs ├── problem_2163_minimum_difference_in_sums_after_removal_of_elements │ ├── binary_heap.rs │ └── mod.rs ├── problem_2164_sort_even_and_odd_indices_independently │ ├── mod.rs │ └── out_of_place_sorting.rs ├── problem_2165_smallest_value_of_the_rearranged_number │ ├── iterative.rs │ └── mod.rs ├── problem_2166_design_bitset │ ├── dense_storage.rs │ └── mod.rs ├── problem_2167_minimum_time_to_remove_all_cars_containing_illegal_goods │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_2169_count_operations_to_obtain_zero │ ├── mathematical.rs │ └── mod.rs ├── problem_2170_minimum_operations_to_make_the_array_alternating │ ├── hash_map.rs │ └── mod.rs ├── problem_2171_removing_minimum_number_of_magic_beans │ ├── mod.rs │ └── sorting.rs ├── problem_2172_maximum_and_sum_of_array │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_2176_count_equal_and_divisible_pairs_in_an_array │ ├── iterative.rs │ └── mod.rs ├── problem_2177_find_three_consecutive_integers_that_sum_to_a_given_number │ ├── divide_by_3.rs │ └── mod.rs ├── problem_2178_maximum_split_of_positive_even_integers │ ├── greedy.rs │ ├── mathematical.rs │ └── mod.rs ├── problem_2179_count_good_triplets_in_an_array │ ├── fenwick_tree.rs │ └── mod.rs ├── problem_2180_count_integers_with_even_digit_sum │ ├── mathematical.rs │ └── mod.rs ├── problem_2181_merge_nodes_in_between_zeros │ ├── iterative.rs │ └── mod.rs ├── problem_2182_construct_string_with_repeat_limit │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_2183_count_array_pairs_divisible_by_k │ ├── gcd_and_hash_map.rs │ ├── gcd_and_hash_map_2.rs │ └── mod.rs ├── problem_2185_counting_words_with_a_given_prefix │ ├── iterative.rs │ └── mod.rs ├── problem_2186_minimum_number_of_steps_to_make_two_strings_anagram_ii │ ├── iterative.rs │ └── mod.rs ├── problem_2187_minimum_time_to_complete_trips │ ├── binary_search.rs │ └── mod.rs ├── problem_2188_minimum_time_to_finish_the_race │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2190_most_frequent_number_following_key_in_an_array │ ├── iterative.rs │ └── mod.rs ├── problem_2191_sort_the_jumbled_numbers │ ├── iterative.rs │ └── mod.rs ├── problem_2192_all_ancestors_of_a_node_in_a_directed_acyclic_graph │ ├── dfs.rs │ ├── dfs_2.rs │ ├── dfs_3.rs │ └── mod.rs ├── problem_2194_cells_in_a_range_on_an_excel_sheet │ ├── iterative.rs │ └── mod.rs ├── problem_2195_append_k_integers_with_minimal_sum │ ├── greedy.rs │ ├── greedy_2.rs │ ├── mod.rs │ └── quick_select.rs ├── problem_2196_create_binary_tree_from_descriptions │ ├── hash_map.rs │ └── mod.rs ├── problem_2197_replace_non_coprime_numbers_in_array │ ├── mod.rs │ └── stack.rs ├── problem_2200_find_all_k_distant_indices_in_an_array │ ├── iterative.rs │ └── mod.rs ├── problem_2201_count_artifacts_that_can_be_extracted │ ├── brute_force.rs │ └── mod.rs ├── problem_2202_maximize_the_topmost_element_after_k_moves │ ├── iterative.rs │ └── mod.rs ├── problem_2203_minimum_weighted_subgraph_with_the_required_paths │ ├── dijkstra.rs │ └── mod.rs ├── problem_2206_divide_array_into_equal_pairs │ ├── iterative.rs │ └── mod.rs ├── problem_2207_maximize_number_of_subsequences_in_a_string │ ├── greedy.rs │ └── mod.rs ├── problem_2208_minimum_operations_to_halve_array_sum │ ├── greedy_binary_heap.rs │ └── mod.rs ├── problem_2209_minimum_white_tiles_after_covering_with_carpets │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2210_count_hills_and_valleys_in_an_array │ ├── iterative.rs │ └── mod.rs ├── problem_2211_count_collisions_on_a_road │ ├── iterative.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_2212_maximum_points_in_an_archery_competition │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2215_find_the_difference_of_two_arrays │ ├── hash_set.rs │ └── mod.rs ├── problem_2216_minimum_deletions_to_make_array_beautiful │ ├── greedy.rs │ └── mod.rs ├── problem_2217_find_palindrome_with_fixed_length │ ├── mathematical.rs │ └── mod.rs ├── problem_2218_maximum_value_of_k_coins_from_piles │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2220_minimum_bit_flips_to_convert_number │ ├── mod.rs │ └── xor.rs ├── problem_2221_find_triangular_sum_of_an_array │ ├── mod.rs │ └── mod_inverse.rs ├── problem_2222_number_of_ways_to_select_buildings │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_2224_minimum_number_of_operations_to_convert_time │ ├── iterative.rs │ └── mod.rs ├── problem_2225_find_players_with_zero_or_one_losses │ ├── hash_map.rs │ └── mod.rs ├── problem_2226_maximum_candies_allocated_to_k_children │ ├── binary_search.rs │ └── mod.rs ├── problem_2227_encrypt_and_decrypt_strings │ ├── hash_map.rs │ └── mod.rs ├── problem_2231_largest_number_after_digit_swaps_by_parity │ ├── iterative.rs │ └── mod.rs ├── problem_2232_minimize_result_by_adding_parentheses_to_expression │ ├── brute_force.rs │ └── mod.rs ├── problem_2233_maximum_product_after_k_increments │ ├── mod.rs │ └── quick_select.rs ├── problem_2234_maximum_total_beauty_of_the_gardens │ ├── mod.rs │ └── sliding_window.rs ├── problem_2235_add_two_integers │ ├── mod.rs │ └── obvious.rs ├── problem_2236_root_equals_sum_of_children │ ├── mod.rs │ └── obvious.rs ├── problem_2239_find_closest_number_to_zero │ ├── iterative.rs │ └── mod.rs ├── problem_2241_design_an_atm_machine │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_2242_maximum_score_of_a_node_sequence │ ├── greedy.rs │ └── mod.rs ├── problem_2243_calculate_digit_sum_of_a_string │ ├── iterative.rs │ └── mod.rs ├── problem_2244_minimum_rounds_to_complete_all_tasks │ ├── hash_map.rs │ └── mod.rs ├── problem_2245_maximum_trailing_zeros_in_a_cornered_path │ ├── dynamic_programming.rs │ ├── mod.rs │ └── prefix_sums.rs ├── problem_2246_longest_path_with_different_adjacent_characters │ ├── mod.rs │ └── recursive.rs ├── problem_2248_intersection_of_multiple_arrays │ ├── iterative.rs │ └── mod.rs ├── problem_2250_count_number_of_rectangles_containing_each_point │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2251_number_of_flowers_in_full_bloom │ ├── mod.rs │ └── sweep_line.rs ├── problem_2255_count_prefixes_of_a_given_string │ ├── iterative.rs │ └── mod.rs ├── problem_2256_minimum_average_difference │ ├── iterative.rs │ └── mod.rs ├── problem_2257_count_unguarded_cells_in_the_grid │ ├── iterative.rs │ └── mod.rs ├── problem_2258_escape_the_spreading_fire │ ├── bfs.rs │ └── mod.rs ├── problem_2259_remove_digit_from_number_to_maximize_result │ ├── iterative.rs │ └── mod.rs ├── problem_2260_minimum_consecutive_cards_to_pick_up │ ├── iterative.rs │ └── mod.rs ├── problem_2261_k_divisible_elements_subarrays │ ├── mod.rs │ └── sliding_window_and_hash_set.rs ├── problem_2262_total_appeal_of_a_string │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2264_largest_3_same_digit_number_in_string │ ├── iterative.rs │ └── mod.rs ├── problem_2265_count_nodes_equal_to_average_of_subtree │ ├── mod.rs │ └── recursive.rs ├── problem_2266_count_number_of_texts │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2267_check_if_there_is_a_valid_parentheses_string_path │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_2269_find_the_k_beauty_of_a_number │ ├── iterative.rs │ └── mod.rs ├── problem_2270_number_of_ways_to_split_array │ ├── iterative.rs │ └── mod.rs ├── problem_2271_maximum_white_tiles_covered_by_a_carpet │ ├── mod.rs │ └── sliding_window.rs ├── problem_2272_substring_with_largest_variance │ ├── mod.rs │ └── prefix_sums.rs ├── problem_2273_find_resultant_array_after_removing_anagrams │ ├── iterative.rs │ └── mod.rs ├── problem_2274_maximum_consecutive_floors_without_special_floors │ ├── iterative.rs │ └── mod.rs ├── problem_2275_largest_combination_with_bitwise_and_greater_than_zero │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2276_count_integers_in_intervals │ ├── btree_map.rs │ └── mod.rs ├── problem_2278_percentage_of_letter_in_string │ ├── iterative.rs │ └── mod.rs ├── problem_2279_maximum_bags_with_full_capacity_of_rocks │ ├── mod.rs │ └── quick_select.rs ├── problem_2280_minimum_lines_to_represent_a_line_chart │ ├── iterative.rs │ └── mod.rs ├── problem_2283_check_if_number_has_equal_digit_count_and_digit_value │ ├── iterative.rs │ └── mod.rs ├── problem_2284_sender_with_largest_word_count │ ├── hash_map.rs │ └── mod.rs ├── problem_2285_maximum_total_importance_of_roads │ ├── greedy.rs │ └── mod.rs ├── problem_2287_rearrange_characters_to_make_target_string │ ├── iterative.rs │ └── mod.rs ├── problem_2288_apply_discount_to_prices │ ├── iterative_1.rs │ ├── iterative_2.rs │ └── mod.rs ├── problem_2289_steps_to_make_array_non_decreasing │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_2290_minimum_obstacle_removal_to_reach_corner │ ├── bfs.rs │ └── mod.rs ├── problem_2293_min_max_game │ ├── iterative.rs │ └── mod.rs ├── problem_2294_partition_array_such_that_maximum_difference_is_k │ ├── iterative.rs │ └── mod.rs ├── problem_2295_replace_elements_in_an_array │ ├── hash_map.rs │ └── mod.rs ├── problem_2299_strong_password_checker_ii │ ├── iterative.rs │ └── mod.rs ├── problem_2300_successful_pairs_of_spells_and_potions │ ├── binary_search_1.rs │ ├── binary_search_2.rs │ └── mod.rs ├── problem_2302_count_subarrays_with_score_less_than_k │ ├── mod.rs │ └── sliding_window.rs ├── problem_2303_calculate_amount_paid_in_taxes │ ├── iterative.rs │ └── mod.rs ├── problem_2304_minimum_path_cost_in_a_grid │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2305_fair_distribution_of_cookies │ ├── backtracking.rs │ └── mod.rs ├── problem_2306_naming_a_company │ ├── group_by_prefix.rs │ └── mod.rs ├── problem_2309_greatest_english_letter_in_upper_and_lower_case │ ├── iterative.rs │ └── mod.rs ├── problem_2310_sum_of_numbers_with_units_digit_k │ ├── iterative.rs │ └── mod.rs ├── problem_2311_longest_binary_subsequence_less_than_or_equal_to_k │ ├── greedy.rs │ └── mod.rs ├── problem_2312_selling_pieces_of_wood │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2315_count_asterisks │ ├── iterative.rs │ └── mod.rs ├── problem_2316_count_unreachable_pairs_of_nodes_in_an_undirected_graph │ ├── bfs.rs │ └── mod.rs ├── problem_2317_maximum_xor_after_operations │ ├── mathematical.rs │ └── mod.rs ├── problem_2318_number_of_distinct_roll_sequences │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2319_check_if_matrix_is_x_matrix │ ├── iterative.rs │ └── mod.rs ├── problem_2320_count_number_of_ways_to_place_houses │ ├── matrix_multiplication.rs │ └── mod.rs ├── problem_2321_maximum_score_of_spliced_array │ ├── mod.rs │ └── prefix_sums.rs ├── problem_2322_minimum_score_after_removals_on_a_tree │ ├── dfs.rs │ └── mod.rs ├── problem_2325_decode_the_message │ ├── iterative.rs │ └── mod.rs ├── problem_2326_spiral_matrix_iv │ ├── iterative.rs │ └── mod.rs ├── problem_2327_number_of_people_aware_of_a_secret │ ├── mod.rs │ └── sliding_window.rs ├── problem_2328_number_of_increasing_paths_in_a_grid │ ├── bfs.rs │ └── mod.rs ├── problem_2331_evaluate_boolean_binary_tree │ ├── mod.rs │ └── recursive.rs ├── problem_2332_the_latest_time_to_catch_a_bus │ ├── mod.rs │ └── two_pointers.rs ├── problem_2333_minimum_sum_of_squared_difference │ ├── mod.rs │ └── quick_select.rs ├── problem_2335_minimum_amount_of_time_to_fill_cups │ ├── mathematical.rs │ ├── mathematical_2.rs │ └── mod.rs ├── problem_2336_smallest_number_in_infinite_set │ ├── binary_heap.rs │ └── mod.rs ├── problem_2337_move_pieces_to_obtain_a_string │ ├── greedy.rs │ └── mod.rs ├── problem_2338_count_the_number_of_ideal_arrays │ ├── dynamic_programming_and_combinations.rs │ └── mod.rs ├── problem_2341_maximum_number_of_pairs_in_array │ ├── iterative.rs │ └── mod.rs ├── problem_2342_max_sum_of_a_pair_with_equal_sum_of_digits │ ├── mathematical.rs │ └── mod.rs ├── problem_2343_query_kth_smallest_trimmed_number │ ├── mod.rs │ └── radix_sort.rs ├── problem_2344_minimum_deletions_to_make_array_divisible │ ├── gcd.rs │ └── mod.rs ├── problem_2347_best_poker_hand │ ├── brute_force.rs │ └── mod.rs ├── problem_2348_number_of_zero_filled_subarrays │ ├── iterative.rs │ └── mod.rs ├── problem_2349_design_a_number_container_system │ ├── hash_map_and_btree_set.rs │ └── mod.rs ├── problem_2350_shortest_impossible_sequence_of_rolls │ ├── dynamic_programming.rs │ ├── dynamic_programming_2.rs │ └── mod.rs ├── problem_2351_first_letter_to_appear_twice │ ├── iterative.rs │ └── mod.rs ├── problem_2352_equal_row_and_column_pairs │ ├── hash_map.rs │ └── mod.rs ├── problem_2353_design_a_food_rating_system │ ├── binary_heap.rs │ └── mod.rs ├── problem_2354_number_of_excellent_pairs │ ├── iterative.rs │ └── mod.rs ├── problem_2357_make_array_zero_by_subtracting_equal_amounts │ ├── bit_masks.rs │ └── mod.rs ├── problem_2358_maximum_number_of_groups_entering_a_competition │ ├── mod.rs │ └── newtons_method.rs ├── problem_2359_find_closest_node_to_given_two_nodes │ ├── iterative.rs │ └── mod.rs ├── problem_2360_longest_cycle_in_a_graph │ ├── iterative.rs │ └── mod.rs ├── problem_2363_merge_similar_items │ ├── iterative.rs │ └── mod.rs ├── problem_2364_count_number_of_bad_pairs │ ├── iterative.rs │ └── mod.rs ├── problem_2365_task_scheduler_ii │ ├── hash_map.rs │ └── mod.rs ├── problem_2366_minimum_replacements_to_sort_the_array │ ├── greedy.rs │ └── mod.rs ├── problem_2367_number_of_arithmetic_triplets │ ├── iterative.rs │ └── mod.rs ├── problem_2368_reachable_nodes_with_restrictions │ ├── bfs.rs │ └── mod.rs ├── problem_2369_check_if_there_is_a_valid_partition_for_the_array │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2370_longest_ideal_subsequence │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2373_largest_local_values_in_a_matrix │ ├── iterative.rs │ └── mod.rs ├── problem_2374_node_with_highest_edge_score │ ├── iterative.rs │ └── mod.rs ├── problem_2375_construct_smallest_number_from_di_string │ ├── greedy.rs │ ├── greedy_2.rs │ └── mod.rs ├── problem_2376_count_special_integers │ ├── mathematical.rs │ └── mod.rs ├── problem_2379_minimum_recolors_to_get_k_consecutive_black_blocks │ ├── mod.rs │ ├── sliding_window.rs │ └── sliding_window_2.rs ├── problem_2380_time_needed_to_rearrange_a_binary_string │ ├── iterative.rs │ └── mod.rs ├── problem_2381_shifting_letters_ii │ ├── mod.rs │ └── sweep_line.rs ├── problem_2382_maximum_segment_sum_after_removals │ ├── mod.rs │ └── reversed_iteration.rs ├── problem_2383_minimum_hours_of_training_to_win_a_competition │ ├── iterative.rs │ └── mod.rs ├── problem_2384_largest_palindromic_number │ ├── greedy.rs │ └── mod.rs ├── problem_2385_amount_of_time_for_binary_tree_to_be_infected │ ├── mod.rs │ └── recursive.rs ├── problem_2386_find_the_k_sum_of_an_array │ ├── binary_heap.rs │ └── mod.rs ├── problem_2389_longest_subsequence_with_limited_sum │ ├── binary_search.rs │ └── mod.rs ├── problem_2390_removing_stars_from_a_string │ ├── iterative.rs │ └── mod.rs ├── problem_2391_minimum_amount_of_time_to_collect_garbage │ ├── iterative.rs │ └── mod.rs ├── problem_2392_build_a_matrix_with_conditions │ ├── mod.rs │ ├── topological_sorting_bfs.rs │ └── topological_sorting_dfs.rs ├── problem_2395_find_subarrays_with_equal_sum │ ├── hash_set.rs │ └── mod.rs ├── problem_2396_strictly_palindromic_number │ ├── mathematical.rs │ └── mod.rs ├── problem_2397_maximum_rows_covered_by_columns │ ├── brute_force.rs │ └── mod.rs ├── problem_2398_maximum_number_of_robots_within_budget │ ├── mod.rs │ └── sliding_window.rs ├── problem_2399_check_distances_between_same_letters │ ├── iterative.rs │ └── mod.rs ├── problem_2400_number_of_ways_to_reach_a_position_after_exactly_k_steps │ ├── mathematical.rs │ └── mod.rs ├── problem_2401_longest_nice_subarray │ ├── mod.rs │ └── sliding_window.rs ├── problem_2402_meeting_rooms_iii │ ├── binary_heap.rs │ └── mod.rs ├── problem_2404_most_frequent_even_element │ ├── hash_map.rs │ └── mod.rs ├── problem_2405_optimal_partition_of_string │ ├── bit_manipulation.rs │ └── mod.rs ├── problem_2406_divide_intervals_into_minimum_number_of_groups │ ├── mod.rs │ └── sweep_line.rs ├── problem_2409_count_days_spent_together │ ├── mathematical.rs │ └── mod.rs ├── problem_2410_maximum_matching_of_players_with_trainers │ ├── greedy.rs │ └── mod.rs ├── problem_2411_smallest_subarrays_with_maximum_bitwise_or │ ├── greedy.rs │ └── mod.rs ├── problem_2412_minimum_money_required_before_transactions │ ├── greedy.rs │ └── mod.rs ├── problem_2413_smallest_even_multiple │ ├── bit_manipulation.rs │ └── mod.rs ├── problem_2414_length_of_the_longest_alphabetical_continuous_substring │ ├── greedy.rs │ └── mod.rs ├── problem_2415_reverse_odd_levels_of_binary_tree │ ├── bfs.rs │ └── mod.rs ├── problem_2416_sum_of_prefix_scores_of_strings │ ├── mod.rs │ └── trie.rs ├── problem_2418_sort_the_people │ ├── mod.rs │ └── sort_by_key.rs ├── problem_2419_longest_subarray_with_maximum_bitwise_and │ ├── iterative.rs │ └── mod.rs ├── problem_2420_find_all_good_indices │ ├── iterative.rs │ └── mod.rs ├── problem_2421_number_of_good_paths │ ├── mod.rs │ └── union_find.rs ├── problem_2423_remove_letter_to_equalize_frequency │ ├── iterative.rs │ └── mod.rs ├── problem_2424_longest_uploaded_prefix │ ├── array.rs │ ├── hash_map.rs │ └── mod.rs ├── problem_2425_bitwise_xor_of_all_pairings │ ├── mathematical.rs │ └── mod.rs ├── problem_2426_number_of_pairs_satisfying_inequality │ ├── fenwick_tree.rs │ ├── fenwick_tree_2.rs │ ├── merge_sort.rs │ └── mod.rs ├── problem_2427_number_of_common_factors │ ├── gcd.rs │ └── mod.rs ├── problem_2428_maximum_sum_of_an_hourglass │ ├── brute_force.rs │ └── mod.rs ├── problem_2429_minimize_xor │ ├── greedy.rs │ └── mod.rs ├── problem_2432_the_employee_that_worked_on_the_longest_task │ ├── iterative.rs │ └── mod.rs ├── problem_2433_find_the_original_array_of_prefix_xor │ ├── iterative.rs │ └── mod.rs ├── problem_2434_using_a_robot_to_print_the_lexicographically_smallest_string │ ├── greedy.rs │ └── mod.rs ├── problem_2435_paths_in_matrix_whose_sum_is_divisible_by_k │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2437_number_of_valid_clock_times │ ├── mathematical.rs │ └── mod.rs ├── problem_2438_range_product_queries_of_powers │ ├── mod.rs │ └── prefix_sums.rs ├── problem_2439_minimize_maximum_of_array │ ├── iterative.rs │ └── mod.rs ├── problem_2441_largest_positive_integer_that_exists_with_its_negative │ ├── hash_set.rs │ └── mod.rs ├── problem_2442_count_number_of_distinct_integers_after_reverse_operations │ ├── hash_set.rs │ └── mod.rs ├── problem_2443_sum_of_number_and_its_reverse │ ├── brute_force.rs │ └── mod.rs ├── problem_2444_count_subarrays_with_fixed_bounds │ ├── greedy.rs │ └── mod.rs ├── problem_2446_determine_if_two_events_have_conflict │ ├── mathematical.rs │ └── mod.rs ├── problem_2448_minimum_cost_to_make_array_equal │ ├── binary_search.rs │ └── mod.rs ├── problem_2451_odd_string_difference │ ├── iterative.rs │ └── mod.rs ├── problem_2452_words_within_two_edits_of_dictionary │ ├── brute_force.rs │ └── mod.rs ├── problem_2453_destroy_sequential_targets │ ├── buckets.rs │ └── mod.rs ├── problem_2455_average_value_of_even_numbers_that_are_divisible_by_three │ ├── iterative.rs │ └── mod.rs ├── problem_2456_most_popular_video_creator │ ├── hash_map.rs │ ├── hash_map_2.rs │ └── mod.rs ├── problem_2457_minimum_addition_to_make_integer_beautiful │ ├── greedy.rs │ └── mod.rs ├── problem_2460_apply_operations_to_an_array │ ├── iterative.rs │ └── mod.rs ├── problem_2461_maximum_sum_of_distinct_subarrays_with_length_k │ ├── mod.rs │ └── sliding_window.rs ├── problem_2462_total_cost_to_hire_k_workers │ ├── binary_heap.rs │ └── mod.rs ├── problem_2465_number_of_distinct_averages │ ├── hash_set.rs │ └── mod.rs ├── problem_2466_count_ways_to_build_good_strings │ ├── hash_set.rs │ └── mod.rs ├── problem_2469_convert_the_temperature │ ├── mathematical.rs │ └── mod.rs ├── problem_2471_minimum_number_of_operations_to_sort_a_binary_tree_by_level │ ├── bfs.rs │ └── mod.rs ├── problem_2475_number_of_unequal_triplets_in_array │ ├── hash_map.rs │ └── mod.rs ├── problem_2476_closest_nodes_queries_in_a_binary_search_tree │ ├── binary_search.rs │ ├── binary_search_2.rs │ └── mod.rs ├── problem_2477_minimum_fuel_cost_to_report_to_the_capital │ ├── dfs.rs │ └── mod.rs ├── problem_2481_minimum_cuts_to_divide_a_circle │ ├── bit_manipulation.rs │ └── mod.rs ├── problem_2482_difference_between_ones_and_zeros_in_row_and_column │ ├── iterative.rs │ └── mod.rs ├── problem_2483_minimum_penalty_for_a_shop │ ├── iterative.rs │ └── mod.rs ├── problem_2484_count_palindromic_subsequences │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2485_find_the_pivot_integer │ ├── mathematical.rs │ └── mod.rs ├── problem_2486_append_characters_to_string_to_make_subsequence │ ├── greedy.rs │ └── mod.rs ├── problem_2487_remove_nodes_from_linked_list │ ├── mod.rs │ └── monotonic_stack.rs ├── problem_2490_circular_sentence │ ├── iterative.rs │ └── mod.rs ├── problem_2491_divide_players_into_teams_of_equal_skill │ ├── iterative.rs │ └── mod.rs ├── problem_2492_minimum_score_of_a_path_between_two_cities │ ├── mod.rs │ └── union_find.rs ├── problem_2496_maximum_value_of_a_string_in_an_array │ ├── iterative.rs │ └── mod.rs ├── problem_2497_maximum_star_sum_of_a_graph │ ├── greedy.rs │ └── mod.rs ├── problem_2498_frog_jump_ii │ ├── greedy.rs │ └── mod.rs ├── problem_2500_delete_greatest_value_in_each_row │ ├── iterative.rs │ └── mod.rs ├── problem_2501_longest_square_streak_in_an_array │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2506_count_pairs_of_similar_strings │ ├── buckets.rs │ └── mod.rs ├── problem_2511_maximum_enemy_forts_that_can_be_captured │ ├── iterative.rs │ └── mod.rs ├── problem_2512_reward_top_k_students │ ├── hash_set.rs │ └── mod.rs ├── problem_2514_count_anagrams │ ├── mathematical.rs │ └── mod.rs ├── problem_2515_shortest_distance_to_target_string_in_a_circular_array │ ├── greedy.rs │ └── mod.rs ├── problem_2516_take_k_of_each_character_from_left_and_right │ ├── mod.rs │ └── sliding_window.rs ├── problem_2517_maximum_tastiness_of_candy_basket │ ├── binary_search.rs │ └── mod.rs ├── problem_2520_count_the_digits_that_divide_a_number │ ├── iterative.rs │ └── mod.rs ├── problem_2522_partition_string_into_substrings_with_values_at_most_k │ ├── greedy.rs │ └── mod.rs ├── problem_2525_categorize_box_according_to_criteria │ ├── brute_force.rs │ └── mod.rs ├── problem_2526_find_consecutive_integers_from_a_data_stream │ ├── greedy.rs │ └── mod.rs ├── problem_2527_find_xor_beauty_of_array │ ├── mathematical.rs │ └── mod.rs ├── problem_2529_maximum_count_of_positive_integer_and_negative_integer │ ├── iterative.rs │ └── mod.rs ├── problem_2530_maximal_score_after_applying_k_operations │ ├── binary_heap.rs │ └── mod.rs ├── problem_2535_difference_between_element_sum_and_digit_sum_of_an_array │ ├── iterative.rs │ └── mod.rs ├── problem_2540_minimum_common_value │ ├── iterative.rs │ └── mod.rs ├── problem_2542_maximum_subsequence_score │ ├── binary_heap.rs │ └── mod.rs ├── problem_2544_alternating_digit_sum │ ├── mathematical.rs │ └── mod.rs ├── problem_2545_sort_the_students_by_their_kth_score │ ├── mod.rs │ └── sort_by_key.rs ├── problem_2546_apply_bitwise_operations_to_make_strings_equal │ ├── mathematical.rs │ └── mod.rs ├── problem_2549_count_distinct_numbers_on_board │ ├── mathematical.rs │ └── mod.rs ├── problem_2550_count_collisions_of_monkeys_on_a_polygon │ ├── mathematical.rs │ └── mod.rs ├── problem_2553_separate_the_digits_in_an_array │ ├── iterative.rs │ └── mod.rs ├── problem_2554_maximum_number_of_integers_to_choose_from_a_range_i │ ├── greedy.rs │ └── mod.rs ├── problem_2558_take_gifts_from_the_richest_pile │ ├── binary_heap.rs │ └── mod.rs ├── problem_2559_count_vowel_strings_in_ranges │ ├── mod.rs │ └── prefix_sums.rs ├── problem_2560_house_robber_iv │ ├── binary_search.rs │ └── mod.rs ├── problem_2562_find_the_array_concatenation_value │ ├── iterative.rs │ └── mod.rs ├── problem_2563_count_the_number_of_fair_pairs │ ├── mod.rs │ └── sliding_window.rs ├── problem_2564_substring_xor_queries │ ├── mod.rs │ └── sliding_window.rs ├── problem_2566_maximum_difference_by_remapping_a_digit │ ├── greedy.rs │ └── mod.rs ├── problem_2570_merge_two_2d_arrays_by_summing_values │ ├── iterative.rs │ └── mod.rs ├── problem_2571_minimum_operations_to_reduce_an_integer_to_0 │ ├── greedy.rs │ └── mod.rs ├── problem_2574_left_and_right_sum_differences │ ├── iterative.rs │ └── mod.rs ├── problem_2575_find_the_divisibility_array_of_a_string │ ├── mod.rs │ └── modular_arithmetic.rs ├── problem_2578_split_with_minimum_sum │ ├── greedy.rs │ └── mod.rs ├── problem_2579_count_total_number_of_colored_cells │ ├── mathematical.rs │ └── mod.rs ├── problem_2580_count_ways_to_group_overlapping_ranges │ ├── iterative.rs │ └── mod.rs ├── problem_2582_pass_the_pillow │ ├── mathematical.rs │ └── mod.rs ├── problem_2583_kth_largest_sum_in_a_binary_tree │ ├── bfs.rs │ └── mod.rs ├── problem_2586_count_the_number_of_vowel_strings_in_range │ ├── iterative.rs │ └── mod.rs ├── problem_2587_rearrange_array_to_maximize_prefix_score │ ├── mod.rs │ └── quick_select.rs ├── problem_2588_count_the_number_of_beautiful_subarrays │ ├── hash_map.rs │ └── mod.rs ├── problem_2591_distribute_money_to_maximum_children │ ├── greedy.rs │ └── mod.rs ├── problem_2592_maximize_greatness_of_an_array │ ├── greedy.rs │ └── mod.rs ├── problem_2593_find_score_of_an_array_after_marking_all_elements │ ├── iterative.rs │ └── mod.rs ├── problem_2594_minimum_time_to_repair_cars │ ├── binary_search.rs │ └── mod.rs ├── problem_2595_number_of_even_and_odd_bits │ ├── bit_manipulation.rs │ └── mod.rs ├── problem_2596_check_knight_tour_configuration │ ├── iterative.rs │ └── mod.rs ├── problem_2598_smallest_missing_non_negative_integer_after_operations │ ├── mod.rs │ └── modular_arithmetic.rs ├── problem_2600_k_items_with_the_maximum_sum │ ├── mod.rs │ └── modular_arithmetic.rs ├── problem_2601_prime_subtraction_operation │ ├── greedy.rs │ └── mod.rs ├── problem_2602_minimum_operations_to_make_all_array_elements_equal │ ├── mod.rs │ └── prefix_sums_and_binary_search.rs ├── problem_2609_find_the_longest_balanced_substring_of_a_binary_string │ ├── iterative.rs │ └── mod.rs ├── problem_2610_convert_an_array_into_a_2d_array_with_conditions │ ├── greedy.rs │ └── mod.rs ├── problem_2614_prime_in_diagonal │ ├── iterative.rs │ ├── mod.rs │ └── sieve_of_eratosthenes.rs ├── problem_2639_find_the_width_of_columns_of_a_grid │ ├── iterative.rs │ └── mod.rs ├── problem_2660_determine_the_winner_of_a_bowling_game │ ├── iterative.rs │ └── mod.rs ├── problem_2661_first_completely_painted_row_or_column │ ├── greedy.rs │ └── mod.rs ├── problem_2670_find_the_distinct_difference_array │ ├── iterative.rs │ └── mod.rs ├── problem_2671_frequency_tracker │ ├── hash_map.rs │ └── mod.rs ├── problem_2673_make_costs_of_paths_equal_in_a_binary_tree │ ├── dynamic_programming.rs │ └── mod.rs ├── problem_2678_number_of_senior_citizens │ ├── iterative.rs │ └── mod.rs ├── problem_2679_sum_in_a_matrix │ ├── iterative.rs │ └── mod.rs ├── problem_2682_find_the_losers_of_the_circular_game │ ├── brute_force.rs │ └── mod.rs ├── problem_2683_neighboring_bitwise_xor │ ├── mathematical.rs │ └── mod.rs └── test_utilities.rs ├── tools ├── check-cpp-code-format │ ├── Cargo.toml │ └── src │ │ └── main.rs └── progress-tracker │ ├── Cargo.toml │ └── src │ ├── html.rs │ ├── main.rs │ ├── problems.rs │ ├── progress_chart.rs │ ├── report.rs │ └── solutions.rs └── xtask ├── Cargo.toml └── src ├── coverage └── mod.rs ├── main.rs ├── tools ├── mod.rs └── windows.rs └── utilities.rs /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | xtask = "run --package xtask --release --" 3 | -------------------------------------------------------------------------------- /.clippy.toml: -------------------------------------------------------------------------------- 1 | avoid-breaking-exported-api = false 2 | warn-on-all-wildcard-imports = true 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Cargo.lock 2 | .vscode/ 3 | /__* 4 | /coverage/ 5 | /target/ 6 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | # format_strings = true 2 | # group_imports = "One" 3 | # imports_granularity = "Module" 4 | max_width = 120 5 | newline_style = "Native" 6 | use_field_init_shorthand = true 7 | -------------------------------------------------------------------------------- /c++/.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Microsoft 2 | AccessModifierOffset: -4 3 | AlwaysBreakTemplateDeclarations: Yes 4 | BinPackArguments: false 5 | BinPackParameters: false 6 | BreakBeforeBraces: Attach 7 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 8 | IncludeBlocks: Merge 9 | IndentCaseLabels: true 10 | IndentGotoLabels: false 11 | # InsertTrailingCommas: Wrapped 12 | KeepEmptyLinesAtTheStartOfBlocks: false 13 | NamespaceIndentation: Inner 14 | SpacesInContainerLiterals: false 15 | -------------------------------------------------------------------------------- /c++/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | -------------------------------------------------------------------------------- /c++/include/leet-code/data-structures/list-node.h: -------------------------------------------------------------------------------- 1 | #ifndef LEET_CODE_DATA_STRUCTURES_LIST_NODE_H 2 | #define LEET_CODE_DATA_STRUCTURES_LIST_NODE_H 3 | 4 | namespace leet_code::data_structures::list_node { 5 | struct ListNode { 6 | int val; 7 | ListNode *next = nullptr; 8 | 9 | explicit ListNode(int x) : val{x} { 10 | } 11 | }; 12 | } // namespace leet_code::data_structures::list_node 13 | 14 | #endif // LEET_CODE_DATA_STRUCTURES_LIST_NODE_H 15 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0116-populating-next-right-pointers-in-each-node/iterative.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0116_populating_next_right_pointers_in_each_node::tests { 5 | TEST(Problem0116PopulatingNextRightPointersInEachNode, Iterative) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0116_populating_next_right_pointers_in_each_node::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0116-populating-next-right-pointers-in-each-node/recursive.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0116_populating_next_right_pointers_in_each_node::tests { 5 | TEST(Problem0116PopulatingNextRightPointersInEachNode, Recursive) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0116_populating_next_right_pointers_in_each_node::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0117-populating-next-right-pointers-in-each-node-ii/iterative.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0117_populating_next_right_pointers_in_each_node_ii::tests { 5 | TEST(Problem0117PopulatingNextRightPointersInEachNodeIi, Iterative) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0117_populating_next_right_pointers_in_each_node_ii::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0237-delete-node-in-a-linked-list/modify-this.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0237_delete_node_in_a_linked_list::tests { 5 | TEST(Problem0237DeleteNodeInALinkedList, ModifyThis) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0237_delete_node_in_a_linked_list::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0321-create-maximum-number/dynamic-programming.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0321_create_maximum_number::tests { 5 | TEST(Problem0321CreateMaximumNumber, DynamicProgramming) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0321_create_maximum_number::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0321-create-maximum-number/greedy.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0321_create_maximum_number::tests { 5 | TEST(Problem0321CreateMaximumNumber, Greedy) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0321_create_maximum_number::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0373-find-k-pairs-with-smallest-sums/bfs-2.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0373_find_k_pairs_with_smallest_sums::tests { 5 | TEST(Problem0373FindKPairsWithSmallestSums, Bfs2) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0373_find_k_pairs_with_smallest_sums::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0373-find-k-pairs-with-smallest-sums/bfs.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0373_find_k_pairs_with_smallest_sums::tests { 5 | TEST(Problem0373FindKPairsWithSmallestSums, Bfs) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0373_find_k_pairs_with_smallest_sums::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0378-kth-smallest-element-in-a-sorted-matrix/bfs-2.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0378_kth_smallest_element_in_a_sorted_matrix::tests { 5 | TEST(Problem0378KthSmallestElementInASortedMatrix, Bfs2) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0378_kth_smallest_element_in_a_sorted_matrix::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0378-kth-smallest-element-in-a-sorted-matrix/binary-search-2.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0378_kth_smallest_element_in_a_sorted_matrix::tests { 5 | TEST(Problem0378KthSmallestElementInASortedMatrix, BinarySearch2) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0378_kth_smallest_element_in_a_sorted_matrix::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0378-kth-smallest-element-in-a-sorted-matrix/binary-search-3.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0378_kth_smallest_element_in_a_sorted_matrix::tests { 5 | TEST(Problem0378KthSmallestElementInASortedMatrix, BinarySearch3) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0378_kth_smallest_element_in_a_sorted_matrix::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0378-kth-smallest-element-in-a-sorted-matrix/binary-search.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0378_kth_smallest_element_in_a_sorted_matrix::tests { 5 | TEST(Problem0378KthSmallestElementInASortedMatrix, BinarySearch) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0378_kth_smallest_element_in_a_sorted_matrix::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0386-lexicographical-numbers/iterative-dfs.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0386_lexicographical_numbers::tests { 5 | TEST(Problem0386LexicographicalNumbers, IterativeDfs) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0386_lexicographical_numbers::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0402-remove-k-digits/greedy-2.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0402_remove_k_digits::tests { 5 | TEST(Problem0402RemoveKDigits, Greedy2) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0402_remove_k_digits::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0402-remove-k-digits/greedy.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0402_remove_k_digits::tests { 5 | TEST(Problem0402RemoveKDigits, Greedy) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0402_remove_k_digits::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0406-queue-reconstruction-by-height/binary-search-tree.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0406_queue_reconstruction_by_height::tests { 5 | TEST(Problem0406QueueReconstructionByHeight, BinarySearchTree) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0406_queue_reconstruction_by_height::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0406-queue-reconstruction-by-height/fenwick-tree.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0406_queue_reconstruction_by_height::tests { 5 | TEST(Problem0406QueueReconstructionByHeight, FenwickTree) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0406_queue_reconstruction_by_height::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0406-queue-reconstruction-by-height/insertion.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0406_queue_reconstruction_by_height::tests { 5 | TEST(Problem0406QueueReconstructionByHeight, Insertion) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0406_queue_reconstruction_by_height::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0436-find-right-interval/sort-and-merge.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0436_find_right_interval::tests { 5 | TEST(Problem0436FindRightInterval, SortAndMerge) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0436_find_right_interval::tests 9 | -------------------------------------------------------------------------------- /c++/tests/leet-code/problem-0436-find-right-interval/sort-and-scan.cpp: -------------------------------------------------------------------------------- 1 | #include "tests.h" 2 | #include 3 | 4 | namespace leet_code::problem_0436_find_right_interval::tests { 5 | TEST(Problem0436FindRightInterval, SortAndScan) { 6 | tests::run(); 7 | } 8 | } // namespace leet_code::problem_0436_find_right_interval::tests 9 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | [toolchain] 2 | channel = "stable" 3 | -------------------------------------------------------------------------------- /src/problem_0005_longest_palindromic_substring/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | 3 | pub trait Solution { 4 | fn longest_palindrome(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("babad", &["bab", "aba"] as &[_]), ("cbbd", &["bb"])]; 13 | 14 | for (s, expected) in test_cases { 15 | assert!(expected.contains(&S::longest_palindrome(s.to_string()).as_str())); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0007_reverse_integer/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | 3 | pub trait Solution { 4 | fn reverse(x: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(123, 321), (-123, -321), (120, 21), (1_534_236_469, 0)]; 13 | 14 | for (x, expected) in test_cases { 15 | assert_eq!(S::reverse(x), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0012_integer_to_roman/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod generic; 2 | pub mod specialized_1; 3 | pub mod specialized_2; 4 | 5 | pub trait Solution { 6 | fn int_to_roman(num: i32) -> String; 7 | } 8 | 9 | #[cfg(test)] 10 | mod tests { 11 | use super::Solution; 12 | 13 | pub fn run() { 14 | let test_cases = [(3, "III"), (4, "IV"), (9, "IX"), (58, "LVIII"), (1994, "MCMXCIV")]; 15 | 16 | for (num, expected) in test_cases { 17 | assert_eq!(S::int_to_roman(num), expected); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/problem_0013_roman_to_integer/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parsing; 2 | pub mod parsing_2; 3 | 4 | pub trait Solution { 5 | fn roman_to_int(s: String) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("III", 3), ("IV", 4), ("IX", 9), ("LVIII", 58), ("MCMXCIV", 1994)]; 14 | 15 | for (s, expected) in test_cases { 16 | assert_eq!(S::roman_to_int(s.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0038_count_and_say/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_and_say(n: i32) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, "1"), (2, "11"), (3, "21"), (4, "1211"), (5, "111221")]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::count_and_say(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0045_jump_game_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bfs; 2 | pub mod bfs_single_loop; 3 | pub mod bfs_with_tricks; 4 | 5 | pub trait Solution { 6 | fn jump(nums: Vec) -> i32; 7 | } 8 | 9 | #[cfg(test)] 10 | mod tests { 11 | use super::Solution; 12 | 13 | pub fn run() { 14 | let test_cases = [(&[2, 3, 1, 1, 4] as &[_], 2)]; 15 | 16 | for (nums, expected) in test_cases { 17 | assert_eq!(S::jump(nums.to_vec()), expected); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/problem_0053_maximum_subarray/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod divide_and_conquer; 2 | pub mod dynamic_programming; 3 | 4 | pub trait Solution { 5 | fn max_sub_array(nums: Vec) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(&[-2, 1, -3, 4, -1, 2, 1, -5, 4] as &[_], 6)]; 14 | 15 | for (nums, expected) in test_cases { 16 | assert_eq!(S::max_sub_array(nums.to_vec()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0055_jump_game/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn can_jump(nums: Vec) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 3, 1, 1, 4] as &[_], true), (&[3, 2, 1, 0, 4], false)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::can_jump(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0058_length_of_last_word/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod manual_reversed_iteration; 2 | pub mod reversed_iteration; 3 | 4 | pub trait Solution { 5 | fn length_of_last_word(s: String) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("Hello World", 5), (" ", 0)]; 14 | 15 | for (s, expected) in test_cases { 16 | assert_eq!(S::length_of_last_word(s.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0060_permutation_sequence/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn get_permutation(n: i32, k: i32) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((3, 3), "213"), ((4, 9), "2314"), ((1, 1), "1")]; 13 | 14 | for ((n, k), expected) in test_cases { 15 | assert_eq!(S::get_permutation(n, k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0091_decode_ways/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | pub mod dynamic_programming_2; 3 | 4 | pub trait Solution { 5 | fn num_decodings(s: String) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("12", 2), ("226", 3), ("0", 0), ("06", 0), ("", 1), ("27", 1)]; 14 | 15 | for (s, expected) in test_cases { 16 | assert_eq!(S::num_decodings(s.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0115_distinct_subsequences/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn num_distinct(s: String, t: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("rabbbit", "rabbit"), 3), (("babgbag", "bag"), 5)]; 13 | 14 | for ((s, t), expected) in test_cases { 15 | assert_eq!(S::num_distinct(s.to_string(), t.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0119_pascals_triangle_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn get_row(row_index: i32) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(0, &[1] as &[_]), (3, &[1, 3, 3, 1]), (4, &[1, 4, 6, 4, 1])]; 13 | 14 | for (num_rows, expected) in test_cases { 15 | assert_eq!(S::get_row(num_rows), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0121_best_time_to_buy_and_sell_stock/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn max_profit(prices: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[7, 1, 5, 3, 6, 4] as &[_], 5), (&[7, 6, 4, 3, 1], 0)]; 13 | 14 | for (prices, expected) in test_cases { 15 | assert_eq!(S::max_profit(prices.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0128_longest_consecutive_sequence/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_set; 2 | 3 | pub trait Solution { 4 | fn longest_consecutive(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[100, 4, 200, 1, 3, 2] as &[_], 4)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::longest_consecutive(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0132_palindrome_partitioning_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn min_cut(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("aab", 1), ("a", 0), ("ab", 1), ("aab", 1), ("efe", 0)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::min_cut(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0136_single_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod reduce_xor; 2 | 3 | pub trait Solution { 4 | fn single_number(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 2, 1] as &[_], 1), (&[4, 1, 2, 1, 2], 4)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::single_number(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0137_single_number_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn single_number(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 2, 3, 2] as &[_], 3), (&[0, 1, 0, 1, 0, 1, 99], 99)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::single_number(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0152_maximum_product_subarray/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn max_product(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 3, -2, 4] as &[_], 6), (&[-2, 0, -1], 0), (&[2, 3, -2, 4], 6)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::max_product(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0153_find_minimum_in_rotated_sorted_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_search; 2 | 3 | pub trait Solution { 4 | fn find_min(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 4, 5, 1, 2] as &[_], 1), (&[4, 5, 6, 7, 0, 1, 2], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::find_min(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0154_find_minimum_in_rotated_sorted_array_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_search; 2 | 3 | pub trait Solution { 4 | fn find_min(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 3, 5] as &[_], 1), (&[2, 2, 2, 0, 1], 0), (&[1], 1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::find_min(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0162_find_peak_element/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_search; 2 | 3 | pub trait Solution { 4 | fn find_peak_element(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2, 3, 1] as &[_], &[2] as &[_]), (&[1, 2, 1, 3, 5, 6, 4], &[1, 5])]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert!(expected.contains(&S::find_peak_element(nums.to_vec()))); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0168_excel_sheet_column_title/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn convert_to_title(n: i32) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, "A"), (28, "AB"), (701, "ZY")]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::convert_to_title(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0169_majority_element/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod boyer_moore_majority_vote; 2 | 3 | pub trait Solution { 4 | fn majority_element(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 2, 3] as &[_], 3), (&[2, 2, 1, 1, 1, 2, 2], 2), (&[6, 5, 5], 5)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::majority_element(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0171_excel_sheet_column_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn title_to_number(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("A", 1), ("AB", 28), ("ZY", 701)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::title_to_number(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0190_reverse_bits/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cheating; 2 | pub mod divide_and_conquer; 3 | pub mod iterative; 4 | 5 | pub trait Solution { 6 | fn reverse_bits(n: u32) -> u32; 7 | } 8 | 9 | #[cfg(test)] 10 | mod tests { 11 | use super::Solution; 12 | 13 | pub fn run() { 14 | let test_cases = [(43_261_596, 964_176_192), (4_294_967_293, 3_221_225_471)]; 15 | 16 | for (n, expected) in test_cases { 17 | assert_eq!(S::reverse_bits(n), expected); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/problem_0191_number_of_1_bits/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cheating; 2 | pub mod iterative; 3 | pub mod iterative_2; 4 | 5 | pub trait Solution { 6 | fn hamming_weight(n: u32) -> i32; 7 | } 8 | 9 | #[cfg(test)] 10 | mod tests { 11 | use super::Solution; 12 | 13 | pub fn run() { 14 | let test_cases = [(11, 3), (128, 1), (4_294_967_294, 31)]; 15 | 16 | for (n, expected) in test_cases { 17 | assert_eq!(S::hamming_weight(n), expected); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/problem_0198_house_robber/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | pub mod dynamic_programming_2; 3 | 4 | pub trait Solution { 5 | fn rob(nums: Vec) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(&[1, 2, 3, 1] as &[_], 4), (&[2, 7, 9, 3, 1], 12)]; 14 | 15 | for (nums, expected) in test_cases { 16 | assert_eq!(S::rob(nums.to_vec()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0201_bitwise_and_of_numbers_range/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | pub mod iterative_2; 3 | 4 | pub trait Solution { 5 | fn range_bitwise_and(m: i32, n: i32) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [((5, 7), 4), ((0, 1), 0), ((2, 2), 2)]; 14 | 15 | for ((m, n), expected) in test_cases { 16 | assert_eq!(S::range_bitwise_and(m, n), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0202_happy_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_set; 2 | pub mod two_runners; 3 | 4 | pub trait Solution { 5 | fn is_happy(n: i32) -> bool; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(19, true)]; 14 | 15 | for (n, expected) in test_cases { 16 | assert_eq!(S::is_happy(n), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0213_house_robber_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn rob(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 3, 2] as &[_], 3), (&[1, 2, 3, 1], 4), (&[0], 0), (&[2, 3], 3)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::rob(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0214_shortest_palindrome/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | pub mod kmp; 3 | 4 | pub trait Solution { 5 | fn shortest_palindrome(s: String) -> String; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("aacecaaa", "aaacecaaa"), ("abcd", "dcbabcd")]; 14 | 15 | for (s, expected) in test_cases { 16 | assert_eq!(S::shortest_palindrome(s.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0231_power_of_two/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bit_manipulation; 2 | pub mod division; 3 | pub mod enumeration; 4 | 5 | pub trait Solution { 6 | fn is_power_of_two(n: i32) -> bool; 7 | } 8 | 9 | #[cfg(test)] 10 | mod tests { 11 | use super::Solution; 12 | 13 | pub fn run() { 14 | let test_cases = [(1, true), (16, true), (218, false)]; 15 | 16 | for (n, expected) in test_cases { 17 | assert_eq!(S::is_power_of_two(n), expected); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/problem_0238_product_of_array_except_self/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod two_passes; 2 | 3 | pub trait Solution { 4 | fn product_except_self(nums: Vec) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2, 3, 4] as &[_], [24, 12, 8, 6])]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::product_except_self(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0258_add_digits/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod formula; 2 | 3 | pub trait Solution { 4 | fn add_digits(num: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(38, 2)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::add_digits(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0274_h_index/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod counting_sort; 2 | 3 | pub trait Solution { 4 | fn h_index(citations: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 0, 6, 1, 5] as &[_], 3), (&[1, 3, 1], 1), (&[0], 0)]; 13 | 14 | for (citations, expected) in test_cases { 15 | assert_eq!(S::h_index(citations.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0275_h_index_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_search; 2 | pub mod iterative; 3 | 4 | pub trait Solution { 5 | fn h_index(citations: Vec) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(&[0, 1, 3, 5, 6] as &[_], 3), (&[0], 0)]; 14 | 15 | for (citations, expected) in test_cases { 16 | assert_eq!(S::h_index(citations.to_vec()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0309_best_time_to_buy_and_sell_stock_with_cooldown/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn max_profit(prices: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2, 3, 0, 2] as &[_], 3), (&[1], 0), (&[], 0)]; 13 | 14 | for (prices, expected) in test_cases { 15 | assert_eq!(S::max_profit(prices.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0312_burst_balloons/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn max_coins(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 1, 5, 8] as &[_], 167)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::max_coins(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0316_remove_duplicate_letters/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod stack; 2 | 3 | pub trait Solution { 4 | fn remove_duplicate_letters(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("bcabc", "abc"), ("cbacdcbc", "acdb")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::remove_duplicate_letters(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0319_bulb_switcher/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn bulb_switch(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(0, 0), (1, 1), (2, 1), (3, 1)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::bulb_switch(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0326_power_of_three/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod division; 2 | 3 | pub trait Solution { 4 | fn is_power_of_three(n: i32) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(27, true), (0, false), (9, true), (45, false)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::is_power_of_three(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0338_counting_bits/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | pub mod dynamic_programming_2; 3 | 4 | pub trait Solution { 5 | fn count_bits(num: i32) -> Vec; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(2, &[0, 1, 1] as &[_]), (5, &[0, 1, 1, 2, 1, 2])]; 14 | 15 | for (num, expected) in test_cases { 16 | assert_eq!(S::count_bits(num), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0342_power_of_four/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bit_mask; 2 | 3 | pub trait Solution { 4 | fn is_power_of_four(num: i32) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(16, true), (5, false)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::is_power_of_four(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0345_reverse_vowels_of_a_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterator; 2 | pub mod iterator_2; 3 | 4 | pub trait Solution { 5 | fn reverse_vowels(s: String) -> String; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("hello", "holle"), ("leetcode", "leotcede")]; 14 | 15 | for (s, expected) in test_cases { 16 | assert_eq!(S::reverse_vowels(s.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0365_water_and_jug_problem/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn can_measure_water(x: i32, y: i32, z: i32) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((3, 5, 4), true), ((2, 6, 5), false), ((0, 0, 0), true)]; 13 | 14 | for ((x, y, z), expected) in test_cases { 15 | assert_eq!(S::can_measure_water(x, y, z), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0367_valid_perfect_square/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_search; 2 | pub mod newtons_method; 3 | 4 | pub trait Solution { 5 | fn is_perfect_square(num: i32) -> bool; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(16, true), (14, false), (2_147_395_600, true)]; 14 | 15 | for (num, expected) in test_cases { 16 | assert_eq!(S::is_perfect_square(num), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0371_sum_of_two_integers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod sum_and_carry; 2 | 3 | pub trait Solution { 4 | fn get_sum(a: i32, b: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((1, 2), 3), ((-2, 3), 1)]; 13 | 14 | for ((a, b), expected) in test_cases { 15 | assert_eq!(S::get_sum(a, b), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0387_first_unique_character_in_a_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn first_uniq_char(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("leetcode", 0), ("loveleetcode", 2)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::first_uniq_char(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0392_is_subsequence/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn is_subsequence(s: String, t: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("abc", "ahbgdc"), true), (("axc", "ahbgdc"), false)]; 13 | 14 | for ((s, t), expected) in test_cases { 15 | assert_eq!(S::is_subsequence(s.to_string(), t.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0396_rotate_function/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn max_rotate_function(a: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[4, 3, 2, 6] as &[_], 26), (&[], 0)]; 13 | 14 | for (a, expected) in test_cases { 15 | assert_eq!(S::max_rotate_function(a.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0405_convert_a_number_to_hexadecimal/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cheating; 2 | pub mod iterative; 3 | 4 | pub trait Solution { 5 | fn to_hex(num: i32) -> String; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(-1, "ffffffff"), (0, "0"), (26, "1a")]; 14 | 15 | for (num, expected) in test_cases { 16 | assert_eq!(S::to_hex(num), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0409_longest_palindrome/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | pub mod iterative_2; 3 | 4 | pub trait Solution { 5 | fn longest_palindrome(s: String) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("abccccdd", 7), ("a", 1), ("bb", 2)]; 14 | 15 | for (s, expected) in test_cases { 16 | assert_eq!(S::longest_palindrome(s.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0423_reconstruct_original_digits_from_english/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod solve_equations; 2 | 3 | pub trait Solution { 4 | fn original_digits(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("owoztneoer", "012"), ("fviefuro", "45"), ("xsi", "6"), ("nnei", "9")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::original_digits(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0459_repeated_substring_pattern/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bidirectional_search; 2 | 3 | pub trait Solution { 4 | fn repeated_substring_pattern(s: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abab", true), ("aba", false), ("abcabcabcabc", true)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::repeated_substring_pattern(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0461_hamming_distance/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod xor; 2 | 3 | pub trait Solution { 4 | fn hamming_distance(x: i32, y: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((1, 4), 2)]; 13 | 14 | for ((x, y), expected) in test_cases { 15 | assert_eq!(S::hamming_distance(x, y), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0467_unique_substrings_in_wraparound_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | 3 | pub trait Solution { 4 | fn find_substring_in_wrapround_string(p: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("a", 1), ("cac", 2), ("zab", 6), ("", 0)]; 13 | 14 | for (p, expected) in test_cases { 15 | assert_eq!(S::find_substring_in_wrapround_string(p.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0477_total_hamming_distance/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn total_hamming_distance(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[4, 14, 2] as &[_], 6), (&[4, 14, 4], 4)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::total_hamming_distance(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0486_predict_the_winner/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn predict_the_winner(nums: Vec) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 5, 2] as &[_], false), (&[1, 5, 233, 7], true)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::predict_the_winner(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0492_construct_the_rectangle/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn construct_rectangle(area: i32) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(4, [2, 2]), (37, [37, 1]), (122_122, [427, 286])]; 13 | 14 | for (area, expected) in test_cases { 15 | assert_eq!(S::construct_rectangle(area), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0504_base_7/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn convert_to_base7(num: i32) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(100, "202"), (-7, "-10"), (0, "0")]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::convert_to_base7(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0514_freedom_trail/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn find_rotate_steps(ring: String, key: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("godding", "gd"), 4), (("godding", "godding"), 13)]; 13 | 14 | for ((ring, key), expected) in test_cases { 15 | assert_eq!(S::find_rotate_steps(ring.to_string(), key.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0517_super_washing_machines/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn find_min_moves(machines: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 0, 5] as &[_], 3), (&[0, 3, 0], 2), (&[0, 2, 0], -1)]; 13 | 14 | for (machines, expected) in test_cases { 15 | assert_eq!(S::find_min_moves(machines.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0518_coin_change_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn change(amount: i32, coins: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((5, &[1, 2, 5] as &[_]), 4), ((3, &[2]), 0), ((10, &[10]), 1)]; 13 | 14 | for ((amount, coins), expected) in test_cases { 15 | assert_eq!(S::change(amount, coins.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0525_contiguous_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn find_max_length(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[0, 1] as &[_], 2), (&[0, 1, 0], 2)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::find_max_length(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0541_reverse_string_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod reverse_by_chunks; 2 | 3 | pub trait Solution { 4 | fn reverse_str(s: String, k: i32) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("abcdefg", 2), "bacdfeg"), (("abcd", 2), "bacd")]; 13 | 14 | for ((s, k), expected) in test_cases { 15 | assert_eq!(S::reverse_str(s.to_string(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0552_student_attendance_record_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | pub mod matrix_multiplication; 3 | 4 | pub trait Solution { 5 | fn check_record(n: i32) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(1, 3), (2, 8), (10101, 183_236_316)]; 14 | 15 | for (n, expected) in test_cases { 16 | assert_eq!(S::check_record(n), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0561_array_partition/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod sorting; 2 | 3 | pub trait Solution { 4 | fn array_pair_sum(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 4, 3, 2] as &[_], 4), (&[6, 2, 6, 5, 1, 2], 9)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::array_pair_sum(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0565_array_nesting/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn array_nesting(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[5, 4, 0, 3, 1, 6, 2] as &[_], 4), (&[0, 1, 2], 1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::array_nesting(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0575_distribute_candies/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_set; 2 | 3 | pub trait Solution { 4 | fn distribute_candies(candy_type: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 1, 2, 2, 3, 3] as &[_], 3), (&[1, 1, 2, 3], 2), (&[6, 6, 6, 6], 1)]; 13 | 14 | for (candy_type, expected) in test_cases { 15 | assert_eq!(S::distribute_candies(candy_type.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0611_valid_triangle_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod sort_then_binary_search; 2 | 3 | pub trait Solution { 4 | fn triangle_number(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 2, 3, 4] as &[_], 3), (&[4, 2, 3, 4], 4), (&[0, 0, 0], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::triangle_number(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0628_maximum_product_of_three_numbers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn maximum_product(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2, 3] as &[_], 6), (&[1, 2, 3, 4], 24), (&[-1, -2, -3], -6)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::maximum_product(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0647_palindromic_substrings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | 3 | pub trait Solution { 4 | fn count_substrings(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("", 0), ("a", 1), ("abc", 3), ("aaa", 6), ("aba", 4)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::count_substrings(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0649_dota2_senate/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn predict_party_victory(senate: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("RD", "Radiant"), ("RDD", "Dire"), ("DDRRR", "Dire")]; 13 | 14 | for (senate, expected) in test_cases { 15 | assert_eq!(S::predict_party_victory(senate.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0657_robot_return_to_origin/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn judge_circle(moves: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("UD", true), ("LL", false), ("RRDD", false), ("LDRRLRUULR", false)]; 13 | 14 | for (moves, expected) in test_cases { 15 | assert_eq!(S::judge_circle(moves.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0664_strange_printer/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn strange_printer(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("aaabbb", 2), ("aba", 2)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::strange_printer(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0668_kth_smallest_number_in_multiplication_table/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_search; 2 | 3 | pub trait Solution { 4 | fn find_kth_number(m: i32, n: i32, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((3, 3, 5), 3), ((2, 3, 6), 6), ((41, 31, 777), 351)]; 13 | 14 | for ((m, n, k), expected) in test_cases { 15 | assert_eq!(S::find_kth_number(m, n, k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0674_longest_continuous_increasing_subsequence/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn find_length_of_lcis(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 3, 5, 4, 7] as &[_], 3), (&[2, 2, 2, 2, 2], 1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::find_length_of_lcis(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0696_count_binary_substrings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_binary_substrings(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("00110011", 6), ("10101", 4)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::count_binary_substrings(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0697_degree_of_an_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_map; 2 | 3 | pub trait Solution { 4 | fn find_shortest_sub_array(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2, 2, 3, 1] as &[_], 2), (&[1, 2, 2, 3, 1, 4, 2], 6)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::find_shortest_sub_array(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0709_to_lower_case/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cheating; 2 | pub mod iterative; 3 | 4 | pub trait Solution { 5 | fn to_lower_case(str: String) -> String; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("Hello", "hello"), ("here", "here"), ("LOVELY", "lovely")]; 14 | 15 | for (str, expected) in test_cases { 16 | assert_eq!(S::to_lower_case(str.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0717_1_bit_and_2_bit_characters/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn is_one_bit_character(bits: Vec) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 0, 0] as &[_], true), (&[1, 1, 1, 0], false)]; 13 | 14 | for (bits, expected) in test_cases { 15 | assert_eq!(S::is_one_bit_character(bits.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0724_find_pivot_index/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn pivot_index(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 7, 3, 6, 5, 6] as &[_], 3), (&[1, 2, 3], -1), (&[2, 1, -1], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::pivot_index(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0761_special_binary_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod recursive; 2 | pub mod recursive_2; 3 | 4 | pub trait Solution { 5 | fn make_largest_special(s: String) -> String; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("11011000", "11100100"), ("10", "10"), ("101010", "101010")]; 14 | 15 | for (s, expected) in test_cases { 16 | assert_eq!(S::make_largest_special(s.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0765_couples_holding_hands/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod find_cycles; 2 | 3 | pub trait Solution { 4 | fn min_swaps_couples(row: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[0, 2, 1, 3] as &[_], 1), (&[3, 2, 0, 1], 0)]; 13 | 14 | for (row, expected) in test_cases { 15 | assert_eq!(S::min_swaps_couples(row.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0768_max_chunks_to_make_sorted_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn max_chunks_to_sorted(arr: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[5, 4, 3, 2, 1] as &[_], 1), (&[2, 1, 3, 4, 4], 4)]; 13 | 14 | for (arr, expected) in test_cases { 15 | assert_eq!(S::max_chunks_to_sorted(arr.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0769_max_chunks_to_make_sorted/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn max_chunks_to_sorted(arr: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[4, 3, 2, 1, 0] as &[_], 1), (&[1, 0, 2, 3, 4], 4)]; 13 | 14 | for (arr, expected) in test_cases { 15 | assert_eq!(S::max_chunks_to_sorted(arr.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0771_jewels_and_stones/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | 3 | pub trait Solution { 4 | fn num_jewels_in_stones(j: String, s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("aA", "aAAbbbb"), 3), (("z", "ZZ"), 0)]; 13 | 14 | for ((j, s), expected) in test_cases { 15 | assert_eq!(S::num_jewels_in_stones(j.to_string(), s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0779_k_th_symbol_in_grammar/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn kth_grammar(n: i32, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | // https://oeis.org/A010060. 13 | 14 | let test_cases = [((1, 1), 0), ((2, 1), 0), ((2, 2), 1), ((3, 1), 0)]; 15 | 16 | for ((n, k), expected) in test_cases { 17 | assert_eq!(S::kth_grammar(n, k), expected); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/problem_0781_rabbits_in_forest/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod buckets; 2 | 3 | pub trait Solution { 4 | fn num_rabbits(answers: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 1, 2] as &[_], 5), (&[10, 10, 10], 11)]; 13 | 14 | for (answers, expected) in test_cases { 15 | assert_eq!(S::num_rabbits(answers.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0798_smallest_rotation_with_highest_score/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod count_interval_intersections; 2 | 3 | pub trait Solution { 4 | fn best_rotation(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 3, 1, 4, 0] as &[_], 3), (&[1, 3, 0, 2, 4], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::best_rotation(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0838_push_dominoes/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn push_dominoes(dominoes: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("RR.L", "RR.L"), (".L.R...LR..L..", "LL.RR.LLRRLL..")]; 13 | 14 | for (dominoes, expected) in test_cases { 15 | assert_eq!(S::push_dominoes(dominoes.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0858_mirror_reflection/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | pub mod mathematical_2; 3 | 4 | pub trait Solution { 5 | fn mirror_reflection(p: i32, q: i32) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [((2, 1), 2), ((3, 1), 1), ((3, 2), 0), ((5, 3), 1)]; 14 | 15 | for ((p, q), expected) in test_cases { 16 | assert_eq!(S::mirror_reflection(p, q), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0868_binary_gap/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn binary_gap(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(22, 2), (5, 2), (6, 1), (8, 0), (1, 0)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::binary_gap(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0877_stone_game/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | pub mod mathematical; 3 | 4 | pub trait Solution { 5 | fn stone_game(piles: Vec) -> bool; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(&[5, 3, 4, 5] as &[_], true), (&[3, 7, 2, 3], true)]; 14 | 15 | for (piles, expected) in test_cases { 16 | assert_eq!(S::stone_game(piles.to_vec()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0898_bitwise_ors_of_subarrays/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn subarray_bitwise_o_rs(arr: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[0] as &[_], 1), (&[1, 1, 2], 3), (&[1, 2, 4], 6)]; 13 | 14 | for (arr, expected) in test_cases { 15 | assert_eq!(S::subarray_bitwise_o_rs(arr.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0899_orderly_queue/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod duval; 2 | 3 | pub trait Solution { 4 | fn orderly_queue(s: String, k: i32) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("cba", 1), "acb"), (("baaca", 3), "aaabc")]; 13 | 14 | for ((s, k), expected) in test_cases { 15 | assert_eq!(S::orderly_queue(s.to_string(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0903_valid_permutations_for_di_sequence/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn num_perms_di_sequence(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("DID", 5), ("D", 1), ("IDDDIIDIIIIIIIIDIDID", 853_197_538)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::num_perms_di_sequence(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0910_smallest_range_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn smallest_range_ii(nums: Vec, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((&[1] as &[_], 0), 0), ((&[0, 10], 2), 6), ((&[1, 3, 6], 3), 3)]; 13 | 14 | for ((nums, k), expected) in test_cases { 15 | assert_eq!(S::smallest_range_ii(nums.to_vec(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0915_partition_array_into_disjoint_intervals/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn partition_disjoint(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[5, 0, 3, 8, 6] as &[_], 3), (&[1, 1, 1, 0, 6, 12], 4)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::partition_disjoint(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0920_number_of_music_playlists/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn num_music_playlists(n: i32, goal: i32, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((3, 3, 1), 6), ((2, 3, 0), 6), ((2, 3, 1), 2)]; 13 | 14 | for ((n, goal, k), expected) in test_cases { 15 | assert_eq!(S::num_music_playlists(n, goal, k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0921_minimum_add_to_make_parentheses_valid/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod stack; 2 | 3 | pub trait Solution { 4 | fn min_add_to_make_valid(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("())", 1), ("(((", 3)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::min_add_to_make_valid(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0926_flip_string_to_monotone_increasing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | pub mod iterative_2; 3 | 4 | pub trait Solution { 5 | fn min_flips_mono_incr(s: String) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("00110", 1), ("010110", 2), ("00011000", 2)]; 14 | 15 | for (s, expected) in test_cases { 16 | assert_eq!(S::min_flips_mono_incr(s.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_0940_distinct_subsequences_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn distinct_subseq_ii(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abc", 7), ("aba", 6), ("aaa", 3)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::distinct_subseq_ii(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0945_minimum_increment_to_make_array_unique/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn min_increment_for_unique(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2, 2] as &[_], 1), (&[3, 2, 1, 2, 1, 7], 6)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::min_increment_for_unique(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0962_maximum_width_ramp/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod monotonic_stack; 2 | 3 | pub trait Solution { 4 | fn max_width_ramp(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[6, 0, 8, 2, 1, 5] as &[_], 4), (&[9, 8, 1, 0, 1, 9, 4, 0, 4, 1], 7)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::max_width_ramp(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0974_subarray_sums_divisible_by_k/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn subarrays_div_by_k(nums: Vec, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((&[4, 5, 0, -2, -3, 1] as &[_], 5), 7), ((&[5], 9), 0)]; 13 | 14 | for ((nums, k), expected) in test_cases { 15 | assert_eq!(S::subarrays_div_by_k(nums.to_vec(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0976_largest_perimeter_triangle/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn largest_perimeter(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 1, 2] as &[_], 5), (&[1, 2, 1], 0), (&[3, 6, 2, 3], 8)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::largest_perimeter(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0982_triples_with_bitwise_and_equal_to_zero/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_triplets(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 1, 3] as &[_], 12), (&[0, 0, 0], 27)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::count_triplets(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_0991_broken_calculator/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn broken_calc(start_value: i32, target: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((2, 3), 2), ((5, 8), 2), ((3, 10), 3)]; 13 | 14 | for ((start_value, target), expected) in test_cases { 15 | assert_eq!(S::broken_calc(start_value, target), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1006_clumsy_factorial/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn clumsy(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 1), (2, 2), (4, 7), (5, 7), (10, 12)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::clumsy(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1012_numbers_with_repeated_digits/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn num_dup_digits_at_most_n(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(20, 1), (100, 10), (1000, 262)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::num_dup_digits_at_most_n(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1014_best_sightseeing_pair/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn max_score_sightseeing_pair(values: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[8, 1, 5, 2, 6] as &[_], 11), (&[1, 2], 2), (&[2, 1], 2)]; 13 | 14 | for (values, expected) in test_cases { 15 | assert_eq!(S::max_score_sightseeing_pair(values.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1015_smallest_integer_divisible_by_k/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod find_cycle; 2 | 3 | pub trait Solution { 4 | fn smallest_repunit_div_by_k(k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 1), (2, -1), (3, 3), (4, -1)]; 13 | 14 | for (k, expected) in test_cases { 15 | assert_eq!(S::smallest_repunit_div_by_k(k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1025_divisor_game/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn divisor_game(n: i32) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(2, true), (3, false)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::divisor_game(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1040_moving_stones_until_consecutive_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn num_moves_stones_ii(stones: Vec) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[7, 4, 9] as &[_], [1, 2]), (&[6, 5, 4, 3, 10], [2, 3])]; 13 | 14 | for (stones, expected) in test_cases { 15 | assert_eq!(S::num_moves_stones_ii(stones.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1046_last_stone_weight/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force_with_binary_heap; 2 | 3 | pub trait Solution { 4 | fn last_stone_weight(stones: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 7, 4, 1, 8, 1] as &[_], 1), (&[1], 1), (&[2, 2], 0)]; 13 | 14 | for (stones, expected) in test_cases { 15 | assert_eq!(S::last_stone_weight(stones.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1047_remove_all_adjacent_duplicates_in_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn remove_duplicates(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abbaca", "ca"), ("azxxzy", "ay")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::remove_duplicates(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1049_last_stone_weight_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn last_stone_weight_ii(stones: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 7, 4, 1, 8, 1] as &[_], 1), (&[31, 26, 33, 21, 40], 5)]; 13 | 14 | for (stones, expected) in test_cases { 15 | assert_eq!(S::last_stone_weight_ii(stones.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1081_smallest_subsequence_of_distinct_characters/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod stack; 2 | 3 | pub trait Solution { 4 | fn smallest_subsequence(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("bcabc", "abc"), ("cbacdcbc", "acdb")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::smallest_subsequence(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1104_path_in_zigzag_labelled_binary_tree/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn path_in_zig_zag_tree(label: i32) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(14, &[1, 3, 4, 14] as &[_]), (26, &[1, 2, 6, 10, 26]), (5, &[1, 3, 5])]; 13 | 14 | for (label, expected) in test_cases { 15 | assert_eq!(S::path_in_zig_zag_tree(label), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1108_defanging_an_ip_address/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | 3 | pub trait Solution { 4 | fn defang_i_paddr(address: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("1.1.1.1", "1[.]1[.]1[.]1"), ("255.100.50.0", "255[.]100[.]50[.]0")]; 13 | 14 | for (address, expected) in test_cases { 15 | assert_eq!(S::defang_i_paddr(address.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1124_longest_well_performing_interval/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod monotonic_stack; 2 | 3 | pub trait Solution { 4 | fn longest_wpi(hours: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[9, 9, 6, 0, 6, 6, 9] as &[_], 3), (&[6, 6, 6], 0), (&[6, 6, 9], 1)]; 13 | 14 | for (hours, expected) in test_cases { 15 | assert_eq!(S::longest_wpi(hours.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1137_n_th_tribonacci_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod matrix_multiplication; 2 | 3 | pub trait Solution { 4 | fn tribonacci(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(0, 0), (1, 1), (2, 1), (3, 2), (4, 4), (25, 1_389_537)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::tribonacci(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1140_stone_game_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn stone_game_ii(piles: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 7, 9, 4, 4] as &[_], 10), (&[1, 2, 3, 4, 5, 100], 104)]; 13 | 14 | for (piles, expected) in test_cases { 15 | assert_eq!(S::stone_game_ii(piles.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1156_swap_for_longest_repeated_character_substring/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn max_rep_opt1(text: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("ababa", 3), ("aaabaaa", 6), ("aaaaa", 5), ("bbababaaaa", 6)]; 13 | 14 | for (text, expected) in test_cases { 15 | assert_eq!(S::max_rep_opt1(text.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1163_last_substring_in_lexicographical_order/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn last_substring(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abab", "bab"), ("leetcode", "tcode"), ("aaaaaaab", "b")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::last_substring(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1189_maximum_number_of_balloons/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod count_letters; 2 | 3 | pub trait Solution { 4 | fn max_number_of_balloons(text: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("nlaebolko", 1), ("loonbalxballpoon", 2), ("leetcode", 0)]; 13 | 14 | for (text, expected) in test_cases { 15 | assert_eq!(S::max_number_of_balloons(text.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1220_count_vowels_permutation/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod matrix_multiplication; 2 | 3 | pub trait Solution { 4 | fn count_vowel_permutation(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 5), (2, 10), (5, 68)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::count_vowel_permutation(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1221_split_a_string_in_balanced_strings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn balanced_string_split(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("RLRRLLRLRL", 4), ("RLLLLRRRLR", 3), ("LLLLRRRR", 1)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::balanced_string_split(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1227_airplane_seat_assignment_probability/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn nth_person_gets_nth_seat(n: i32) -> f64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 1.0), (2, 0.5)]; 13 | 14 | for (n, expected) in test_cases { 15 | approx::assert_ulps_eq!(S::nth_person_gets_nth_seat(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1240_tiling_a_rectangle_with_the_fewest_squares/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod backtracking; 2 | 3 | pub trait Solution { 4 | fn tiling_rectangle(n: i32, m: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((2, 3), 3), ((5, 8), 5), ((11, 13), 6), ((13, 11), 6)]; 13 | 14 | for ((n, m), expected) in test_cases { 15 | assert_eq!(S::tiling_rectangle(n, m), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1247_minimum_swaps_to_make_strings_equal/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn minimum_swap(s1: String, s2: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("xx", "yy"), 1), (("xy", "yx"), 2), (("xx", "xy"), -1)]; 13 | 14 | for ((s1, s2), expected) in test_cases { 15 | assert_eq!(S::minimum_swap(s1.to_string(), s2.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1250_check_if_it_is_a_good_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn is_good_array(nums: Vec) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[12, 5, 7, 23] as &[_], true), (&[29, 6, 10], true), (&[3, 6], false)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::is_good_array(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1278_palindrome_partitioning_iii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn palindrome_partition(s: String, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("abc", 2), 1), (("aabbc", 3), 0), (("leetcode", 8), 0)]; 13 | 14 | for ((s, k), expected) in test_cases { 15 | assert_eq!(S::palindrome_partition(s.to_string(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1281_subtract_the_product_and_sum_of_digits_of_an_integer/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn subtract_product_and_sum(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(234, 15), (4421, 21), (114, -2)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::subtract_product_and_sum(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1287_element_appearing_more_than_25_in_sorted_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn find_special_integer(arr: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2, 2, 6, 6, 6, 6, 7, 10] as &[_], 6), (&[1, 1], 1)]; 13 | 14 | for (arr, expected) in test_cases { 15 | assert_eq!(S::find_special_integer(arr.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1295_find_numbers_with_even_number_of_digits/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn find_numbers(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[12, 345, 2, 6, 7896] as &[_], 2), (&[555, 901, 482, 1771], 1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::find_numbers(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1309_decrypt_string_from_alphabet_to_integer_mapping/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn freq_alphabets(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("10#11#12", "jkab"), ("1326#", "acz"), ("26#11#418#5", "zkdre")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::freq_alphabets(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1316_distinct_echo_substrings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod sliding; 2 | 3 | pub trait Solution { 4 | fn distinct_echo_substrings(text: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abcabcabc", 3), ("leetcodeleetcode", 2)]; 13 | 14 | for (text, expected) in test_cases { 15 | assert_eq!(S::distinct_echo_substrings(text.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1318_minimum_flips_to_make_a_or_b_equal_to_c/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bit_manipulation; 2 | 3 | pub trait Solution { 4 | fn min_flips(a: i32, b: i32, c: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((2, 6, 5), 3), ((4, 2, 7), 1), ((1, 2, 3), 0), ((8, 3, 5), 3)]; 13 | 14 | for ((a, b, c), expected) in test_cases { 15 | assert_eq!(S::min_flips(a, b, c), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1323_maximum_69_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn maximum69_number(num: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(9669, 9969), (9996, 9999), (9999, 9999)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::maximum69_number(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1328_break_a_palindrome/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn break_palindrome(palindrome: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abccba", "aaccba"), ("a", ""), ("aa", "ab"), ("aabaa", "aabab")]; 13 | 14 | for (palindrome, expected) in test_cases { 15 | assert_eq!(S::break_palindrome(palindrome.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1332_remove_palindromic_subsequences/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn remove_palindrome_sub(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("ababa", 1), ("abb", 2), ("baabb", 2)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::remove_palindrome_sub(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1342_number_of_steps_to_reduce_a_number_to_zero/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | pub mod brute_force_2; 3 | 4 | pub trait Solution { 5 | fn number_of_steps(num: i32) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(14, 6), (8, 4), (123, 12)]; 14 | 15 | for (num, expected) in test_cases { 16 | assert_eq!(S::number_of_steps(num), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_1346_check_if_n_and_its_double_exist/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_set; 2 | 3 | pub trait Solution { 4 | fn check_if_exist(arr: Vec) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[10, 2, 5, 3] as &[_], true), (&[3, 1, 7, 11], false)]; 13 | 14 | for (arr, expected) in test_cases { 15 | assert_eq!(S::check_if_exist(arr.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1358_number_of_substrings_containing_all_three_characters/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod sliding_window; 2 | 3 | pub trait Solution { 4 | fn number_of_substrings(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abcabc", 10), ("aaacb", 3), ("abc", 1)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::number_of_substrings(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1359_count_all_valid_pickup_and_delivery_options/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn count_orders(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 1), (2, 6), (3, 90)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::count_orders(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1370_increasing_decreasing_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn sort_string(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("aaaabbbbcccc", "abccbaabccba"), ("rat", "art")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::sort_string(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1375_number_of_times_binary_string_is_prefix_aligned/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn num_times_all_blue(flips: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 2, 4, 1, 5] as &[_], 2), (&[4, 1, 2, 3], 1)]; 13 | 14 | for (flips, expected) in test_cases { 15 | assert_eq!(S::num_times_all_blue(flips.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1392_longest_happy_prefix/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn longest_prefix(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("level", "l"), ("ababab", "abab"), ("babbb", "b")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::longest_prefix(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1400_construct_k_palindrome_strings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn can_construct(s: String, k: i32) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("annabelle", 2), true), (("leetcode", 3), false), (("true", 4), true)]; 13 | 14 | for ((s, k), expected) in test_cases { 15 | assert_eq!(S::can_construct(s.to_string(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1404_number_of_steps_to_reduce_a_number_in_binary_representation_to_one/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn num_steps(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("1101", 6), ("10", 1), ("1", 0)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::num_steps(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1411_number_of_ways_to_paint_n_3_grid/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | pub mod matrix_multiplication; 3 | 4 | pub trait Solution { 5 | fn num_of_ways(n: i32) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [(1, 12), (5000, 30_228_214)]; 14 | 15 | for (n, expected) in test_cases { 16 | assert_eq!(S::num_of_ways(n), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_1413_minimum_value_to_get_positive_step_by_step_sum/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn min_start_value(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[-3, 2, -3, 4, 2] as &[_], 5), (&[1, 2], 1), (&[1, -2, -3], 5)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::min_start_value(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1414_find_the_minimum_number_of_fibonacci_numbers_whose_sum_is_k/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn find_min_fibonacci_numbers(k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(7, 2), (10, 2), (19, 3), (645_157_245, 13)]; 13 | 14 | for (k, expected) in test_cases { 15 | assert_eq!(S::find_min_fibonacci_numbers(k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1422_maximum_score_after_splitting_a_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn max_score(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("011101", 5), ("00111", 5), ("1111", 3)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::max_score(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1442_count_triplets_that_can_form_two_arrays_of_equal_xor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_triplets(arr: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 3, 1, 6, 7] as &[_], 4), (&[1, 1, 1, 1, 1], 10)]; 13 | 14 | for (arr, expected) in test_cases { 15 | assert_eq!(S::count_triplets(arr.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1446_consecutive_characters/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn max_power(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("leetcode", 2), ("abbcccddddeeeeedcba", 5), ("tourist", 1)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::max_power(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1464_maximum_product_of_two_elements_in_an_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn max_product(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 4, 5, 2] as &[_], 12), (&[1, 5, 4, 5], 16), (&[3, 7], 12)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::max_product(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1478_allocate_mailboxes/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn min_distance(houses: Vec, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((&[1, 4, 8, 10, 20] as &[_], 3), 5), ((&[2, 3, 5, 12, 18], 2), 9)]; 13 | 14 | for ((houses, k), expected) in test_cases { 15 | assert_eq!(S::min_distance(houses.to_vec(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1486_xor_operation_in_an_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bit_manipulation; 2 | 3 | pub trait Solution { 4 | fn xor_operation(n: i32, start: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((5, 0), 8), ((4, 3), 8)]; 13 | 14 | for ((n, start), expected) in test_cases { 15 | assert_eq!(S::xor_operation(n, start), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1496_path_crossing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_set; 2 | 3 | pub trait Solution { 4 | fn is_path_crossing(path: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("NES", false), ("NESWW", true)]; 13 | 14 | for (path, expected) in test_cases { 15 | assert_eq!(S::is_path_crossing(path.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1512_number_of_good_pairs/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn num_identical_pairs(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2, 3, 1, 1, 3] as &[_], 4), (&[1, 1, 1, 1], 6), (&[1, 2, 3], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::num_identical_pairs(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1513_number_of_substrings_with_only_1s/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn num_sub(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("0110111", 9), ("101", 2), ("111111", 21)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::num_sub(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1518_water_bottles/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn num_water_bottles(num_bottles: i32, num_exchange: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((9, 3), 13), ((15, 4), 19)]; 13 | 14 | for ((num_bottles, num_exchange), expected) in test_cases { 15 | assert_eq!(S::num_water_bottles(num_bottles, num_exchange), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1523_count_odd_numbers_in_an_interval_range/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | pub mod mathematical_2; 3 | 4 | pub trait Solution { 5 | fn count_odds(low: i32, high: i32) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [((3, 7), 3), ((8, 10), 1)]; 14 | 15 | for ((low, high), expected) in test_cases { 16 | assert_eq!(S::count_odds(low, high), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_1524_number_of_sub_arrays_with_odd_sum/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn num_of_subarrays(arr: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 3, 5] as &[_], 4), (&[2, 4, 6], 0), (&[1, 2, 3, 4, 5, 6, 7], 16)]; 13 | 14 | for (arr, expected) in test_cases { 15 | assert_eq!(S::num_of_subarrays(arr.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1525_number_of_good_ways_to_split_a_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn num_splits(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("aacaba", 2), ("abcd", 1)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::num_splits(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1529_minimum_suffix_flips/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | pub mod greedy_2; 3 | 4 | pub trait Solution { 5 | fn min_flips(target: String) -> i32; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("10111", 3), ("101", 3), ("00000", 0)]; 14 | 15 | for (target, expected) in test_cases { 16 | assert_eq!(S::min_flips(target.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_1535_find_the_winner_of_an_array_game/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod simulation; 2 | 3 | pub trait Solution { 4 | fn get_winner(arr: Vec, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((&[2, 1, 3, 5, 4, 6, 7] as &[_], 2), 5), ((&[3, 2, 1], 10), 3)]; 13 | 14 | for ((arr, k), expected) in test_cases { 15 | assert_eq!(S::get_winner(arr.to_vec(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1539_kth_missing_positive_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_search; 2 | 3 | pub trait Solution { 4 | fn find_kth_positive(arr: Vec, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((&[2, 3, 4, 7, 11] as &[_], 5), 9), ((&[1, 2, 3, 4], 2), 6)]; 13 | 14 | for ((arr, k), expected) in test_cases { 15 | assert_eq!(S::find_kth_positive(arr.to_vec(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1541_minimum_insertions_to_balance_a_parentheses_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod stack; 2 | 3 | pub trait Solution { 4 | fn min_insertions(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("(()))", 1), ("())", 0), ("))())(", 3), ("()()()()()(", 7)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::min_insertions(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1542_find_longest_awesome_substring/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn longest_awesome(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("3242415", 5), ("12345678", 1), ("213123", 6)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::longest_awesome(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1544_make_the_string_great/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod stack; 2 | 3 | pub trait Solution { 4 | fn make_good(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("leEeetcode", "leetcode"), ("abBAcC", ""), ("s", "s")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::make_good(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1545_find_kth_bit_in_nth_binary_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | pub mod mathematical; 3 | 4 | pub trait Solution { 5 | fn find_kth_bit(n: i32, k: i32) -> char; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [((3, 1), '0'), ((3, 5), '0'), ((4, 11), '1'), ((4, 12), '0')]; 14 | 15 | for ((n, k), expected) in test_cases { 16 | assert_eq!(S::find_kth_bit(n, k), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_1551_minimum_operations_to_make_array_equal/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn min_operations(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(3, 2), (6, 9)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::min_operations(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1558_minimum_numbers_of_function_calls_to_make_target_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod count_bits; 2 | 3 | pub trait Solution { 4 | fn min_operations(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 5] as &[_], 5), (&[2, 2], 3), (&[4, 2, 5], 6)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::min_operations(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1569_number_of_ways_to_reorder_array_to_get_same_bst/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod recursive; 2 | 3 | pub trait Solution { 4 | fn num_of_ways(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 1, 3] as &[_], 1), (&[3, 4, 5, 1, 2], 5), (&[1, 2, 3], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::num_of_ways(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1573_number_of_ways_to_split_a_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn num_ways(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("10101", 4), ("1001", 0), ("0000", 3), ("100100010100110", 12)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::num_ways(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1593_split_a_string_into_the_max_number_of_unique_substrings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod backtracking; 2 | 3 | pub trait Solution { 4 | fn max_unique_split(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("ababccc", 5), ("aba", 2), ("aa", 1)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::max_unique_split(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1614_maximum_nesting_depth_of_the_parentheses/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod stack; 2 | 3 | pub trait Solution { 4 | fn max_depth(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("(1+(2*3)+((8)/4))+1", 3), ("(1)+((2))+(((3)))", 3)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::max_depth(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1621_number_of_sets_of_k_non_overlapping_line_segments/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod combinations; 2 | 3 | pub trait Solution { 4 | fn number_of_sets(n: i32, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((4, 2), 5), ((3, 1), 3), ((30, 7), 796_297_179)]; 13 | 14 | for ((n, k), expected) in test_cases { 15 | assert_eq!(S::number_of_sets(n, k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1638_count_substrings_that_differ_by_one_character/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_substrings(s: String, t: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("aba", "baba"), 6), (("ab", "bb"), 3)]; 13 | 14 | for ((s, t), expected) in test_cases { 15 | assert_eq!(S::count_substrings(s.to_string(), t.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1641_count_sorted_vowel_strings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn count_vowel_strings(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 5), (2, 15), (33, 66045)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::count_vowel_strings(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1647_minimum_deletions_to_make_character_frequencies_unique/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn min_deletions(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("aab", 0), ("aaabbbcc", 2), ("ceabaacb", 2)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::min_deletions(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1663_smallest_string_with_a_given_numeric_value/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn get_smallest_string(n: i32, k: i32) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((3, 27), "aay"), ((5, 73), "aaszz"), ((3, 3), "aaa")]; 13 | 14 | for ((n, k), expected) in test_cases { 15 | assert_eq!(S::get_smallest_string(n, k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1688_count_of_matches_in_tournament/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn number_of_matches(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(7, 6), (14, 13)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::number_of_matches(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1689_partitioning_into_minimum_number_of_deci_binary_numbers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn min_partitions(n: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("32", 3), ("82734", 8), ("27346209830709182346", 9)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::min_partitions(n.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1690_stone_game_vii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn stone_game_vii(stones: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[5, 3, 1, 4, 2] as &[_], 6), (&[7, 90, 5, 1, 100, 10, 10, 2], 122)]; 13 | 14 | for (stones, expected) in test_cases { 15 | assert_eq!(S::stone_game_vii(stones.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1702_maximum_binary_string_after_change/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn maximum_binary_string(binary: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("000110", "111011"), ("01", "01"), ("1", "1")]; 13 | 14 | for (binary, expected) in test_cases { 15 | assert_eq!(S::maximum_binary_string(binary.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1704_determine_if_string_halves_are_alike/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn halves_are_alike(s: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("book", true), ("textbook", false), ("AbCdEfGh", true)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::halves_are_alike(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1711_count_good_meals/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_map; 2 | 3 | pub trait Solution { 4 | fn count_pairs(deliciousness: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 3, 5, 7, 9] as &[_], 4), (&[1, 1, 1, 3, 3, 3, 7], 15), (&[0], 0)]; 13 | 14 | for (deliciousness, expected) in test_cases { 15 | assert_eq!(S::count_pairs(deliciousness.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1716_calculate_money_in_leetcode_bank/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn total_money(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(4, 10), (10, 37), (20, 96)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::total_money(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1726_tuple_with_same_product/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_map; 2 | 3 | pub trait Solution { 4 | fn tuple_same_product(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 3, 4, 6] as &[_], 8), (&[1, 2, 4, 5, 10], 16)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::tuple_same_product(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1732_find_the_highest_altitude/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn largest_altitude(gain: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[-5, 1, 5, 0, -7] as &[_], 1), (&[-4, -3, -2, -1, 4, 3, 2], 0)]; 13 | 14 | for (gain, expected) in test_cases { 15 | assert_eq!(S::largest_altitude(gain.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1734_decode_xored_permutation/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn decode(encoded: Vec) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 1] as &[_], &[1, 2, 3] as &[_]), (&[6, 5, 4, 6], &[2, 4, 1, 5, 3])]; 13 | 14 | for (encoded, expected) in test_cases { 15 | assert_eq!(S::decode(encoded.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1753_maximum_score_from_removing_stones/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn maximum_score(a: i32, b: i32, c: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((2, 4, 6), 6), ((4, 4, 6), 7), ((1, 8, 8), 8), ((6, 2, 1), 3)]; 13 | 14 | for ((a, b, c), expected) in test_cases { 15 | assert_eq!(S::maximum_score(a, b, c), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1759_count_number_of_homogenous_substrings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn count_homogenous(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abbcccaa", 13), ("xy", 2), ("zzzzz", 15)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::count_homogenous(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1763_longest_nice_substring/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod divide_and_conquer; 2 | 3 | pub trait Solution { 4 | fn longest_nice_substring(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("YazaAay", "aAa"), ("Bb", "Bb"), ("c", "")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::longest_nice_substring(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1780_check_if_number_is_a_sum_of_powers_of_three/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod ternary_number; 2 | 3 | pub trait Solution { 4 | fn check_powers_of_three(n: i32) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(12, true), (91, true), (21, false)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::check_powers_of_three(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1781_sum_of_beauty_of_all_substrings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | 3 | pub trait Solution { 4 | fn beauty_sum(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("aabcb", 5), ("aabcbaa", 17)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::beauty_sum(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1784_check_if_binary_string_has_at_most_one_segment_of_ones/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn check_ones_segment(s: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("1001", false), ("110", true), ("111", true)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::check_ones_segment(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1799_maximize_score_after_n_operations/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn max_score(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2] as &[_], 1), (&[3, 4, 6, 8], 11), (&[1, 2, 3, 4, 5, 6], 14)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::max_score(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1806_minimum_number_of_operations_to_reinitialize_a_permutation/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod reversed_iteration; 2 | 3 | pub trait Solution { 4 | fn reinitialize_permutation(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(2, 1), (4, 2), (6, 4), (8, 3), (10, 6)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::reinitialize_permutation(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1812_determine_color_of_a_chessboard_square/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn square_is_white(coordinates: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("a1", false), ("h3", true), ("c7", false)]; 13 | 14 | for (coordinates, expected) in test_cases { 15 | assert_eq!(S::square_is_white(coordinates.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1814_count_nice_pairs_in_an_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_map; 2 | 3 | pub trait Solution { 4 | fn count_nice_pairs(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[42, 11, 1, 97] as &[_], 2), (&[13, 10, 35, 24, 76], 4)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::count_nice_pairs(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1827_minimum_operations_to_make_the_array_increasing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn min_operations(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 1, 1] as &[_], 3), (&[1, 5, 2, 4, 1], 14), (&[8], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::min_operations(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1837_sum_of_digits_in_base_k/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn sum_base(n: i32, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((34, 6), 9), ((10, 10), 1)]; 13 | 14 | for ((n, k), expected) in test_cases { 15 | assert_eq!(S::sum_base(n, k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1844_replace_all_digits_with_characters/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn replace_digits(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("a1c1e1", "abcdef"), ("a1b2c3d4e", "abbdcfdhe")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::replace_digits(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1860_incremental_memory_leak/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod simulation; 2 | 3 | pub trait Solution { 4 | fn mem_leak(memory1: i32, memory2: i32) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((2, 2), [3, 1, 0]), ((8, 11), [6, 0, 4])]; 13 | 14 | for ((memory1, memory2), expected) in test_cases { 15 | assert_eq!(S::mem_leak(memory1, memory2), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1863_sum_of_all_subset_xor_totals/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn subset_xor_sum(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 3] as &[_], 6), (&[5, 1, 6], 28), (&[3, 4, 5, 6, 7, 8], 480)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::subset_xor_sum(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1864_minimum_number_of_swaps_to_make_the_binary_string_alternating/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn min_swaps(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("111000", 1), ("010", 0), ("1110", -1), ("1", 0)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::min_swaps(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1866_number_of_ways_to_rearrange_sticks_with_k_sticks_visible/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn rearrange_sticks(n: i32, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((3, 2), 3), ((5, 5), 1)]; 13 | 14 | for ((n, k), expected) in test_cases { 15 | assert_eq!(S::rearrange_sticks(n, k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1869_longer_contiguous_segments_of_ones_than_zeros/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn check_zero_ones(s: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("1101", true), ("111000", false), ("110100010", false)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::check_zero_ones(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1876_substrings_of_size_three_with_distinct_characters/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_good_substrings(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("xyzzaz", 1), ("aababcabc", 4)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::count_good_substrings(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1877_minimize_maximum_pair_sum_in_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn min_pair_sum(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 5, 2, 3] as &[_], 7), (&[3, 5, 4, 2, 4, 6], 8)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::min_pair_sum(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1881_maximum_value_after_insertion/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn max_value(n: String, x: i32) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("99", 9), "999"), (("-13", 2), "-123")]; 13 | 14 | for ((n, x), expected) in test_cases { 15 | assert_eq!(S::max_value(n.to_string(), x), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1903_largest_odd_number_in_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn largest_odd_number(num: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("52", "5"), ("4206", ""), ("35427", "35427")]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::largest_odd_number(num.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1915_number_of_wonderful_substrings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod prefix_xor; 2 | 3 | pub trait Solution { 4 | fn wonderful_substrings(word: String) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("aba", 4), ("aabb", 9), ("he", 2)]; 13 | 14 | for (word, expected) in test_cases { 15 | assert_eq!(S::wonderful_substrings(word.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1922_count_good_numbers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn count_good_numbers(n: i64) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 5), (4, 400), (50, 564_908_303)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::count_good_numbers(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1927_sum_game/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn sum_game(num: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("5023", false), ("25??", true), ("?3295???", false)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::sum_game(num.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1930_unique_length_3_palindromic_subsequences/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_palindromic_subsequence(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("aabca", 3), ("adc", 0), ("bbcbaba", 4)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::count_palindromic_subsequence(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1941_check_if_all_characters_have_equal_number_of_occurrences/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn are_occurrences_equal(s: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abacbc", true), ("aaabb", false)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::are_occurrences_equal(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1945_sum_of_digits_of_string_after_convert/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn get_lucky(s: String, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("iiii", 1), 36), (("leetcode", 2), 6), (("zbax", 2), 8)]; 13 | 14 | for ((s, k), expected) in test_cases { 15 | assert_eq!(S::get_lucky(s.to_string(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1957_delete_characters_to_make_fancy_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn make_fancy_string(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("leeetcode", "leetcode"), ("aaabaaaa", "aabaa"), ("aab", "aab")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::make_fancy_string(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1962_remove_stones_to_minimize_the_total/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_heap; 2 | 3 | pub trait Solution { 4 | fn min_stone_sum(piles: Vec, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((&[5, 4, 9] as &[_], 2), 12), ((&[4, 3, 6, 7], 3), 12)]; 13 | 14 | for ((piles, k), expected) in test_cases { 15 | assert_eq!(S::min_stone_sum(piles.to_vec(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1963_minimum_number_of_swaps_to_make_the_string_balanced/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn min_swaps(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("][][", 1), ("]]][[[", 2), ("[]", 0)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::min_swaps(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1969_minimum_non_zero_product_of_the_array_elements/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn min_non_zero_product(p: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 1), (2, 6), (3, 1512), (33, 861_896_614)]; 13 | 14 | for (p, expected) in test_cases { 15 | assert_eq!(S::min_non_zero_product(p), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1974_minimum_time_to_type_word_using_special_typewriter/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn min_time_to_type(word: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abc", 5), ("bza", 7), ("zjpc", 34)]; 13 | 14 | for (word, expected) in test_cases { 15 | assert_eq!(S::min_time_to_type(word.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1991_find_the_middle_index_in_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn find_middle_index(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 3, -1, 8, 4] as &[_], 3), (&[1, -1, 4], 2), (&[2, 5], -1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::find_middle_index(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_1995_count_special_quadruplets/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_map; 2 | 3 | pub trait Solution { 4 | fn count_quadruplets(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2, 3, 6] as &[_], 1), (&[3, 3, 6, 4, 5], 0), (&[1, 1, 1, 3, 5], 4)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::count_quadruplets(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2002_maximum_product_of_the_length_of_two_palindromic_subsequences/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn max_product(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("leetcodecom", 9), ("bb", 1), ("accbcaxxcxx", 25)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::max_product(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2012_sum_of_beauty_in_the_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn sum_of_beauties(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 2, 3] as &[_], 2), (&[2, 4, 6, 4], 1), (&[3, 2, 1], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::sum_of_beauties(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2027_minimum_moves_to_convert_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn minimum_moves(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("XXX", 1), ("XXOX", 2), ("OOOO", 0)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::minimum_moves(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2048_next_greater_numerically_balanced_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_search; 2 | 3 | pub trait Solution { 4 | fn next_beautiful_number(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 22), (1000, 1333), (3000, 3133)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::next_beautiful_number(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2063_vowels_of_all_substrings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_vowels(word: String) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("aba", 6), ("abc", 3), ("ltcd", 0)]; 13 | 14 | for (word, expected) in test_cases { 15 | assert_eq!(S::count_vowels(word.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2078_two_furthest_houses_with_different_colors/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn max_distance(colors: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 1, 1, 6, 1, 1, 1] as &[_], 3), (&[1, 8, 3, 8, 3], 4), (&[0, 1], 1)]; 13 | 14 | for (colors, expected) in test_cases { 15 | assert_eq!(S::max_distance(colors.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2081_sum_of_k_mirror_numbers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cheating; 2 | pub mod cheating_2; 3 | 4 | pub trait Solution { 5 | fn k_mirror(k: i32, n: i32) -> i64; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [((2, 5), 25), ((3, 7), 499), ((7, 17), 20_379_000)]; 14 | 15 | for ((k, n), expected) in test_cases { 16 | assert_eq!(S::k_mirror(k, n), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_2103_rings_and_rods/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_points(rings: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("B0B6G0R6R0R6G9", 1), ("B0R0G0R9R0B0G0", 1), ("G4", 0)]; 13 | 14 | for (rings, expected) in test_cases { 15 | assert_eq!(S::count_points(rings.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2119_a_number_after_a_double_reversal/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn is_same_after_reversals(num: i32) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(526, true), (1800, false), (0, true)]; 13 | for (num, expected) in test_cases { 14 | assert_eq!(S::is_same_after_reversals(num), expected); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/problem_2139_minimum_moves_to_reach_target_score/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn min_moves(target: i32, max_doubles: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((5, 0), 4), ((19, 2), 7), ((10, 4), 4), ((1, 100), 0)]; 13 | 14 | for ((target, max_doubles), expected) in test_cases { 15 | assert_eq!(S::min_moves(target, max_doubles), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2147_number_of_ways_to_divide_a_long_corridor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn number_of_ways(corridor: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("SSPPSPS", 3), ("PPSPSP", 1), ("S", 0), ("P", 0)]; 13 | 14 | for (corridor, expected) in test_cases { 15 | assert_eq!(S::number_of_ways(corridor.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2160_minimum_sum_of_four_digit_number_after_splitting_digits/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn minimum_sum(num: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(2932, 52), (4009, 13)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::minimum_sum(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2169_count_operations_to_obtain_zero/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn count_operations(num1: i32, num2: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((2, 3), 3), ((10, 10), 1), ((79, 68), 14)]; 13 | 14 | for ((num1, num2), expected) in test_cases { 15 | assert_eq!(S::count_operations(num1, num2), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2170_minimum_operations_to_make_the_array_alternating/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_map; 2 | 3 | pub trait Solution { 4 | fn minimum_operations(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 1, 3, 2, 4, 3] as &[_], 3), (&[1, 2, 2, 2, 2], 2)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::minimum_operations(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2171_removing_minimum_number_of_magic_beans/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod sorting; 2 | 3 | pub trait Solution { 4 | fn minimum_removal(beans: Vec) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[4, 1, 6, 5] as &[_], 4), (&[2, 10, 3, 2], 7)]; 13 | 14 | for (beans, expected) in test_cases { 15 | assert_eq!(S::minimum_removal(beans.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2177_find_three_consecutive_integers_that_sum_to_a_given_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod divide_by_3; 2 | 3 | pub trait Solution { 4 | fn sum_of_three(num: i64) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(33, &[10_i64, 11, 12] as &[_]), (4, &[])]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::sum_of_three(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2180_count_integers_with_even_digit_sum/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn count_even(num: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(4, 2), (30, 14), (910, 455)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::count_even(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2206_divide_array_into_equal_pairs/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn divide_array(nums: Vec) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 2, 3, 2, 2, 2] as &[_], true), (&[1, 2, 3, 4], false)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::divide_array(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2208_minimum_operations_to_halve_array_sum/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy_binary_heap; 2 | 3 | pub trait Solution { 4 | fn halve_array(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[5, 19, 8, 1] as &[_], 3), (&[3, 8, 20], 3)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::halve_array(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2216_minimum_deletions_to_make_array_beautiful/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn min_deletion(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 1, 2, 3, 5] as &[_], 1), (&[1, 1, 2, 2, 3, 3], 2)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::min_deletion(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2220_minimum_bit_flips_to_convert_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod xor; 2 | 3 | pub trait Solution { 4 | fn min_bit_flips(start: i32, goal: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((10, 7), 3), ((3, 4), 3)]; 13 | 14 | for ((start, goal), expected) in test_cases { 15 | assert_eq!(S::min_bit_flips(start, goal), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2222_number_of_ways_to_select_buildings/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | pub mod dynamic_programming_2; 3 | 4 | pub trait Solution { 5 | fn number_of_ways(s: String) -> i64; 6 | } 7 | 8 | #[cfg(test)] 9 | mod tests { 10 | use super::Solution; 11 | 12 | pub fn run() { 13 | let test_cases = [("001101", 6), ("11100", 0)]; 14 | 15 | for (s, expected) in test_cases { 16 | assert_eq!(S::number_of_ways(s.to_string()), expected); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/problem_2231_largest_number_after_digit_swaps_by_parity/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn largest_integer(num: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1234, 3412), (65875, 87655)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::largest_integer(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2233_maximum_product_after_k_increments/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod quick_select; 2 | 3 | pub trait Solution { 4 | fn maximum_product(nums: Vec, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((&[0, 4] as &[_], 5), 20), ((&[6, 3, 3, 2], 2), 216)]; 13 | 14 | for ((nums, k), expected) in test_cases { 15 | assert_eq!(S::maximum_product(nums.to_vec(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2235_add_two_integers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod obvious; 2 | 3 | pub trait Solution { 4 | fn sum(num1: i32, num2: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((12, 5), 17), ((-10, 4), -6)]; 13 | 14 | for ((num1, num2), expected) in test_cases { 15 | assert_eq!(S::sum(num1, num2), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2239_find_closest_number_to_zero/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn find_closest_number(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[-4, -2, 1, 4, 8] as &[_], 1), (&[2, -1, 1], 1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::find_closest_number(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2243_calculate_digit_sum_of_a_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn digit_sum(s: String, k: i32) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("11111222223", 3), "135"), (("00000000", 3), "000")]; 13 | 14 | for ((s, k), expected) in test_cases { 15 | assert_eq!(S::digit_sum(s.to_string(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2244_minimum_rounds_to_complete_all_tasks/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_map; 2 | 3 | pub trait Solution { 4 | fn minimum_rounds(tasks: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 2, 3, 3, 2, 4, 4, 4, 4, 4] as &[_], 4), (&[2, 3, 3], -1)]; 13 | 14 | for (tasks, expected) in test_cases { 15 | assert_eq!(S::minimum_rounds(tasks.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2256_minimum_average_difference/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn minimum_average_difference(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 5, 3, 9, 5, 3] as &[_], 3), (&[0], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::minimum_average_difference(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2260_minimum_consecutive_cards_to_pick_up/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn minimum_card_pickup(cards: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 4, 2, 3, 4, 7] as &[_], 4), (&[1, 0, 5, 3], -1)]; 13 | 14 | for (cards, expected) in test_cases { 15 | assert_eq!(S::minimum_card_pickup(cards.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2262_total_appeal_of_a_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn appeal_sum(s: String) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abbca", 28), ("code", 20)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::appeal_sum(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2269_find_the_k_beauty_of_a_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn divisor_substrings(num: i32, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((240, 2), 2), ((430_043, 2), 2)]; 13 | 14 | for ((num, k), expected) in test_cases { 15 | assert_eq!(S::divisor_substrings(num, k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2270_number_of_ways_to_split_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn ways_to_split_array(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[10, 4, -8, 7] as &[_], 2), (&[2, 3, 1, 0], 2), (&[1, 1, 1, 2, 3], 1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::ways_to_split_array(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2278_percentage_of_letter_in_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn percentage_letter(s: String, letter: char) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("foobar", 'o'), 33), (("jjjj", 'k'), 0)]; 13 | 14 | for ((s, letter), expected) in test_cases { 15 | assert_eq!(S::percentage_letter(s.to_string(), letter), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2283_check_if_number_has_equal_digit_count_and_digit_value/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn digit_count(num: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("1210", true), ("030", false)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::digit_count(num.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2293_min_max_game/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn min_max_game(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 3, 5, 2, 4, 8, 2, 2] as &[_], 1), (&[3], 3)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::min_max_game(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2309_greatest_english_letter_in_upper_and_lower_case/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn greatest_letter(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("lEeTcOdE", "E"), ("arRAzFif", "R"), ("AbCdEfGhIjK", "")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::greatest_letter(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2310_sum_of_numbers_with_units_digit_k/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn minimum_numbers(num: i32, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((58, 9), 2), ((37, 2), -1), ((0, 7), 0), ((10, 8), -1), ((10, 5), 2)]; 13 | 14 | for ((num, k), expected) in test_cases { 15 | assert_eq!(S::minimum_numbers(num, k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2317_maximum_xor_after_operations/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn maximum_xor(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 2, 4, 6] as &[_], 7), (&[1, 2, 3, 9, 2], 11)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::maximum_xor(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2318_number_of_distinct_roll_sequences/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn distinct_sequences(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(0, 1), (1, 6), (2, 22), (3, 66), (4, 184)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::distinct_sequences(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2320_count_number_of_ways_to_place_houses/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod matrix_multiplication; 2 | 3 | pub trait Solution { 4 | fn count_house_placements(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(0, 1), (1, 4), (2, 9), (3, 25), (4, 64), (5, 169), (1000, 500_478_595)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::count_house_placements(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2338_count_the_number_of_ideal_arrays/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming_and_combinations; 2 | 3 | pub trait Solution { 4 | fn ideal_arrays(n: i32, max_value: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((2, 5), 10), ((5, 3), 11), ((5, 9), 111)]; 13 | 14 | for ((n, max_value), expected) in test_cases { 15 | assert_eq!(S::ideal_arrays(n, max_value), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2342_max_sum_of_a_pair_with_equal_sum_of_digits/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn maximum_sum(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[18, 43, 36, 13, 7] as &[_], 54), (&[10, 12, 19, 14], -1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::maximum_sum(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2351_first_letter_to_appear_twice/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn repeated_character(s: String) -> char; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abccbaacz", 'c'), ("abcdd", 'd')]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::repeated_character(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2354_number_of_excellent_pairs/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_excellent_pairs(nums: Vec, k: i32) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((&[1, 2, 3, 1] as &[_], 3), 5), ((&[5, 1, 1], 10), 0)]; 13 | 14 | for ((nums, k), expected) in test_cases { 15 | assert_eq!(S::count_excellent_pairs(nums.to_vec(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2357_make_array_zero_by_subtracting_equal_amounts/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bit_masks; 2 | 3 | pub trait Solution { 4 | fn minimum_operations(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 5, 0, 3, 5] as &[_], 3), (&[0], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::minimum_operations(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2358_maximum_number_of_groups_entering_a_competition/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod newtons_method; 2 | 3 | pub trait Solution { 4 | fn maximum_groups(grades: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[10, 6, 12, 7, 3, 5] as &[_], 3), (&[8, 8], 1)]; 13 | 14 | for (grades, expected) in test_cases { 15 | assert_eq!(S::maximum_groups(grades.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2364_count_number_of_bad_pairs/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_bad_pairs(nums: Vec) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[4, 1, 3, 3] as &[_], 5), (&[1, 2, 3, 4, 5], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::count_bad_pairs(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2370_longest_ideal_subsequence/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn longest_ideal_string(s: String, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("acfgbd", 2), 4), (("abcd", 3), 4)]; 13 | 14 | for ((s, k), expected) in test_cases { 15 | assert_eq!(S::longest_ideal_string(s.to_string(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2374_node_with_highest_edge_score/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn edge_score(edges: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 0, 0, 0, 0, 7, 7, 5] as &[_], 7), (&[2, 0, 0, 2], 0)]; 13 | 14 | for (edges, expected) in test_cases { 15 | assert_eq!(S::edge_score(edges.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2376_count_special_integers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn count_special_numbers(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (20, 19), (99, 90), (135, 110)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::count_special_numbers(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2380_time_needed_to_rearrange_a_binary_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn seconds_to_remove_occurrences(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("0110101", 4), ("11100", 0)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::seconds_to_remove_occurrences(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2384_largest_palindromic_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn largest_palindromic(num: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("444947137", "7449447"), ("00009", "9"), ("6006", "6006")]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::largest_palindromic(num.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2390_removing_stars_from_a_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn remove_stars(s: String) -> String; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("leet**cod*e", "lecoe"), ("erase*****", ""), ("abcd", "abcd")]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::remove_stars(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2396_strictly_palindromic_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn is_strictly_palindromic(n: i32) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | for n in 4..100_000 { 13 | assert!(!S::is_strictly_palindromic(n)); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/problem_2401_longest_nice_subarray/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod sliding_window; 2 | 3 | pub trait Solution { 4 | fn longest_nice_subarray(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 3, 8, 48, 10] as &[_], 3), (&[3, 1, 5, 11, 13], 1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::longest_nice_subarray(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2405_optimal_partition_of_string/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bit_manipulation; 2 | 3 | pub trait Solution { 4 | fn partition_string(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abacaba", 4), ("ssssss", 6)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::partition_string(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2413_smallest_even_multiple/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bit_manipulation; 2 | 3 | pub trait Solution { 4 | fn smallest_even_multiple(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(5, 10), (6, 6)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::smallest_even_multiple(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2414_length_of_the_longest_alphabetical_continuous_substring/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn longest_continuous_substring(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abacaba", 2), ("abcde", 5)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::longest_continuous_substring(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2423_remove_letter_to_equalize_frequency/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn equal_frequency(word: String) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("abcc", true), ("aazz", false), ("bac", true)]; 13 | 14 | for (word, expected) in test_cases { 15 | assert_eq!(S::equal_frequency(word.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2427_number_of_common_factors/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod gcd; 2 | 3 | pub trait Solution { 4 | fn common_factors(a: i32, b: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((12, 6), 4), ((25, 30), 2), ((43, 945), 1)]; 13 | 14 | for ((a, b), expected) in test_cases { 15 | assert_eq!(S::common_factors(a, b), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2429_minimize_xor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn minimize_xor(num1: i32, num2: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((3, 5), 3), ((1, 12), 3), ((25, 72), 24), ((8, 75), 15), ((91, 18), 80)]; 13 | 14 | for ((num1, num2), expected) in test_cases { 15 | assert_eq!(S::minimize_xor(num1, num2), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2433_find_the_original_array_of_prefix_xor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn find_array(pref: Vec) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[5, 2, 0, 3, 1] as &[_], &[5, 7, 2, 3, 2] as &[_]), (&[13], &[13])]; 13 | 14 | for (pref, expected) in test_cases { 15 | assert_eq!(S::find_array(pref.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2439_minimize_maximum_of_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn minimize_array_value(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[3, 7, 1, 6] as &[_], 5), (&[10, 1], 10)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::minimize_array_value(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2443_sum_of_number_and_its_reverse/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | 3 | pub trait Solution { 4 | fn sum_of_number_and_reverse(num: i32) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(443, true), (63, false), (181, true)]; 13 | for (num, expected) in test_cases { 14 | assert_eq!(S::sum_of_number_and_reverse(num), expected); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/problem_2455_average_value_of_even_numbers_that_are_divisible_by_three/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn average_value(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 3, 6, 10, 12, 15] as &[_], 9), (&[1, 2, 4, 7, 10], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::average_value(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2465_number_of_distinct_averages/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_set; 2 | 3 | pub trait Solution { 4 | fn distinct_averages(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[4, 1, 4, 0, 3, 5] as &[_], 2), (&[1, 100], 1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::distinct_averages(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2469_convert_the_temperature/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn convert_temperature(celsius: f64) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(36.5, [309.65, 97.7]), (122.11, [395.26, 251.798])]; 13 | 14 | for (celsius, expected) in test_cases { 15 | assert_eq!(S::convert_temperature(celsius), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2475_number_of_unequal_triplets_in_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_map; 2 | 3 | pub trait Solution { 4 | fn unequal_triplets(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[4, 4, 2, 4, 3] as &[_], 3), (&[1, 1, 1, 1, 1], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::unequal_triplets(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2483_minimum_penalty_for_a_shop/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn best_closing_time(customers: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("YYNY", 2), ("NNNNN", 0), ("YYYY", 4)]; 13 | 14 | for (customers, expected) in test_cases { 15 | assert_eq!(S::best_closing_time(customers.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2484_count_palindromic_subsequences/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn count_palindromes(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("103301", 2), ("0000000", 21), ("9999900000", 2)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::count_palindromes(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2485_find_the_pivot_integer/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn piovt_integer(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 1), (4, -1), (8, 6)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::piovt_integer(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2498_frog_jump_ii/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn max_jump(stones: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[0, 2, 5, 6, 7] as &[_], 5), (&[0, 3, 9], 9), (&[0, 3], 3)]; 13 | 14 | for (stones, expected) in test_cases { 15 | assert_eq!(S::max_jump(stones.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2501_longest_square_streak_in_an_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod dynamic_programming; 2 | 3 | pub trait Solution { 4 | fn longest_square_streak(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[4, 3, 6, 16, 8, 2] as &[_], 3), (&[2, 3, 5, 6, 7], -1)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::longest_square_streak(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2514_count_anagrams/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn count_anagrams(s: String) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [("too hot", 18), ("aa", 1)]; 13 | 14 | for (s, expected) in test_cases { 15 | assert_eq!(S::count_anagrams(s.to_string()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2516_take_k_of_each_character_from_left_and_right/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod sliding_window; 2 | 3 | pub trait Solution { 4 | fn take_characters(s: String, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(("aabaaaacaabc", 2), 8), (("a", 1), -1)]; 13 | 14 | for ((s, k), expected) in test_cases { 15 | assert_eq!(S::take_characters(s.to_string(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2520_count_the_digits_that_divide_a_number/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn count_digits(num: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(7, 1), (121, 2), (1248, 4)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::count_digits(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2527_find_xor_beauty_of_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn xor_beauty(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 4] as &[_], 5), (&[15, 45, 20, 2, 34, 35, 5, 44, 32, 30], 34)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::xor_beauty(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2535_difference_between_element_sum_and_digit_sum_of_an_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn difference_of_sum(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 15, 6, 3] as &[_], 9), (&[1, 2, 3, 4], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::difference_of_sum(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2544_alternating_digit_sum/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn alternate_digit_sum(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(521, 4), (111, 1), (886_996, 0)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::alternate_digit_sum(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2549_count_distinct_numbers_on_board/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn distinct_integers(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 1), (2, 1), (3, 2), (4, 3), (5, 4)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::distinct_integers(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2550_count_collisions_of_monkeys_on_a_polygon/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn monkey_move(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(3, 6), (4, 14), (5, 30)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::monkey_move(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2558_take_gifts_from_the_richest_pile/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_heap; 2 | 3 | pub trait Solution { 4 | fn pick_gifts(gifts: Vec, k: i32) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((&[25, 64, 9, 4, 100] as &[_], 4), 29), ((&[1, 1, 1, 1], 4), 4)]; 13 | 14 | for ((gifts, k), expected) in test_cases { 15 | assert_eq!(S::pick_gifts(gifts.to_vec(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2560_house_robber_iv/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod binary_search; 2 | 3 | pub trait Solution { 4 | fn min_capability(nums: Vec, k: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((&[2, 3, 5, 9] as &[_], 2), 5), ((&[2, 7, 9, 3, 1], 2), 2)]; 13 | 14 | for ((nums, k), expected) in test_cases { 15 | assert_eq!(S::min_capability(nums.to_vec(), k), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2562_find_the_array_concatenation_value/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn find_the_array_conc_val(nums: Vec) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[7, 52, 2, 4] as &[_], 596), (&[5, 14, 13, 8, 12], 673)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::find_the_array_conc_val(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2566_maximum_difference_by_remapping_a_digit/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn min_max_difference(num: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(11891, 99009), (90, 99), (99999, 99999)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::min_max_difference(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2571_minimum_operations_to_reduce_an_integer_to_0/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn min_operations(n: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(39, 3), (54, 3)]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::min_operations(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2574_left_and_right_sum_differences/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn left_right_difference(nums: Vec) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[10, 4, 8, 3] as &[_], &[15, 1, 11, 22] as &[_]), (&[1], &[0])]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::left_right_difference(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2578_split_with_minimum_sum/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn split_num(num: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(4325, 59), (687, 75)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::split_num(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2579_count_total_number_of_colored_cells/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn colored_cells(num: i32) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(1, 1), (2, 5), (3, 13), (4, 25)]; 13 | 14 | for (num, expected) in test_cases { 15 | assert_eq!(S::colored_cells(num), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2582_pass_the_pillow/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn pass_the_pillow(n: i32, time: i32) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | pub fn run() { 11 | let test_cases = [((4, 5), 2), ((3, 2), 3)]; 12 | 13 | for ((n, time), expected) in test_cases { 14 | assert_eq!(S::pass_the_pillow(n, time), expected); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/problem_2588_count_the_number_of_beautiful_subarrays/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod hash_map; 2 | 3 | pub trait Solution { 4 | fn beautiful_subarrays(nums: Vec) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[4, 3, 1, 2, 4] as &[_], 2), (&[1, 10, 4], 0)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::beautiful_subarrays(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2592_maximize_greatness_of_an_array/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod greedy; 2 | 3 | pub trait Solution { 4 | fn maximize_greatness(nums: Vec) -> i32; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 3, 5, 2, 1, 3, 1] as &[_], 4), (&[1, 2, 3, 4], 3)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::maximize_greatness(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2593_find_score_of_an_array_after_marking_all_elements/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod iterative; 2 | 3 | pub trait Solution { 4 | fn find_score(nums: Vec) -> i64; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[2, 1, 3, 4, 5, 2] as &[_], 7), (&[2, 3, 5, 1, 3, 2], 5)]; 13 | 14 | for (nums, expected) in test_cases { 15 | assert_eq!(S::find_score(nums.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2595_number_of_even_and_odd_bits/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod bit_manipulation; 2 | 3 | pub trait Solution { 4 | fn even_odd_bit(n: i32) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(50, [1, 2]), (2, [0, 1])]; 13 | 14 | for (n, expected) in test_cases { 15 | assert_eq!(S::even_odd_bit(n), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2682_find_the_losers_of_the_circular_game/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod brute_force; 2 | 3 | pub trait Solution { 4 | fn circular_game_losers(n: i32, k: i32) -> Vec; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [((5, 2), &[4, 5] as &[_]), ((4, 4), &[2, 3, 4])]; 13 | 14 | for ((n, k), expected) in test_cases { 15 | assert_eq!(S::circular_game_losers(n, k), expected,); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/problem_2683_neighboring_bitwise_xor/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod mathematical; 2 | 3 | pub trait Solution { 4 | fn does_valid_array_exist(derived: Vec) -> bool; 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::Solution; 10 | 11 | pub fn run() { 12 | let test_cases = [(&[1, 1, 0] as &[_], true), (&[1, 1], true), (&[1, 0], false)]; 13 | 14 | for (derived, expected) in test_cases { 15 | assert_eq!(S::does_valid_array_exist(derived.to_vec()), expected); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tools/check-cpp-code-format/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["EFanZh "] 3 | edition = "2024" 4 | name = "check-cpp-code-format" 5 | publish = false 6 | version = "0.1.0" 7 | 8 | [lints] 9 | workspace = true 10 | 11 | [dependencies] 12 | regex = "*" 13 | -------------------------------------------------------------------------------- /tools/progress-tracker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["EFanZh "] 3 | edition = "2024" 4 | name = "progress-tracker" 5 | publish = false 6 | version = "0.1.0" 7 | 8 | [lints] 9 | workspace = true 10 | 11 | [dependencies] 12 | chrono = "*" 13 | git2 = "*" 14 | http = "*" 15 | num = "*" 16 | plotters = "*" 17 | reqwest = { version = "*", features = ["blocking", "json"] } 18 | serde = { version = "*", features = ["derive"] } 19 | 20 | [dev-dependencies] 21 | serde_json = "*" 22 | -------------------------------------------------------------------------------- /xtask/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["EFanZh "] 3 | edition = "2024" 4 | name = "xtask" 5 | publish = false 6 | version = "0.1.0" 7 | 8 | [lints] 9 | workspace = true 10 | 11 | [dependencies] 12 | cfg-if = "*" 13 | clap = { version = "*", features = ["derive"] } 14 | regex-syntax = "*" 15 | serde_json = "*" 16 | shell-escape = "*" 17 | tempfile = "*" 18 | which = "*" 19 | 20 | [target.'cfg(target_os="windows")'.dependencies] 21 | cc = "*" 22 | -------------------------------------------------------------------------------- /xtask/src/main.rs: -------------------------------------------------------------------------------- 1 | #![expect(missing_docs, reason = "unnecessary")] 2 | 3 | use crate::coverage::Subcommand; 4 | use clap::Parser; 5 | use std::env; 6 | 7 | mod coverage; 8 | mod tools; 9 | mod utilities; 10 | 11 | #[derive(Parser)] 12 | enum Config { 13 | Coverage(Subcommand), 14 | } 15 | 16 | fn main() { 17 | assert_eq!(env::current_dir().unwrap(), utilities::get_project_dir()); 18 | 19 | match Config::parse() { 20 | Config::Coverage(command) => command.run(), 21 | } 22 | } 23 | --------------------------------------------------------------------------------