pydsa-engine 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pydsa/__init__.py +182 -0
- pydsa/__main__.py +218 -0
- pydsa/algorithms/arrays/1_bit_and_2_bit_characters.py +42 -0
- pydsa/algorithms/arrays/4sum_ii.py +55 -0
- pydsa/algorithms/arrays/__init__.py +0 -0
- pydsa/algorithms/arrays/absolute_difference_between_maximum_and_minimum_k_elements.py +56 -0
- pydsa/algorithms/arrays/accepted_candidates_from_the_interviews.py +52 -0
- pydsa/algorithms/arrays/account_balance.py +39 -0
- pydsa/algorithms/arrays/actors_and_directors_cooperated_three_times.py +49 -0
- pydsa/algorithms/arrays/ad_free_sessions.py +61 -0
- pydsa/algorithms/arrays/add_minimum_number_of_rungs.py +59 -0
- pydsa/algorithms/arrays/adjacent_increasing_subarrays_detection_i.py +150 -0
- pydsa/algorithms/arrays/adjacent_increasing_subarrays_detection_ii.py +83 -0
- pydsa/algorithms/arrays/alert_using_same_key_card_three_or_more_times_in_a_one_hour_period.py +55 -0
- pydsa/algorithms/arrays/all_divisions_with_the_highest_score_of_a_binary_array.py +134 -0
- pydsa/algorithms/arrays/alternating_groups_i.py +123 -0
- pydsa/algorithms/arrays/alternating_groups_ii.py +72 -0
- pydsa/algorithms/arrays/amount_of_new_area_painted_each_day.py +88 -0
- pydsa/algorithms/arrays/analyze_subscription_conversion.py +56 -0
- pydsa/algorithms/arrays/analyze_user_website_visit_pattern.py +85 -0
- pydsa/algorithms/arrays/apple_redistribution_into_boxes.py +53 -0
- pydsa/algorithms/arrays/apply_discount_every_n_orders.py +93 -0
- pydsa/algorithms/arrays/apply_discount_to_prices.py +122 -0
- pydsa/algorithms/arrays/apply_operations_to_an_array.py +53 -0
- pydsa/algorithms/arrays/apply_operations_to_make_all_array_elements_equal_to_zero.py +33 -0
- pydsa/algorithms/arrays/apply_operations_to_make_sum_of_array_greater_than_or_equal_to_k.py +156 -0
- pydsa/algorithms/arrays/apply_operations_to_maximize_frequency_score.py +95 -0
- pydsa/algorithms/arrays/apply_operations_to_maximize_score.py +255 -0
- pydsa/algorithms/arrays/apply_transform_over_each_element_in_array.py +41 -0
- pydsa/algorithms/arrays/arithmetic_subarrays.py +61 -0
- pydsa/algorithms/arrays/arrange_table_by_gender.py +39 -0
- pydsa/algorithms/arrays/array_nesting.py +69 -0
- pydsa/algorithms/arrays/array_of_objects_to_matrix.py +50 -0
- pydsa/algorithms/arrays/array_prototype_foreach.py +76 -0
- pydsa/algorithms/arrays/array_prototype_last.py +36 -0
- pydsa/algorithms/arrays/array_reduce_transformation.py +52 -0
- pydsa/algorithms/arrays/array_transformation.py +61 -0
- pydsa/algorithms/arrays/array_with_elements_not_equal_to_average_of_neighbors.py +68 -0
- pydsa/algorithms/arrays/array_wrapper.py +80 -0
- pydsa/algorithms/arrays/available_captures_for_rook.py +73 -0
- pydsa/algorithms/arrays/average_height_of_buildings_in_each_segment.py +73 -0
- pydsa/algorithms/arrays/average_salary_excluding_the_minimum_and_maximum_salary.py +51 -0
- pydsa/algorithms/arrays/average_time_of_process_per_machine.py +54 -0
- pydsa/algorithms/arrays/average_value_of_even_numbers_that_are_divisible_by_three.py +54 -0
- pydsa/algorithms/arrays/average_waiting_time.py +51 -0
- pydsa/algorithms/arrays/bank-account-summary-ii.py +39 -0
- pydsa/algorithms/arrays/bank_account_summary.py +24 -0
- pydsa/algorithms/arrays/battleships_in_a_board.py +55 -0
- pydsa/algorithms/arrays/beautiful_arrangement_ii.py +69 -0
- pydsa/algorithms/arrays/beautiful_pairs.py +56 -0
- pydsa/algorithms/arrays/beautiful_towers_i.py +36 -0
- pydsa/algorithms/arrays/beautiful_towers_ii.py +101 -0
- pydsa/algorithms/arrays/best_time_to_buy_and_sell_stock.py +48 -0
- pydsa/algorithms/arrays/biggest_window_between_visits.py +61 -0
- pydsa/algorithms/arrays/bikes_last_time_used.py +47 -0
- pydsa/algorithms/arrays/bitwise_or_of_adjacent_elements.py +45 -0
- pydsa/algorithms/arrays/block_placement_queries.py +234 -0
- pydsa/algorithms/arrays/booking_concert_tickets_in_groups.py +82 -0
- pydsa/algorithms/arrays/books_with_null_ratings.py +43 -0
- pydsa/algorithms/arrays/brick_wall.py +55 -0
- pydsa/algorithms/arrays/brightest_position_on_street.py +65 -0
- pydsa/algorithms/arrays/build_a_matrix_with_conditions.py +76 -0
- pydsa/algorithms/arrays/build_array_from_permutation.py +50 -0
- pydsa/algorithms/arrays/buildings_with_an_ocean_view.py +50 -0
- pydsa/algorithms/arrays/button_with_longest_push_time.py +71 -0
- pydsa/algorithms/arrays/buy_two_chocolates.py +52 -0
- pydsa/algorithms/arrays/cache_with_time_limit.py +153 -0
- pydsa/algorithms/arrays/calculate_orders_within_each_interval.py +55 -0
- pydsa/algorithms/arrays/calculate_parking_fees_and_duration.py +64 -0
- pydsa/algorithms/arrays/calculate_product_final_price.py +51 -0
- pydsa/algorithms/arrays/calculate_salaries.py +61 -0
- pydsa/algorithms/arrays/calculate_score_after_performing_instructions.py +44 -0
- pydsa/algorithms/arrays/calculate_special_bonus.py +67 -0
- pydsa/algorithms/arrays/calculate_trapping_rain_water.py +64 -0
- pydsa/algorithms/arrays/can_make_arithmetic_progression_from_sequence.py +46 -0
- pydsa/algorithms/arrays/candy_crush.py +77 -0
- pydsa/algorithms/arrays/car_fleet_ii.py +72 -0
- pydsa/algorithms/arrays/car_pooling.py +57 -0
- pydsa/algorithms/arrays/card_flipping_game.py +59 -0
- pydsa/algorithms/arrays/categorize_box_according_to_criteria.py +65 -0
- pydsa/algorithms/arrays/cells_with_odd_values_in_a_matrix.py +58 -0
- pydsa/algorithms/arrays/change_data_type.py +51 -0
- pydsa/algorithms/arrays/change_null_values_in_a_table_to_the_previous_value.py +71 -0
- pydsa/algorithms/arrays/check_array_formation_through_concatenation.py +52 -0
- pydsa/algorithms/arrays/check_if_all_1s_are_at_least_length_k_places_away.py +48 -0
- pydsa/algorithms/arrays/check_if_all_the_integers_in_a_range_are_covered.py +60 -0
- pydsa/algorithms/arrays/check_if_an_array_is_consecutive.py +52 -0
- pydsa/algorithms/arrays/check_if_any_element_has_prime_frequency.py +71 -0
- pydsa/algorithms/arrays/check_if_array_is_good.py +42 -0
- pydsa/algorithms/arrays/check_if_array_is_sorted_and_rotated.py +51 -0
- pydsa/algorithms/arrays/check_if_array_pairs_are_divisible_by_k.py +59 -0
- pydsa/algorithms/arrays/check_if_every_row_and_column_contains_all_numbers.py +65 -0
- pydsa/algorithms/arrays/check_if_grid_satisfies_conditions.py +49 -0
- pydsa/algorithms/arrays/check_if_it_is_possible_to_split_array.py +65 -0
- pydsa/algorithms/arrays/check_if_matrix_is_x_matrix.py +54 -0
- pydsa/algorithms/arrays/check_if_n_and_its_double_exist.py +43 -0
- pydsa/algorithms/arrays/choose_numbers_from_two_arrays_in_range.py +102 -0
- pydsa/algorithms/arrays/chunk_array.py +36 -0
- pydsa/algorithms/arrays/class_performance.py +55 -0
- pydsa/algorithms/arrays/closest_equal_element_queries.py +104 -0
- pydsa/algorithms/arrays/color_the_triangle_red.py +60 -0
- pydsa/algorithms/arrays/combine_two_tables.py +58 -0
- pydsa/algorithms/arrays/compare_sums_of_bitonic_parts.py +58 -0
- pydsa/algorithms/arrays/compute_alternating_sum.py +42 -0
- pydsa/algorithms/arrays/concatenate_array_with_reverse.py +35 -0
- pydsa/algorithms/arrays/concatenation_of_array.py +41 -0
- pydsa/algorithms/arrays/consecutive_available_seats_ii.py +55 -0
- pydsa/algorithms/arrays/consecutive_numbers.py +41 -0
- pydsa/algorithms/arrays/consecutive_transactions_with_increasing_amounts.py +52 -0
- pydsa/algorithms/arrays/construct_uniform_parity_array_i.py +49 -0
- pydsa/algorithms/arrays/construct_uniform_parity_array_ii.py +53 -0
- pydsa/algorithms/arrays/contains_duplicate.py +38 -0
- pydsa/algorithms/arrays/contiguous_array.py +57 -0
- pydsa/algorithms/arrays/convert_1d_array_into_2d_array.py +51 -0
- pydsa/algorithms/arrays/convert_an_array_into_a_2d_array_with_conditions.py +58 -0
- pydsa/algorithms/arrays/corporate_flight_bookings.py +53 -0
- pydsa/algorithms/arrays/count-unhappy-friends.py +65 -0
- pydsa/algorithms/arrays/count_almost_equal_pairs_i.py +150 -0
- pydsa/algorithms/arrays/count_almost_equal_pairs_ii.py +86 -0
- pydsa/algorithms/arrays/count_alternating_subarrays.py +52 -0
- pydsa/algorithms/arrays/count_array_pairs_divisible_by_k.py +76 -0
- pydsa/algorithms/arrays/count_artist_occurrences_on_spotify_ranking_list.py +42 -0
- pydsa/algorithms/arrays/count_beautiful_splits_in_an_array.py +66 -0
- pydsa/algorithms/arrays/count_bowl_subarrays.py +195 -0
- pydsa/algorithms/arrays/count_cells_in_overlapping_horizontal_and_vertical_substrings.py +82 -0
- pydsa/algorithms/arrays/count_collisions_on_a_road.py +61 -0
- pydsa/algorithms/arrays/count_distinct_subarrays_divisible_by_k_in_sorted_array.py +53 -0
- pydsa/algorithms/arrays/count_dominant_indices.py +55 -0
- pydsa/algorithms/arrays/count_elements_with_at_least_k_greater_values.py +60 -0
- pydsa/algorithms/arrays/count_elements_with_maximum_frequency.py +52 -0
- pydsa/algorithms/arrays/count_elements_with_strictly_smaller_and_greater_elements.py +69 -0
- pydsa/algorithms/arrays/count_equal_and_divisible_pairs_in_an_array.py +42 -0
- pydsa/algorithms/arrays/count_fertile_pyramids_in_a_land.py +66 -0
- pydsa/algorithms/arrays/count_good_meals.py +77 -0
- pydsa/algorithms/arrays/count_good_triplets.py +55 -0
- pydsa/algorithms/arrays/count_good_triplets_in_an_array.py +47 -0
- pydsa/algorithms/arrays/count_hills_and_valleys_in_an_array.py +54 -0
- pydsa/algorithms/arrays/count_houses_in_a_circular_street.py +213 -0
- pydsa/algorithms/arrays/count_houses_in_a_circular_street_ii.py +62 -0
- pydsa/algorithms/arrays/count_increasing_quadruplets.py +171 -0
- pydsa/algorithms/arrays/count_indices_with_opposite_parity.py +42 -0
- pydsa/algorithms/arrays/count_items_matching_a_rule.py +68 -0
- pydsa/algorithms/arrays/count_number_of_bad_pairs.py +59 -0
- pydsa/algorithms/arrays/count_number_of_distinct_integers_after_reverse_operations.py +44 -0
- pydsa/algorithms/arrays/count_number_of_maximum_bitwise_or_subsets.py +55 -0
- pydsa/algorithms/arrays/count_number_of_pairs_with_absolute_difference_k.py +53 -0
- pydsa/algorithms/arrays/count_number_of_rectangles_containing_each_point.py +115 -0
- pydsa/algorithms/arrays/count_of_interesting_subarrays.py +60 -0
- pydsa/algorithms/arrays/count_of_matches_in_tournament.py +35 -0
- pydsa/algorithms/arrays/count_of_smaller_numbers_after_self.py +83 -0
- pydsa/algorithms/arrays/count_pairs_in_two_arrays.py +53 -0
- pydsa/algorithms/arrays/count_pairs_that_form_a_complete_day_i.py +48 -0
- pydsa/algorithms/arrays/count_pairs_that_form_a_complete_day_ii.py +66 -0
- pydsa/algorithms/arrays/count_positions_on_street_with_required_brightness.py +75 -0
- pydsa/algorithms/arrays/count_prime_gap_balanced_subarrays.py +99 -0
- pydsa/algorithms/arrays/count_salary_categories.py +61 -0
- pydsa/algorithms/arrays/count_servers_that_communicate.py +62 -0
- pydsa/algorithms/arrays/count_smaller_elements_with_opposite_parity.py +84 -0
- pydsa/algorithms/arrays/count_special_quadruplets.py +195 -0
- pydsa/algorithms/arrays/count_special_triplets.py +71 -0
- pydsa/algorithms/arrays/count_stable_subarrays.py +79 -0
- pydsa/algorithms/arrays/count_strictly_increasing_subarrays.py +79 -0
- pydsa/algorithms/arrays/count_subarrays_of_length_three_with_a_condition.py +50 -0
- pydsa/algorithms/arrays/count_subarrays_with_majority_element_i.py +90 -0
- pydsa/algorithms/arrays/count_subarrays_with_majority_element_ii.py +96 -0
- pydsa/algorithms/arrays/count_subarrays_with_median_k.py +159 -0
- pydsa/algorithms/arrays/count_subarrays_with_more_ones_than_zeros.py +92 -0
- pydsa/algorithms/arrays/count_submatrices_with_all_ones.py +79 -0
- pydsa/algorithms/arrays/count_submatrices_with_equal_frequency_of_x_and_y.py +74 -0
- pydsa/algorithms/arrays/count_submatrices_with_top_left_element_and_sum_less_than_k.py +114 -0
- pydsa/algorithms/arrays/count_tested_devices_after_test_operations.py +56 -0
- pydsa/algorithms/arrays/count_the_number_of_beautiful_subarrays.py +55 -0
- pydsa/algorithms/arrays/count_the_number_of_fair_pairs.py +58 -0
- pydsa/algorithms/arrays/count_the_number_of_good_partitions.py +76 -0
- pydsa/algorithms/arrays/count_the_number_of_k_big_indices.py +35 -0
- pydsa/algorithms/arrays/count_the_number_of_special_characters_ii.py +64 -0
- pydsa/algorithms/arrays/count_total_number_of_colored_cells.py +75 -0
- pydsa/algorithms/arrays/count_zero_request_servers.py +63 -0
- pydsa/algorithms/arrays/counting_elements.py +51 -0
- pydsa/algorithms/arrays/create_a_dataframe_from_list.py +37 -0
- pydsa/algorithms/arrays/create_a_new_column.py +42 -0
- pydsa/algorithms/arrays/create_a_session_bar_chart.py +45 -0
- pydsa/algorithms/arrays/create_object_from_two_arrays.py +43 -0
- pydsa/algorithms/arrays/create_sorted_array_through_instructions.py +80 -0
- pydsa/algorithms/arrays/create_target_array_in_the_given_order.py +36 -0
- pydsa/algorithms/arrays/customer-who-visited-but-did-not-make-any-transactions.py +47 -0
- pydsa/algorithms/arrays/customer_order_frequency.py +38 -0
- pydsa/algorithms/arrays/customer_purchasing_behavior_analysis.py +49 -0
- pydsa/algorithms/arrays/customers_who_bought_all_products.py +70 -0
- pydsa/algorithms/arrays/customers_with_maximum_number_of_transactions_on_consecutive_days.py +84 -0
- pydsa/algorithms/arrays/customers_with_strictly_increasing_purchases.py +61 -0
- pydsa/algorithms/arrays/cyclically_rotating_a_grid.py +88 -0
- pydsa/algorithms/arrays/decode_xored_array.py +69 -0
- pydsa/algorithms/arrays/decompress_run_length_encoded_list.py +44 -0
- pydsa/algorithms/arrays/deep_merge_of_two_objects.py +46 -0
- pydsa/algorithms/arrays/deep_object_filter.py +59 -0
- pydsa/algorithms/arrays/defuse_the_bomb.py +76 -0
- pydsa/algorithms/arrays/degree_of_an_array.py +57 -0
- pydsa/algorithms/arrays/delayed_count_of_equal_elements.py +206 -0
- pydsa/algorithms/arrays/delete_greatest_value_in_each_row.py +350 -0
- pydsa/algorithms/arrays/describe_the_painting.py +229 -0
- pydsa/algorithms/arrays/design_a_3d_binary_matrix_with_efficient_layer_tracking.py +110 -0
- pydsa/algorithms/arrays/design_a_file_sharing_system.py +144 -0
- pydsa/algorithms/arrays/design_a_number_container_system.py +96 -0
- pydsa/algorithms/arrays/design_a_todo_list.py +106 -0
- pydsa/algorithms/arrays/design_an_array_statistics_tracker.py +109 -0
- pydsa/algorithms/arrays/design_an_atm_machine.py +95 -0
- pydsa/algorithms/arrays/design_an_ordered_stream.py +232 -0
- pydsa/algorithms/arrays/design_auction_system.py +159 -0
- pydsa/algorithms/arrays/design_authentication_manager.py +109 -0
- pydsa/algorithms/arrays/design_circular_queue.py +138 -0
- pydsa/algorithms/arrays/design_front_middle_back_queue.py +110 -0
- pydsa/algorithms/arrays/design_hashmap.py +86 -0
- pydsa/algorithms/arrays/design_hashset.py +61 -0
- pydsa/algorithms/arrays/design_memory_allocator.py +103 -0
- pydsa/algorithms/arrays/design_neighbor_sum_service.py +88 -0
- pydsa/algorithms/arrays/design_parking_system.py +80 -0
- pydsa/algorithms/arrays/design_snake_game.py +123 -0
- pydsa/algorithms/arrays/design_spreadsheet.py +129 -0
- pydsa/algorithms/arrays/design_tic_tac_toe.py +102 -0
- pydsa/algorithms/arrays/design_underground_system.py +88 -0
- pydsa/algorithms/arrays/design_video_sharing_platform.py +100 -0
- pydsa/algorithms/arrays/destroy_sequential_targets.py +56 -0
- pydsa/algorithms/arrays/destroying_asteroids.py +71 -0
- pydsa/algorithms/arrays/determine_if_two_events_have_conflict.py +39 -0
- pydsa/algorithms/arrays/determine_whether_matrix_can_be_obtained_by_rotation.py +49 -0
- pydsa/algorithms/arrays/diagonal_traverse.py +64 -0
- pydsa/algorithms/arrays/diagonal_traverse_ii.py +147 -0
- pydsa/algorithms/arrays/difference_between_ones_and_zeros_in_row_and_column.py +56 -0
- pydsa/algorithms/arrays/difference_of_number_of_distinct_values_on_diagonals.py +66 -0
- pydsa/algorithms/arrays/display_the_first_three_rows.py +38 -0
- pydsa/algorithms/arrays/distance_between_bus_stops.py +48 -0
- pydsa/algorithms/arrays/distribute_elements_into_two_arrays_i.py +44 -0
- pydsa/algorithms/arrays/distribute_elements_into_two_arrays_ii.py +88 -0
- pydsa/algorithms/arrays/distribute_repeating_integers.py +55 -0
- pydsa/algorithms/arrays/divide_array_into_equal_pairs.py +47 -0
- pydsa/algorithms/arrays/divide_array_into_increasing_sequences.py +56 -0
- pydsa/algorithms/arrays/divide_players_into_teams_of_equal_skill.py +53 -0
- pydsa/algorithms/arrays/dot_product_of_two_sparse_vectors.py +87 -0
- pydsa/algorithms/arrays/drop_duplicate_rows.py +43 -0
- pydsa/algorithms/arrays/drop_missing_data.py +46 -0
- pydsa/algorithms/arrays/drop_type_1_orders_for_customers_with_type_0_orders.py +45 -0
- pydsa/algorithms/arrays/duplicate_zeros.py +46 -0
- pydsa/algorithms/arrays/dynamic_pivoting_of_a_table.py +136 -0
- pydsa/algorithms/arrays/dynamic_unpivoting_of_a_table.py +69 -0
- pydsa/algorithms/arrays/earliest_second_to_mark_indices_i.py +80 -0
- pydsa/algorithms/arrays/earliest_second_to_mark_indices_ii.py +92 -0
- pydsa/algorithms/arrays/election_results.py +51 -0
- pydsa/algorithms/arrays/element_more_than_25_percent.py +87 -0
- pydsa/algorithms/arrays/elements_in_array_after_removing_and_replacing_elements.py +142 -0
- pydsa/algorithms/arrays/employee_task_duration_and_concurrent_tasks.py +138 -0
- pydsa/algorithms/arrays/employees_whose_manager_left_the_company.py +47 -0
- pydsa/algorithms/arrays/employees_with_deductions.py +41 -0
- pydsa/algorithms/arrays/employees_with_missing_information.py +57 -0
- pydsa/algorithms/arrays/equal_row_and_column_pairs.py +49 -0
- pydsa/algorithms/arrays/equal_sum_arrays_with_minimum_number_of_operations.py +277 -0
- pydsa/algorithms/arrays/equal_sum_grid_partition_i.py +88 -0
- pydsa/algorithms/arrays/equal_sum_grid_partition_ii.py +79 -0
- pydsa/algorithms/arrays/even_number_digits.py +39 -0
- pydsa/algorithms/arrays/fair_candy_swap.py +34 -0
- pydsa/algorithms/arrays/faulty_sensor.py +73 -0
- pydsa/algorithms/arrays/favorite_companies_subset.py +57 -0
- pydsa/algorithms/arrays/fill_missing_data.py +35 -0
- pydsa/algorithms/arrays/filter_elements_from_array.py +36 -0
- pydsa/algorithms/arrays/filter_restaurants_by_vegan_friendly_price_and_distance.py +101 -0
- pydsa/algorithms/arrays/final_array_state_after_k_multiplication_operations_i.py +55 -0
- pydsa/algorithms/arrays/final_array_state_after_k_multiplication_operations_ii.py +300 -0
- pydsa/algorithms/arrays/final_element_after_subarray_deletions.py +106 -0
- pydsa/algorithms/arrays/final_prices_with_a_special_discount_in_a_shop.py +52 -0
- pydsa/algorithms/arrays/find_a_good_subset_of_the_matrix.py +78 -0
- pydsa/algorithms/arrays/find_a_value_of_a_mysterious_function_closest_to_target.py +43 -0
- pydsa/algorithms/arrays/find_all_duplicates_in_an_array.py +47 -0
- pydsa/algorithms/arrays/find_all_good_indices.py +193 -0
- pydsa/algorithms/arrays/find_all_lonely_numbers_in_the_array.py +50 -0
- pydsa/algorithms/arrays/find_all_numbers_disappeared_in_an_array.py +46 -0
- pydsa/algorithms/arrays/find_anagram_mappings.py +46 -0
- pydsa/algorithms/arrays/find_beautiful_indices_in_the_given_array_i.py +78 -0
- pydsa/algorithms/arrays/find_beautiful_indices_in_the_given_array_ii.py +139 -0
- pydsa/algorithms/arrays/find_books_with_no_available_copies.py +48 -0
- pydsa/algorithms/arrays/find_books_with_polarized_opinions.py +49 -0
- pydsa/algorithms/arrays/find_bursty_behavior.py +67 -0
- pydsa/algorithms/arrays/find_candidates_for_data_scientist_position.py +44 -0
- pydsa/algorithms/arrays/find_candidates_for_data_scientist_position_ii.py +163 -0
- pydsa/algorithms/arrays/find_champion_i.py +44 -0
- pydsa/algorithms/arrays/find_champion_ii.py +45 -0
- pydsa/algorithms/arrays/find_churn_risk_customers.py +59 -0
- pydsa/algorithms/arrays/find_closest_number_to_zero.py +41 -0
- pydsa/algorithms/arrays/find_closest_person.py +76 -0
- pydsa/algorithms/arrays/find_common_elements_between_two_arrays.py +49 -0
- pydsa/algorithms/arrays/find_consecutive_integers_from_a_data_stream.py +86 -0
- pydsa/algorithms/arrays/find_consistently_improving_employees.py +58 -0
- pydsa/algorithms/arrays/find_covid_recovery_patients.py +62 -0
- pydsa/algorithms/arrays/find_customers_with_positive_revenue_this_year.py +66 -0
- pydsa/algorithms/arrays/find_cutoff_score_for_each_school.py +56 -0
- pydsa/algorithms/arrays/find_drivers_with_improved_fuel_efficiency.py +66 -0
- pydsa/algorithms/arrays/find_emotionally_consistent_users.py +74 -0
- pydsa/algorithms/arrays/find_expensive_cities.py +57 -0
- pydsa/algorithms/arrays/find_followers_count.py +48 -0
- pydsa/algorithms/arrays/find_golden_hour_customers.py +69 -0
- pydsa/algorithms/arrays/find_good_days_to_rob_the_bank.py +65 -0
- pydsa/algorithms/arrays/find_if_array_can_be_sorted.py +64 -0
- pydsa/algorithms/arrays/find_indices_of_stable_mountains.py +54 -0
- pydsa/algorithms/arrays/find_indices_with_index_and_value_difference_i.py +45 -0
- pydsa/algorithms/arrays/find_indices_with_index_and_value_difference_ii.py +138 -0
- pydsa/algorithms/arrays/find_interview_candidates.py +60 -0
- pydsa/algorithms/arrays/find_kth_largest_xor_coordinate_value.py +49 -0
- pydsa/algorithms/arrays/find_latest_group_of_size_m.py +53 -0
- pydsa/algorithms/arrays/find_latest_salaries.py +46 -0
- pydsa/algorithms/arrays/find_longest_calls.py +51 -0
- pydsa/algorithms/arrays/find_loyal_customers.py +48 -0
- pydsa/algorithms/arrays/find_lucky_integer_in_an_array.py +50 -0
- pydsa/algorithms/arrays/find_missing_and_repeated_values.py +75 -0
- pydsa/algorithms/arrays/find_missing_elements.py +51 -0
- pydsa/algorithms/arrays/find_nearest_point_that_has_the_same_x_or_y_coordinate.py +47 -0
- pydsa/algorithms/arrays/find_occurrences_of_an_element_in_an_array.py +47 -0
- pydsa/algorithms/arrays/find_original_array_from_doubled_array.py +88 -0
- pydsa/algorithms/arrays/find_overbooked_employees.py +79 -0
- pydsa/algorithms/arrays/find_peak_calling_hours_for_each_city.py +74 -0
- pydsa/algorithms/arrays/find_pivot_index.py +42 -0
- pydsa/algorithms/arrays/find_players_with_zero_or_one_losses.py +55 -0
- pydsa/algorithms/arrays/find_product_recommendation_pairs.py +75 -0
- pydsa/algorithms/arrays/find_products_of_elements_of_big_array.py +68 -0
- pydsa/algorithms/arrays/find_products_with_three_consecutive_digits.py +46 -0
- pydsa/algorithms/arrays/find_products_with_valid_serial_numbers.py +49 -0
- pydsa/algorithms/arrays/find_score_of_an_array_after_marking_all_elements.py +101 -0
- pydsa/algorithms/arrays/find_smallest_common_element_in_all_rows.py +65 -0
- pydsa/algorithms/arrays/find_sorted_submatrices_with_maximum_element_at_most_k.py +82 -0
- pydsa/algorithms/arrays/find_stores_with_inventory_imbalance.py +49 -0
- pydsa/algorithms/arrays/find_students_who_improved.py +49 -0
- pydsa/algorithms/arrays/find_students_with_study_spiral_pattern.py +151 -0
- pydsa/algorithms/arrays/find_subarrays_with_equal_sum.py +66 -0
- pydsa/algorithms/arrays/find_subsequence_of_length_k_with_the_largest_sum.py +60 -0
- pydsa/algorithms/arrays/find_target_indices_after_sorting_array.py +46 -0
- pydsa/algorithms/arrays/find_the_array_concatenation_value.py +70 -0
- pydsa/algorithms/arrays/find_the_celebrity.py +63 -0
- pydsa/algorithms/arrays/find_the_child_who_has_the_ball_after_k_seconds.py +46 -0
- pydsa/algorithms/arrays/find_the_difference_of_two_arrays.py +44 -0
- pydsa/algorithms/arrays/find_the_distinct_difference_array.py +77 -0
- pydsa/algorithms/arrays/find_the_first_player_to_win_k_games_in_a_row.py +51 -0
- pydsa/algorithms/arrays/find_the_grid_of_region_average.py +70 -0
- pydsa/algorithms/arrays/find_the_highest_altitude.py +39 -0
- pydsa/algorithms/arrays/find_the_index_of_permutation.py +42 -0
- pydsa/algorithms/arrays/find_the_index_of_the_large_integer.py +49 -0
- pydsa/algorithms/arrays/find_the_k_sum_of_an_array.py +60 -0
- pydsa/algorithms/arrays/find_the_kth_largest_integer_in_the_array.py +36 -0
- pydsa/algorithms/arrays/find_the_largest_almost_missing_integer.py +53 -0
- pydsa/algorithms/arrays/find_the_maximum_divisibility_score.py +50 -0
- pydsa/algorithms/arrays/find_the_maximum_length_of_valid_subsequence_i.py +108 -0
- pydsa/algorithms/arrays/find_the_maximum_length_of_valid_subsequence_ii.py +55 -0
- pydsa/algorithms/arrays/find_the_maximum_number_of_elements_in_subset.py +64 -0
- pydsa/algorithms/arrays/find_the_maximum_number_of_marked_indices.py +50 -0
- pydsa/algorithms/arrays/find_the_maximum_sum_of_node_values.py +64 -0
- pydsa/algorithms/arrays/find_the_middle_index_in_array.py +40 -0
- pydsa/algorithms/arrays/find_the_minimum_area_to_cover_all_ones_i.py +68 -0
- pydsa/algorithms/arrays/find_the_minimum_cost_array_permutation.py +40 -0
- pydsa/algorithms/arrays/find_the_missing_ids.py +43 -0
- pydsa/algorithms/arrays/find_the_number_of_distinct_colors_among_the_balls.py +60 -0
- pydsa/algorithms/arrays/find_the_number_of_good_pairs_i.py +47 -0
- pydsa/algorithms/arrays/find_the_number_of_good_pairs_ii.py +50 -0
- pydsa/algorithms/arrays/find_the_number_of_subarrays_where_boundary_elements_are_maximum.py +141 -0
- pydsa/algorithms/arrays/find_the_original_array_of_prefix_xor.py +53 -0
- pydsa/algorithms/arrays/find_the_peaks.py +59 -0
- pydsa/algorithms/arrays/find_the_prefix_common_array_of_two_arrays.py +337 -0
- pydsa/algorithms/arrays/find_the_quiet_students_in_all_exams.py +68 -0
- pydsa/algorithms/arrays/find_the_score_difference_in_a_game.py +46 -0
- pydsa/algorithms/arrays/find_the_score_of_all_prefixes_of_an_array.py +41 -0
- pydsa/algorithms/arrays/find_the_smallest_balanced_index.py +47 -0
- pydsa/algorithms/arrays/find_the_sum_of_encrypted_integers.py +91 -0
- pydsa/algorithms/arrays/find_the_value_of_the_partition.py +62 -0
- pydsa/algorithms/arrays/find_the_width_of_columns_of_a_grid.py +57 -0
- pydsa/algorithms/arrays/find_the_winner_of_an_array_game.py +54 -0
- pydsa/algorithms/arrays/find_third_transaction.py +45 -0
- pydsa/algorithms/arrays/find_top_performing_driver.py +56 -0
- pydsa/algorithms/arrays/find_top_scoring_students.py +52 -0
- pydsa/algorithms/arrays/find_top_scoring_students_ii.py +72 -0
- pydsa/algorithms/arrays/find_total_time_spent_by_each_employee.py +41 -0
- pydsa/algorithms/arrays/find_triangular_sum_of_an_array.py +45 -0
- pydsa/algorithms/arrays/find_two_non_overlapping_sub_arrays_each_with_target_sum.py +130 -0
- pydsa/algorithms/arrays/find_users_with_high_token_usage.py +54 -0
- pydsa/algorithms/arrays/find_users_with_persistent_behavior_patterns.py +48 -0
- pydsa/algorithms/arrays/find_valid_matrix_given_row_and_column_sums.py +230 -0
- pydsa/algorithms/arrays/find_winner_on_a_tic_tac_toe_game.py +68 -0
- pydsa/algorithms/arrays/find_x_sum_of_all_k_long_subarrays_i.py +55 -0
- pydsa/algorithms/arrays/find_x_value_of_array_i.py +73 -0
- pydsa/algorithms/arrays/find_x_value_of_array_ii.py +140 -0
- pydsa/algorithms/arrays/find_zombie_sessions.py +59 -0
- pydsa/algorithms/arrays/finding_mk_average.py +245 -0
- pydsa/algorithms/arrays/finding_pairs_with_a_certain_sum.py +53 -0
- pydsa/algorithms/arrays/finding_the_number_of_visible_mountains.py +67 -0
- pydsa/algorithms/arrays/first_and_last_call_on_the_same_day.py +71 -0
- pydsa/algorithms/arrays/first_completely_painted_row_or_column.py +69 -0
- pydsa/algorithms/arrays/first_element_with_unique_frequency.py +46 -0
- pydsa/algorithms/arrays/first_missing_positive.py +56 -0
- pydsa/algorithms/arrays/first_unique_even_element.py +45 -0
- pydsa/algorithms/arrays/first_unique_number.py +46 -0
- pydsa/algorithms/arrays/flatten_2d_vector.py +81 -0
- pydsa/algorithms/arrays/flatten_deeply_nested_array.py +56 -0
- pydsa/algorithms/arrays/flight_occupancy_and_waitlist_analysis.py +114 -0
- pydsa/algorithms/arrays/flip_columns_for_maximum_number_of_equal_rows.py +62 -0
- pydsa/algorithms/arrays/flip_square_submatrix_vertically.py +50 -0
- pydsa/algorithms/arrays/flipping_an_image.py +46 -0
- pydsa/algorithms/arrays/form_array_by_concatenating_subarrays_of_another_array.py +53 -0
- pydsa/algorithms/arrays/frequency_tracker.py +131 -0
- pydsa/algorithms/arrays/friday_purchases_i.py +49 -0
- pydsa/algorithms/arrays/friday_purchases_ii.py +59 -0
- pydsa/algorithms/arrays/friendly_movies_streamed_last_month.py +88 -0
- pydsa/algorithms/arrays/friends_of_appropriate_ages.py +74 -0
- pydsa/algorithms/arrays/frog_jump_ii.py +72 -0
- pydsa/algorithms/arrays/game_of_life.py +84 -0
- pydsa/algorithms/arrays/game_play_analysis_i.py +55 -0
- pydsa/algorithms/arrays/game_play_analysis_ii.py +43 -0
- pydsa/algorithms/arrays/game_play_analysis_v.py +71 -0
- pydsa/algorithms/arrays/generate_circular_array_values.py +53 -0
- pydsa/algorithms/arrays/generate_the_invoice.py +51 -0
- pydsa/algorithms/arrays/get_biggest_three_rhombus_sums_in_a_grid.py +134 -0
- pydsa/algorithms/arrays/get_maximum_in_generated_array.py +64 -0
- pydsa/algorithms/arrays/get_the_maximum_score.py +97 -0
- pydsa/algorithms/arrays/get_the_second_most_recent_activity.py +44 -0
- pydsa/algorithms/arrays/get_the_size_of_a_dataframe.py +40 -0
- pydsa/algorithms/arrays/good_subsequence_queries.py +55 -0
- pydsa/algorithms/arrays/grand_slam_titles.py +50 -0
- pydsa/algorithms/arrays/grid_illumination.py +367 -0
- pydsa/algorithms/arrays/group_by.py +50 -0
- pydsa/algorithms/arrays/group_employees_of_the_same_salary.py +51 -0
- pydsa/algorithms/arrays/guess_the_majority_in_a_hidden_array.py +114 -0
- pydsa/algorithms/arrays/h_index.py +56 -0
- pydsa/algorithms/arrays/handling_sum_queries_after_update.py +69 -0
- pydsa/algorithms/arrays/height_checker.py +49 -0
- pydsa/algorithms/arrays/high_access_employees.py +48 -0
- pydsa/algorithms/arrays/high_five.py +56 -0
- pydsa/algorithms/arrays/highest_salaries_difference.py +47 -0
- pydsa/algorithms/arrays/hopper_company_queries_i.py +94 -0
- pydsa/algorithms/arrays/hopper_company_queries_ii.py +95 -0
- pydsa/algorithms/arrays/hopper_company_queries_iii.py +109 -0
- pydsa/algorithms/arrays/how_many_numbers_are_smaller_than_the_current_number.py +42 -0
- pydsa/algorithms/arrays/image_overlap.py +68 -0
- pydsa/algorithms/arrays/image_smoother.py +58 -0
- pydsa/algorithms/arrays/immediate_food_delivery_iii.py +65 -0
- pydsa/algorithms/arrays/increasing_triplet_subsequence.py +54 -0
- pydsa/algorithms/arrays/increment_submatrices_by_one.py +67 -0
- pydsa/algorithms/arrays/incremental_memory_leak.py +54 -0
- pydsa/algorithms/arrays/insert_delete_getrandom_o1.py +100 -0
- pydsa/algorithms/arrays/insert_delete_getrandom_o1_duplicates_allowed.py +106 -0
- pydsa/algorithms/arrays/intersection_of_multiple_arrays.py +48 -0
- pydsa/algorithms/arrays/intersection_of_three_sorted_arrays.py +55 -0
- pydsa/algorithms/arrays/intersection_of_two_arrays.py +45 -0
- pydsa/algorithms/arrays/intersection_of_two_arrays_ii.py +49 -0
- pydsa/algorithms/arrays/intervals_between_identical_elements.py +62 -0
- pydsa/algorithms/arrays/invalid_transactions.py +69 -0
- pydsa/algorithms/arrays/inversion_of_object.py +39 -0
- pydsa/algorithms/arrays/island_perimeter.py +54 -0
- pydsa/algorithms/arrays/join_two_arrays_by_id.py +60 -0
- pydsa/algorithms/arrays/jump_game_viii.py +158 -0
- pydsa/algorithms/arrays/k_diff_pairs_in_an_array.py +58 -0
- pydsa/algorithms/arrays/k_divisible_elements_subarrays.py +54 -0
- pydsa/algorithms/arrays/k_empty_slots.py +293 -0
- pydsa/algorithms/arrays/k_highest_ranked_items_within_a_price_range.py +56 -0
- pydsa/algorithms/arrays/k_items_with_the_maximum_sum.py +37 -0
- pydsa/algorithms/arrays/keep_multiplying_found_values_by_two.py +45 -0
- pydsa/algorithms/arrays/kids_with_the_greatest_number_of_candies.py +42 -0
- pydsa/algorithms/arrays/kth_missing_positive_number.py +56 -0
- pydsa/algorithms/arrays/kth_smallest_remaining_even_integer_in_subarray_queries.py +180 -0
- pydsa/algorithms/arrays/largest_combination_with_bitwise_and_greater_than_zero.py +52 -0
- pydsa/algorithms/arrays/largest_element_in_an_array_after_merge_operations.py +103 -0
- pydsa/algorithms/arrays/largest_local_values_in_a_matrix.py +47 -0
- pydsa/algorithms/arrays/largest_local_values_in_a_matrix_ii.py +57 -0
- pydsa/algorithms/arrays/largest_magic_square.py +82 -0
- pydsa/algorithms/arrays/largest_number_at_least_twice_of_others.py +62 -0
- pydsa/algorithms/arrays/largest_positive_integer_that_exists_with_its_negative.py +40 -0
- pydsa/algorithms/arrays/largest_subarray_length_k.py +58 -0
- pydsa/algorithms/arrays/largest_submatrix_with_rearrangements.py +70 -0
- pydsa/algorithms/arrays/largest_unique_number.py +45 -0
- pydsa/algorithms/arrays/largest_values_from_labels.py +46 -0
- pydsa/algorithms/arrays/last_visited_integers.py +239 -0
- pydsa/algorithms/arrays/league_statistics.py +61 -0
- pydsa/algorithms/arrays/least_number_of_unique_integers_after_k_removals.py +59 -0
- pydsa/algorithms/arrays/left_and_right_sum_differences.py +47 -0
- pydsa/algorithms/arrays/leftmost_column_with_at_least_a_one.py +71 -0
- pydsa/algorithms/arrays/loan_types.py +42 -0
- pydsa/algorithms/arrays/logger_rate_limiter.py +84 -0
- pydsa/algorithms/arrays/lonely_pixel_i.py +64 -0
- pydsa/algorithms/arrays/lonely_pixel_ii.py +62 -0
- pydsa/algorithms/arrays/longest_alternating_subarray.py +56 -0
- pydsa/algorithms/arrays/longest_balanced_subarray_i.py +57 -0
- pydsa/algorithms/arrays/longest_consecutive_sequence.py +57 -0
- pydsa/algorithms/arrays/longest_continuous_increasing_subsequence.py +50 -0
- pydsa/algorithms/arrays/longest_fibonacci_subarray.py +64 -0
- pydsa/algorithms/arrays/longest_harmonious_subsequence.py +50 -0
- pydsa/algorithms/arrays/longest_non_decreasing_subarray_from_two_arrays.py +77 -0
- pydsa/algorithms/arrays/longest_square_streak_in_an_array.py +76 -0
- pydsa/algorithms/arrays/longest_strictly_increasing_or_decreasing_subarray.py +60 -0
- pydsa/algorithms/arrays/longest_subarray_with_maximum_bitwise_and.py +52 -0
- pydsa/algorithms/arrays/longest_subsequence_with_limited_sum.py +43 -0
- pydsa/algorithms/arrays/longest_team_pass_streak.py +47 -0
- pydsa/algorithms/arrays/longest_winning_streak.py +53 -0
- pydsa/algorithms/arrays/low_quality_problems.py +67 -0
- pydsa/algorithms/arrays/lucky_numbers_in_a_matrix.py +64 -0
- pydsa/algorithms/arrays/magic_squares_in_grid.py +72 -0
- pydsa/algorithms/arrays/majority_element.py +47 -0
- pydsa/algorithms/arrays/majority_element_ii.py +0 -0
- pydsa/algorithms/arrays/make-sum-divisible-by-p.py +60 -0
- pydsa/algorithms/arrays/make_array_elements_equal_to_zero.py +88 -0
- pydsa/algorithms/arrays/make_array_empty.py +302 -0
- pydsa/algorithms/arrays/make_k_subarray_sums_equal.py +59 -0
- pydsa/algorithms/arrays/make_lexicographically_smallest_array_by_swapping_elements.py +70 -0
- pydsa/algorithms/arrays/make_the_prefix_sum_non_negative.py +69 -0
- pydsa/algorithms/arrays/make_two_arrays_equal.py +58 -0
- pydsa/algorithms/arrays/manager_of_the_largest_department.py +72 -0
- pydsa/algorithms/arrays/mark_elements_on_array_by_performing_queries.py +58 -0
- pydsa/algorithms/arrays/market_analysis_iii.py +93 -0
- pydsa/algorithms/arrays/match_alphanumerical_pattern_in_matrix_i.py +74 -0
- pydsa/algorithms/arrays/matrix_block_sum.py +97 -0
- pydsa/algorithms/arrays/matrix_cells_in_distance_order.py +39 -0
- pydsa/algorithms/arrays/matrix_diagonal_sum.py +48 -0
- pydsa/algorithms/arrays/matrix_similarity_after_cyclic_shifts.py +92 -0
- pydsa/algorithms/arrays/max_chunks_to_make_sorted.py +60 -0
- pydsa/algorithms/arrays/max_chunks_to_make_sorted_ii.py +61 -0
- pydsa/algorithms/arrays/max_consecutive_ones.py +41 -0
- pydsa/algorithms/arrays/max_increase_to_keep_city_skyline.py +61 -0
- pydsa/algorithms/arrays/max_pair_sum_in_an_array.py +41 -0
- pydsa/algorithms/arrays/max_sum_of_a_pair_with_equal_sum_of_digits.py +56 -0
- pydsa/algorithms/arrays/maximize_active_section_with_trade_i.py +58 -0
- pydsa/algorithms/arrays/maximize_area_of_square_hole_in_grid.py +58 -0
- pydsa/algorithms/arrays/maximize_consecutive_elements_in_an_array_after_modification.py +62 -0
- pydsa/algorithms/arrays/maximize_distance_to_closest_person.py +53 -0
- pydsa/algorithms/arrays/maximize_fixed_points_after_deletions.py +111 -0
- pydsa/algorithms/arrays/maximize_greatness_of_an_array.py +63 -0
- pydsa/algorithms/arrays/maximize_score_after_pair_deletions.py +71 -0
- pydsa/algorithms/arrays/maximize_subarray_gcd_score.py +64 -0
- pydsa/algorithms/arrays/maximize_the_beauty_of_the_garden.py +266 -0
- pydsa/algorithms/arrays/maximize_the_number_of_partitions_after_operations.py +302 -0
- pydsa/algorithms/arrays/maximize_total_tastiness_of_purchased_fruits.py +111 -0
- pydsa/algorithms/arrays/maximize_y_sum_by_picking_a_triplet_of_distinct_x_values.py +52 -0
- pydsa/algorithms/arrays/maximum-profit-of-operating-a-centennial-wheel.py +74 -0
- pydsa/algorithms/arrays/maximum-sum-obtained-of-any-permutation.py +47 -0
- pydsa/algorithms/arrays/maximum_absolute_sum_of_any_subarray.py +54 -0
- pydsa/algorithms/arrays/maximum_and_minimum_sums_of_at_most_size_k_subsequences.py +76 -0
- pydsa/algorithms/arrays/maximum_area_of_a_piece_of_cake_after_horizontal_and_vertical_cuts.py +57 -0
- pydsa/algorithms/arrays/maximum_area_of_longest_diagonal_rectangle.py +52 -0
- pydsa/algorithms/arrays/maximum_area_rectangle_with_point_constraints_ii.py +162 -0
- pydsa/algorithms/arrays/maximum_array_hopping_score_i.py +63 -0
- pydsa/algorithms/arrays/maximum_ascending_subarray_sum.py +53 -0
- pydsa/algorithms/arrays/maximum_beauty_of_array_after_operation.py +36 -0
- pydsa/algorithms/arrays/maximum_consecutive_floors_without_special_floors.py +59 -0
- pydsa/algorithms/arrays/maximum_containers_on_a_ship.py +53 -0
- pydsa/algorithms/arrays/maximum_difference_between_adjacent_elements_in_a_circular_array.py +49 -0
- pydsa/algorithms/arrays/maximum_difference_between_even_and_odd_frequency_i.py +67 -0
- pydsa/algorithms/arrays/maximum_difference_between_even_and_odd_frequency_ii.py +66 -0
- pydsa/algorithms/arrays/maximum_difference_between_increasing_elements.py +57 -0
- pydsa/algorithms/arrays/maximum_difference_score_in_a_grid.py +52 -0
- pydsa/algorithms/arrays/maximum_distance_between_a_pair_of_values.py +54 -0
- pydsa/algorithms/arrays/maximum_distance_between_unequal_words_in_array_i.py +48 -0
- pydsa/algorithms/arrays/maximum_distance_in_arrays.py +68 -0
- pydsa/algorithms/arrays/maximum_element_after_decreasing_and_rearranging.py +57 -0
- pydsa/algorithms/arrays/maximum_element_sum_of_a_complete_subset_of_indices.py +110 -0
- pydsa/algorithms/arrays/maximum_enemy_forts_that_can_be_captured.py +51 -0
- pydsa/algorithms/arrays/maximum_equal_frequency.py +87 -0
- pydsa/algorithms/arrays/maximum_frequency_of_an_element_after_performing_operations_i.py +94 -0
- pydsa/algorithms/arrays/maximum_frequency_of_an_element_after_performing_operations_ii.py +62 -0
- pydsa/algorithms/arrays/maximum_gap.py +77 -0
- pydsa/algorithms/arrays/maximum_gcd_sum_of_a_subarray.py +135 -0
- pydsa/algorithms/arrays/maximum_genetic_difference_query.py +300 -0
- pydsa/algorithms/arrays/maximum_good_subarray_sum.py +138 -0
- pydsa/algorithms/arrays/maximum_hamming_distances.py +315 -0
- pydsa/algorithms/arrays/maximum_increasing_triplet_value.py +55 -0
- pydsa/algorithms/arrays/maximum_length_of_subarray_with_positive_product.py +64 -0
- pydsa/algorithms/arrays/maximum_matrix_sum.py +279 -0
- pydsa/algorithms/arrays/maximum_median_sum_of_subsequences_of_size_3.py +81 -0
- pydsa/algorithms/arrays/maximum_number_of_balls_in_a_box.py +43 -0
- pydsa/algorithms/arrays/maximum_number_of_coins_you_can_get.py +57 -0
- pydsa/algorithms/arrays/maximum_number_of_consecutive_values_you_can_make.py +123 -0
- pydsa/algorithms/arrays/maximum_number_of_distinct_elements_after_operations.py +69 -0
- pydsa/algorithms/arrays/maximum_number_of_equal_length_runs.py +115 -0
- pydsa/algorithms/arrays/maximum_number_of_intersections_on_the_chart.py +116 -0
- pydsa/algorithms/arrays/maximum_number_of_k_divisible_components.py +61 -0
- pydsa/algorithms/arrays/maximum_number_of_matching_indices_after_right_shifts.py +68 -0
- pydsa/algorithms/arrays/maximum_number_of_non_overlapping_subarrays_with_sum_equals_target.py +61 -0
- pydsa/algorithms/arrays/maximum_number_of_operations_to_move_ones_to_the_end.py +499 -0
- pydsa/algorithms/arrays/maximum_number_of_operations_with_the_same_score_i.py +83 -0
- pydsa/algorithms/arrays/maximum_number_of_operations_with_the_same_score_ii.py +568 -0
- pydsa/algorithms/arrays/maximum_number_of_pairs_in_array.py +52 -0
- pydsa/algorithms/arrays/maximum_number_of_people_that_can_be_caught_in_tag.py +239 -0
- pydsa/algorithms/arrays/maximum_number_of_removal_queries_that_can_be_processed_i.py +260 -0
- pydsa/algorithms/arrays/maximum_number_of_robots_within_budget.py +63 -0
- pydsa/algorithms/arrays/maximum_number_of_ways_to_partition_an_array.py +79 -0
- pydsa/algorithms/arrays/maximum_number_that_sum_of_the_prices_is_less_than_or_equal_to_k.py +48 -0
- pydsa/algorithms/arrays/maximum_of_minimum_values_in_all_subarrays.py +80 -0
- pydsa/algorithms/arrays/maximum_points_activated_with_one_addition.py +220 -0
- pydsa/algorithms/arrays/maximum_points_after_enemy_battles.py +280 -0
- pydsa/algorithms/arrays/maximum_points_you_can_obtain_from_cards.py +62 -0
- pydsa/algorithms/arrays/maximum_population_year.py +58 -0
- pydsa/algorithms/arrays/maximum_product_difference_between_two_pairs.py +37 -0
- pydsa/algorithms/arrays/maximum_product_of_first_and_last_elements_of_a_subsequence.py +150 -0
- pydsa/algorithms/arrays/maximum_product_of_three_elements_after_one_replacement.py +168 -0
- pydsa/algorithms/arrays/maximum_product_of_two_elements_in_an_array.py +48 -0
- pydsa/algorithms/arrays/maximum_profitable_triplets_with_increasing_prices_i.py +53 -0
- pydsa/algorithms/arrays/maximum_profitable_triplets_with_increasing_prices_ii.py +226 -0
- pydsa/algorithms/arrays/maximum_rows_covered_by_columns.py +142 -0
- pydsa/algorithms/arrays/maximum_score_after_binary_swaps.py +101 -0
- pydsa/algorithms/arrays/maximum_score_of_a_good_subarray.py +86 -0
- pydsa/algorithms/arrays/maximum_score_of_a_split.py +56 -0
- pydsa/algorithms/arrays/maximum_score_of_spliced_array.py +68 -0
- pydsa/algorithms/arrays/maximum_segment_sum_after_removals.py +153 -0
- pydsa/algorithms/arrays/maximum_size_of_a_set_after_removals.py +58 -0
- pydsa/algorithms/arrays/maximum_size_subarray_sum_equals_k.py +56 -0
- pydsa/algorithms/arrays/maximum_sized_array.py +51 -0
- pydsa/algorithms/arrays/maximum_students_on_a_single_bench.py +54 -0
- pydsa/algorithms/arrays/maximum_subarray_min_product.py +83 -0
- pydsa/algorithms/arrays/maximum_subarray_sum_with_length_divisible_by_k.py +66 -0
- pydsa/algorithms/arrays/maximum_subarray_with_equal_products.py +67 -0
- pydsa/algorithms/arrays/maximum_subsequence_score.py +65 -0
- pydsa/algorithms/arrays/maximum_sum_circular_subarray.py +65 -0
- pydsa/algorithms/arrays/maximum_sum_of_an_hourglass.py +63 -0
- pydsa/algorithms/arrays/maximum_sum_of_three_numbers_divisible_by_three.py +93 -0
- pydsa/algorithms/arrays/maximum_sum_queries.py +207 -0
- pydsa/algorithms/arrays/maximum_sum_with_exactly_k_elements.py +56 -0
- pydsa/algorithms/arrays/maximum_tastiness_of_candy_basket.py +71 -0
- pydsa/algorithms/arrays/maximum_total_beauty_of_the_gardens.py +254 -0
- pydsa/algorithms/arrays/maximum_transaction_each_day.py +54 -0
- pydsa/algorithms/arrays/maximum_value_after_insertion.py +43 -0
- pydsa/algorithms/arrays/maximum_value_of_an_ordered_triplet_i.py +56 -0
- pydsa/algorithms/arrays/maximum_value_of_an_ordered_triplet_ii.py +136 -0
- pydsa/algorithms/arrays/maximum_value_sum_by_placing_three_rooks_i.py +74 -0
- pydsa/algorithms/arrays/maximum_value_sum_by_placing_three_rooks_ii.py +102 -0
- pydsa/algorithms/arrays/maximum_white_tiles_covered_by_a_carpet.py +66 -0
- pydsa/algorithms/arrays/mean_of_array_after_removing_some_elements.py +66 -0
- pydsa/algorithms/arrays/merge_operations_to_turn_array_into_a_palindrome.py +281 -0
- pydsa/algorithms/arrays/merge_similar_items.py +46 -0
- pydsa/algorithms/arrays/merge_triplets_to_form_target_triplet.py +56 -0
- pydsa/algorithms/arrays/merge_two_2d_arrays_by_summing_values.py +69 -0
- pydsa/algorithms/arrays/method_chaining.py +73 -0
- pydsa/algorithms/arrays/mice_and_cheese.py +82 -0
- pydsa/algorithms/arrays/minimize_array_sum_using_divisible_replacements.py +72 -0
- pydsa/algorithms/arrays/minimize_hamming_distance_after_swap_operations.py +64 -0
- pydsa/algorithms/arrays/minimize_length_of_array_using_operations.py +50 -0
- pydsa/algorithms/arrays/minimize_maximum_of_array.py +66 -0
- pydsa/algorithms/arrays/minimize_the_difference_between_target_and_chosen_elements.py +233 -0
- pydsa/algorithms/arrays/minimize_the_maximum_difference_of_pairs.py +72 -0
- pydsa/algorithms/arrays/minimize_the_maximum_of_two_arrays.py +66 -0
- pydsa/algorithms/arrays/minimum_absolute_difference.py +53 -0
- pydsa/algorithms/arrays/minimum_absolute_difference_between_elements_with_constraint.py +96 -0
- pydsa/algorithms/arrays/minimum_absolute_difference_between_two_values.py +51 -0
- pydsa/algorithms/arrays/minimum_absolute_distance_between_mirror_pairs.py +64 -0
- pydsa/algorithms/arrays/minimum_adjacent_swaps_for_k_consecutive_ones.py +88 -0
- pydsa/algorithms/arrays/minimum_adjacent_swaps_to_alternate_parity.py +100 -0
- pydsa/algorithms/arrays/minimum_adjacent_swaps_to_make_a_valid_array.py +89 -0
- pydsa/algorithms/arrays/minimum_amount_of_time_to_collect_garbage.py +59 -0
- pydsa/algorithms/arrays/minimum_array_changes_to_make_differences_equal.py +39 -0
- pydsa/algorithms/arrays/minimum_array_length_after_pair_removals.py +62 -0
- pydsa/algorithms/arrays/minimum_average_difference.py +110 -0
- pydsa/algorithms/arrays/minimum_consecutive_cards_to_pick_up.py +51 -0
- pydsa/algorithms/arrays/minimum_cost_of_buying_candies_with_discount.py +51 -0
- pydsa/algorithms/arrays/minimum_cost_to_buy_apples.py +54 -0
- pydsa/algorithms/arrays/minimum_cost_to_buy_apples_ii.py +43 -0
- pydsa/algorithms/arrays/minimum_cost_to_equalize_arrays_using_swaps.py +308 -0
- pydsa/algorithms/arrays/minimum_cost_to_make_array_palindromic.py +50 -0
- pydsa/algorithms/arrays/minimum_cost_to_make_arrays_identical.py +47 -0
- pydsa/algorithms/arrays/minimum_cost_to_split_an_array.py +274 -0
- pydsa/algorithms/arrays/minimum_deletions_to_make_array_divisible.py +40 -0
- pydsa/algorithms/arrays/minimum_difference_between_highest_and_lowest_of_k_scores.py +48 -0
- pydsa/algorithms/arrays/minimum_difference_between_largest_and_smallest_value_in_three_moves.py +80 -0
- pydsa/algorithms/arrays/minimum_distance_between_three_equal_elements_i.py +57 -0
- pydsa/algorithms/arrays/minimum_distance_between_three_equal_elements_ii.py +66 -0
- pydsa/algorithms/arrays/minimum_distance_to_the_target_element.py +50 -0
- pydsa/algorithms/arrays/minimum_increase_to_maximize_special_indices.py +61 -0
- pydsa/algorithms/arrays/minimum_index_of_a_valid_split.py +144 -0
- pydsa/algorithms/arrays/minimum_index_sum_of_common_elements.py +61 -0
- pydsa/algorithms/arrays/minimum_index_sum_of_two_lists.py +47 -0
- pydsa/algorithms/arrays/minimum_lines_to_represent_a_line_chart.py +66 -0
- pydsa/algorithms/arrays/minimum_money_required_before_transactions.py +50 -0
- pydsa/algorithms/arrays/minimum_moves_to_balance_circular_array.py +72 -0
- pydsa/algorithms/arrays/minimum_moves_to_equal_array_elements_iii.py +82 -0
- pydsa/algorithms/arrays/minimum_moves_to_make_array_complementary.py +41 -0
- pydsa/algorithms/arrays/minimum_moves_to_make_array_complementary2.py +42 -0
- pydsa/algorithms/arrays/minimum_moves_to_pick_k_ones.py +79 -0
- pydsa/algorithms/arrays/minimum_number_game.py +38 -0
- pydsa/algorithms/arrays/minimum_number_of_flips_to_make_binary_grid_palindromic_i.py +55 -0
- pydsa/algorithms/arrays/minimum_number_of_increments_on_subarrays_to_form_a_target_array.py +56 -0
- pydsa/algorithms/arrays/minimum_number_of_moves_to_seat_everyone.py +48 -0
- pydsa/algorithms/arrays/minimum_number_of_operations_to_have_distinct_elements.py +52 -0
- pydsa/algorithms/arrays/minimum_number_of_operations_to_make_array_empty.py +64 -0
- pydsa/algorithms/arrays/minimum_number_of_operations_to_make_elements_in_array_distinct.py +51 -0
- pydsa/algorithms/arrays/minimum_number_of_operations_to_move_all_balls_to_each_box.py +58 -0
- pydsa/algorithms/arrays/minimum_number_of_operations_to_reinitialize_a_permutation.py +101 -0
- pydsa/algorithms/arrays/minimum_operations_to_achieve_at_least_k_peaks.py +62 -0
- pydsa/algorithms/arrays/minimum_operations_to_collect_elements.py +68 -0
- pydsa/algorithms/arrays/minimum_operations_to_convert_all_elements_to_zero.py +50 -0
- pydsa/algorithms/arrays/minimum_operations_to_equalize_array.py +51 -0
- pydsa/algorithms/arrays/minimum_operations_to_exceed_threshold_value_i.py +46 -0
- pydsa/algorithms/arrays/minimum_operations_to_exceed_threshold_value_ii.py +100 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_all_array_elements_equal.py +45 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_all_grid_elements_equal.py +62 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_array_elements_zero.py +51 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_array_equal_ii.py +57 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_array_equal_to_target.py +56 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_array_modulo_alternating_i.py +114 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_array_modulo_alternating_ii.py +66 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_array_parity_alternating.py +86 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_columns_strictly_increasing.py +58 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_median_of_array_equal_to_k.py +63 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_subarray_elements_equal.py +50 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_the_array_alternating.py +78 -0
- pydsa/algorithms/arrays/minimum_operations_to_make_the_array_beautiful.py +56 -0
- pydsa/algorithms/arrays/minimum_operations_to_maximize_last_elements_in_arrays.py +42 -0
- pydsa/algorithms/arrays/minimum_operations_to_reduce_x_to_zero.py +69 -0
- pydsa/algorithms/arrays/minimum_operations_to_sort_a_permutation.py +59 -0
- pydsa/algorithms/arrays/minimum_operations_to_transform_array.py +66 -0
- pydsa/algorithms/arrays/minimum_operations_to_transform_array_into_alternating_prime.py +166 -0
- pydsa/algorithms/arrays/minimum_operations_to_write_the_letter_y_on_a_grid.py +81 -0
- pydsa/algorithms/arrays/minimum_pair_removal_to_sort_array_i.py +79 -0
- pydsa/algorithms/arrays/minimum_positive_sum_subarray.py +144 -0
- pydsa/algorithms/arrays/minimum_relative_loss_after_buying_chocolates.py +58 -0
- pydsa/algorithms/arrays/minimum_removals_to_balance_array.py +86 -0
- pydsa/algorithms/arrays/minimum_right_shifts_to_sort_the_array.py +69 -0
- pydsa/algorithms/arrays/minimum_score_by_changing_two_elements.py +65 -0
- pydsa/algorithms/arrays/minimum_seconds_to_equalize_a_circular_array.py +260 -0
- pydsa/algorithms/arrays/minimum_split_into_subarrays_with_gcd_greater_than_one.py +341 -0
- pydsa/algorithms/arrays/minimum_subarrays_in_a_valid_split.py +57 -0
- pydsa/algorithms/arrays/minimum_subsequence_in_non_increasing_order.py +50 -0
- pydsa/algorithms/arrays/minimum_sum_of_mountain_triplets_i.py +65 -0
- pydsa/algorithms/arrays/minimum_sum_of_mountain_triplets_ii.py +119 -0
- pydsa/algorithms/arrays/minimum_sum_of_squared_difference.py +154 -0
- pydsa/algorithms/arrays/minimum_swaps_to_arrange_a_binary_grid.py +84 -0
- pydsa/algorithms/arrays/minimum_swaps_to_avoid_forbidden_values.py +307 -0
- pydsa/algorithms/arrays/minimum_swaps_to_group_all_1s_together_ii.py +64 -0
- pydsa/algorithms/arrays/minimum_swaps_to_sort_by_digit_sum.py +80 -0
- pydsa/algorithms/arrays/minimum_time_to_make_array_sum_at_most_x.py +260 -0
- pydsa/algorithms/arrays/minimum_time_to_make_rope_colorful.py +50 -0
- pydsa/algorithms/arrays/minimum_time_to_repair_cars.py +68 -0
- pydsa/algorithms/arrays/minimum_total_cost_to_make_arrays_unequal.py +68 -0
- pydsa/algorithms/arrays/minimum_total_distance_traveled.py +257 -0
- pydsa/algorithms/arrays/minimum_unlocked_indices_to_sort_nums.py +253 -0
- pydsa/algorithms/arrays/minimum_value_to_get_positive_step_by_step_sum.py +46 -0
- pydsa/algorithms/arrays/missing_number.py +43 -0
- pydsa/algorithms/arrays/missing_ranges.py +64 -0
- pydsa/algorithms/arrays/modify_columns.py +42 -0
- pydsa/algorithms/arrays/modify_the_matrix.py +49 -0
- pydsa/algorithms/arrays/monotonic_array.py +52 -0
- pydsa/algorithms/arrays/most_beautiful_item_for_each_query.py +100 -0
- pydsa/algorithms/arrays/most_common_course_pairs.py +58 -0
- pydsa/algorithms/arrays/most_expensive_item_that_can_not_be_bought.py +50 -0
- pydsa/algorithms/arrays/most_frequent_even_element.py +56 -0
- pydsa/algorithms/arrays/most_frequent_ids.py +51 -0
- pydsa/algorithms/arrays/most_frequent_number_following_key_in_an_array.py +62 -0
- pydsa/algorithms/arrays/most_popular_video_creator.py +46 -0
- pydsa/algorithms/arrays/most_visited_sector_in_a_circular_track.py +71 -0
- pydsa/algorithms/arrays/movement_of_robots.py +201 -0
- pydsa/algorithms/arrays/n_repeated_element_in_size_2n_array.py +42 -0
- pydsa/algorithms/arrays/neither_minimum_nor_maximum.py +48 -0
- pydsa/algorithms/arrays/nested_array_generator.py +40 -0
- pydsa/algorithms/arrays/next_permutation.py +75 -0
- pydsa/algorithms/arrays/npv_queries.py +65 -0
- pydsa/algorithms/arrays/number_of_accounts_that_did_not_stream.py +44 -0
- pydsa/algorithms/arrays/number_of_adjacent_elements_with_the_same_color.py +40 -0
- pydsa/algorithms/arrays/number_of_arithmetic_triplets.py +45 -0
- pydsa/algorithms/arrays/number_of_black_blocks.py +51 -0
- pydsa/algorithms/arrays/number_of_distinct_averages.py +50 -0
- pydsa/algorithms/arrays/number_of_employees_who_met_the_target.py +41 -0
- pydsa/algorithms/arrays/number_of_equal_numbers_blocks.py +49 -0
- pydsa/algorithms/arrays/number_of_equivalent_domino_pairs.py +54 -0
- pydsa/algorithms/arrays/number_of_excellent_pairs.py +67 -0
- pydsa/algorithms/arrays/number_of_flowers_in_full_bloom.py +59 -0
- pydsa/algorithms/arrays/number_of_good_pairs.py +47 -0
- pydsa/algorithms/arrays/number_of_laser_beams_in_a_bank.py +49 -0
- pydsa/algorithms/arrays/number_of_pairs_after_increment.py +116 -0
- pydsa/algorithms/arrays/number_of_pairs_of_interchangeable_rectangles.py +52 -0
- pydsa/algorithms/arrays/number_of_pairs_satisfying_inequality.py +195 -0
- pydsa/algorithms/arrays/number_of_rectangles_that_can_form_the_largest_square.py +42 -0
- pydsa/algorithms/arrays/number_of_senior_citizens.py +40 -0
- pydsa/algorithms/arrays/number_of_students_homework_time.py +43 -0
- pydsa/algorithms/arrays/number_of_subarrays_having_even_product.py +56 -0
- pydsa/algorithms/arrays/number_of_subarrays_that_match_a_pattern_i.py +76 -0
- pydsa/algorithms/arrays/number_of_subarrays_that_match_a_pattern_ii.py +79 -0
- pydsa/algorithms/arrays/number_of_subarrays_with_and_value_of_k.py +59 -0
- pydsa/algorithms/arrays/number_of_subarrays_with_gcd_equal_to_k.py +63 -0
- pydsa/algorithms/arrays/number_of_subarrays_with_lcm_equal_to_k.py +68 -0
- pydsa/algorithms/arrays/number_of_subarrays_with_odd_sum.py +67 -0
- pydsa/algorithms/arrays/number_of_times_a_driver_was_a_passenger.py +148 -0
- pydsa/algorithms/arrays/number_of_unequal_triplets_in_array.py +88 -0
- pydsa/algorithms/arrays/number_of_unique_categories.py +37 -0
- pydsa/algorithms/arrays/number_of_unique_subjects_taught_by_each_teacher.py +62 -0
- pydsa/algorithms/arrays/number_of_visible_people_in_a_queue.py +62 -0
- pydsa/algorithms/arrays/number_of_ways_to_reach_target.py +66 -0
- pydsa/algorithms/arrays/number_of_ways_to_select_buildings.py +55 -0
- pydsa/algorithms/arrays/number_of_ways_to_separate_numbers.py +300 -0
- pydsa/algorithms/arrays/number_of_ways_to_split_array.py +48 -0
- pydsa/algorithms/arrays/number_of_zero_filled_subarrays.py +50 -0
- pydsa/algorithms/arrays/odd_and_even_transactions.py +44 -0
- pydsa/algorithms/arrays/once_twice.py +46 -0
- pydsa/algorithms/arrays/order_two_columns_independently.py +55 -0
- pydsa/algorithms/arrays/orders_with_maximum_quantity_above_average.py +48 -0
- pydsa/algorithms/arrays/pairs_of_songs_with_total_durations_divisible_by_60.py +51 -0
- pydsa/algorithms/arrays/parallel_execution_of_promises.py +58 -0
- pydsa/algorithms/arrays/partition_array_according_to_given_pivot.py +52 -0
- pydsa/algorithms/arrays/partition_array_into_disjoint_intervals.py +124 -0
- pydsa/algorithms/arrays/partition_array_into_three_parts_with_equal_sum.py +58 -0
- pydsa/algorithms/arrays/partition_array_such_that_maximum_difference_is_k.py +50 -0
- pydsa/algorithms/arrays/path_crossing.py +61 -0
- pydsa/algorithms/arrays/patients_with_a_condition.py +57 -0
- pydsa/algorithms/arrays/peaks_in_array.py +57 -0
- pydsa/algorithms/arrays/peeking_iterator.py +99 -0
- pydsa/algorithms/arrays/plates_between_candles.py +66 -0
- pydsa/algorithms/arrays/plus_one.py +31 -0
- pydsa/algorithms/arrays/points_that_intersect_with_cars.py +70 -0
- pydsa/algorithms/arrays/popularity_percentage.py +52 -0
- pydsa/algorithms/arrays/pour_water.py +266 -0
- pydsa/algorithms/arrays/power_of_heroes.py +82 -0
- pydsa/algorithms/arrays/power_update_after_kth_largest_insertion_i.py +48 -0
- pydsa/algorithms/arrays/power_update_after_kth_largest_insertion_ii.py +77 -0
- pydsa/algorithms/arrays/premier_league_table_ranking.py +31 -0
- pydsa/algorithms/arrays/premier_league_table_ranking_ii.py +67 -0
- pydsa/algorithms/arrays/premier_league_table_ranking_iii.py +82 -0
- pydsa/algorithms/arrays/primary_department_for_each_employee.py +56 -0
- pydsa/algorithms/arrays/prime_in_diagonal.py +75 -0
- pydsa/algorithms/arrays/prime_subtraction_operation.py +79 -0
- pydsa/algorithms/arrays/product_of_array_except_self.py +54 -0
- pydsa/algorithms/arrays/product_of_the_last_k_numbers.py +87 -0
- pydsa/algorithms/arrays/product_of_two_run_length_encoded_arrays.py +67 -0
- pydsa/algorithms/arrays/product_sales_analysis_iv.py +67 -0
- pydsa/algorithms/arrays/product_sales_analysis_v.py +58 -0
- pydsa/algorithms/arrays/products_price_for_each_store.py +86 -0
- pydsa/algorithms/arrays/put_boxes_into_the_warehouse_i.py +36 -0
- pydsa/algorithms/arrays/put_boxes_into_the_warehouse_ii.py +130 -0
- pydsa/algorithms/arrays/put_marbles_in_bags.py +49 -0
- pydsa/algorithms/arrays/queens_that_can_attack_the_king.py +69 -0
- pydsa/algorithms/arrays/queries_on_a_permutation_with_key.py +58 -0
- pydsa/algorithms/arrays/query_batching.py +54 -0
- pydsa/algorithms/arrays/random_pick_index.py +69 -0
- pydsa/algorithms/arrays/range_addition.py +49 -0
- pydsa/algorithms/arrays/range_frequency_queries.py +78 -0
- pydsa/algorithms/arrays/range_product_queries_of_powers.py +68 -0
- pydsa/algorithms/arrays/range_sum_query_2d_immutable.py +93 -0
- pydsa/algorithms/arrays/range_sum_query_2d_mutable.py +135 -0
- pydsa/algorithms/arrays/range_sum_query_immutable.py +71 -0
- pydsa/algorithms/arrays/range_sum_query_mutable.py +105 -0
- pydsa/algorithms/arrays/rank_transform_of_a_matrix.py +60 -0
- pydsa/algorithms/arrays/rank_transform_of_an_array.py +40 -0
- pydsa/algorithms/arrays/rearrange_array_elements_by_sign.py +55 -0
- pydsa/algorithms/arrays/rearrange_array_to_maximize_prefix_score.py +56 -0
- pydsa/algorithms/arrays/rearrange_products_table.py +64 -0
- pydsa/algorithms/arrays/rearranging_fruits.py +83 -0
- pydsa/algorithms/arrays/recover_the_original_array.py +308 -0
- pydsa/algorithms/arrays/reduction_operations_to_make_the_array_elements_equal.py +29 -0
- pydsa/algorithms/arrays/relative_ranks.py +58 -0
- pydsa/algorithms/arrays/relative_sort_array.py +57 -0
- pydsa/algorithms/arrays/remove_all_ones_with_row_and_column_flips.py +62 -0
- pydsa/algorithms/arrays/remove_one_element_to_make_the_array_strictly_increasing.py +63 -0
- pydsa/algorithms/arrays/removing_minimum_and_maximum_from_array.py +249 -0
- pydsa/algorithms/arrays/rename_columns.py +59 -0
- pydsa/algorithms/arrays/replace_elements_greatest_right.py +53 -0
- pydsa/algorithms/arrays/replace_elements_in_an_array.py +39 -0
- pydsa/algorithms/arrays/replace_employee_id_with_the_unique_identifier.py +42 -0
- pydsa/algorithms/arrays/replace_non_coprime_numbers_in_array.py +52 -0
- pydsa/algorithms/arrays/reshape_data_concatenate.py +47 -0
- pydsa/algorithms/arrays/reshape_data_melt.py +48 -0
- pydsa/algorithms/arrays/reshape_data_pivot.py +73 -0
- pydsa/algorithms/arrays/reshape_the_matrix.py +58 -0
- pydsa/algorithms/arrays/restaurant_growth.py +46 -0
- pydsa/algorithms/arrays/restore_the_array.py +86 -0
- pydsa/algorithms/arrays/restore_the_array_from_adjacent_pairs.py +75 -0
- pydsa/algorithms/arrays/reverse_k_subarrays.py +58 -0
- pydsa/algorithms/arrays/reward_top_k_students.py +54 -0
- pydsa/algorithms/arrays/richest_customer_wealth.py +41 -0
- pydsa/algorithms/arrays/rings_and_rods.py +50 -0
- pydsa/algorithms/arrays/rle_iterator.py +75 -0
- pydsa/algorithms/arrays/rolling_average_steps.py +50 -0
- pydsa/algorithms/arrays/rotate_array.py +58 -0
- pydsa/algorithms/arrays/rotate_image.py +48 -0
- pydsa/algorithms/arrays/rotate_non_negative_elements.py +65 -0
- pydsa/algorithms/arrays/rotating_the_box.py +63 -0
- pydsa/algorithms/arrays/row_with_maximum_ones.py +48 -0
- pydsa/algorithms/arrays/running_sum_of_1d_array.py +39 -0
- pydsa/algorithms/arrays/sales_analysis_i.py +60 -0
- pydsa/algorithms/arrays/sales_analysis_ii.py +60 -0
- pydsa/algorithms/arrays/sales_analysis_iii.py +72 -0
- pydsa/algorithms/arrays/sales_by_day_of_the_week.py +54 -0
- pydsa/algorithms/arrays/score_validator.py +48 -0
- pydsa/algorithms/arrays/seasonal_sales_analysis.py +55 -0
- pydsa/algorithms/arrays/second_day_verification.py +47 -0
- pydsa/algorithms/arrays/select_data.py +39 -0
- pydsa/algorithms/arrays/sellers_with_no_sales.py +46 -0
- pydsa/algorithms/arrays/separate_black_and_white_balls.py +50 -0
- pydsa/algorithms/arrays/separate_the_digits_in_an_array.py +35 -0
- pydsa/algorithms/arrays/set_matrix_zeroes.py +74 -0
- pydsa/algorithms/arrays/set_mismatch.py +78 -0
- pydsa/algorithms/arrays/shift_2d_grid.py +55 -0
- pydsa/algorithms/arrays/shortest_distance_to_a_character.py +50 -0
- pydsa/algorithms/arrays/shortest_subarray_to_be_removed_to_make_array_sorted.py +70 -0
- pydsa/algorithms/arrays/shortest_subarray_with_or_at_least_k_i.py +62 -0
- pydsa/algorithms/arrays/shortest_subarray_with_or_at_least_k_ii.py +63 -0
- pydsa/algorithms/arrays/shortest_unsorted_continuous_subarray.py +76 -0
- pydsa/algorithms/arrays/shortest_word_distance.py +54 -0
- pydsa/algorithms/arrays/shortest_word_distance_ii.py +88 -0
- pydsa/algorithms/arrays/shortest_word_distance_iii.py +79 -0
- pydsa/algorithms/arrays/shuffle_an_array.py +98 -0
- pydsa/algorithms/arrays/shuffle_the_array.py +39 -0
- pydsa/algorithms/arrays/simple_bank_system.py +90 -0
- pydsa/algorithms/arrays/slowest_key.py +60 -0
- pydsa/algorithms/arrays/smallest_absent_positive_greater_than_average.py +57 -0
- pydsa/algorithms/arrays/smallest_index_with_equal_value.py +37 -0
- pydsa/algorithms/arrays/smallest_missing_non_negative_integer_after_operations.py +47 -0
- pydsa/algorithms/arrays/smallest_pair_with_different_frequencies.py +77 -0
- pydsa/algorithms/arrays/smallest_rotation_with_highest_score.py +115 -0
- pydsa/algorithms/arrays/smallest_stable_index_i.py +47 -0
- pydsa/algorithms/arrays/smallest_stable_index_ii.py +59 -0
- pydsa/algorithms/arrays/snail_traversal.py +65 -0
- pydsa/algorithms/arrays/snaps_analysis.py +70 -0
- pydsa/algorithms/arrays/sort_an_array.py +71 -0
- pydsa/algorithms/arrays/sort_array_by_absolute_value.py +40 -0
- pydsa/algorithms/arrays/sort_array_by_increasing_frequency.py +39 -0
- pydsa/algorithms/arrays/sort_array_by_moving_items_to_empty_space.py +105 -0
- pydsa/algorithms/arrays/sort_by.py +60 -0
- pydsa/algorithms/arrays/sort_colors.py +55 -0
- pydsa/algorithms/arrays/sort_even_and_odd_indices_independently.py +58 -0
- pydsa/algorithms/arrays/sort_features_by_popularity.py +53 -0
- pydsa/algorithms/arrays/sort_matrix_by_diagonals.py +62 -0
- pydsa/algorithms/arrays/sort_the_jumbled_numbers.py +55 -0
- pydsa/algorithms/arrays/sort_the_matrix_diagonally.py +44 -0
- pydsa/algorithms/arrays/sort_the_olympic_table.py +68 -0
- pydsa/algorithms/arrays/sort_the_people.py +41 -0
- pydsa/algorithms/arrays/sort_the_students_by_their_kth_score.py +52 -0
- pydsa/algorithms/arrays/sort_threats_by_severity_and_exploitability.py +53 -0
- pydsa/algorithms/arrays/sorting_three_groups.py +69 -0
- pydsa/algorithms/arrays/special-positions-in-a-binary-matrix.py +62 -0
- pydsa/algorithms/arrays/special_array_i.py +69 -0
- pydsa/algorithms/arrays/special_array_ii.py +63 -0
- pydsa/algorithms/arrays/special_array_with_x_elements_greater_than_or_equal_x.py +51 -0
- pydsa/algorithms/arrays/spiral_matrix.py +67 -0
- pydsa/algorithms/arrays/spiral_matrix_ii.py +72 -0
- pydsa/algorithms/arrays/spiral_matrix_iii.py +72 -0
- pydsa/algorithms/arrays/spiral_matrix_iv.py +81 -0
- pydsa/algorithms/arrays/split_and_merge_array_transformation.py +52 -0
- pydsa/algorithms/arrays/split_array_by_prime_indices.py +71 -0
- pydsa/algorithms/arrays/split_array_into_maximum_number_of_subarrays.py +37 -0
- pydsa/algorithms/arrays/split_array_with_equal_sum.py +84 -0
- pydsa/algorithms/arrays/split_the_array.py +49 -0
- pydsa/algorithms/arrays/split_the_array_to_make_coprime_products.py +132 -0
- pydsa/algorithms/arrays/split_with_minimum_sum.py +99 -0
- pydsa/algorithms/arrays/stable_subarrays_with_equal_boundary_and_interior_sum.py +106 -0
- pydsa/algorithms/arrays/stamping_the_grid.py +67 -0
- pydsa/algorithms/arrays/statistics_from_a_large_sample.py +61 -0
- pydsa/algorithms/arrays/steps_to_make_array_non_decreasing.py +246 -0
- pydsa/algorithms/arrays/subarray_sum_equals_k.py +50 -0
- pydsa/algorithms/arrays/subarray_sums_divisible_by_k.py +55 -0
- pydsa/algorithms/arrays/subarray_with_elements_greater_than_varying_threshold.py +82 -0
- pydsa/algorithms/arrays/subarrays_with_xor_at_least_k.py +123 -0
- pydsa/algorithms/arrays/subrectangle_queries.py +84 -0
- pydsa/algorithms/arrays/subsequence_of_size_k_with_the_largest_even_sum.py +89 -0
- pydsa/algorithms/arrays/subsequence_with_the_minimum_score.py +101 -0
- pydsa/algorithms/arrays/successful_pairs_of_spells_and_potions.py +64 -0
- pydsa/algorithms/arrays/sum-of-all-odd-length-subarrays.py +52 -0
- pydsa/algorithms/arrays/sum_in_a_matrix.py +33 -0
- pydsa/algorithms/arrays/sum_of_absolute_differences_in_a_sorted_array.py +47 -0
- pydsa/algorithms/arrays/sum_of_beauty_in_the_array.py +66 -0
- pydsa/algorithms/arrays/sum_of_consecutive_subarrays.py +48 -0
- pydsa/algorithms/arrays/sum_of_elements_with_frequency_divisible_by_k.py +54 -0
- pydsa/algorithms/arrays/sum_of_even_numbers_after_queries.py +49 -0
- pydsa/algorithms/arrays/sum_of_imbalance_numbers_of_all_subarrays.py +82 -0
- pydsa/algorithms/arrays/sum_of_increasing_product_blocks.py +76 -0
- pydsa/algorithms/arrays/sum_of_matrix_after_queries.py +63 -0
- pydsa/algorithms/arrays/sum_of_special_evenly_spaced_elements_in_array.py +52 -0
- pydsa/algorithms/arrays/sum_of_squares_of_special_elements.py +47 -0
- pydsa/algorithms/arrays/sum_of_subarray_ranges.py +89 -0
- pydsa/algorithms/arrays/sum_of_total_strength_of_wizards.py +372 -0
- pydsa/algorithms/arrays/sum_of_unique_elements.py +45 -0
- pydsa/algorithms/arrays/sum_of_variable_length_subarrays.py +57 -0
- pydsa/algorithms/arrays/sum_of_weighted_modes_in_subarrays.py +90 -0
- pydsa/algorithms/arrays/summary_ranges.py +54 -0
- pydsa/algorithms/arrays/suspicious_bank_accounts.py +55 -0
- pydsa/algorithms/arrays/team_dominance_by_pass_success.py +53 -0
- pydsa/algorithms/arrays/teemo_attacking.py +43 -0
- pydsa/algorithms/arrays/the-most-frequently-ordered-products-for-each-customer.py +53 -0
- pydsa/algorithms/arrays/the_category_of_each_member_in_the_store.py +72 -0
- pydsa/algorithms/arrays/the_change_in_global_rankings.py +228 -0
- pydsa/algorithms/arrays/the_employee_that_worked_on_the_longest_task.py +45 -0
- pydsa/algorithms/arrays/the_first_day_of_the_maximum_recorded_degree_in_each_city.py +47 -0
- pydsa/algorithms/arrays/the_k_weakest_rows_in_a_matrix.py +57 -0
- pydsa/algorithms/arrays/the_latest_login_in_2020.py +59 -0
- pydsa/algorithms/arrays/the_latest_time_to_catch_a_bus.py +269 -0
- pydsa/algorithms/arrays/the_most_recent_orders_for_each_product.py +57 -0
- pydsa/algorithms/arrays/the_most_recent_three_orders.py +98 -0
- pydsa/algorithms/arrays/the_number_of_passengers_in_each_bus_i.py +252 -0
- pydsa/algorithms/arrays/the_number_of_passengers_in_each_bus_ii.py +261 -0
- pydsa/algorithms/arrays/the_number_of_rich_customers.py +41 -0
- pydsa/algorithms/arrays/the_number_of_seniors_and_juniors_to_join_the_company.py +66 -0
- pydsa/algorithms/arrays/the_number_of_seniors_and_juniors_to_join_the_company_ii.py +72 -0
- pydsa/algorithms/arrays/the_number_of_users_that_are_eligible_for_discount.py +52 -0
- pydsa/algorithms/arrays/the_number_of_weak_characters_in_the_game.py +68 -0
- pydsa/algorithms/arrays/the_users_that_are_eligible_for_discount.py +46 -0
- pydsa/algorithms/arrays/the_winner_university.py +154 -0
- pydsa/algorithms/arrays/third_maximum_number.py +53 -0
- pydsa/algorithms/arrays/three_consecutive_odds.py +45 -0
- pydsa/algorithms/arrays/threshold_majority_queries.py +138 -0
- pydsa/algorithms/arrays/time_needed_to_buy_tickets.py +51 -0
- pydsa/algorithms/arrays/toeplitz_matrix.py +45 -0
- pydsa/algorithms/arrays/top_percentile_fraud.py +104 -0
- pydsa/algorithms/arrays/transform_array_by_parity.py +47 -0
- pydsa/algorithms/arrays/transform_array_to_all_equal_elements.py +50 -0
- pydsa/algorithms/arrays/transformed_array.py +63 -0
- pydsa/algorithms/arrays/transpose_file.py +36 -0
- pydsa/algorithms/arrays/transpose_matrix.py +48 -0
- pydsa/algorithms/arrays/trionic_array_i.py +65 -0
- pydsa/algorithms/arrays/trionic_array_ii.py +274 -0
- pydsa/algorithms/arrays/tuple_with_same_product.py +46 -0
- pydsa/algorithms/arrays/tweet_counts_per_frequency.py +99 -0
- pydsa/algorithms/arrays/two_furthest_houses_with_different_colors.py +85 -0
- pydsa/algorithms/arrays/two_out_of_three.py +55 -0
- pydsa/algorithms/arrays/two_sum.py +62 -0
- pydsa/algorithms/arrays/two_sum_iii_design.py +50 -0
- pydsa/algorithms/arrays/unique_number_of_occurrences.py +41 -0
- pydsa/algorithms/arrays/unique_orders_and_customers_per_month.py +73 -0
- pydsa/algorithms/arrays/unpopular_books.py +54 -0
- pydsa/algorithms/arrays/user_activities_within_time_bounds.py +52 -0
- pydsa/algorithms/arrays/users_with_two_purchases_within_seven_days.py +56 -0
- pydsa/algorithms/arrays/valid_elements_in_an_array.py +41 -0
- pydsa/algorithms/arrays/valid_mountain_array.py +60 -0
- pydsa/algorithms/arrays/valid_sudoku.py +73 -0
- pydsa/algorithms/arrays/valid_word_square.py +49 -0
- pydsa/algorithms/arrays/walking_robot_simulation.py +70 -0
- pydsa/algorithms/arrays/watering_plants.py +46 -0
- pydsa/algorithms/arrays/ways_to_make_a_fair_array.py +76 -0
- pydsa/algorithms/arrays/ways_to_split_array_into_three_subarrays.py +65 -0
- pydsa/algorithms/arrays/where_will_the_ball_fall.py +59 -0
- pydsa/algorithms/arrays/widest_pair_of_indices_with_equal_range_sum.py +87 -0
- pydsa/algorithms/arrays/widest_vertical_area_between_two_points_containing_no_points.py +44 -0
- pydsa/algorithms/arrays/wiggle_sort.py +52 -0
- pydsa/algorithms/arrays/wiggle_sort_ii.py +256 -0
- pydsa/algorithms/arrays/zero_array_transformation_i.py +54 -0
- pydsa/algorithms/arrays/zero_array_transformation_ii.py +271 -0
- pydsa/algorithms/arrays/zero_array_transformation_iii.py +215 -0
- pydsa/algorithms/arrays/zero_array_transformation_iv.py +57 -0
- pydsa/algorithms/arrays/zigzag_iterator.py +94 -0
- pydsa/algorithms/backtracking/24_game.py +71 -0
- pydsa/algorithms/backtracking/__init__.py +0 -0
- pydsa/algorithms/backtracking/additive_number.py +90 -0
- pydsa/algorithms/backtracking/allow_one_function_call.py +72 -0
- pydsa/algorithms/backtracking/android_unlock_patterns.py +76 -0
- pydsa/algorithms/backtracking/beautiful_arrangement.py +60 -0
- pydsa/algorithms/backtracking/binary_watch.py +46 -0
- pydsa/algorithms/backtracking/closest_subsequence_sum.py +88 -0
- pydsa/algorithms/backtracking/combination_sum.py +69 -0
- pydsa/algorithms/backtracking/combination_sum_ii.py +63 -0
- pydsa/algorithms/backtracking/combination_sum_iii.py +57 -0
- pydsa/algorithms/backtracking/combinations.py +53 -0
- pydsa/algorithms/backtracking/cracking_the_safe.py +100 -0
- pydsa/algorithms/backtracking/different_ways_to_add_parentheses.py +73 -0
- pydsa/algorithms/backtracking/expression_add_operators.py +80 -0
- pydsa/algorithms/backtracking/factor_combinations.py +58 -0
- pydsa/algorithms/backtracking/fair_distribution_of_cookies.py +68 -0
- pydsa/algorithms/backtracking/find_invalid_ip_addresses.py +66 -0
- pydsa/algorithms/backtracking/find_minimum_time_to_finish_all_jobs.py +84 -0
- pydsa/algorithms/backtracking/find_minimum_time_to_finish_all_jobs_ii.py +83 -0
- pydsa/algorithms/backtracking/flip_game_ii.py +70 -0
- pydsa/algorithms/backtracking/generalized_abbreviation.py +61 -0
- pydsa/algorithms/backtracking/generate_binary_strings_without_adjacent_zeros.py +62 -0
- pydsa/algorithms/backtracking/generate_parentheses.py +53 -0
- pydsa/algorithms/backtracking/iterator_for_combination.py +101 -0
- pydsa/algorithms/backtracking/letter_case_permutation.py +60 -0
- pydsa/algorithms/backtracking/letter_combinations_of_a_phone_number.py +72 -0
- pydsa/algorithms/backtracking/letter_tile_possibilities.py +64 -0
- pydsa/algorithms/backtracking/matchsticks_to_square.py +91 -0
- pydsa/algorithms/backtracking/maximize_grid_happiness.py +76 -0
- pydsa/algorithms/backtracking/maximum_good_people_based_on_statements.py +70 -0
- pydsa/algorithms/backtracking/maximum_length_of_a_concatenated_string_with_unique_characters.py +71 -0
- pydsa/algorithms/backtracking/maximum_requests_without_violating_the_limit.py +67 -0
- pydsa/algorithms/backtracking/maximum_score_words_formed_by_letters.py +95 -0
- pydsa/algorithms/backtracking/min_flips_zero_matrix.py +93 -0
- pydsa/algorithms/backtracking/minimum_moves_to_get_a_peaceful_board.py +90 -0
- pydsa/algorithms/backtracking/minimum_unique_word_abbreviation.py +109 -0
- pydsa/algorithms/backtracking/n_queens.py +65 -0
- pydsa/algorithms/backtracking/n_queens_ii.py +135 -0
- pydsa/algorithms/backtracking/non_decreasing_subsequences.py +61 -0
- pydsa/algorithms/backtracking/number_of_squareful_arrays.py +74 -0
- pydsa/algorithms/backtracking/numbers_with_same_consecutive_differences.py +61 -0
- pydsa/algorithms/backtracking/optimal_account_balancing.py +73 -0
- pydsa/algorithms/backtracking/palindrome_partitioning.py +62 -0
- pydsa/algorithms/backtracking/palindrome_permutation_ii.py +80 -0
- pydsa/algorithms/backtracking/partition_to_k_equal_sum_subsets.py +92 -0
- pydsa/algorithms/backtracking/path_with_maximum_gold.py +67 -0
- pydsa/algorithms/backtracking/permutations.py +55 -0
- pydsa/algorithms/backtracking/permutations_ii.py +63 -0
- pydsa/algorithms/backtracking/permutations_iii.py +109 -0
- pydsa/algorithms/backtracking/permutations_iv.py +62 -0
- pydsa/algorithms/backtracking/pyramid_transition_matrix.py +71 -0
- pydsa/algorithms/backtracking/remove_invalid_parentheses.py +86 -0
- pydsa/algorithms/backtracking/restore_ip_addresses.py +88 -0
- pydsa/algorithms/backtracking/special_permutations.py +92 -0
- pydsa/algorithms/backtracking/split_array_into_fibonacci_sequence.py +102 -0
- pydsa/algorithms/backtracking/splitting_a_string_into_descending_consecutive_values.py +44 -0
- pydsa/algorithms/backtracking/stepping_numbers.py +73 -0
- pydsa/algorithms/backtracking/strobogrammatic_number_ii.py +72 -0
- pydsa/algorithms/backtracking/strobogrammatic_number_iii.py +83 -0
- pydsa/algorithms/backtracking/subsets.py +72 -0
- pydsa/algorithms/backtracking/subsets_ii.py +55 -0
- pydsa/algorithms/backtracking/sudoku_solver.py +82 -0
- pydsa/algorithms/backtracking/synonymous_sentences.py +73 -0
- pydsa/algorithms/backtracking/the_knights_tour.py +91 -0
- pydsa/algorithms/backtracking/the_number_of_beautiful_subsets.py +142 -0
- pydsa/algorithms/backtracking/tiling_a_rectangle_with_the_fewest_squares.py +109 -0
- pydsa/algorithms/backtracking/unique_paths_iii.py +85 -0
- pydsa/algorithms/backtracking/verbal_arithmetic_puzzle.py +181 -0
- pydsa/algorithms/backtracking/word_break_ii.py +75 -0
- pydsa/algorithms/backtracking/word_pattern_ii.py +216 -0
- pydsa/algorithms/backtracking/word_search.py +81 -0
- pydsa/algorithms/backtracking/word_search_ii.py +62 -0
- pydsa/algorithms/backtracking/word_squares.py +104 -0
- pydsa/algorithms/backtracking/word_squares_ii.py +505 -0
- pydsa/algorithms/backtracking/zuma_game.py +300 -0
- pydsa/algorithms/binary_search/__init__.py +0 -0
- pydsa/algorithms/binary_search/array_upper_bound.py +50 -0
- pydsa/algorithms/binary_search/binary_search.py +45 -0
- pydsa/algorithms/binary_search/binary_searchable_numbers_in_an_unsorted_array.py +72 -0
- pydsa/algorithms/binary_search/capacity_to_ship_packages_within_d_days.py +73 -0
- pydsa/algorithms/binary_search/check_if_a_number_is_majority_element_in_a_sorted_array.py +77 -0
- pydsa/algorithms/binary_search/compare_strings_by_frequency_of_the_smallest_character.py +115 -0
- pydsa/algorithms/binary_search/count_negative_numbers_in_a_sorted_matrix.py +51 -0
- pydsa/algorithms/binary_search/count_of_range_sum.py +71 -0
- pydsa/algorithms/binary_search/cutting_ribbons.py +59 -0
- pydsa/algorithms/binary_search/divide_chocolate.py +68 -0
- pydsa/algorithms/binary_search/find_a_peak_element_ii.py +70 -0
- pydsa/algorithms/binary_search/find_first_and_last_position_of_element_in_sorted_array.py +64 -0
- pydsa/algorithms/binary_search/find_in_mountain_array.py +88 -0
- pydsa/algorithms/binary_search/find_k_closest_elements.py +59 -0
- pydsa/algorithms/binary_search/find_kth_smallest_pair_distance.py +62 -0
- pydsa/algorithms/binary_search/find_minimum_in_rotated_sorted_array.py +61 -0
- pydsa/algorithms/binary_search/find_minimum_in_rotated_sorted_array_ii.py +49 -0
- pydsa/algorithms/binary_search/find_nth_smallest_integer_with_k_one_bits.py +82 -0
- pydsa/algorithms/binary_search/find_peak_element.py +0 -0
- pydsa/algorithms/binary_search/find_smallest_letter_greater_than_target.py +54 -0
- pydsa/algorithms/binary_search/find_the_distance_value_between_two_arrays.py +56 -0
- pydsa/algorithms/binary_search/find_the_integer_added_to_array_ii.py +263 -0
- pydsa/algorithms/binary_search/find_the_median_of_the_uniqueness_array.py +94 -0
- pydsa/algorithms/binary_search/first_bad_version.py +54 -0
- pydsa/algorithms/binary_search/fixed_point.py +49 -0
- pydsa/algorithms/binary_search/guess_number_higher_or_lower.py +51 -0
- pydsa/algorithms/binary_search/guess_the_number_using_bitwise_questions_i.py +57 -0
- pydsa/algorithms/binary_search/guess_the_number_using_bitwise_questions_ii.py +78 -0
- pydsa/algorithms/binary_search/h_index_ii.py +61 -0
- pydsa/algorithms/binary_search/heaters.py +71 -0
- pydsa/algorithms/binary_search/k_th_nearest_obstacle_queries.py +83 -0
- pydsa/algorithms/binary_search/koko_eating_bananas.py +65 -0
- pydsa/algorithms/binary_search/kth_smallest_element_in_a_sorted_matrix.py +66 -0
- pydsa/algorithms/binary_search/kth_smallest_number_in_multiplication_table.py +68 -0
- pydsa/algorithms/binary_search/kth_smallest_product_of_two_sorted_arrays.py +90 -0
- pydsa/algorithms/binary_search/kth_smallest_subarray_sum.py +74 -0
- pydsa/algorithms/binary_search/limit_occurrences_in_sorted_array.py +69 -0
- pydsa/algorithms/binary_search/longest_binary_subsequence_less_than_or_equal_to_k.py +239 -0
- pydsa/algorithms/binary_search/longest_common_subpath.py +99 -0
- pydsa/algorithms/binary_search/magnetic_force_between_two_balls.py +68 -0
- pydsa/algorithms/binary_search/max_side_length_square_sum.py +77 -0
- pydsa/algorithms/binary_search/maximize_the_minimum_game_score.py +92 -0
- pydsa/algorithms/binary_search/maximize_the_minimum_powered_city.py +324 -0
- pydsa/algorithms/binary_search/maximum_average_subarray_ii.py +80 -0
- pydsa/algorithms/binary_search/maximum_building_height.py +64 -0
- pydsa/algorithms/binary_search/maximum_candies_allocated_to_k_children.py +225 -0
- pydsa/algorithms/binary_search/maximum_capacity_within_budget.py +290 -0
- pydsa/algorithms/binary_search/maximum_count_of_positive_integer_and_negative_integer.py +57 -0
- pydsa/algorithms/binary_search/maximum_number_of_removable_characters.py +298 -0
- pydsa/algorithms/binary_search/maximum_value_at_a_given_index_in_a_bounded_array.py +93 -0
- pydsa/algorithms/binary_search/median_of_a_row_wise_sorted_matrix.py +71 -0
- pydsa/algorithms/binary_search/median_of_two_sorted_arrays.py +69 -0
- pydsa/algorithms/binary_search/minimize_max_distance_to_gas_station.py +69 -0
- pydsa/algorithms/binary_search/minimize_maximum_value_in_a_grid.py +74 -0
- pydsa/algorithms/binary_search/minimize_the_maximum_adjacent_element_difference.py +300 -0
- pydsa/algorithms/binary_search/minimized_maximum_of_products_distributed_to_any_store.py +72 -0
- pydsa/algorithms/binary_search/minimum_absolute_difference_queries.py +57 -0
- pydsa/algorithms/binary_search/minimum_absolute_sum_difference.py +73 -0
- pydsa/algorithms/binary_search/minimum_capacity_box.py +70 -0
- pydsa/algorithms/binary_search/minimum_k_to_reduce_array_within_limit.py +241 -0
- pydsa/algorithms/binary_search/minimum_limit_of_balls_in_a_bag.py +46 -0
- pydsa/algorithms/binary_search/minimum_number_of_days_to_make_m_bouquets.py +74 -0
- pydsa/algorithms/binary_search/minimum_prefix_removal_to_make_array_strictly_increasing.py +83 -0
- pydsa/algorithms/binary_search/minimum_speed_to_arrive_on_time.py +90 -0
- pydsa/algorithms/binary_search/minimum_stability_factor_of_array.py +93 -0
- pydsa/algorithms/binary_search/minimum_time_to_complete_all_deliveries.py +84 -0
- pydsa/algorithms/binary_search/minimum_time_to_complete_trips.py +58 -0
- pydsa/algorithms/binary_search/minimum_time_to_eat_all_grains.py +72 -0
- pydsa/algorithms/binary_search/minimum_time_to_transport_all_individuals.py +91 -0
- pydsa/algorithms/binary_search/missing_element_in_sorted_array.py +62 -0
- pydsa/algorithms/binary_search/number_of_perfect_pairs.py +76 -0
- pydsa/algorithms/binary_search/number_of_ships_in_a_rectangle.py +88 -0
- pydsa/algorithms/binary_search/online_election.py +100 -0
- pydsa/algorithms/binary_search/online_majority_element_in_subarray.py +99 -0
- pydsa/algorithms/binary_search/peak_index_in_a_mountain_array.py +43 -0
- pydsa/algorithms/binary_search/preimage_size_of_factorial_zeroes_function.py +73 -0
- pydsa/algorithms/binary_search/query_kth_smallest_trimmed_number.py +65 -0
- pydsa/algorithms/binary_search/random_pick_with_weight.py +71 -0
- pydsa/algorithms/binary_search/reverse_pairs.py +78 -0
- pydsa/algorithms/binary_search/search_a_2d_matrix.py +63 -0
- pydsa/algorithms/binary_search/search_a_2d_matrix_ii.py +60 -0
- pydsa/algorithms/binary_search/search_in_a_sorted_array_of_unknown_size.py +67 -0
- pydsa/algorithms/binary_search/search_in_rotated_sorted_array.py +61 -0
- pydsa/algorithms/binary_search/search_in_rotated_sorted_array_ii.py +64 -0
- pydsa/algorithms/binary_search/search_insert_position.py +54 -0
- pydsa/algorithms/binary_search/separate_squares_i.py +182 -0
- pydsa/algorithms/binary_search/separate_squares_ii.py +128 -0
- pydsa/algorithms/binary_search/shortest_distance_to_target_color.py +60 -0
- pydsa/algorithms/binary_search/single_element_in_a_sorted_array.py +54 -0
- pydsa/algorithms/binary_search/smallest_divisor_threshold.py +61 -0
- pydsa/algorithms/binary_search/smallest_rectangle_enclosing_black_pixels.py +256 -0
- pydsa/algorithms/binary_search/snapshot_array.py +98 -0
- pydsa/algorithms/binary_search/split_array_largest_sum.py +72 -0
- pydsa/algorithms/binary_search/sqrt_x.py +55 -0
- pydsa/algorithms/binary_search/sum_mutated_array_closest.py +74 -0
- pydsa/algorithms/binary_search/time_based_key_value_store.py +93 -0
- pydsa/algorithms/binary_search/ugly_number_iii.py +81 -0
- pydsa/algorithms/binary_search/valid_perfect_square.py +49 -0
- pydsa/algorithms/bit_manipulation/__init__.py +0 -0
- pydsa/algorithms/bit_manipulation/binary_gap.py +51 -0
- pydsa/algorithms/bit_manipulation/binary_number_with_alternating_bits.py +45 -0
- pydsa/algorithms/bit_manipulation/bitwise_and_of_numbers_range.py +42 -0
- pydsa/algorithms/bit_manipulation/bitwise_or_of_all_subsequence_sums.py +47 -0
- pydsa/algorithms/bit_manipulation/bitwise_or_of_even_numbers_in_an_array.py +43 -0
- pydsa/algorithms/bit_manipulation/bitwise_user_permissions_analysis.py +44 -0
- pydsa/algorithms/bit_manipulation/check_if_bitwise_or_has_trailing_zeros.py +57 -0
- pydsa/algorithms/bit_manipulation/circular_permutation_in_binary_representation.py +56 -0
- pydsa/algorithms/bit_manipulation/complement_of_base_10_integer.py +57 -0
- pydsa/algorithms/bit_manipulation/construct_the_minimum_bitwise_array_i.py +227 -0
- pydsa/algorithms/bit_manipulation/construct_the_minimum_bitwise_array_ii.py +73 -0
- pydsa/algorithms/bit_manipulation/count_pairs_with_xor_in_a_range.py +108 -0
- pydsa/algorithms/bit_manipulation/count_triplets_equal_xor.py +52 -0
- pydsa/algorithms/bit_manipulation/counting_bits.py +41 -0
- pydsa/algorithms/bit_manipulation/design_bitset.py +78 -0
- pydsa/algorithms/bit_manipulation/find_maximum_balanced_xor_subarray_length.py +57 -0
- pydsa/algorithms/bit_manipulation/find_the_k_or_of_an_array.py +45 -0
- pydsa/algorithms/bit_manipulation/find_the_xor_of_numbers_which_appear_twice.py +42 -0
- pydsa/algorithms/bit_manipulation/find_xor_beauty_of_array.py +50 -0
- pydsa/algorithms/bit_manipulation/find_xor_sum_of_all_pairs_bitwise_and.py +70 -0
- pydsa/algorithms/bit_manipulation/finding_the_topic_of_each_post.py +147 -0
- pydsa/algorithms/bit_manipulation/hamming_distance.py +42 -0
- pydsa/algorithms/bit_manipulation/ip_to_cidr.py +86 -0
- pydsa/algorithms/bit_manipulation/longest_subsequence_with_non_zero_bitwise_xor.py +61 -0
- pydsa/algorithms/bit_manipulation/make_the_xor_of_all_segments_equal_to_zero.py +36 -0
- pydsa/algorithms/bit_manipulation/maximum_bitwise_and_after_increment_operations.py +304 -0
- pydsa/algorithms/bit_manipulation/maximum_bitwise_xor_after_rearrangement.py +242 -0
- pydsa/algorithms/bit_manipulation/maximum_number_that_makes_result_of_bitwise_and_zero.py +101 -0
- pydsa/algorithms/bit_manipulation/maximum_odd_binary_number.py +51 -0
- pydsa/algorithms/bit_manipulation/maximum_or.py +68 -0
- pydsa/algorithms/bit_manipulation/maximum_product_of_word_lengths.py +68 -0
- pydsa/algorithms/bit_manipulation/maximum_strong_pair_xor_i.py +58 -0
- pydsa/algorithms/bit_manipulation/maximum_strong_pair_xor_ii.py +113 -0
- pydsa/algorithms/bit_manipulation/maximum_subarray_xor_with_bounded_range.py +296 -0
- pydsa/algorithms/bit_manipulation/maximum_value_of_concatenated_binary_segments.py +66 -0
- pydsa/algorithms/bit_manipulation/maximum_xor_after_operations.py +234 -0
- pydsa/algorithms/bit_manipulation/maximum_xor_for_each_query.py +139 -0
- pydsa/algorithms/bit_manipulation/maximum_xor_of_subsequences.py +63 -0
- pydsa/algorithms/bit_manipulation/maximum_xor_of_two_numbers_in_an_array.py +76 -0
- pydsa/algorithms/bit_manipulation/maximum_xor_product.py +268 -0
- pydsa/algorithms/bit_manipulation/maximum_xor_score_subarray_queries.py +86 -0
- pydsa/algorithms/bit_manipulation/maximum_xor_with_an_element_from_array.py +98 -0
- pydsa/algorithms/bit_manipulation/minimize_or_of_remaining_elements_using_operations.py +75 -0
- pydsa/algorithms/bit_manipulation/minimum_bit_flips_to_convert_number.py +37 -0
- pydsa/algorithms/bit_manipulation/minimum_flips_to_make_a_or_b_equal_to_c.py +55 -0
- pydsa/algorithms/bit_manipulation/minimum_impossible_or.py +265 -0
- pydsa/algorithms/bit_manipulation/minimum_number_of_flips_to_reverse_binary_string.py +178 -0
- pydsa/algorithms/bit_manipulation/minimum_number_of_operations_to_make_array_xor_equal_to_k.py +51 -0
- pydsa/algorithms/bit_manipulation/neighboring_bitwise_xor.py +44 -0
- pydsa/algorithms/bit_manipulation/number_complement.py +58 -0
- pydsa/algorithms/bit_manipulation/number_of_1_bits.py +42 -0
- pydsa/algorithms/bit_manipulation/number_of_bit_changes_to_make_two_integers_equal.py +41 -0
- pydsa/algorithms/bit_manipulation/number_of_steps_to_reduce_a_number_in_binary_representation_to_one.py +53 -0
- pydsa/algorithms/bit_manipulation/number_of_unique_xor_triplets_i.py +77 -0
- pydsa/algorithms/bit_manipulation/number_of_unique_xor_triplets_ii.py +230 -0
- pydsa/algorithms/bit_manipulation/number_of_valid_words_for_each_puzzle.py +87 -0
- pydsa/algorithms/bit_manipulation/power_of_four.py +29 -0
- pydsa/algorithms/bit_manipulation/power_of_two.py +41 -0
- pydsa/algorithms/bit_manipulation/prime_number_of_set_bits_in_binary_representation.py +41 -0
- pydsa/algorithms/bit_manipulation/range_xor_queries_with_subarray_reversals.py +147 -0
- pydsa/algorithms/bit_manipulation/reverse_bits.py +44 -0
- pydsa/algorithms/bit_manipulation/single_number.py +45 -0
- pydsa/algorithms/bit_manipulation/single_number_ii.py +52 -0
- pydsa/algorithms/bit_manipulation/single_number_iii.py +53 -0
- pydsa/algorithms/bit_manipulation/sort_integers_by_the_number_of_1_bits.py +40 -0
- pydsa/algorithms/bit_manipulation/sum_of_all_subset_xor_totals.py +43 -0
- pydsa/algorithms/bit_manipulation/sum_of_two_integers.py +70 -0
- pydsa/algorithms/bit_manipulation/total_hamming_distance.py +58 -0
- pydsa/algorithms/bit_manipulation/utf8_validation.py +62 -0
- pydsa/algorithms/bit_manipulation/xor_after_range_multiplication_queries_i.py +135 -0
- pydsa/algorithms/bit_manipulation/xor_after_range_multiplication_queries_ii.py +151 -0
- pydsa/algorithms/bit_manipulation/xor_queries_of_a_subarray.py +47 -0
- pydsa/algorithms/design/__init__.py +0 -0
- pydsa/algorithms/design/throttle.py +60 -0
- pydsa/algorithms/dfs/__init__.py +0 -0
- pydsa/algorithms/dfs/length_of_longest_v_shaped_diagonal_segment.py +82 -0
- pydsa/algorithms/dp/2_keys_keyboard.py +57 -0
- pydsa/algorithms/dp/4_keys_keyboard.py +81 -0
- pydsa/algorithms/dp/__init__.py +0 -0
- pydsa/algorithms/dp/allocate_mailboxes.py +71 -0
- pydsa/algorithms/dp/arithmetic_slices.py +56 -0
- pydsa/algorithms/dp/arithmetic_slices_ii_subsequence.py +64 -0
- pydsa/algorithms/dp/best_sightseeing_pair.py +48 -0
- pydsa/algorithms/dp/best_team_with_no_conflicts.py +62 -0
- pydsa/algorithms/dp/best_time_to_buy_and_sell_stock_iii.py +58 -0
- pydsa/algorithms/dp/best_time_to_buy_and_sell_stock_iv.py +42 -0
- pydsa/algorithms/dp/best_time_to_buy_and_sell_stock_using_strategy.py +60 -0
- pydsa/algorithms/dp/best_time_to_buy_and_sell_stock_v.py +94 -0
- pydsa/algorithms/dp/best_time_to_buy_and_sell_stock_with_cooldown.py +71 -0
- pydsa/algorithms/dp/best_time_to_buy_and_sell_stock_with_transaction_fee.py +61 -0
- pydsa/algorithms/dp/binary_trees_with_factors.py +231 -0
- pydsa/algorithms/dp/bitwise_ors_of_subarrays.py +61 -0
- pydsa/algorithms/dp/bomb_enemy.py +144 -0
- pydsa/algorithms/dp/build_array_where_you_can_find_the_maximum_exactly_k_comparisons.py +276 -0
- pydsa/algorithms/dp/burst_balloons.py +67 -0
- pydsa/algorithms/dp/campus_bikes_ii.py +79 -0
- pydsa/algorithms/dp/can_i_win.py +77 -0
- pydsa/algorithms/dp/cat_and_mouse.py +101 -0
- pydsa/algorithms/dp/champagne_tower.py +100 -0
- pydsa/algorithms/dp/check_if_there_is_a_valid_parentheses_string_path.py +69 -0
- pydsa/algorithms/dp/check_if_there_is_a_valid_partition_for_the_array.py +52 -0
- pydsa/algorithms/dp/cherry_pickup.py +78 -0
- pydsa/algorithms/dp/cherry_pickup_ii.py +81 -0
- pydsa/algorithms/dp/climbing_stairs.py +55 -0
- pydsa/algorithms/dp/climbing_stairs_ii.py +61 -0
- pydsa/algorithms/dp/closest_dessert_cost.py +70 -0
- pydsa/algorithms/dp/coin_change.py +57 -0
- pydsa/algorithms/dp/coin_change_ii.py +49 -0
- pydsa/algorithms/dp/coin_path.py +301 -0
- pydsa/algorithms/dp/collecting_chocolates.py +108 -0
- pydsa/algorithms/dp/combination_sum_iv.py +52 -0
- pydsa/algorithms/dp/constrained_subsequence_sum.py +62 -0
- pydsa/algorithms/dp/constructing_two_increasing_arrays.py +66 -0
- pydsa/algorithms/dp/count_different_palindromic_subsequences.py +78 -0
- pydsa/algorithms/dp/count_k_subsequences_of_a_string_with_maximum_beauty.py +57 -0
- pydsa/algorithms/dp/count_non_decreasing_arrays_with_given_digit_sums.py +87 -0
- pydsa/algorithms/dp/count_non_decreasing_subarrays_after_k_operations.py +280 -0
- pydsa/algorithms/dp/count_number_of_balanced_permutations.py +325 -0
- pydsa/algorithms/dp/count_number_of_special_subsequences.py +71 -0
- pydsa/algorithms/dp/count_number_of_teams.py +63 -0
- pydsa/algorithms/dp/count_numbers_with_non_decreasing_digits.py +78 -0
- pydsa/algorithms/dp/count_of_integers.py +83 -0
- pydsa/algorithms/dp/count_of_sub_multisets_with_bounded_sum.py +57 -0
- pydsa/algorithms/dp/count_palindromic_subsequences.py +102 -0
- pydsa/algorithms/dp/count_partitions_with_max_min_difference_at_most_k.py +61 -0
- pydsa/algorithms/dp/count_routes_to_climb_a_rectangular_grid.py +55 -0
- pydsa/algorithms/dp/count_sequences_to_k.py +70 -0
- pydsa/algorithms/dp/count_special_subsequences.py +172 -0
- pydsa/algorithms/dp/count_square_submatrices_with_all_ones.py +63 -0
- pydsa/algorithms/dp/count_stepping_numbers_in_range.py +90 -0
- pydsa/algorithms/dp/count_the_number_of_arrays_with_k_matching_adjacent_elements.py +62 -0
- pydsa/algorithms/dp/count_the_number_of_powerful_integers.py +156 -0
- pydsa/algorithms/dp/count_the_number_of_square_free_subsets.py +111 -0
- pydsa/algorithms/dp/count_the_number_of_winning_sequences.py +108 -0
- pydsa/algorithms/dp/count_vowels_permutation.py +71 -0
- pydsa/algorithms/dp/count_ways_to_build_good_strings.py +52 -0
- pydsa/algorithms/dp/count_ways_to_build_rooms_in_an_ant_colony.py +120 -0
- pydsa/algorithms/dp/count_ways_to_make_array_with_product.py +95 -0
- pydsa/algorithms/dp/decode_ways.py +56 -0
- pydsa/algorithms/dp/decode_ways_ii.py +100 -0
- pydsa/algorithms/dp/delete_and_earn.py +63 -0
- pydsa/algorithms/dp/delete_columns_to_make_sorted_iii.py +60 -0
- pydsa/algorithms/dp/delete_operation_for_two_strings.py +56 -0
- pydsa/algorithms/dp/delivering_boxes_from_storage_to_ports.py +277 -0
- pydsa/algorithms/dp/dice_roll_simulation.py +70 -0
- pydsa/algorithms/dp/difference_between_maximum_and_minimum_price_sum.py +299 -0
- pydsa/algorithms/dp/direction_assignments_with_exactly_k_visible_people.py +269 -0
- pydsa/algorithms/dp/distinct_subsequences.py +51 -0
- pydsa/algorithms/dp/distinct_subsequences_ii.py +66 -0
- pydsa/algorithms/dp/divide_an_array_into_subarrays_with_minimum_cost_i.py +69 -0
- pydsa/algorithms/dp/divide_an_array_into_subarrays_with_minimum_cost_ii.py +108 -0
- pydsa/algorithms/dp/domino_and_tromino_tiling.py +67 -0
- pydsa/algorithms/dp/dungeon_game.py +63 -0
- pydsa/algorithms/dp/edit_distance.py +64 -0
- pydsa/algorithms/dp/egg_drop_with_2_eggs_and_n_floors.py +54 -0
- pydsa/algorithms/dp/encode_string_with_shortest_length.py +114 -0
- pydsa/algorithms/dp/extra_characters_in_a_string.py +79 -0
- pydsa/algorithms/dp/fancy_sequence.py +229 -0
- pydsa/algorithms/dp/fibonacci_number.py +50 -0
- pydsa/algorithms/dp/filling_bookcase_shelves.py +61 -0
- pydsa/algorithms/dp/find_all_good_strings.py +106 -0
- pydsa/algorithms/dp/find_all_possible_stable_binary_arrays_i.py +69 -0
- pydsa/algorithms/dp/find_all_possible_stable_binary_arrays_ii.py +129 -0
- pydsa/algorithms/dp/find_array_given_subset_sums.py +348 -0
- pydsa/algorithms/dp/find_maximum_non_decreasing_array_length.py +63 -0
- pydsa/algorithms/dp/find_maximum_removals_from_source_string.py +66 -0
- pydsa/algorithms/dp/find_maximum_value_in_a_constrained_sequence.py +71 -0
- pydsa/algorithms/dp/find_minimum_cost_to_remove_array_elements.py +66 -0
- pydsa/algorithms/dp/find_number_of_ways_to_reach_the_kth_stair.py +66 -0
- pydsa/algorithms/dp/find_the_count_of_monotonic_pairs_i.py +397 -0
- pydsa/algorithms/dp/find_the_count_of_monotonic_pairs_ii.py +255 -0
- pydsa/algorithms/dp/find_the_derangement_of_an_array.py +60 -0
- pydsa/algorithms/dp/find_the_longest_valid_obstacle_course_at_each_position.py +69 -0
- pydsa/algorithms/dp/find_the_maximum_length_of_a_good_subsequence_i.py +58 -0
- pydsa/algorithms/dp/find_the_maximum_length_of_a_good_subsequence_ii.py +211 -0
- pydsa/algorithms/dp/find_the_maximum_number_of_fruits_collected.py +154 -0
- pydsa/algorithms/dp/find_the_maximum_sequence_value_of_array.py +103 -0
- pydsa/algorithms/dp/find_the_minimum_area_to_cover_all_ones_ii.py +110 -0
- pydsa/algorithms/dp/find_the_number_of_copy_arrays.py +76 -0
- pydsa/algorithms/dp/find_the_number_of_k_even_arrays.py +95 -0
- pydsa/algorithms/dp/find_the_number_of_possible_ways_for_an_event.py +66 -0
- pydsa/algorithms/dp/find_the_original_typed_string_ii.py +45 -0
- pydsa/algorithms/dp/find_the_shortest_superstring.py +107 -0
- pydsa/algorithms/dp/find_the_shortest_superstring_ii.py +100 -0
- pydsa/algorithms/dp/find_the_sum_of_subsequence_powers.py +199 -0
- pydsa/algorithms/dp/flip_string_to_monotone_increasing.py +53 -0
- pydsa/algorithms/dp/form_largest_integer_digits_target.py +85 -0
- pydsa/algorithms/dp/freedom_trail.py +86 -0
- pydsa/algorithms/dp/frequencies_of_shortest_supersequences.py +76 -0
- pydsa/algorithms/dp/friday_purchase_iii.py +61 -0
- pydsa/algorithms/dp/frog_jump.py +63 -0
- pydsa/algorithms/dp/greatest_sum_divisible_by_three.py +57 -0
- pydsa/algorithms/dp/guess_number_higher_or_lower_ii.py +59 -0
- pydsa/algorithms/dp/handshakes_that_dont_cross.py +54 -0
- pydsa/algorithms/dp/house_robber.py +44 -0
- pydsa/algorithms/dp/house_robber_ii.py +54 -0
- pydsa/algorithms/dp/house_robber_iii.py +81 -0
- pydsa/algorithms/dp/house_robber_iv.py +232 -0
- pydsa/algorithms/dp/house_robber_v.py +78 -0
- pydsa/algorithms/dp/integer_break.py +58 -0
- pydsa/algorithms/dp/interleaving_string.py +61 -0
- pydsa/algorithms/dp/inverse_coin_change.py +68 -0
- pydsa/algorithms/dp/jump_game_ix.py +59 -0
- pydsa/algorithms/dp/jump_game_v.py +69 -0
- pydsa/algorithms/dp/jump_game_vi.py +59 -0
- pydsa/algorithms/dp/jump_game_vii.py +205 -0
- pydsa/algorithms/dp/k_concatenation_maximum_sum.py +78 -0
- pydsa/algorithms/dp/k_inverse_pairs_array.py +66 -0
- pydsa/algorithms/dp/knight_dialer.py +89 -0
- pydsa/algorithms/dp/knight_probability_in_chessboard.py +60 -0
- pydsa/algorithms/dp/largest_1_bordered_square.py +72 -0
- pydsa/algorithms/dp/largest_divisible_subset.py +65 -0
- pydsa/algorithms/dp/largest_multiple_of_three.py +88 -0
- pydsa/algorithms/dp/largest_plus_sign.py +77 -0
- pydsa/algorithms/dp/largest_sum_of_averages.py +70 -0
- pydsa/algorithms/dp/last_stone_weight_ii.py +58 -0
- pydsa/algorithms/dp/least_operators_to_express_number.py +85 -0
- pydsa/algorithms/dp/length_of_longest_fibonacci_subsequence.py +60 -0
- pydsa/algorithms/dp/length_of_the_longest_subsequence_that_sums_to_target.py +56 -0
- pydsa/algorithms/dp/longest_arithmetic_sequence_after_changing_at_most_one_element.py +172 -0
- pydsa/algorithms/dp/longest_arithmetic_subsequence.py +57 -0
- pydsa/algorithms/dp/longest_arithmetic_subsequence_of_given_difference.py +52 -0
- pydsa/algorithms/dp/longest_common_subsequence.py +50 -0
- pydsa/algorithms/dp/longest_common_subsequence_between_sorted_arrays.py +51 -0
- pydsa/algorithms/dp/longest_ideal_subsequence.py +59 -0
- pydsa/algorithms/dp/longest_increasing_path_in_a_matrix.py +68 -0
- pydsa/algorithms/dp/longest_increasing_subsequence.py +62 -0
- pydsa/algorithms/dp/longest_increasing_subsequence_ii.py +97 -0
- pydsa/algorithms/dp/longest_line_of_consecutive_one_in_matrix.py +66 -0
- pydsa/algorithms/dp/longest_palindromic_subsequence.py +62 -0
- pydsa/algorithms/dp/longest_palindromic_subsequence_after_at_most_k_operations.py +75 -0
- pydsa/algorithms/dp/longest_palindromic_subsequence_ii.py +118 -0
- pydsa/algorithms/dp/longest_palindromic_substring.py +72 -0
- pydsa/algorithms/dp/longest_strictly_increasing_subsequence_with_non_zero_bitwise_and.py +112 -0
- pydsa/algorithms/dp/longest_string_chain.py +57 -0
- pydsa/algorithms/dp/longest_subsequence_with_decreasing_adjacent_difference.py +74 -0
- pydsa/algorithms/dp/longest_unequal_adjacent_groups_subsequence_ii.py +50 -0
- pydsa/algorithms/dp/longest_valid_parentheses.py +59 -0
- pydsa/algorithms/dp/make_array_non_decreasing.py +63 -0
- pydsa/algorithms/dp/make_array_non_decreasing_or_non_increasing.py +70 -0
- pydsa/algorithms/dp/make_array_strictly_increasing.py +192 -0
- pydsa/algorithms/dp/max_dot_product_two_subsequences.py +57 -0
- pydsa/algorithms/dp/max_sum_of_rectangle_no_larger_than_k.py +77 -0
- pydsa/algorithms/dp/maximal_rectangle.py +81 -0
- pydsa/algorithms/dp/maximal_square.py +37 -0
- pydsa/algorithms/dp/maximize_amount_after_two_days_of_conversions.py +74 -0
- pydsa/algorithms/dp/maximize_cyclic_partition_score.py +82 -0
- pydsa/algorithms/dp/maximize_happiness_of_selected_children.py +73 -0
- pydsa/algorithms/dp/maximize_number_of_subsequences_in_a_string.py +173 -0
- pydsa/algorithms/dp/maximize_palindrome_length_from_subsequences.py +115 -0
- pydsa/algorithms/dp/maximize_score_after_n_operations.py +262 -0
- pydsa/algorithms/dp/maximize_subarray_sum_after_removing_all_occurrences_of_one_element.py +70 -0
- pydsa/algorithms/dp/maximize_the_profit_as_the_salesman.py +61 -0
- pydsa/algorithms/dp/maximize_total_cost_of_alternating_subarrays.py +117 -0
- pydsa/algorithms/dp/maximize_value_of_function_in_a_ball_passing_game.py +84 -0
- pydsa/algorithms/dp/maximize_win_from_two_segments.py +73 -0
- pydsa/algorithms/dp/maximum-non-negative-product-in-a-matrix.py +81 -0
- pydsa/algorithms/dp/maximum_alternating_subarray_sum.py +68 -0
- pydsa/algorithms/dp/maximum_alternating_subsequence_sum.py +59 -0
- pydsa/algorithms/dp/maximum_alternating_sum_of_squares.py +67 -0
- pydsa/algorithms/dp/maximum_amount_of_money_robot_can_earn.py +68 -0
- pydsa/algorithms/dp/maximum_array_hopping_score_ii.py +71 -0
- pydsa/algorithms/dp/maximum_balanced_shipments.py +289 -0
- pydsa/algorithms/dp/maximum_balanced_subsequence_sum.py +154 -0
- pydsa/algorithms/dp/maximum_calories_burnt_from_jumps.py +135 -0
- pydsa/algorithms/dp/maximum_coin_collection.py +71 -0
- pydsa/algorithms/dp/maximum_compatibility_score_sum.py +239 -0
- pydsa/algorithms/dp/maximum_cost_of_trip_with_k_highways.py +65 -0
- pydsa/algorithms/dp/maximum_earnings_from_taxi.py +80 -0
- pydsa/algorithms/dp/maximum_elegance_of_a_k_length_subsequence.py +64 -0
- pydsa/algorithms/dp/maximum_energy_boost_from_two_drinks.py +64 -0
- pydsa/algorithms/dp/maximum_length_of_repeated_subarray.py +57 -0
- pydsa/algorithms/dp/maximum_linear_stock_score.py +35 -0
- pydsa/algorithms/dp/maximum_multiplication_score.py +77 -0
- pydsa/algorithms/dp/maximum_number_of_books_you_can_take.py +76 -0
- pydsa/algorithms/dp/maximum_number_of_events_that_can_be_attended_ii.py +63 -0
- pydsa/algorithms/dp/maximum_number_of_groups_getting_fresh_donuts.py +214 -0
- pydsa/algorithms/dp/maximum_number_of_groups_with_increasing_length.py +92 -0
- pydsa/algorithms/dp/maximum_number_of_jumps_to_reach_the_last_index.py +65 -0
- pydsa/algorithms/dp/maximum_number_of_points_with_cost.py +77 -0
- pydsa/algorithms/dp/maximum_partition_factor.py +68 -0
- pydsa/algorithms/dp/maximum_path_intersection_sum_in_a_grid.py +98 -0
- pydsa/algorithms/dp/maximum_path_score_in_a_grid.py +58 -0
- pydsa/algorithms/dp/maximum_points_in_an_archery_competition.py +91 -0
- pydsa/algorithms/dp/maximum_points_tourist_can_earn.py +112 -0
- pydsa/algorithms/dp/maximum_product_of_subsequences_with_an_alternating_sum_equal_to_k.py +91 -0
- pydsa/algorithms/dp/maximum_product_of_the_length_of_two_palindromic_subsequences.py +66 -0
- pydsa/algorithms/dp/maximum_product_subarray.py +58 -0
- pydsa/algorithms/dp/maximum_profit_from_trading_stocks.py +51 -0
- pydsa/algorithms/dp/maximum_profit_from_trading_stocks_with_discounts.py +103 -0
- pydsa/algorithms/dp/maximum_profit_in_job_scheduling.py +59 -0
- pydsa/algorithms/dp/maximum_score_from_performing_multiplication_operations.py +64 -0
- pydsa/algorithms/dp/maximum_score_of_non_overlapping_intervals.py +74 -0
- pydsa/algorithms/dp/maximum_square_area_by_removing_fences_from_a_field.py +59 -0
- pydsa/algorithms/dp/maximum_strength_of_a_group.py +84 -0
- pydsa/algorithms/dp/maximum_strength_of_k_disjoint_subarrays.py +75 -0
- pydsa/algorithms/dp/maximum_strictly_increasing_cells_in_a_matrix.py +65 -0
- pydsa/algorithms/dp/maximum_students_taking_exam.py +71 -0
- pydsa/algorithms/dp/maximum_subarray.py +48 -0
- pydsa/algorithms/dp/maximum_subarray_sum_after_one_operation.py +63 -0
- pydsa/algorithms/dp/maximum_subarray_sum_with_one_deletion.py +68 -0
- pydsa/algorithms/dp/maximum_sum_of_3_non_overlapping_subarrays.py +86 -0
- pydsa/algorithms/dp/maximum_sum_of_alternating_subsequence_with_distance_at_least_k.py +116 -0
- pydsa/algorithms/dp/maximum_sum_of_subsequence_with_non_adjacent_elements.py +62 -0
- pydsa/algorithms/dp/maximum_sum_score_of_array.py +85 -0
- pydsa/algorithms/dp/maximum_total_damage_with_spell_casting.py +241 -0
- pydsa/algorithms/dp/maximum_total_from_optimal_activation_order.py +65 -0
- pydsa/algorithms/dp/maximum_total_reward_using_operations_i.py +67 -0
- pydsa/algorithms/dp/maximum_total_reward_using_operations_ii.py +72 -0
- pydsa/algorithms/dp/maximum_total_subarray_value_i.py +51 -0
- pydsa/algorithms/dp/maximum_total_subarray_value_ii.py +94 -0
- pydsa/algorithms/dp/maximum_total_sum_with_threshold_constraints.py +264 -0
- pydsa/algorithms/dp/maximum_trailing_zeros_in_a_cornered_path.py +115 -0
- pydsa/algorithms/dp/maximum_vacation_days.py +153 -0
- pydsa/algorithms/dp/maximum_value_of_k_coins_from_piles.py +63 -0
- pydsa/algorithms/dp/maximum_weight_in_two_bags.py +76 -0
- pydsa/algorithms/dp/memoize.py +88 -0
- pydsa/algorithms/dp/memoize_ii.py +79 -0
- pydsa/algorithms/dp/merge_operations_for_minimum_travel_time.py +63 -0
- pydsa/algorithms/dp/min_cost_climbing_stairs.py +51 -0
- pydsa/algorithms/dp/min_falling_path_sum_ii.py +69 -0
- pydsa/algorithms/dp/min_max_game.py +158 -0
- pydsa/algorithms/dp/minimum_array_sum.py +122 -0
- pydsa/algorithms/dp/minimum_ascii_delete_sum_for_two_strings.py +61 -0
- pydsa/algorithms/dp/minimum_cost_for_cutting_cake_i.py +171 -0
- pydsa/algorithms/dp/minimum_cost_for_cutting_cake_ii.py +82 -0
- pydsa/algorithms/dp/minimum_cost_for_tickets.py +64 -0
- pydsa/algorithms/dp/minimum_cost_good_caption.py +103 -0
- pydsa/algorithms/dp/minimum_cost_to_acquire_required_items.py +96 -0
- pydsa/algorithms/dp/minimum_cost_to_change_the_final_value_of_expression.py +96 -0
- pydsa/algorithms/dp/minimum_cost_to_cut_a_stick.py +67 -0
- pydsa/algorithms/dp/minimum_cost_to_divide_array_into_subarrays.py +53 -0
- pydsa/algorithms/dp/minimum_cost_to_merge_stones.py +81 -0
- pydsa/algorithms/dp/minimum_cost_to_partition_a_binary_string.py +121 -0
- pydsa/algorithms/dp/minimum_cost_to_reach_destination_in_time.py +215 -0
- pydsa/algorithms/dp/minimum_cost_to_separate_sentence_into_rows.py +53 -0
- pydsa/algorithms/dp/minimum_cost_to_split_into_ones.py +79 -0
- pydsa/algorithms/dp/minimum_difficulty_of_a_job_schedule.py +74 -0
- pydsa/algorithms/dp/minimum_distance_to_type_a_word_using_two_fingers.py +124 -0
- pydsa/algorithms/dp/minimum_falling_path_sum.py +62 -0
- pydsa/algorithms/dp/minimum_health_to_beat_game.py +65 -0
- pydsa/algorithms/dp/minimum_hours_of_training_to_win_a_competition.py +219 -0
- pydsa/algorithms/dp/minimum_incompatibility.py +221 -0
- pydsa/algorithms/dp/minimum_insertion_steps_to_make_a_string_palindrome.py +61 -0
- pydsa/algorithms/dp/minimum_number_of_coins_for_fruits.py +70 -0
- pydsa/algorithms/dp/minimum_number_of_coins_for_fruits_ii.py +249 -0
- pydsa/algorithms/dp/minimum_number_of_days_to_eat_n_oranges.py +84 -0
- pydsa/algorithms/dp/minimum_number_of_flips_to_make_binary_grid_palindromic_ii.py +323 -0
- pydsa/algorithms/dp/minimum_number_of_increasing_subsequence_to_be_removed.py +76 -0
- pydsa/algorithms/dp/minimum_number_of_operations_to_make_string_sorted.py +55 -0
- pydsa/algorithms/dp/minimum_number_of_people_to_teach.py +115 -0
- pydsa/algorithms/dp/minimum_number_of_removals_to_make_mountain_array.py +63 -0
- pydsa/algorithms/dp/minimum_number_of_valid_strings_to_form_target_i.py +69 -0
- pydsa/algorithms/dp/minimum_number_of_valid_strings_to_form_target_ii.py +336 -0
- pydsa/algorithms/dp/minimum_number_of_work_sessions_to_finish_the_tasks.py +72 -0
- pydsa/algorithms/dp/minimum_numbers_of_function_calls_to_make_target_array.py +247 -0
- pydsa/algorithms/dp/minimum_operations_to_form_subsequence_with_target_sum.py +54 -0
- pydsa/algorithms/dp/minimum_operations_to_make_a_subsequence.py +68 -0
- pydsa/algorithms/dp/minimum_operations_to_make_array_non_decreasing.py +71 -0
- pydsa/algorithms/dp/minimum_operations_to_make_elements_within_k_subarrays_equal.py +128 -0
- pydsa/algorithms/dp/minimum_operations_to_make_the_array_k_increasing.py +86 -0
- pydsa/algorithms/dp/minimum_pair_removal_to_sort_array_ii.py +104 -0
- pydsa/algorithms/dp/minimum_partition_score.py +72 -0
- pydsa/algorithms/dp/minimum_partition_score_ii.py +74 -0
- pydsa/algorithms/dp/minimum_path_cost_in_a_grid.py +58 -0
- pydsa/algorithms/dp/minimum_path_sum.py +59 -0
- pydsa/algorithms/dp/minimum_removals_to_achieve_target_xor.py +93 -0
- pydsa/algorithms/dp/minimum_rounds_to_complete_all_tasks.py +54 -0
- pydsa/algorithms/dp/minimum_score_triangulation_of_polygon.py +60 -0
- pydsa/algorithms/dp/minimum_sideway_jumps.py +68 -0
- pydsa/algorithms/dp/minimum_skips_to_arrive_at_meeting_on_time.py +275 -0
- pydsa/algorithms/dp/minimum_space_wasted_from_packaging.py +232 -0
- pydsa/algorithms/dp/minimum_sum_after_divisible_sum_deletions.py +134 -0
- pydsa/algorithms/dp/minimum_sum_of_values_by_dividing_array.py +42 -0
- pydsa/algorithms/dp/minimum_swaps_to_make_sequences_increasing.py +190 -0
- pydsa/algorithms/dp/minimum_total_space_wasted_with_k_resizing_operations.py +75 -0
- pydsa/algorithms/dp/minimum_white_tiles_after_covering_with_carpets.py +72 -0
- pydsa/algorithms/dp/minimum_window_subsequence.py +80 -0
- pydsa/algorithms/dp/minimum_xor_path_in_a_grid.py +69 -0
- pydsa/algorithms/dp/minimum_xor_sum_of_two_arrays.py +61 -0
- pydsa/algorithms/dp/n_th_tribonacci_number.py +54 -0
- pydsa/algorithms/dp/new_21_game.py +163 -0
- pydsa/algorithms/dp/non_negative_integers_without_consecutive_ones.py +87 -0
- pydsa/algorithms/dp/number_of_alternating_xor_partitions.py +86 -0
- pydsa/algorithms/dp/number_of_beautiful_integers_in_the_range.py +83 -0
- pydsa/algorithms/dp/number_of_beautiful_partitions.py +226 -0
- pydsa/algorithms/dp/number_of_corner_rectangles.py +59 -0
- pydsa/algorithms/dp/number_of_dice_rolls_with_target_sum.py +70 -0
- pydsa/algorithms/dp/number_of_distinct_binary_strings_after_applying_operations.py +43 -0
- pydsa/algorithms/dp/number_of_distinct_roll_sequences.py +77 -0
- pydsa/algorithms/dp/number_of_good_binary_strings.py +105 -0
- pydsa/algorithms/dp/number_of_great_partitions.py +77 -0
- pydsa/algorithms/dp/number_of_longest_increasing_subsequence.py +58 -0
- pydsa/algorithms/dp/number_of_music_playlists.py +59 -0
- pydsa/algorithms/dp/number_of_paths_with_max_score.py +134 -0
- pydsa/algorithms/dp/number_of_people_aware_of_a_secret.py +67 -0
- pydsa/algorithms/dp/number_of_sets_of_k_non_overlapping_line_segments.py +94 -0
- pydsa/algorithms/dp/number_of_smooth_descent_periods_of_a_stock.py +55 -0
- pydsa/algorithms/dp/number_of_stable_subsequences.py +62 -0
- pydsa/algorithms/dp/number_of_submatrices_that_sum_to_target.py +74 -0
- pydsa/algorithms/dp/number_of_subsequences_that_satisfy_the_given_sum_condition.py +64 -0
- pydsa/algorithms/dp/number_of_unique_good_subsequences.py +76 -0
- pydsa/algorithms/dp/number_of_ways_cutting_pizza.py +309 -0
- pydsa/algorithms/dp/number_of_ways_to_build_house_of_cards.py +119 -0
- pydsa/algorithms/dp/number_of_ways_to_build_sturdy_brick_wall.py +140 -0
- pydsa/algorithms/dp/number_of_ways_to_divide_a_long_corridor.py +139 -0
- pydsa/algorithms/dp/number_of_ways_to_earn_points.py +65 -0
- pydsa/algorithms/dp/number_of_ways_to_form_a_target_string_given_a_dictionary.py +68 -0
- pydsa/algorithms/dp/number_of_ways_to_paint_n_x_3_grid.py +113 -0
- pydsa/algorithms/dp/number_of_ways_to_paint_sheets.py +46 -0
- pydsa/algorithms/dp/number_of_ways_to_reach_a_position_after_exactly_k_steps.py +111 -0
- pydsa/algorithms/dp/number_of_ways_to_reach_destination_in_the_grid.py +57 -0
- pydsa/algorithms/dp/number_of_ways_to_rearrange_sticks_with_k_sticks_visible.py +65 -0
- pydsa/algorithms/dp/number_of_ways_to_stay_in_the_same_place_after_some_steps.py +247 -0
- pydsa/algorithms/dp/number_of_ways_to_wear_different_hats_to_each_other.py +75 -0
- pydsa/algorithms/dp/number_of_zigzag_arrays_i.py +94 -0
- pydsa/algorithms/dp/number_of_zigzag_arrays_ii.py +77 -0
- pydsa/algorithms/dp/number_of_zigzag_arrays_iii.py +112 -0
- pydsa/algorithms/dp/numbers_at_most_n_given_digit_set.py +75 -0
- pydsa/algorithms/dp/numbers_with_repeated_digits.py +94 -0
- pydsa/algorithms/dp/odd_even_jump.py +104 -0
- pydsa/algorithms/dp/ones_and_zeroes.py +53 -0
- pydsa/algorithms/dp/out_of_boundary_paths.py +55 -0
- pydsa/algorithms/dp/paint_fence.py +70 -0
- pydsa/algorithms/dp/paint_house.py +51 -0
- pydsa/algorithms/dp/paint_house_ii.py +73 -0
- pydsa/algorithms/dp/paint_house_iii.py +67 -0
- pydsa/algorithms/dp/paint_house_iv.py +72 -0
- pydsa/algorithms/dp/painting_a_grid_with_three_different_colors.py +95 -0
- pydsa/algorithms/dp/painting_the_walls.py +33 -0
- pydsa/algorithms/dp/palindrome_partitioning_ii.py +66 -0
- pydsa/algorithms/dp/palindrome_partitioning_iii.py +75 -0
- pydsa/algorithms/dp/palindrome_partitioning_iv.py +66 -0
- pydsa/algorithms/dp/palindrome_removal.py +69 -0
- pydsa/algorithms/dp/palindromic_substrings.py +66 -0
- pydsa/algorithms/dp/parallel_courses_ii.py +84 -0
- pydsa/algorithms/dp/partition_array_for_maximum_sum.py +52 -0
- pydsa/algorithms/dp/partition_array_for_maximum_xor_and.py +67 -0
- pydsa/algorithms/dp/partition_array_into_two_arrays_to_minimize_sum_difference.py +93 -0
- pydsa/algorithms/dp/partition_array_into_two_equal_product_subsets.py +77 -0
- pydsa/algorithms/dp/partition_array_to_minimize_xor.py +57 -0
- pydsa/algorithms/dp/partition_equal_subset_sum.py +58 -0
- pydsa/algorithms/dp/partition_string_into_substrings_with_values_at_most_k.py +84 -0
- pydsa/algorithms/dp/paths_in_matrix_whose_sum_is_divisible_by_k.py +62 -0
- pydsa/algorithms/dp/perfect_squares.py +54 -0
- pydsa/algorithms/dp/pizza_toppings_cost_analysis.py +84 -0
- pydsa/algorithms/dp/pizza_with_3n_slices.py +86 -0
- pydsa/algorithms/dp/predict_the_winner.py +62 -0
- pydsa/algorithms/dp/profitable_schemes.py +129 -0
- pydsa/algorithms/dp/race_car.py +62 -0
- pydsa/algorithms/dp/regular_expression_matching.py +63 -0
- pydsa/algorithms/dp/remove_boxes.py +207 -0
- pydsa/algorithms/dp/russian_doll_envelopes.py +65 -0
- pydsa/algorithms/dp/scramble_string.py +66 -0
- pydsa/algorithms/dp/select_cells_in_grid_with_maximum_score.py +194 -0
- pydsa/algorithms/dp/select_k_disjoint_special_substrings.py +93 -0
- pydsa/algorithms/dp/sentence_screen_fitting.py +77 -0
- pydsa/algorithms/dp/shopping_offers.py +71 -0
- pydsa/algorithms/dp/smallest_sufficient_team.py +153 -0
- pydsa/algorithms/dp/solving_questions_with_brainpower.py +62 -0
- pydsa/algorithms/dp/soup_servings.py +80 -0
- pydsa/algorithms/dp/split_array_with_minimum_difference.py +53 -0
- pydsa/algorithms/dp/split_array_with_same_average.py +80 -0
- pydsa/algorithms/dp/stickers_to_spell_word.py +88 -0
- pydsa/algorithms/dp/stone_game.py +45 -0
- pydsa/algorithms/dp/stone_game_ii.py +112 -0
- pydsa/algorithms/dp/stone_game_iii.py +58 -0
- pydsa/algorithms/dp/stone_game_iv.py +279 -0
- pydsa/algorithms/dp/stone_game_ix.py +256 -0
- pydsa/algorithms/dp/stone_game_v.py +115 -0
- pydsa/algorithms/dp/stone_game_vii.py +69 -0
- pydsa/algorithms/dp/stone_game_viii.py +120 -0
- pydsa/algorithms/dp/strange_printer.py +79 -0
- pydsa/algorithms/dp/string_transformation.py +103 -0
- pydsa/algorithms/dp/student_attendance_record_ii.py +79 -0
- pydsa/algorithms/dp/subsequence_sum_after_capping_elements.py +89 -0
- pydsa/algorithms/dp/subsequences_with_a_unique_middle_mode_i.py +108 -0
- pydsa/algorithms/dp/subsequences_with_a_unique_middle_mode_ii.py +106 -0
- pydsa/algorithms/dp/sum_of_beautiful_subsequences.py +62 -0
- pydsa/algorithms/dp/sum_of_consecutive_subsequences.py +140 -0
- pydsa/algorithms/dp/sum_of_good_subsequences.py +79 -0
- pydsa/algorithms/dp/super_egg_drop.py +56 -0
- pydsa/algorithms/dp/tallest_billboard.py +75 -0
- pydsa/algorithms/dp/target_sum.py +58 -0
- pydsa/algorithms/dp/the_earliest_and_latest_rounds_where_players_compete.py +278 -0
- pydsa/algorithms/dp/the_number_of_good_subsets.py +239 -0
- pydsa/algorithms/dp/the_number_of_ways_to_make_the_sum.py +50 -0
- pydsa/algorithms/dp/toss_strange_coins.py +64 -0
- pydsa/algorithms/dp/total_distance_to_type_a_string_using_one_finger.py +66 -0
- pydsa/algorithms/dp/total_score_of_dungeon_runs.py +75 -0
- pydsa/algorithms/dp/triangle.py +53 -0
- pydsa/algorithms/dp/uncrossed_lines.py +55 -0
- pydsa/algorithms/dp/unique_binary_search_trees.py +60 -0
- pydsa/algorithms/dp/unique_paths.py +52 -0
- pydsa/algorithms/dp/unique_paths_ii.py +59 -0
- pydsa/algorithms/dp/unique_substrings_in_wraparound_string.py +111 -0
- pydsa/algorithms/dp/valid_palindrome_iii.py +63 -0
- pydsa/algorithms/dp/valid_permutations_for_di_sequence.py +75 -0
- pydsa/algorithms/dp/visit_array_positions_to_maximize_score.py +303 -0
- pydsa/algorithms/dp/ways_to_express_an_integer_as_sum_of_powers.py +62 -0
- pydsa/algorithms/dp/wildcard_matching.py +71 -0
- pydsa/algorithms/dp/word_break.py +55 -0
- pydsa/algorithms/geometry/__init__.py +0 -0
- pydsa/algorithms/geometry/maximum_area_rectangle_with_point_constraints_i.py +86 -0
- pydsa/algorithms/geometry/minimum_rectangles_to_cover_points.py +73 -0
- pydsa/algorithms/graphs/01_matrix.py +66 -0
- pydsa/algorithms/graphs/__init__.py +0 -0
- pydsa/algorithms/graphs/accounts_merge.py +86 -0
- pydsa/algorithms/graphs/add_edges_to_make_degrees_of_all_nodes_even.py +56 -0
- pydsa/algorithms/graphs/alien_dictionary.py +83 -0
- pydsa/algorithms/graphs/all_ancestors_of_a_node_in_a_directed_acyclic_graph.py +64 -0
- pydsa/algorithms/graphs/all_paths_from_source_lead_to_destination.py +89 -0
- pydsa/algorithms/graphs/all_paths_from_source_to_target.py +55 -0
- pydsa/algorithms/graphs/all_the_pairs_with_the_maximum_number_of_common_followers.py +68 -0
- pydsa/algorithms/graphs/analyze_organization_hierarchy.py +95 -0
- pydsa/algorithms/graphs/as_far_from_land_as_possible.py +68 -0
- pydsa/algorithms/graphs/bricks_falling_when_hit.py +332 -0
- pydsa/algorithms/graphs/bus_routes.py +73 -0
- pydsa/algorithms/graphs/calculate_the_influence_of_each_salesperson.py +67 -0
- pydsa/algorithms/graphs/cat_and_mouse_ii.py +147 -0
- pydsa/algorithms/graphs/cheapest_flights_within_k_stops.py +57 -0
- pydsa/algorithms/graphs/check_for_contradictions_in_equations.py +83 -0
- pydsa/algorithms/graphs/check_if_grid_can_be_cut_into_sections.py +79 -0
- pydsa/algorithms/graphs/check_if_the_rectangle_corner_is_reachable.py +71 -0
- pydsa/algorithms/graphs/check_if_there_is_a_path_with_equal_number_of_0s_and_1s.py +82 -0
- pydsa/algorithms/graphs/check_if_there_is_a_valid_path_in_a_grid.py +82 -0
- pydsa/algorithms/graphs/check_knight_tour_configuration.py +69 -0
- pydsa/algorithms/graphs/checking_existence_of_edge_length_limited_paths.py +81 -0
- pydsa/algorithms/graphs/checking_existence_of_edge_length_limited_paths_ii.py +87 -0
- pydsa/algorithms/graphs/choose_edges_to_maximize_score_in_a_tree.py +133 -0
- pydsa/algorithms/graphs/clone_graph.py +44 -0
- pydsa/algorithms/graphs/collect_coins_in_a_tree.py +91 -0
- pydsa/algorithms/graphs/coloring_a_border.py +86 -0
- pydsa/algorithms/graphs/connecting_cities_with_minimum_cost.py +83 -0
- pydsa/algorithms/graphs/construct_2d_grid_matching_graph_layout.py +92 -0
- pydsa/algorithms/graphs/contain_virus.py +219 -0
- pydsa/algorithms/graphs/count_all_possible_routes.py +64 -0
- pydsa/algorithms/graphs/count_artifacts_that_can_be_extracted.py +91 -0
- pydsa/algorithms/graphs/count_connected_components_in_lcm_graph.py +53 -0
- pydsa/algorithms/graphs/count_connected_subgraphs_with_even_node_sum.py +104 -0
- pydsa/algorithms/graphs/count_covered_buildings.py +300 -0
- pydsa/algorithms/graphs/count_distinct_numbers_on_board.py +65 -0
- pydsa/algorithms/graphs/count_good_integers_on_a_grid_path.py +74 -0
- pydsa/algorithms/graphs/count_islands_with_total_value_divisible_by_k.py +75 -0
- pydsa/algorithms/graphs/count_nodes_with_the_highest_score.py +107 -0
- pydsa/algorithms/graphs/count_pairs_of_connectable_servers_in_a_weighted_tree_network.py +73 -0
- pydsa/algorithms/graphs/count_pairs_of_nodes.py +66 -0
- pydsa/algorithms/graphs/count_paths_with_the_given_xor_value.py +98 -0
- pydsa/algorithms/graphs/count_sub_islands.py +74 -0
- pydsa/algorithms/graphs/count_the_number_of_complete_components.py +67 -0
- pydsa/algorithms/graphs/count_unguarded_cells_in_the_grid.py +73 -0
- pydsa/algorithms/graphs/count_unreachable_pairs_of_nodes_in_an_undirected_graph.py +76 -0
- pydsa/algorithms/graphs/count_valid_paths_in_a_tree.py +268 -0
- pydsa/algorithms/graphs/count_visited_nodes_in_a_directed_graph.py +56 -0
- pydsa/algorithms/graphs/countries_you_can_safely_invest_in.py +84 -0
- pydsa/algorithms/graphs/course_schedule.py +47 -0
- pydsa/algorithms/graphs/course_schedule_ii.py +56 -0
- pydsa/algorithms/graphs/course_schedule_iv.py +56 -0
- pydsa/algorithms/graphs/create_components_with_same_value.py +71 -0
- pydsa/algorithms/graphs/critical_connections_in_a_network.py +75 -0
- pydsa/algorithms/graphs/cut_off_trees_for_golf_event.py +80 -0
- pydsa/algorithms/graphs/cycle_length_queries_in_a_tree.py +108 -0
- pydsa/algorithms/graphs/design_excel_sum_formula.py +79 -0
- pydsa/algorithms/graphs/design_graph_with_shortest_path_calculator.py +117 -0
- pydsa/algorithms/graphs/design_ride_sharing_system.py +100 -0
- pydsa/algorithms/graphs/destination_city.py +39 -0
- pydsa/algorithms/graphs/detect_cycles_in_2d_grid.py +80 -0
- pydsa/algorithms/graphs/determine_if_a_cell_is_reachable_at_a_given_time.py +62 -0
- pydsa/algorithms/graphs/determine_if_a_simple_graph_exists.py +50 -0
- pydsa/algorithms/graphs/detonate_the_maximum_bombs.py +75 -0
- pydsa/algorithms/graphs/disconnect_path_in_a_binary_matrix_by_at_most_one_flip.py +127 -0
- pydsa/algorithms/graphs/distance_to_a_cycle_in_undirected_graph.py +78 -0
- pydsa/algorithms/graphs/divide_nodes_into_the_maximum_number_of_groups.py +79 -0
- pydsa/algorithms/graphs/employee_importance.py +63 -0
- pydsa/algorithms/graphs/employees_project_allocation.py +73 -0
- pydsa/algorithms/graphs/erect_the_fence_ii.py +72 -0
- pydsa/algorithms/graphs/escape_a_large_maze.py +276 -0
- pydsa/algorithms/graphs/escape_the_spreading_fire.py +220 -0
- pydsa/algorithms/graphs/evaluate_division.py +71 -0
- pydsa/algorithms/graphs/find_a_safe_walk_through_a_grid.py +91 -0
- pydsa/algorithms/graphs/find_all_groups_of_farmland.py +69 -0
- pydsa/algorithms/graphs/find_all_people_with_secret.py +86 -0
- pydsa/algorithms/graphs/find_all_possible_recipes_from_given_supplies.py +81 -0
- pydsa/algorithms/graphs/find_all_the_lonely_nodes.py +46 -0
- pydsa/algorithms/graphs/find_building_where_alice_and_bob_can_meet.py +45 -0
- pydsa/algorithms/graphs/find_center_of_star_graph.py +43 -0
- pydsa/algorithms/graphs/find_circular_gift_exchange_chains.py +63 -0
- pydsa/algorithms/graphs/find_cities_in_each_state.py +244 -0
- pydsa/algorithms/graphs/find_cities_in_each_state_ii.py +116 -0
- pydsa/algorithms/graphs/find_closest_node_to_given_two_nodes.py +88 -0
- pydsa/algorithms/graphs/find_critical_and_pseudo_critical_edges_in_minimum_spanning_tree.py +111 -0
- pydsa/algorithms/graphs/find_diameter_endpoints_of_a_tree.py +83 -0
- pydsa/algorithms/graphs/find_edges_in_shortest_paths.py +81 -0
- pydsa/algorithms/graphs/find_eventual_safe_states.py +75 -0
- pydsa/algorithms/graphs/find_if_path_exists_in_graph.py +75 -0
- pydsa/algorithms/graphs/find_minimum_time_to_reach_last_room_i.py +70 -0
- pydsa/algorithms/graphs/find_minimum_time_to_reach_last_room_ii.py +78 -0
- pydsa/algorithms/graphs/find_shortest_path_with_k_hops.py +68 -0
- pydsa/algorithms/graphs/find_the_city_with_the_smallest_number_of_neighbors_at_a_threshold_distance.py +71 -0
- pydsa/algorithms/graphs/find_the_closest_marked_node.py +64 -0
- pydsa/algorithms/graphs/find_the_degree_of_each_vertex.py +45 -0
- pydsa/algorithms/graphs/find_the_minimum_diameter_after_merging_two_trees.py +101 -0
- pydsa/algorithms/graphs/find_the_safest_path_in_a_grid.py +89 -0
- pydsa/algorithms/graphs/find_the_town_judge.py +85 -0
- pydsa/algorithms/graphs/first_day_where_you_have_been_in_all_the_rooms.py +69 -0
- pydsa/algorithms/graphs/flood_fill.py +46 -0
- pydsa/algorithms/graphs/flower_planting_with_no_adjacent.py +69 -0
- pydsa/algorithms/graphs/form_a_chemical_bond.py +61 -0
- pydsa/algorithms/graphs/friends_with_no_mutual_friends.py +65 -0
- pydsa/algorithms/graphs/gcd_sort_of_an_array.py +91 -0
- pydsa/algorithms/graphs/get_watched_videos_by_your_friends.py +80 -0
- pydsa/algorithms/graphs/graph_connectivity_with_threshold.py +82 -0
- pydsa/algorithms/graphs/graph_valid_tree.py +69 -0
- pydsa/algorithms/graphs/greatest_common_divisor_traversal.py +105 -0
- pydsa/algorithms/graphs/grid_game.py +60 -0
- pydsa/algorithms/graphs/grid_teleportation_traversal.py +77 -0
- pydsa/algorithms/graphs/implement_router.py +127 -0
- pydsa/algorithms/graphs/incremental_even_weighted_cycle_queries.py +97 -0
- pydsa/algorithms/graphs/is_graph_bipartite.py +62 -0
- pydsa/algorithms/graphs/jump_game_iii.py +58 -0
- pydsa/algorithms/graphs/jump_game_iv.py +85 -0
- pydsa/algorithms/graphs/k_similar_strings.py +76 -0
- pydsa/algorithms/graphs/keys_and_rooms.py +47 -0
- pydsa/algorithms/graphs/kill_process.py +64 -0
- pydsa/algorithms/graphs/kth_smallest_path_xor_sum.py +91 -0
- pydsa/algorithms/graphs/largest_color_value_in_a_directed_graph.py +86 -0
- pydsa/algorithms/graphs/last_day_where_you_can_still_cross.py +127 -0
- pydsa/algorithms/graphs/leetcodify_friends_recommendations.py +62 -0
- pydsa/algorithms/graphs/leetcodify_similar_friends.py +45 -0
- pydsa/algorithms/graphs/length_of_the_longest_increasing_path.py +68 -0
- pydsa/algorithms/graphs/lexicographically_smallest_equivalent_string.py +77 -0
- pydsa/algorithms/graphs/longest_cycle_in_a_graph.py +63 -0
- pydsa/algorithms/graphs/longest_palindromic_path_in_graph.py +353 -0
- pydsa/algorithms/graphs/longest_path_with_different_adjacent_characters.py +65 -0
- pydsa/algorithms/graphs/longest_special_path_ii.py +98 -0
- pydsa/algorithms/graphs/loud_and_rich.py +64 -0
- pydsa/algorithms/graphs/make_a_square_with_the_same_color.py +57 -0
- pydsa/algorithms/graphs/making_a_large_island.py +86 -0
- pydsa/algorithms/graphs/map_of_highest_peak.py +62 -0
- pydsa/algorithms/graphs/max_area_of_island.py +70 -0
- pydsa/algorithms/graphs/max_candies_boxes.py +324 -0
- pydsa/algorithms/graphs/max_value_of_equation.py +102 -0
- pydsa/algorithms/graphs/maximal_network_rank.py +63 -0
- pydsa/algorithms/graphs/maximize_spanning_tree_stability_with_upgrades.py +202 -0
- pydsa/algorithms/graphs/maximize_sum_of_weights_after_edge_removals.py +78 -0
- pydsa/algorithms/graphs/maximize_target_nodes_connecting_trees_i.py +131 -0
- pydsa/algorithms/graphs/maximize_target_nodes_connecting_trees_ii.py +95 -0
- pydsa/algorithms/graphs/maximum_employees_to_be_invited_to_a_meeting.py +146 -0
- pydsa/algorithms/graphs/maximum_number_of_accepted_invitations.py +74 -0
- pydsa/algorithms/graphs/maximum_number_of_achievable_transfer_requests.py +227 -0
- pydsa/algorithms/graphs/maximum_number_of_fish_in_a_grid.py +73 -0
- pydsa/algorithms/graphs/maximum_number_of_moves_in_a_grid.py +63 -0
- pydsa/algorithms/graphs/maximum_number_of_moves_to_kill_all_pawns.py +91 -0
- pydsa/algorithms/graphs/maximum_number_of_points_from_grid_queries.py +308 -0
- pydsa/algorithms/graphs/maximum_points_after_collecting_coins_from_all_nodes.py +197 -0
- pydsa/algorithms/graphs/maximum_profit_from_valid_topological_order_in_dag.py +65 -0
- pydsa/algorithms/graphs/maximum_score_after_applying_operations_on_a_tree.py +115 -0
- pydsa/algorithms/graphs/maximum_score_of_a_node_sequence.py +136 -0
- pydsa/algorithms/graphs/maximum_star_sum_of_a_graph.py +59 -0
- pydsa/algorithms/graphs/maximum_subgraph_score_in_a_tree.py +93 -0
- pydsa/algorithms/graphs/maximum_sum_of_edge_values_in_a_graph.py +79 -0
- pydsa/algorithms/graphs/maximum_total_importance_of_roads.py +54 -0
- pydsa/algorithms/graphs/maximum_weighted_k_edge_path.py +53 -0
- pydsa/algorithms/graphs/min-cost-to-connect-all-points.py +68 -0
- pydsa/algorithms/graphs/min_time_to_collect_apples.py +64 -0
- pydsa/algorithms/graphs/minesweeper.py +84 -0
- pydsa/algorithms/graphs/minimize_malware_spread.py +95 -0
- pydsa/algorithms/graphs/minimize_malware_spread_ii.py +100 -0
- pydsa/algorithms/graphs/minimize_maximum_component_cost.py +132 -0
- pydsa/algorithms/graphs/minimize_the_maximum_edge_weight_of_graph.py +100 -0
- pydsa/algorithms/graphs/minimum-cost-to-connect-two-groups-of-points.py +72 -0
- pydsa/algorithms/graphs/minimum_bitwise_or_from_grid.py +69 -0
- pydsa/algorithms/graphs/minimum_cost_homecoming_of_a_robot_in_a_grid.py +49 -0
- pydsa/algorithms/graphs/minimum_cost_of_a_path_with_special_roads.py +90 -0
- pydsa/algorithms/graphs/minimum_cost_path_with_alternating_directions_i.py +83 -0
- pydsa/algorithms/graphs/minimum_cost_path_with_alternating_directions_ii.py +95 -0
- pydsa/algorithms/graphs/minimum_cost_path_with_edge_reversals.py +87 -0
- pydsa/algorithms/graphs/minimum_cost_path_with_teleportations.py +87 -0
- pydsa/algorithms/graphs/minimum_cost_to_convert_string_ii.py +105 -0
- pydsa/algorithms/graphs/minimum_cost_to_make_at_least_one_valid_path_in_a_grid.py +81 -0
- pydsa/algorithms/graphs/minimum_cost_to_move_between_indices.py +67 -0
- pydsa/algorithms/graphs/minimum_cost_to_reach_city_with_discounts.py +80 -0
- pydsa/algorithms/graphs/minimum_cost_to_reach_every_position.py +75 -0
- pydsa/algorithms/graphs/minimum_cost_to_repair_edges_to_traverse_a_graph.py +79 -0
- pydsa/algorithms/graphs/minimum_cost_walk_in_weighted_graph.py +72 -0
- pydsa/algorithms/graphs/minimum_costs_using_the_train_line.py +74 -0
- pydsa/algorithms/graphs/minimum_degree_of_a_connected_trio_in_a_graph.py +68 -0
- pydsa/algorithms/graphs/minimum_distance_excluding_one_maximum_weighted_edge.py +63 -0
- pydsa/algorithms/graphs/minimum_edge_reversals_so_every_node_is_reachable.py +85 -0
- pydsa/algorithms/graphs/minimum_edge_toggles_on_a_tree.py +174 -0
- pydsa/algorithms/graphs/minimum_edge_weight_equilibrium_queries_in_a_tree.py +331 -0
- pydsa/algorithms/graphs/minimum_fuel_cost_to_report_to_the_capital.py +73 -0
- pydsa/algorithms/graphs/minimum_genetic_mutation.py +80 -0
- pydsa/algorithms/graphs/minimum_height_trees.py +80 -0
- pydsa/algorithms/graphs/minimum_jumps_to_reach_end_via_prime_teleportation.py +81 -0
- pydsa/algorithms/graphs/minimum_jumps_to_reach_home.py +84 -0
- pydsa/algorithms/graphs/minimum_knight_moves.py +68 -0
- pydsa/algorithms/graphs/minimum_moves_to_move_a_box_to_their_target_location.py +141 -0
- pydsa/algorithms/graphs/minimum_moves_to_reach_target_in_grid.py +73 -0
- pydsa/algorithms/graphs/minimum_moves_to_reach_target_with_rotations.py +109 -0
- pydsa/algorithms/graphs/minimum_number_of_days_to_disconnect_island.py +81 -0
- pydsa/algorithms/graphs/minimum_number_of_lines_to_cover_points.py +99 -0
- pydsa/algorithms/graphs/minimum_number_of_vertices_to_reach_all_nodes.py +52 -0
- pydsa/algorithms/graphs/minimum_number_of_visited_cells_in_a_grid.py +331 -0
- pydsa/algorithms/graphs/minimum_obstacle_removal_to_reach_corner.py +78 -0
- pydsa/algorithms/graphs/minimum_path_cost_in_a_hidden_grid.py +107 -0
- pydsa/algorithms/graphs/minimum_score_after_removals_on_a_tree.py +353 -0
- pydsa/algorithms/graphs/minimum_score_of_a_path_between_two_cities.py +65 -0
- pydsa/algorithms/graphs/minimum_sensors_to_cover_grid.py +73 -0
- pydsa/algorithms/graphs/minimum_threshold_path_with_limited_heavy_edges.py +141 -0
- pydsa/algorithms/graphs/minimum_time_for_k_connected_components.py +86 -0
- pydsa/algorithms/graphs/minimum_time_for_k_virus_variants_to_spread.py +102 -0
- pydsa/algorithms/graphs/minimum_time_takes_to_reach_destination_without_drowning.py +67 -0
- pydsa/algorithms/graphs/minimum_time_to_break_locks_i.py +63 -0
- pydsa/algorithms/graphs/minimum_time_to_break_locks_ii.py +176 -0
- pydsa/algorithms/graphs/minimum_time_to_reach_destination_in_directed_graph.py +72 -0
- pydsa/algorithms/graphs/minimum_time_to_visit_a_cell_in_a_grid.py +78 -0
- pydsa/algorithms/graphs/minimum_time_to_visit_all_houses.py +84 -0
- pydsa/algorithms/graphs/minimum_time_to_visit_disappearing_nodes.py +77 -0
- pydsa/algorithms/graphs/minimum_weighted_subgraph_with_the_required_paths.py +123 -0
- pydsa/algorithms/graphs/minimum_weighted_subgraph_with_the_required_paths_ii.py +67 -0
- pydsa/algorithms/graphs/modify_graph_edge_weights.py +70 -0
- pydsa/algorithms/graphs/most_profitable_path_in_a_tree.py +73 -0
- pydsa/algorithms/graphs/most_stones_removed_with_same_row_or_column.py +169 -0
- pydsa/algorithms/graphs/multi_source_flood_fill.py +66 -0
- pydsa/algorithms/graphs/nearest_exit_from_entrance_in_maze.py +69 -0
- pydsa/algorithms/graphs/network_delay_time.py +73 -0
- pydsa/algorithms/graphs/network_recovery_pathways.py +68 -0
- pydsa/algorithms/graphs/node_with_highest_edge_score.py +61 -0
- pydsa/algorithms/graphs/number_of_closed_islands.py +71 -0
- pydsa/algorithms/graphs/number_of_connected_components_in_an_undirected_graph.py +59 -0
- pydsa/algorithms/graphs/number_of_distinct_islands.py +74 -0
- pydsa/algorithms/graphs/number_of_distinct_islands_ii.py +95 -0
- pydsa/algorithms/graphs/number_of_enclaves.py +66 -0
- pydsa/algorithms/graphs/number_of_good_paths.py +106 -0
- pydsa/algorithms/graphs/number_of_increasing_paths_in_a_grid.py +67 -0
- pydsa/algorithms/graphs/number_of_islands.py +65 -0
- pydsa/algorithms/graphs/number_of_islands_ii.py +90 -0
- pydsa/algorithms/graphs/number_of_operations_to_make_network_connected.py +71 -0
- pydsa/algorithms/graphs/number_of_people_that_can_be_seen_in_a_grid.py +70 -0
- pydsa/algorithms/graphs/number_of_prefix_connected_groups.py +68 -0
- pydsa/algorithms/graphs/number_of_provinces.py +51 -0
- pydsa/algorithms/graphs/number_of_restricted_paths_from_first_to_last_node.py +82 -0
- pydsa/algorithms/graphs/number_of_trusted_contacts_of_a_customer.py +82 -0
- pydsa/algorithms/graphs/number_of_ways_to_arrive_at_destination.py +73 -0
- pydsa/algorithms/graphs/number_of_ways_to_assign_edge_weights_i.py +70 -0
- pydsa/algorithms/graphs/number_of_ways_to_assign_edge_weights_ii.py +95 -0
- pydsa/algorithms/graphs/number_of_ways_to_reconstruct_a_tree.py +218 -0
- pydsa/algorithms/graphs/open_the_lock.py +75 -0
- pydsa/algorithms/graphs/optimize_water_distribution_in_a_village.py +93 -0
- pydsa/algorithms/graphs/pacific_atlantic_water_flow.py +71 -0
- pydsa/algorithms/graphs/parallel_courses.py +72 -0
- pydsa/algorithms/graphs/parallel_courses_iii.py +76 -0
- pydsa/algorithms/graphs/path_existence_queries_in_a_graph_i.py +70 -0
- pydsa/algorithms/graphs/path_existence_queries_in_a_graph_ii.py +131 -0
- pydsa/algorithms/graphs/path_with_maximum_minimum_value.py +72 -0
- pydsa/algorithms/graphs/path_with_maximum_probability.py +74 -0
- pydsa/algorithms/graphs/path_with_minimum_effort.py +82 -0
- pydsa/algorithms/graphs/paths_in_maze_that_lead_to_same_room.py +311 -0
- pydsa/algorithms/graphs/possible_bipartition.py +77 -0
- pydsa/algorithms/graphs/power_grid_maintenance.py +83 -0
- pydsa/algorithms/graphs/process_restricted_friend_requests.py +313 -0
- pydsa/algorithms/graphs/promise_pool.py +83 -0
- pydsa/algorithms/graphs/promise_time_limit.py +68 -0
- pydsa/algorithms/graphs/properties_graph.py +107 -0
- pydsa/algorithms/graphs/reachable_nodes_in_subdivided_graph.py +104 -0
- pydsa/algorithms/graphs/reachable_nodes_with_restrictions.py +62 -0
- pydsa/algorithms/graphs/reconstruct_itinerary.py +62 -0
- pydsa/algorithms/graphs/redundant_connection.py +76 -0
- pydsa/algorithms/graphs/redundant_connection_ii.py +122 -0
- pydsa/algorithms/graphs/regions_cut_by_slashes.py +72 -0
- pydsa/algorithms/graphs/remove_max_number_of_edges_to_keep_graph_fully_traversable.py +208 -0
- pydsa/algorithms/graphs/remove_stones_to_minimize_the_total.py +91 -0
- pydsa/algorithms/graphs/reorder_routes_to_make_all_paths_lead_to_the_city_zero.py +69 -0
- pydsa/algorithms/graphs/restore_finishing_order.py +71 -0
- pydsa/algorithms/graphs/robot_room_cleaner.py +165 -0
- pydsa/algorithms/graphs/rotting_oranges.py +75 -0
- pydsa/algorithms/graphs/satisfiability_of_equality_equations.py +81 -0
- pydsa/algorithms/graphs/second_minimum_time_to_reach_destination.py +86 -0
- pydsa/algorithms/graphs/sentence_similarity_ii.py +88 -0
- pydsa/algorithms/graphs/sequence_reconstruction.py +78 -0
- pydsa/algorithms/graphs/sequential_grid_path_cover.py +73 -0
- pydsa/algorithms/graphs/shortest_bridge.py +82 -0
- pydsa/algorithms/graphs/shortest_cycle_in_a_graph.py +75 -0
- pydsa/algorithms/graphs/shortest_distance_after_road_addition_queries_i.py +70 -0
- pydsa/algorithms/graphs/shortest_distance_after_road_addition_queries_ii.py +82 -0
- pydsa/algorithms/graphs/shortest_distance_from_all_buildings.py +78 -0
- pydsa/algorithms/graphs/shortest_path_in_a_hidden_grid.py +97 -0
- pydsa/algorithms/graphs/shortest_path_in_a_weighted_tree.py +63 -0
- pydsa/algorithms/graphs/shortest_path_in_binary_matrix.py +69 -0
- pydsa/algorithms/graphs/shortest_path_obstacles.py +73 -0
- pydsa/algorithms/graphs/shortest_path_to_get_all_keys.py +96 -0
- pydsa/algorithms/graphs/shortest_path_to_get_food.py +87 -0
- pydsa/algorithms/graphs/shortest_path_visiting_all_nodes.py +71 -0
- pydsa/algorithms/graphs/shortest_path_with_alternating_colors.py +82 -0
- pydsa/algorithms/graphs/similar_string_groups.py +88 -0
- pydsa/algorithms/graphs/sliding_puzzle.py +82 -0
- pydsa/algorithms/graphs/smallest_string_with_swaps.py +87 -0
- pydsa/algorithms/graphs/snake_in_matrix.py +62 -0
- pydsa/algorithms/graphs/snakes_and_ladders.py +81 -0
- pydsa/algorithms/graphs/sort_items_by_groups_respecting_dependencies.py +113 -0
- pydsa/algorithms/graphs/status_of_flight_tickets.py +108 -0
- pydsa/algorithms/graphs/strange-printer-ii.py +293 -0
- pydsa/algorithms/graphs/strong_friendship.py +278 -0
- pydsa/algorithms/graphs/sum_of_remoteness_of_all_cells.py +107 -0
- pydsa/algorithms/graphs/surrounded_regions.py +73 -0
- pydsa/algorithms/graphs/swim_in_rising_water.py +65 -0
- pydsa/algorithms/graphs/taking_maximum_energy_from_the_mystic_dungeon.py +64 -0
- pydsa/algorithms/graphs/the_airport_with_the_most_traffic.py +105 -0
- pydsa/algorithms/graphs/the_earliest_moment_when_everyone_become_friends.py +78 -0
- pydsa/algorithms/graphs/the_maze.py +66 -0
- pydsa/algorithms/graphs/the_maze_ii.py +77 -0
- pydsa/algorithms/graphs/the_maze_iii.py +233 -0
- pydsa/algorithms/graphs/the_most_similar_path_in_a_graph.py +88 -0
- pydsa/algorithms/graphs/the_number_of_employees_which_report_to_each_employee.py +63 -0
- pydsa/algorithms/graphs/time_needed_to_inform_all_employees.py +59 -0
- pydsa/algorithms/graphs/time_taken_to_mark_all_nodes.py +81 -0
- pydsa/algorithms/graphs/top_travellers.py +77 -0
- pydsa/algorithms/graphs/total_sum_of_interaction_cost_in_tree_groups.py +88 -0
- pydsa/algorithms/graphs/tree_of_coprimes.py +137 -0
- pydsa/algorithms/graphs/twisted_mirror_path_count.py +291 -0
- pydsa/algorithms/graphs/unit_conversion_ii.py +72 -0
- pydsa/algorithms/graphs/valid_arrangement_of_pairs.py +72 -0
- pydsa/algorithms/graphs/validate_binary_tree_nodes.py +105 -0
- pydsa/algorithms/graphs/viewers_turned_streamers.py +42 -0
- pydsa/algorithms/graphs/walls_and_gates.py +64 -0
- pydsa/algorithms/graphs/warehouse_manager.py +59 -0
- pydsa/algorithms/graphs/web_crawler.py +88 -0
- pydsa/algorithms/graphs/web_crawler_multithreaded.py +123 -0
- pydsa/algorithms/graphs/word_ladder.py +68 -0
- pydsa/algorithms/graphs/word_ladder_ii.py +101 -0
- pydsa/algorithms/graphs/zigzag_grid_traversal_with_skip.py +75 -0
- pydsa/algorithms/greedy/__init__.py +0 -0
- pydsa/algorithms/greedy/advantage_shuffle.py +264 -0
- pydsa/algorithms/greedy/apply_operations_on_array_to_maximize_sum_of_squares.py +337 -0
- pydsa/algorithms/greedy/array_of_doubled_pairs.py +73 -0
- pydsa/algorithms/greedy/array_partition.py +37 -0
- pydsa/algorithms/greedy/assign_cookies.py +50 -0
- pydsa/algorithms/greedy/assign_elements_to_groups_with_constraints.py +58 -0
- pydsa/algorithms/greedy/avoid_flood_in_the_city.py +79 -0
- pydsa/algorithms/greedy/bag_of_tokens.py +71 -0
- pydsa/algorithms/greedy/best_reachable_tower.py +143 -0
- pydsa/algorithms/greedy/best_time_to_buy_and_sell_stock_ii.py +50 -0
- pydsa/algorithms/greedy/boats_to_save_people.py +55 -0
- pydsa/algorithms/greedy/broken_calculator.py +56 -0
- pydsa/algorithms/greedy/campus_bikes.py +67 -0
- pydsa/algorithms/greedy/can_place_flowers.py +58 -0
- pydsa/algorithms/greedy/candy.py +50 -0
- pydsa/algorithms/greedy/cinema_seat_allocation.py +53 -0
- pydsa/algorithms/greedy/construct_smallest_number_from_di_string.py +61 -0
- pydsa/algorithms/greedy/construct_string_with_repeat_limit.py +189 -0
- pydsa/algorithms/greedy/construct_the_lexicographically_largest_valid_sequence.py +302 -0
- pydsa/algorithms/greedy/couples_holding_hands.py +59 -0
- pydsa/algorithms/greedy/course_schedule_iii.py +61 -0
- pydsa/algorithms/greedy/create_maximum_number.py +82 -0
- pydsa/algorithms/greedy/decrease_elements_to_make_array_zigzag.py +61 -0
- pydsa/algorithms/greedy/delete_columns_to_make_sorted.py +50 -0
- pydsa/algorithms/greedy/delete_columns_to_make_sorted_ii.py +64 -0
- pydsa/algorithms/greedy/determine_the_minimum_sum_of_a_k_avoiding_array.py +57 -0
- pydsa/algorithms/greedy/di_string_match.py +51 -0
- pydsa/algorithms/greedy/distribute_candies.py +37 -0
- pydsa/algorithms/greedy/divide_array_consecutive_sets.py +60 -0
- pydsa/algorithms/greedy/divide_array_into_arrays_with_max_difference.py +53 -0
- pydsa/algorithms/greedy/dota2_senate.py +63 -0
- pydsa/algorithms/greedy/earliest_finish_time_for_land_and_water_rides_i.py +48 -0
- pydsa/algorithms/greedy/earliest_finish_time_for_land_and_water_rides_ii.py +70 -0
- pydsa/algorithms/greedy/earliest_possible_day_of_full_bloom.py +61 -0
- pydsa/algorithms/greedy/earliest_time_to_finish_one_task.py +54 -0
- pydsa/algorithms/greedy/eat_pizzas.py +45 -0
- pydsa/algorithms/greedy/eliminate_maximum_number_of_monsters.py +63 -0
- pydsa/algorithms/greedy/execution_of_all_suffix_instructions_staying_in_a_grid.py +247 -0
- pydsa/algorithms/greedy/find_permutation.py +66 -0
- pydsa/algorithms/greedy/find_polygon_with_the_largest_perimeter.py +58 -0
- pydsa/algorithms/greedy/find_the_lexicographically_smallest_valid_sequence.py +197 -0
- pydsa/algorithms/greedy/find_the_minimum_possible_sum_of_a_beautiful_array.py +31 -0
- pydsa/algorithms/greedy/fruits_into_baskets_ii.py +50 -0
- pydsa/algorithms/greedy/furthest_building_you_can_reach.py +60 -0
- pydsa/algorithms/greedy/gas_station.py +55 -0
- pydsa/algorithms/greedy/generate_schedule.py +77 -0
- pydsa/algorithms/greedy/group_the_people.py +51 -0
- pydsa/algorithms/greedy/hand_of_straights.py +62 -0
- pydsa/algorithms/greedy/happy_students.py +101 -0
- pydsa/algorithms/greedy/how_many_apples_can_you_put_into_the_basket.py +52 -0
- pydsa/algorithms/greedy/integer_replacement.py +58 -0
- pydsa/algorithms/greedy/jump_game.py +49 -0
- pydsa/algorithms/greedy/jump_game_ii.py +55 -0
- pydsa/algorithms/greedy/largest_number.py +56 -0
- pydsa/algorithms/greedy/largest_perimeter_triangle.py +44 -0
- pydsa/algorithms/greedy/lemonade_change.py +52 -0
- pydsa/algorithms/greedy/longest_chunked_palindrome_decomposition.py +54 -0
- pydsa/algorithms/greedy/longest_happy_string.py +76 -0
- pydsa/algorithms/greedy/make_a_positive_array.py +72 -0
- pydsa/algorithms/greedy/make_array_zero_by_subtracting_equal_amounts.py +46 -0
- pydsa/algorithms/greedy/maximize_active_section_with_trade_ii.py +246 -0
- pydsa/algorithms/greedy/maximize_alternating_sum_using_swaps.py +99 -0
- pydsa/algorithms/greedy/maximize_items.py +64 -0
- pydsa/algorithms/greedy/maximize_points_after_choosing_k_tasks.py +53 -0
- pydsa/algorithms/greedy/maximize_profit_from_task_assignment.py +118 -0
- pydsa/algorithms/greedy/maximize_score_of_numbers_in_ranges.py +100 -0
- pydsa/algorithms/greedy/maximize_sum_of_array_after_k_negations.py +58 -0
- pydsa/algorithms/greedy/maximize_sum_of_at_most_k_distinct_elements.py +63 -0
- pydsa/algorithms/greedy/maximize_the_topmost_element_after_k_moves.py +60 -0
- pydsa/algorithms/greedy/maximize_the_total_height_of_unique_towers.py +268 -0
- pydsa/algorithms/greedy/maximum_bags_with_full_capacity_of_rocks.py +56 -0
- pydsa/algorithms/greedy/maximum_coins_from_k_consecutive_bags.py +90 -0
- pydsa/algorithms/greedy/maximum_coins_heroes_can_collect.py +63 -0
- pydsa/algorithms/greedy/maximum_height_by_stacking_cuboids.py +70 -0
- pydsa/algorithms/greedy/maximum_ice_cream_bars.py +49 -0
- pydsa/algorithms/greedy/maximum_k_to_sort_a_permutation.py +46 -0
- pydsa/algorithms/greedy/maximum_length_of_pair_chain.py +52 -0
- pydsa/algorithms/greedy/maximum_nesting_depth_of_two_valid_parentheses_strings.py +70 -0
- pydsa/algorithms/greedy/maximum_number_of_alloys.py +84 -0
- pydsa/algorithms/greedy/maximum_number_of_events_that_can_be_attended.py +68 -0
- pydsa/algorithms/greedy/maximum_number_of_groups_entering_a_competition.py +57 -0
- pydsa/algorithms/greedy/maximum_number_of_ones.py +97 -0
- pydsa/algorithms/greedy/maximum_number_of_potholes_that_can_be_fixed.py +51 -0
- pydsa/algorithms/greedy/maximum_number_of_tasks_you_can_assign.py +76 -0
- pydsa/algorithms/greedy/maximum_running_time_of_n_computers.py +68 -0
- pydsa/algorithms/greedy/maximum_score_from_grid_operations.py +58 -0
- pydsa/algorithms/greedy/maximum_score_from_removing_stones.py +54 -0
- pydsa/algorithms/greedy/maximum_score_using_exactly_k_pairs.py +61 -0
- pydsa/algorithms/greedy/maximum_spending_after_buying_items.py +245 -0
- pydsa/algorithms/greedy/maximum_swap.py +61 -0
- pydsa/algorithms/greedy/maximum_transactions_without_negative_balance.py +65 -0
- pydsa/algorithms/greedy/maximum_units_on_a_truck.py +48 -0
- pydsa/algorithms/greedy/maximum_walls_destroyed_by_robots.py +72 -0
- pydsa/algorithms/greedy/minimize_maximum_pair_sum_in_array.py +51 -0
- pydsa/algorithms/greedy/minimize_product_sum_of_two_arrays.py +49 -0
- pydsa/algorithms/greedy/minimize_rounding_error_to_meet_target.py +97 -0
- pydsa/algorithms/greedy/minimize_the_total_price_of_the_trips.py +60 -0
- pydsa/algorithms/greedy/minimizing_array_after_replacing_pairs_with_their_product.py +64 -0
- pydsa/algorithms/greedy/minimum_amount_of_damage_dealt_to_bob.py +198 -0
- pydsa/algorithms/greedy/minimum_cost_to_move_chips_to_the_same_position.py +38 -0
- pydsa/algorithms/greedy/minimum_deletions_to_make_array_beautiful.py +61 -0
- pydsa/algorithms/greedy/minimum_discards_to_balance_inventory.py +98 -0
- pydsa/algorithms/greedy/minimum_division_operations_to_make_array_non_decreasing.py +58 -0
- pydsa/algorithms/greedy/minimum_domino_rotations_for_equal_row.py +65 -0
- pydsa/algorithms/greedy/minimum_increment_operations_to_make_array_beautiful.py +58 -0
- pydsa/algorithms/greedy/minimum_increment_to_make_array_unique.py +58 -0
- pydsa/algorithms/greedy/minimum_increments_for_target_multiples_in_an_array.py +48 -0
- pydsa/algorithms/greedy/minimum_initial_energy_to_finish_tasks.py +58 -0
- pydsa/algorithms/greedy/minimum_number_of_groups_to_create_a_valid_assignment.py +240 -0
- pydsa/algorithms/greedy/minimum_number_of_k_consecutive_bit_flips.py +292 -0
- pydsa/algorithms/greedy/minimum_number_of_operations_to_make_arrays_similar.py +254 -0
- pydsa/algorithms/greedy/minimum_number_of_operations_to_make_word_k_periodic.py +59 -0
- pydsa/algorithms/greedy/minimum_number_of_operations_to_satisfy_conditions.py +283 -0
- pydsa/algorithms/greedy/minimum_number_of_pushes_to_type_word_i.py +62 -0
- pydsa/algorithms/greedy/minimum_number_of_pushes_to_type_word_ii.py +73 -0
- pydsa/algorithms/greedy/minimum_number_of_refueling_stops.py +72 -0
- pydsa/algorithms/greedy/minimum_number_of_seconds_to_make_mountain_height_zero.py +103 -0
- pydsa/algorithms/greedy/minimum_number_of_taps_to_open_to_water_a_garden.py +66 -0
- pydsa/algorithms/greedy/minimum_operations_to_halve_array_sum.py +62 -0
- pydsa/algorithms/greedy/minimum_operations_to_make_binary_array_elements_equal_to_one_i.py +128 -0
- pydsa/algorithms/greedy/minimum_operations_to_make_the_array_increasing.py +51 -0
- pydsa/algorithms/greedy/minimum_operations_to_remove_adjacent_ones_in_matrix.py +83 -0
- pydsa/algorithms/greedy/minimum_penalty_for_a_shop.py +48 -0
- pydsa/algorithms/greedy/minimum_possible_integer_after_at_most_k_adjacent_swaps_on_digits.py +67 -0
- pydsa/algorithms/greedy/minimum_processing_time.py +47 -0
- pydsa/algorithms/greedy/minimum_replacements_to_sort_the_array.py +68 -0
- pydsa/algorithms/greedy/minimum_swaps_to_make_strings_equal.py +69 -0
- pydsa/algorithms/greedy/minimum_time_to_complete_all_tasks.py +259 -0
- pydsa/algorithms/greedy/minimum_time_to_finish_the_race.py +72 -0
- pydsa/algorithms/greedy/minimum_time_to_kill_all_monsters.py +92 -0
- pydsa/algorithms/greedy/minimum_time_to_remove_all_cars_containing_illegal_goods.py +55 -0
- pydsa/algorithms/greedy/minimum_total_operations.py +48 -0
- pydsa/algorithms/greedy/monotone_increasing_digits.py +63 -0
- pydsa/algorithms/greedy/most_profit_assigning_work.py +57 -0
- pydsa/algorithms/greedy/non_decreasing_array.py +57 -0
- pydsa/algorithms/greedy/number_of_unique_flavors_after_sharing_k_candies.py +63 -0
- pydsa/algorithms/greedy/pancake_sorting.py +64 -0
- pydsa/algorithms/greedy/partition_array_into_k_distinct_groups.py +51 -0
- pydsa/algorithms/greedy/partition_labels.py +53 -0
- pydsa/algorithms/greedy/patching_array.py +51 -0
- pydsa/algorithms/greedy/previous_permutation_with_one_swap.py +67 -0
- pydsa/algorithms/greedy/queue_reconstruction_by_height.py +53 -0
- pydsa/algorithms/greedy/reach_end_of_array_with_max_score.py +283 -0
- pydsa/algorithms/greedy/rearrange_string_k_distance_apart.py +70 -0
- pydsa/algorithms/greedy/reconstruct_a_2_row_binary_matrix.py +91 -0
- pydsa/algorithms/greedy/reduce_array_size_to_the_half.py +56 -0
- pydsa/algorithms/greedy/reducing_dishes.py +294 -0
- pydsa/algorithms/greedy/relocate_marbles.py +48 -0
- pydsa/algorithms/greedy/remove_all_ones_with_row_and_column_flips_ii.py +82 -0
- pydsa/algorithms/greedy/removing_minimum_number_of_magic_beans.py +52 -0
- pydsa/algorithms/greedy/reschedule_meetings_for_maximum_free_time_i.py +82 -0
- pydsa/algorithms/greedy/reschedule_meetings_for_maximum_free_time_ii.py +201 -0
- pydsa/algorithms/greedy/score_after_flipping_matrix.py +68 -0
- pydsa/algorithms/greedy/server_utilization_time.py +121 -0
- pydsa/algorithms/greedy/set_intersection_size_at_least_two.py +66 -0
- pydsa/algorithms/greedy/shortest_impossible_sequence_of_rolls.py +81 -0
- pydsa/algorithms/greedy/smallest_range_ii.py +62 -0
- pydsa/algorithms/greedy/split_a_string_in_balanced_strings.py +50 -0
- pydsa/algorithms/greedy/split_array_into_consecutive_subsequences.py +44 -0
- pydsa/algorithms/greedy/stamping_the_sequence.py +77 -0
- pydsa/algorithms/greedy/stone_game_vi.py +58 -0
- pydsa/algorithms/greedy/string_without_aaa_or_bbb.py +60 -0
- pydsa/algorithms/greedy/strong_password_checker.py +73 -0
- pydsa/algorithms/greedy/super_washing_machines.py +62 -0
- pydsa/algorithms/greedy/task_scheduler.py +72 -0
- pydsa/algorithms/greedy/task_scheduler_ii.py +58 -0
- pydsa/algorithms/greedy/time_needed_to_rearrange_a_binary_string.py +300 -0
- pydsa/algorithms/greedy/time_to_cross_a_bridge.py +158 -0
- pydsa/algorithms/greedy/two_city_scheduling.py +53 -0
- pydsa/algorithms/greedy/valid_parenthesis_string.py +71 -0
- pydsa/algorithms/greedy/video_stitching.py +60 -0
- pydsa/algorithms/greedy/watering_plants_ii.py +61 -0
- pydsa/algorithms/greedy/wiggle_subsequence.py +56 -0
- pydsa/algorithms/heaps/__init__.py +0 -0
- pydsa/algorithms/heaps/choose_k_elements_with_maximum_sum.py +50 -0
- pydsa/algorithms/heaps/construct_target_array_with_multiple_sums.py +79 -0
- pydsa/algorithms/heaps/design_a_food_rating_system.py +101 -0
- pydsa/algorithms/heaps/design_a_leaderboard.py +81 -0
- pydsa/algorithms/heaps/design_event_manager.py +103 -0
- pydsa/algorithms/heaps/design_exam_scores_tracker.py +92 -0
- pydsa/algorithms/heaps/design_movie_rental_system.py +250 -0
- pydsa/algorithms/heaps/design_task_manager.py +90 -0
- pydsa/algorithms/heaps/design_twitter.py +119 -0
- pydsa/algorithms/heaps/distant_barcodes.py +78 -0
- pydsa/algorithms/heaps/exam_room.py +281 -0
- pydsa/algorithms/heaps/find_k_pairs_with_smallest_sums.py +58 -0
- pydsa/algorithms/heaps/find_median_from_data_stream.py +76 -0
- pydsa/algorithms/heaps/find_servers_that_handled_most_number_of_requests.py +319 -0
- pydsa/algorithms/heaps/find_the_kth_smallest_sum_of_a_matrix_with_sorted_rows.py +66 -0
- pydsa/algorithms/heaps/find_trending_hashtags_ii.py +343 -0
- pydsa/algorithms/heaps/ipo.py +64 -0
- pydsa/algorithms/heaps/k_closest_points_to_origin.py +54 -0
- pydsa/algorithms/heaps/kth_largest_element_in_a_stream.py +97 -0
- pydsa/algorithms/heaps/kth_largest_element_in_an_array.py +61 -0
- pydsa/algorithms/heaps/kth_smallest_prime_fraction.py +64 -0
- pydsa/algorithms/heaps/last_stone_weight.py +56 -0
- pydsa/algorithms/heaps/maximal_score_after_applying_k_operations.py +65 -0
- pydsa/algorithms/heaps/maximum_average_pass_ratio.py +67 -0
- pydsa/algorithms/heaps/maximum_number_of_eaten_apples.py +70 -0
- pydsa/algorithms/heaps/maximum_number_of_upgradable_servers.py +126 -0
- pydsa/algorithms/heaps/maximum_performance_of_a_team.py +67 -0
- pydsa/algorithms/heaps/maximum_product_after_k_increments.py +56 -0
- pydsa/algorithms/heaps/maximum_sum_with_at_most_k_elements.py +53 -0
- pydsa/algorithms/heaps/meeting_rooms_iii.py +336 -0
- pydsa/algorithms/heaps/merge_k_sorted_lists.py +70 -0
- pydsa/algorithms/heaps/minimize_deviation_in_array.py +69 -0
- pydsa/algorithms/heaps/minimum_amount_of_time_to_fill_cups.py +63 -0
- pydsa/algorithms/heaps/minimum_cost_to_connect_sticks.py +61 -0
- pydsa/algorithms/heaps/minimum_cost_to_hire_k_workers.py +71 -0
- pydsa/algorithms/heaps/minimum_cost_to_merge_sorted_lists.py +73 -0
- pydsa/algorithms/heaps/minimum_difference_in_sums_after_removal_of_elements.py +89 -0
- pydsa/algorithms/heaps/minimum_time_to_build_blocks.py +63 -0
- pydsa/algorithms/heaps/number_of_orders_in_the_backlog.py +72 -0
- pydsa/algorithms/heaps/page_recommendations_ii.py +81 -0
- pydsa/algorithms/heaps/process_tasks_using_servers.py +84 -0
- pydsa/algorithms/heaps/reorganize_string.py +75 -0
- pydsa/algorithms/heaps/reveal_cards_in_increasing_order.py +61 -0
- pydsa/algorithms/heaps/seat_reservation_manager.py +73 -0
- pydsa/algorithms/heaps/single_threaded_cpu.py +69 -0
- pydsa/algorithms/heaps/smallest_number_in_infinite_set.py +87 -0
- pydsa/algorithms/heaps/stock_price_fluctuation.py +268 -0
- pydsa/algorithms/heaps/super_ugly_number.py +57 -0
- pydsa/algorithms/heaps/take_gifts_from_the_richest_pile.py +224 -0
- pydsa/algorithms/heaps/the_k_strongest_values_in_an_array.py +57 -0
- pydsa/algorithms/heaps/the_number_of_the_smallest_unoccupied_chair.py +212 -0
- pydsa/algorithms/heaps/the_skyline_problem.py +49 -0
- pydsa/algorithms/heaps/top_k_frequent_elements.py +52 -0
- pydsa/algorithms/heaps/top_k_frequent_words.py +82 -0
- pydsa/algorithms/heaps/top_three_wineries.py +51 -0
- pydsa/algorithms/heaps/total_cost_to_hire_k_workers.py +331 -0
- pydsa/algorithms/heaps/trapping_rain_water_ii.py +80 -0
- pydsa/algorithms/heaps/ugly_number_ii.py +66 -0
- pydsa/algorithms/intervals/__init__.py +0 -0
- pydsa/algorithms/intervals/count_days_spent_together.py +48 -0
- pydsa/algorithms/intervals/count_days_without_meetings.py +61 -0
- pydsa/algorithms/intervals/count_ways_to_group_overlapping_ranges.py +108 -0
- pydsa/algorithms/intervals/custom_interval.py +49 -0
- pydsa/algorithms/intervals/data_stream_as_disjoint_intervals.py +306 -0
- pydsa/algorithms/intervals/divide_intervals_into_minimum_number_of_groups.py +58 -0
- pydsa/algorithms/intervals/employee_free_time.py +73 -0
- pydsa/algorithms/intervals/falling_squares.py +53 -0
- pydsa/algorithms/intervals/find_maximal_uncovered_ranges.py +64 -0
- pydsa/algorithms/intervals/find_right_interval.py +67 -0
- pydsa/algorithms/intervals/insert_interval.py +55 -0
- pydsa/algorithms/intervals/interval_cancellation.py +59 -0
- pydsa/algorithms/intervals/interval_list_intersections.py +50 -0
- pydsa/algorithms/intervals/maximum_team_size_with_overlapping_intervals.py +73 -0
- pydsa/algorithms/intervals/maximum_total_area_occupied_by_pistons.py +59 -0
- pydsa/algorithms/intervals/meeting_rooms.py +43 -0
- pydsa/algorithms/intervals/meeting_rooms_ii.py +59 -0
- pydsa/algorithms/intervals/meeting_scheduler.py +45 -0
- pydsa/algorithms/intervals/merge_intervals.py +49 -0
- pydsa/algorithms/intervals/merge_overlapping_events_in_the_same_hall.py +56 -0
- pydsa/algorithms/intervals/minimize_connected_groups_by_inserting_interval.py +116 -0
- pydsa/algorithms/intervals/minimum_interval_to_include_each_query.py +65 -0
- pydsa/algorithms/intervals/minimum_number_of_arrows_to_burst_balloons.py +54 -0
- pydsa/algorithms/intervals/minimum_number_of_chairs_in_a_waiting_room.py +57 -0
- pydsa/algorithms/intervals/my_calendar_i.py +74 -0
- pydsa/algorithms/intervals/my_calendar_ii.py +76 -0
- pydsa/algorithms/intervals/my_calendar_iii.py +97 -0
- pydsa/algorithms/intervals/non_overlapping_intervals.py +58 -0
- pydsa/algorithms/intervals/range_module.py +93 -0
- pydsa/algorithms/intervals/rectangle_area_ii.py +101 -0
- pydsa/algorithms/intervals/remove_covered_intervals.py +57 -0
- pydsa/algorithms/intervals/remove_interval.py +57 -0
- pydsa/algorithms/intervals/two_best_non_overlapping_events.py +73 -0
- pydsa/algorithms/linked_list/__init__.py +0 -0
- pydsa/algorithms/linked_list/add_two_numbers.py +62 -0
- pydsa/algorithms/linked_list/add_two_numbers_ii.py +133 -0
- pydsa/algorithms/linked_list/add_two_polynomials_represented_as_linked_lists.py +63 -0
- pydsa/algorithms/linked_list/all_o_one_data_structure.py +140 -0
- pydsa/algorithms/linked_list/binary_linked_list_to_int.py +55 -0
- pydsa/algorithms/linked_list/convert_doubly_linked_list_to_array_i.py +46 -0
- pydsa/algorithms/linked_list/convert_doubly_linked_list_to_array_ii.py +50 -0
- pydsa/algorithms/linked_list/copy_list_with_random_pointer.py +71 -0
- pydsa/algorithms/linked_list/delete_n_nodes_after_m_nodes_of_a_linked_list.py +70 -0
- pydsa/algorithms/linked_list/delete_node_in_a_linked_list.py +47 -0
- pydsa/algorithms/linked_list/delete_nodes_from_linked_list_present_in_array.py +39 -0
- pydsa/algorithms/linked_list/delete_the_middle_node_of_a_linked_list.py +41 -0
- pydsa/algorithms/linked_list/design_linked_list.py +154 -0
- pydsa/algorithms/linked_list/design_most_recently_used_queue.py +98 -0
- pydsa/algorithms/linked_list/design_phone_directory.py +93 -0
- pydsa/algorithms/linked_list/design_skiplist.py +147 -0
- pydsa/algorithms/linked_list/double_a_number_represented_as_a_linked_list.py +74 -0
- pydsa/algorithms/linked_list/flatten_a_multilevel_doubly_linked_list.py +80 -0
- pydsa/algorithms/linked_list/insert_greatest_common_divisors_in_linked_list.py +57 -0
- pydsa/algorithms/linked_list/insert_into_a_sorted_circular_linked_list.py +72 -0
- pydsa/algorithms/linked_list/insertion_sort_list.py +59 -0
- pydsa/algorithms/linked_list/intersection_of_two_linked_lists.py +63 -0
- pydsa/algorithms/linked_list/lfu_cache.py +103 -0
- pydsa/algorithms/linked_list/linked_list_components.py +58 -0
- pydsa/algorithms/linked_list/linked_list_cycle.py +40 -0
- pydsa/algorithms/linked_list/linked_list_cycle_ii.py +67 -0
- pydsa/algorithms/linked_list/linked_list_frequency.py +36 -0
- pydsa/algorithms/linked_list/linked_list_random_node.py +61 -0
- pydsa/algorithms/linked_list/lru_cache.py +131 -0
- pydsa/algorithms/linked_list/maximum_twin_sum_of_a_linked_list.py +53 -0
- pydsa/algorithms/linked_list/merge_in_between_linked_lists.py +62 -0
- pydsa/algorithms/linked_list/merge_nodes_in_between_zeros.py +60 -0
- pydsa/algorithms/linked_list/merge_two_sorted_lists.py +45 -0
- pydsa/algorithms/linked_list/middle_of_the_linked_list.py +66 -0
- pydsa/algorithms/linked_list/odd_even_linked_list.py +44 -0
- pydsa/algorithms/linked_list/palindrome_linked_list.py +68 -0
- pydsa/algorithms/linked_list/partition_list.py +67 -0
- pydsa/algorithms/linked_list/plus_one_linked_list.py +78 -0
- pydsa/algorithms/linked_list/print_immutable_linked_list_in_reverse.py +47 -0
- pydsa/algorithms/linked_list/remove_duplicates_from_an_unsorted_linked_list.py +67 -0
- pydsa/algorithms/linked_list/remove_duplicates_from_sorted_list.py +50 -0
- pydsa/algorithms/linked_list/remove_duplicates_from_sorted_list_ii.py +58 -0
- pydsa/algorithms/linked_list/remove_linked_list_elements.py +71 -0
- pydsa/algorithms/linked_list/remove_nodes_from_linked_list.py +66 -0
- pydsa/algorithms/linked_list/remove_nth_node_from_end_of_list.py +55 -0
- pydsa/algorithms/linked_list/remove_zero_sum_consecutive_nodes_from_linked_list.py +66 -0
- pydsa/algorithms/linked_list/reorder_list.py +74 -0
- pydsa/algorithms/linked_list/reverse_linked_list.py +36 -0
- pydsa/algorithms/linked_list/reverse_linked_list_ii.py +65 -0
- pydsa/algorithms/linked_list/reverse_nodes_in_even_length_groups.py +83 -0
- pydsa/algorithms/linked_list/reverse_nodes_in_k_group.py +74 -0
- pydsa/algorithms/linked_list/rotate_list.py +68 -0
- pydsa/algorithms/linked_list/sort_linked_list_already_sorted_using_absolute_values.py +83 -0
- pydsa/algorithms/linked_list/sort_list.py +99 -0
- pydsa/algorithms/linked_list/split_a_circular_linked_list.py +73 -0
- pydsa/algorithms/linked_list/split_linked_list_in_parts.py +79 -0
- pydsa/algorithms/linked_list/swap_nodes_in_pairs.py +57 -0
- pydsa/algorithms/linked_list/swapping_nodes_in_a_linked_list.py +72 -0
- pydsa/algorithms/linked_list/winner_of_the_linked_list_game.py +99 -0
- pydsa/algorithms/math/__init__.py +0 -0
- pydsa/algorithms/math/a_number_after_a_double_reversal.py +304 -0
- pydsa/algorithms/math/abbreviating_the_product_of_a_range.py +51 -0
- pydsa/algorithms/math/account_balance_after_rounded_purchase.py +54 -0
- pydsa/algorithms/math/active_businesses.py +83 -0
- pydsa/algorithms/math/active_users.py +71 -0
- pydsa/algorithms/math/activity_participants.py +68 -0
- pydsa/algorithms/math/add_binary.py +53 -0
- pydsa/algorithms/math/add_digits.py +44 -0
- pydsa/algorithms/math/add_strings.py +53 -0
- pydsa/algorithms/math/add_to_array_form_of_integer.py +57 -0
- pydsa/algorithms/math/add_two_integers.py +32 -0
- pydsa/algorithms/math/add_two_promises.py +39 -0
- pydsa/algorithms/math/adding_two_negabinary_numbers.py +86 -0
- pydsa/algorithms/math/ads_performance.py +56 -0
- pydsa/algorithms/math/airplane_seat_assignment_probability.py +45 -0
- pydsa/algorithms/math/alice_and_bob_playing_flower_game.py +50 -0
- pydsa/algorithms/math/all_people_report_to_the_given_manager.py +60 -0
- pydsa/algorithms/math/all_the_matches_of_the_league.py +40 -0
- pydsa/algorithms/math/alternating_digit_sum.py +42 -0
- pydsa/algorithms/math/angle_between_hands_of_a_clock.py +52 -0
- pydsa/algorithms/math/angles_of_a_triangle.py +60 -0
- pydsa/algorithms/math/ant_on_the_boundary.py +78 -0
- pydsa/algorithms/math/append_k_integers_with_minimal_sum.py +57 -0
- pydsa/algorithms/math/apples_and_oranges.py +209 -0
- pydsa/algorithms/math/armstrong_number.py +61 -0
- pydsa/algorithms/math/arranging_coins.py +55 -0
- pydsa/algorithms/math/article_views_i.py +40 -0
- pydsa/algorithms/math/article_views_ii.py +58 -0
- pydsa/algorithms/math/average_salary_departments_vs_company.py +84 -0
- pydsa/algorithms/math/average_selling_price.py +105 -0
- pydsa/algorithms/math/balanced_k_factor_decomposition.py +97 -0
- pydsa/algorithms/math/base_7.py +49 -0
- pydsa/algorithms/math/basic_calculator_iv.py +140 -0
- pydsa/algorithms/math/beautiful_array.py +68 -0
- pydsa/algorithms/math/best_meeting_point.py +56 -0
- pydsa/algorithms/math/best_position_for_a_service_centre.py +64 -0
- pydsa/algorithms/math/big_countries.py +55 -0
- pydsa/algorithms/math/biggest_single_number.py +47 -0
- pydsa/algorithms/math/binary_prefix_divisible_by_5.py +40 -0
- pydsa/algorithms/math/bitwise_xor_of_all_pairings.py +156 -0
- pydsa/algorithms/math/build_the_equation.py +109 -0
- pydsa/algorithms/math/building_boxes.py +40 -0
- pydsa/algorithms/math/building_h2o.py +80 -0
- pydsa/algorithms/math/bulb_switcher.py +45 -0
- pydsa/algorithms/math/bulb_switcher_ii.py +272 -0
- pydsa/algorithms/math/calculate_amount_paid_in_taxes.py +55 -0
- pydsa/algorithms/math/calculate_compressed_mean.py +60 -0
- pydsa/algorithms/math/calculate_delayed_arrival_time.py +39 -0
- pydsa/algorithms/math/calculate_money_in_leetcode_bank.py +46 -0
- pydsa/algorithms/math/calculator_with_method_chaining.py +101 -0
- pydsa/algorithms/math/can_you_eat_your_favorite_candy_on_your_favorite_day.py +142 -0
- pydsa/algorithms/math/capital_gain_loss.py +61 -0
- pydsa/algorithms/math/chalkboard_xor_game.py +125 -0
- pydsa/algorithms/math/check_adjacent_digit_differences.py +53 -0
- pydsa/algorithms/math/check_digitorial_permutation.py +45 -0
- pydsa/algorithms/math/check_divisibility_by_digit_sum_and_product.py +61 -0
- pydsa/algorithms/math/check_if_it_is_a_good_array.py +54 -0
- pydsa/algorithms/math/check_if_it_is_a_straight_line.py +63 -0
- pydsa/algorithms/math/check_if_move_is_legal.py +76 -0
- pydsa/algorithms/math/check_if_number_has_equal_digit_count_and_digit_value.py +49 -0
- pydsa/algorithms/math/check_if_number_is_a_sum_of_powers_of_three.py +36 -0
- pydsa/algorithms/math/check_if_point_is_reachable.py +79 -0
- pydsa/algorithms/math/check_if_the_number_is_fascinating.py +58 -0
- pydsa/algorithms/math/check_if_two_chessboard_squares_have_the_same_color.py +43 -0
- pydsa/algorithms/math/circle_and_rectangle_overlapping.py +59 -0
- pydsa/algorithms/math/classes_with_at_least_5_students.py +48 -0
- pydsa/algorithms/math/classifying_triangles_by_lengths.py +56 -0
- pydsa/algorithms/math/closest_divisors.py +50 -0
- pydsa/algorithms/math/closest_fair_integer.py +69 -0
- pydsa/algorithms/math/closest_prime_numbers_in_range.py +70 -0
- pydsa/algorithms/math/clumsy_factorial.py +105 -0
- pydsa/algorithms/math/complete_prime_number.py +74 -0
- pydsa/algorithms/math/complex_number_multiplication.py +52 -0
- pydsa/algorithms/math/compute_decimal_representation.py +47 -0
- pydsa/algorithms/math/compute_the_rank_as_a_percentage.py +80 -0
- pydsa/algorithms/math/concatenate_non_zero_digits_and_multiply_by_sum_i.py +54 -0
- pydsa/algorithms/math/concatenate_non_zero_digits_and_multiply_by_sum_ii.py +279 -0
- pydsa/algorithms/math/concatenated_divisibility.py +70 -0
- pydsa/algorithms/math/concatenation_of_consecutive_binary_numbers.py +51 -0
- pydsa/algorithms/math/confirmation_rate.py +71 -0
- pydsa/algorithms/math/confusing_number.py +62 -0
- pydsa/algorithms/math/confusing_number_ii.py +73 -0
- pydsa/algorithms/math/consecutive_available_seats.py +81 -0
- pydsa/algorithms/math/consecutive_numbers_sum.py +68 -0
- pydsa/algorithms/math/construct_product_matrix.py +111 -0
- pydsa/algorithms/math/construct_the_rectangle.py +55 -0
- pydsa/algorithms/math/continuous_ranges.py +64 -0
- pydsa/algorithms/math/continuous_subarray_sum.py +62 -0
- pydsa/algorithms/math/convert_a_number_to_hexadecimal.py +55 -0
- pydsa/algorithms/math/convert_integer_to_the_sum_of_two_no_zero_integers.py +49 -0
- pydsa/algorithms/math/convert_the_temperature.py +33 -0
- pydsa/algorithms/math/convert_to_base_minus_2.py +61 -0
- pydsa/algorithms/math/convex_polygon.py +67 -0
- pydsa/algorithms/math/coordinate_with_maximum_network_quality.py +70 -0
- pydsa/algorithms/math/count_all_valid_pickup_and_delivery_options.py +26 -0
- pydsa/algorithms/math/count_apples_and_oranges.py +86 -0
- pydsa/algorithms/math/count_beautiful_numbers.py +110 -0
- pydsa/algorithms/math/count_binary_palindromic_numbers.py +101 -0
- pydsa/algorithms/math/count_collisions_of_monkeys_on_a_polygon.py +64 -0
- pydsa/algorithms/math/count_commas_in_range.py +69 -0
- pydsa/algorithms/math/count_commas_in_range_ii.py +80 -0
- pydsa/algorithms/math/count_digit_appearances.py +135 -0
- pydsa/algorithms/math/count_distinct_integers_after_removing_zeros.py +51 -0
- pydsa/algorithms/math/count_fancy_numbers_in_a_range.py +171 -0
- pydsa/algorithms/math/count_good_numbers.py +62 -0
- pydsa/algorithms/math/count_integers_in_intervals.py +61 -0
- pydsa/algorithms/math/count_integers_with_even_digit_sum.py +60 -0
- pydsa/algorithms/math/count_k_reducible_numbers_less_than_n.py +97 -0
- pydsa/algorithms/math/count_kth_roots_in_a_range.py +93 -0
- pydsa/algorithms/math/count_largest_group.py +52 -0
- pydsa/algorithms/math/count_lattice_points_inside_a_circle.py +48 -0
- pydsa/algorithms/math/count_monobit_integers.py +48 -0
- pydsa/algorithms/math/count_nice_pairs_in_an_array.py +51 -0
- pydsa/algorithms/math/count_no_zero_pairs_that_sum_to_n.py +57 -0
- pydsa/algorithms/math/count_number_of_texts.py +99 -0
- pydsa/algorithms/math/count_number_of_trapezoids_i.py +52 -0
- pydsa/algorithms/math/count_number_of_trapezoids_ii.py +64 -0
- pydsa/algorithms/math/count_number_of_ways_to_place_houses.py +92 -0
- pydsa/algorithms/math/count_numbers_with_unique_digits.py +66 -0
- pydsa/algorithms/math/count_numbers_with_unique_digits_ii.py +90 -0
- pydsa/algorithms/math/count_odd_letters_from_number.py +48 -0
- pydsa/algorithms/math/count_odd_numbers_in_an_interval_range.py +36 -0
- pydsa/algorithms/math/count_operations_to_obtain_zero.py +71 -0
- pydsa/algorithms/math/count_partitions_with_even_sum_difference.py +57 -0
- pydsa/algorithms/math/count_primes.py +55 -0
- pydsa/algorithms/math/count_residue_prefixes.py +56 -0
- pydsa/algorithms/math/count_sorted_vowel_strings.py +58 -0
- pydsa/algorithms/math/count_special_integers.py +75 -0
- pydsa/algorithms/math/count_square_sum_triples.py +202 -0
- pydsa/algorithms/math/count_student_number_in_departments.py +66 -0
- pydsa/algorithms/math/count_substrings_with_only_one_distinct_letter.py +58 -0
- pydsa/algorithms/math/count_symmetric_integers.py +58 -0
- pydsa/algorithms/math/count_the_digits_that_divide_a_number.py +41 -0
- pydsa/algorithms/math/count_the_hidden_sequences.py +100 -0
- pydsa/algorithms/math/count_the_number_of_computer_unlocking_permutations.py +55 -0
- pydsa/algorithms/math/count_the_number_of_experiments.py +58 -0
- pydsa/algorithms/math/count_the_number_of_good_subsequences.py +222 -0
- pydsa/algorithms/math/count_the_number_of_houses_at_a_certain_distance_i.py +57 -0
- pydsa/algorithms/math/count_the_number_of_houses_at_a_certain_distance_ii.py +73 -0
- pydsa/algorithms/math/count_the_number_of_ideal_arrays.py +106 -0
- pydsa/algorithms/math/count_the_number_of_infection_sequences.py +121 -0
- pydsa/algorithms/math/count_the_number_of_inversions.py +84 -0
- pydsa/algorithms/math/count_the_number_of_k_free_subsets.py +53 -0
- pydsa/algorithms/math/count_triplets_with_even_xor_set_bits_i.py +47 -0
- pydsa/algorithms/math/count_triplets_with_even_xor_set_bits_ii.py +61 -0
- pydsa/algorithms/math/count_vowel_strings_in_ranges.py +72 -0
- pydsa/algorithms/math/count_ways_to_choose_coprime_integers_from_rows.py +98 -0
- pydsa/algorithms/math/count_ways_to_distribute_candies.py +94 -0
- pydsa/algorithms/math/counter_ii.py +78 -0
- pydsa/algorithms/math/curry.py +49 -0
- pydsa/algorithms/math/customer_placing_largest_number_of_orders.py +57 -0
- pydsa/algorithms/math/customers_who_bought_products_a_and_b_but_not_c.py +51 -0
- pydsa/algorithms/math/customers_who_never_order.py +41 -0
- pydsa/algorithms/math/daily_leads_and_partners.py +61 -0
- pydsa/algorithms/math/day_of_the_week.py +100 -0
- pydsa/algorithms/math/day_of_the_year.py +52 -0
- pydsa/algorithms/math/decode_xored_permutation.py +196 -0
- pydsa/algorithms/math/delay_the_resolution_of_each_promise.py +55 -0
- pydsa/algorithms/math/delete_duplicate_emails.py +32 -0
- pydsa/algorithms/math/department_highest_salary.py +57 -0
- pydsa/algorithms/math/department_top_three_salaries.py +76 -0
- pydsa/algorithms/math/design_cancellable_function.py +66 -0
- pydsa/algorithms/math/detect_squares.py +58 -0
- pydsa/algorithms/math/determine_color_of_a_chessboard_square.py +39 -0
- pydsa/algorithms/math/determine_the_winner_of_a_bowling_game.py +61 -0
- pydsa/algorithms/math/difference_between_element_sum_and_digit_sum_of_an_array.py +42 -0
- pydsa/algorithms/math/digit_count_in_range.py +80 -0
- pydsa/algorithms/math/digit_operations_to_make_two_integers_equal.py +232 -0
- pydsa/algorithms/math/distinct_prime_factors_of_product_of_array.py +52 -0
- pydsa/algorithms/math/distribute_candies_among_children_i.py +54 -0
- pydsa/algorithms/math/distribute_candies_among_children_ii.py +90 -0
- pydsa/algorithms/math/distribute_candies_among_children_iii.py +62 -0
- pydsa/algorithms/math/distribute_candies_to_people.py +99 -0
- pydsa/algorithms/math/distribute_money_to_maximum_children.py +217 -0
- pydsa/algorithms/math/divide_two_integers.py +71 -0
- pydsa/algorithms/math/divisible_and_non_divisible_sums_difference.py +43 -0
- pydsa/algorithms/math/divisor_game.py +47 -0
- pydsa/algorithms/math/double_modular_exponentiation.py +48 -0
- pydsa/algorithms/math/duplicate_emails.py +40 -0
- pydsa/algorithms/math/elimination_game.py +56 -0
- pydsa/algorithms/math/employee_bonus.py +58 -0
- pydsa/algorithms/math/employees_earning_more_than_their_managers.py +33 -0
- pydsa/algorithms/math/encode_and_decode_tinyurl.py +101 -0
- pydsa/algorithms/math/encode_number.py +99 -0
- pydsa/algorithms/math/equal_rational_numbers.py +60 -0
- pydsa/algorithms/math/erect_the_fence.py +70 -0
- pydsa/algorithms/math/escape_the_ghosts.py +50 -0
- pydsa/algorithms/math/excel_sheet_column_number.py +37 -0
- pydsa/algorithms/math/excel_sheet_column_title.py +40 -0
- pydsa/algorithms/math/exchange_seats.py +43 -0
- pydsa/algorithms/math/execute_asynchronous_functions_in_parallel.py +44 -0
- pydsa/algorithms/math/factorial_generator.py +187 -0
- pydsa/algorithms/math/factorial_trailing_zeroes.py +40 -0
- pydsa/algorithms/math/fill_a_special_grid.py +50 -0
- pydsa/algorithms/math/find_cumulative_salary_of_an_employee.py +148 -0
- pydsa/algorithms/math/find_customer_referee.py +53 -0
- pydsa/algorithms/math/find_greatest_common_divisor_of_array.py +42 -0
- pydsa/algorithms/math/find_if_digit_game_can_be_won.py +40 -0
- pydsa/algorithms/math/find_maximum_area_of_a_triangle.py +93 -0
- pydsa/algorithms/math/find_median_given_frequency_of_numbers.py +74 -0
- pydsa/algorithms/math/find_minimum_log_transportation_cost.py +58 -0
- pydsa/algorithms/math/find_minimum_operations_to_make_all_elements_divisible_by_three.py +48 -0
- pydsa/algorithms/math/find_missing_observations.py +45 -0
- pydsa/algorithms/math/find_n_unique_integers_sum_up_to_zero.py +45 -0
- pydsa/algorithms/math/find_palindrome_with_fixed_length.py +71 -0
- pydsa/algorithms/math/find_sum_of_array_product_of_magical_sequences.py +57 -0
- pydsa/algorithms/math/find_the_closest_palindrome.py +87 -0
- pydsa/algorithms/math/find_the_count_of_good_integers.py +92 -0
- pydsa/algorithms/math/find_the_count_of_numbers_which_are_not_special.py +86 -0
- pydsa/algorithms/math/find_the_integer_added_to_array_i.py +55 -0
- pydsa/algorithms/math/find_the_k_beauty_of_a_number.py +40 -0
- pydsa/algorithms/math/find_the_key_of_the_numbers.py +46 -0
- pydsa/algorithms/math/find_the_kth_character_in_string_game_i.py +55 -0
- pydsa/algorithms/math/find_the_kth_character_in_string_game_ii.py +58 -0
- pydsa/algorithms/math/find_the_kth_lucky_number.py +274 -0
- pydsa/algorithms/math/find_the_largest_area_of_square_inside_two_rectangles.py +56 -0
- pydsa/algorithms/math/find_the_largest_palindrome_divisible_by_k.py +317 -0
- pydsa/algorithms/math/find_the_least_frequent_digit.py +65 -0
- pydsa/algorithms/math/find_the_losers_of_the_circular_game.py +112 -0
- pydsa/algorithms/math/find_the_maximum_achievable_number.py +101 -0
- pydsa/algorithms/math/find_the_maximum_factor_score_of_array.py +56 -0
- pydsa/algorithms/math/find_the_minimum_amount_of_time_to_brew_potions.py +132 -0
- pydsa/algorithms/math/find_the_minimum_number_of_fibonacci_numbers_whose_sum_is_k.py +65 -0
- pydsa/algorithms/math/find_the_n_th_value_after_k_seconds.py +36 -0
- pydsa/algorithms/math/find_the_number_of_subsequences_with_equal_gcd.py +82 -0
- pydsa/algorithms/math/find_the_number_of_winning_players.py +57 -0
- pydsa/algorithms/math/find_the_original_typed_string_i.py +249 -0
- pydsa/algorithms/math/find_the_pivot_integer.py +63 -0
- pydsa/algorithms/math/find_the_punishment_number_of_an_integer.py +82 -0
- pydsa/algorithms/math/find_the_student_that_will_replace_the_chalk.py +210 -0
- pydsa/algorithms/math/find_the_subtasks_that_did_not_execute.py +44 -0
- pydsa/algorithms/math/find_the_sum_of_the_power_of_all_subsequences.py +60 -0
- pydsa/algorithms/math/find_the_team_size.py +41 -0
- pydsa/algorithms/math/find_the_winner_of_the_circular_game.py +49 -0
- pydsa/algorithms/math/find_the_winning_player_in_coin_game.py +44 -0
- pydsa/algorithms/math/find_three_consecutive_integers_that_sum_to_a_given_number.py +54 -0
- pydsa/algorithms/math/find_time_required_to_eliminate_bacterial_strains.py +54 -0
- pydsa/algorithms/math/find_unique_binary_string.py +290 -0
- pydsa/algorithms/math/finding_3_digit_even_numbers.py +56 -0
- pydsa/algorithms/math/finding_the_users_active_minutes.py +54 -0
- pydsa/algorithms/math/fizz_buzz.py +51 -0
- pydsa/algorithms/math/fizz_buzz_multithreaded.py +93 -0
- pydsa/algorithms/math/four_divisors.py +52 -0
- pydsa/algorithms/math/fraction_addition_and_subtraction.py +85 -0
- pydsa/algorithms/math/fraction_to_recurring_decimal.py +58 -0
- pydsa/algorithms/math/friend_requests_i_overall_acceptance_rate.py +44 -0
- pydsa/algorithms/math/friend_requests_ii_who_has_the_most_friends.py +65 -0
- pydsa/algorithms/math/function_composition.py +41 -0
- pydsa/algorithms/math/furthest_point_from_origin.py +50 -0
- pydsa/algorithms/math/game_of_nim.py +34 -0
- pydsa/algorithms/math/game_play_analysis_iii.py +67 -0
- pydsa/algorithms/math/game_play_analysis_iv.py +70 -0
- pydsa/algorithms/math/gcd_of_odd_and_even_sums.py +49 -0
- pydsa/algorithms/math/generate_fibonacci_sequence.py +52 -0
- pydsa/algorithms/math/generate_random_point_in_a_circle.py +61 -0
- pydsa/algorithms/math/get_highest_answer_rate_question.py +69 -0
- pydsa/algorithms/math/global_and_local_inversions.py +49 -0
- pydsa/algorithms/math/gray_code.py +44 -0
- pydsa/algorithms/math/guess_the_word.py +95 -0
- pydsa/algorithms/math/happy_number.py +56 -0
- pydsa/algorithms/math/harshad_number.py +47 -0
- pydsa/algorithms/math/hexadecimal_and_hexatrigesimal_conversion.py +56 -0
- pydsa/algorithms/math/hexspeak.py +77 -0
- pydsa/algorithms/math/highest_grade_for_each_student.py +56 -0
- pydsa/algorithms/math/human_traffic_of_stadium.py +68 -0
- pydsa/algorithms/math/identify_the_largest_outlier_in_an_array.py +56 -0
- pydsa/algorithms/math/immediate_food_delivery_i.py +53 -0
- pydsa/algorithms/math/immediate_food_delivery_ii.py +80 -0
- pydsa/algorithms/math/implement_rand10_using_rand7.py +59 -0
- pydsa/algorithms/math/integer_to_roman.py +65 -0
- pydsa/algorithms/math/integers_with_multiple_sum_of_two_cubes.py +62 -0
- pydsa/algorithms/math/investments_in_2016.py +70 -0
- pydsa/algorithms/math/k_th_smallest_in_lexicographical_order.py +76 -0
- pydsa/algorithms/math/k_th_symbol_in_grammar.py +90 -0
- pydsa/algorithms/math/kth_smallest_amount_with_single_denomination_combination.py +93 -0
- pydsa/algorithms/math/largest_component_size_by_common_factor.py +90 -0
- pydsa/algorithms/math/largest_palindrome_product.py +76 -0
- pydsa/algorithms/math/largest_palindromic_number.py +80 -0
- pydsa/algorithms/math/largest_prime_from_consecutive_prime_sum.py +89 -0
- pydsa/algorithms/math/largest_time_for_given_digits.py +63 -0
- pydsa/algorithms/math/largest_triangle_area.py +51 -0
- pydsa/algorithms/math/last_moment_before_all_ants_fall_out_of_a_plank.py +52 -0
- pydsa/algorithms/math/last_person_to_fit_in_the_bus.py +49 -0
- pydsa/algorithms/math/last_remaining_integer_after_alternating_deletion_operations.py +62 -0
- pydsa/algorithms/math/latest_time_by_replacing_hidden_digits.py +60 -0
- pydsa/algorithms/math/lexicographical_numbers.py +49 -0
- pydsa/algorithms/math/lexicographically_smallest_negated_permutation_that_sums_to_target.py +95 -0
- pydsa/algorithms/math/library_late_fee_calculator.py +57 -0
- pydsa/algorithms/math/line_reflection.py +57 -0
- pydsa/algorithms/math/list_the_products_ordered_in_a_period.py +65 -0
- pydsa/algorithms/math/managers_with_at_least_5_direct_reports.py +70 -0
- pydsa/algorithms/math/manhattan_distances_of_all_arrangements_of_pieces.py +215 -0
- pydsa/algorithms/math/market_analysis_i.py +63 -0
- pydsa/algorithms/math/market_analysis_ii.py +72 -0
- pydsa/algorithms/math/math.py +39 -0
- pydsa/algorithms/math/max_darts_inside_circle.py +98 -0
- pydsa/algorithms/math/max_difference_you_can_get_from_changing_an_integer.py +87 -0
- pydsa/algorithms/math/max_points_on_a_line.py +70 -0
- pydsa/algorithms/math/maximize_count_of_distinct_primes_after_split.py +93 -0
- pydsa/algorithms/math/maximize_expression_of_three_elements.py +68 -0
- pydsa/algorithms/math/maximize_number_of_nice_divisors.py +58 -0
- pydsa/algorithms/math/maximize_sum_of_squares_of_digits.py +85 -0
- pydsa/algorithms/math/maximize_the_distance_between_points_on_a_square.py +85 -0
- pydsa/algorithms/math/maximum_69_number.py +42 -0
- pydsa/algorithms/math/maximum_and_sum_of_array.py +41 -0
- pydsa/algorithms/math/maximum_difference_by_remapping_a_digit.py +72 -0
- pydsa/algorithms/math/maximum_font_to_fit_a_sentence_in_a_screen.py +63 -0
- pydsa/algorithms/math/maximum_height_of_a_triangle.py +54 -0
- pydsa/algorithms/math/maximum_manhattan_distance_after_k_changes.py +217 -0
- pydsa/algorithms/math/maximum_number_of_integers_to_choose_from_a_range_i.py +42 -0
- pydsa/algorithms/math/maximum_number_of_integers_to_choose_from_a_range_ii.py +46 -0
- pydsa/algorithms/math/maximum_number_of_visible_points.py +79 -0
- pydsa/algorithms/math/maximum_number_of_weeks_for_which_you_can_work.py +51 -0
- pydsa/algorithms/math/maximum_of_absolute_value_expression.py +68 -0
- pydsa/algorithms/math/maximum_points_inside_the_square.py +180 -0
- pydsa/algorithms/math/maximum_possible_number_by_binary_concatenation.py +63 -0
- pydsa/algorithms/math/maximum_price_to_fill_a_bag.py +340 -0
- pydsa/algorithms/math/maximum_prime_difference.py +57 -0
- pydsa/algorithms/math/maximum_product_of_three_numbers.py +62 -0
- pydsa/algorithms/math/maximum_product_of_two_digits.py +53 -0
- pydsa/algorithms/math/maximum_product_of_two_integers_with_no_common_bits.py +48 -0
- pydsa/algorithms/math/maximum_split_of_positive_even_integers.py +60 -0
- pydsa/algorithms/math/median_employee_salary.py +86 -0
- pydsa/algorithms/math/minimize_manhattan_distances.py +64 -0
- pydsa/algorithms/math/minimize_result_by_adding_parentheses_to_expression.py +157 -0
- pydsa/algorithms/math/minimize_xor.py +51 -0
- pydsa/algorithms/math/minimum_addition_to_make_integer_beautiful.py +51 -0
- pydsa/algorithms/math/minimum_adjacent_swaps_to_reach_the_kth_smallest_number.py +55 -0
- pydsa/algorithms/math/minimum_area_rectangle.py +58 -0
- pydsa/algorithms/math/minimum_area_rectangle_ii.py +83 -0
- pydsa/algorithms/math/minimum_array_end.py +235 -0
- pydsa/algorithms/math/minimum_cost_to_equalize_array.py +49 -0
- pydsa/algorithms/math/minimum_cost_to_make_array_equal.py +51 -0
- pydsa/algorithms/math/minimum_cost_to_set_cooking_time.py +67 -0
- pydsa/algorithms/math/minimum_cuts_to_divide_a_circle.py +71 -0
- pydsa/algorithms/math/minimum_element_after_replacement_with_digit_sum.py +68 -0
- pydsa/algorithms/math/minimum_elements_to_add_to_form_a_given_sum.py +93 -0
- pydsa/algorithms/math/minimum_equal_sum_of_two_arrays_after_replacing_zeros.py +70 -0
- pydsa/algorithms/math/minimum_factorization.py +53 -0
- pydsa/algorithms/math/minimum_garden_perimeter_to_collect_enough_apples.py +105 -0
- pydsa/algorithms/math/minimum_generations_to_target_point.py +58 -0
- pydsa/algorithms/math/minimum_moves_to_capture_the_queen.py +168 -0
- pydsa/algorithms/math/minimum_moves_to_clean_the_classroom.py +118 -0
- pydsa/algorithms/math/minimum_moves_to_equal_array_elements.py +42 -0
- pydsa/algorithms/math/minimum_moves_to_equal_array_elements_ii.py +51 -0
- pydsa/algorithms/math/minimum_moves_to_reach_target_score.py +47 -0
- pydsa/algorithms/math/minimum_moves_to_spread_stones_over_grid.py +75 -0
- pydsa/algorithms/math/minimum_non_zero_product_of_the_array_elements.py +104 -0
- pydsa/algorithms/math/minimum_number_of_coins_to_be_added.py +60 -0
- pydsa/algorithms/math/minimum_number_of_food_buckets_to_feed_the_hamsters.py +39 -0
- pydsa/algorithms/math/minimum_number_of_keypresses.py +155 -0
- pydsa/algorithms/math/minimum_number_of_operations_to_convert_time.py +59 -0
- pydsa/algorithms/math/minimum_number_of_operations_to_make_x_and_y_equal.py +58 -0
- pydsa/algorithms/math/minimum_number_of_primes_to_sum_to_target.py +80 -0
- pydsa/algorithms/math/minimum_one_bit_operations_to_make_integers_zero.py +66 -0
- pydsa/algorithms/math/minimum_operations_to_convert_number.py +249 -0
- pydsa/algorithms/math/minimum_operations_to_make_a_special_number.py +55 -0
- pydsa/algorithms/math/minimum_operations_to_make_a_uni_value_grid.py +161 -0
- pydsa/algorithms/math/minimum_operations_to_make_all_elements_one.py +39 -0
- pydsa/algorithms/math/minimum_operations_to_make_array_equal.py +38 -0
- pydsa/algorithms/math/minimum_operations_to_make_array_sum_divisible_by_k.py +79 -0
- pydsa/algorithms/math/minimum_operations_to_make_array_values_equal_to_k.py +72 -0
- pydsa/algorithms/math/minimum_operations_to_make_numbers_non_positive.py +41 -0
- pydsa/algorithms/math/minimum_operations_to_make_the_integer_zero.py +60 -0
- pydsa/algorithms/math/minimum_operations_to_reach_target_array.py +60 -0
- pydsa/algorithms/math/minimum_operations_to_reduce_an_integer_to_0.py +49 -0
- pydsa/algorithms/math/minimum_reverse_operations.py +59 -0
- pydsa/algorithms/math/minimum_sum_of_four_digit_number_after_splitting_digits.py +44 -0
- pydsa/algorithms/math/minimum_threshold_for_inversion_pairs_count.py +138 -0
- pydsa/algorithms/math/minimum_time_to_type_word_using_special_typewriter.py +45 -0
- pydsa/algorithms/math/minimum_time_visiting_all_points.py +49 -0
- pydsa/algorithms/math/mirror_distance_of_an_integer.py +51 -0
- pydsa/algorithms/math/mirror_reflection.py +211 -0
- pydsa/algorithms/math/missing_number_in_arithmetic_progression.py +54 -0
- pydsa/algorithms/math/monthly_transactions_i.py +88 -0
- pydsa/algorithms/math/monthly_transactions_ii.py +79 -0
- pydsa/algorithms/math/most_frequent_prime.py +66 -0
- pydsa/algorithms/math/movie_rating.py +114 -0
- pydsa/algorithms/math/moving_stones_until_consecutive.py +178 -0
- pydsa/algorithms/math/multiply_strings.py +64 -0
- pydsa/algorithms/math/multiply_two_polynomials.py +101 -0
- pydsa/algorithms/math/new_users_daily_count.py +54 -0
- pydsa/algorithms/math/next_day.py +61 -0
- pydsa/algorithms/math/next_greater_element_iii.py +79 -0
- pydsa/algorithms/math/next_greater_numerically_balanced_number.py +124 -0
- pydsa/algorithms/math/next_palindrome_using_same_digits.py +195 -0
- pydsa/algorithms/math/next_special_palindrome_number.py +66 -0
- pydsa/algorithms/math/nim_game.py +37 -0
- pydsa/algorithms/math/not_boring_movies.py +48 -0
- pydsa/algorithms/math/nth_digit.py +64 -0
- pydsa/algorithms/math/nth_highest_salary.py +43 -0
- pydsa/algorithms/math/nth_magical_number.py +72 -0
- pydsa/algorithms/math/number_of_balanced_integers_in_a_range.py +303 -0
- pydsa/algorithms/math/number_of_beautiful_pairs.py +56 -0
- pydsa/algorithms/math/number_of_boomerangs.py +58 -0
- pydsa/algorithms/math/number_of_burgers_with_no_waste_of_ingredients.py +123 -0
- pydsa/algorithms/math/number_of_calls_between_two_persons.py +53 -0
- pydsa/algorithms/math/number_of_changing_keys.py +52 -0
- pydsa/algorithms/math/number_of_comments_per_post.py +57 -0
- pydsa/algorithms/math/number_of_common_factors.py +53 -0
- pydsa/algorithms/math/number_of_days_between_two_dates.py +59 -0
- pydsa/algorithms/math/number_of_days_in_a_month.py +45 -0
- pydsa/algorithms/math/number_of_different_subsequences_gcds.py +73 -0
- pydsa/algorithms/math/number_of_digit_one.py +76 -0
- pydsa/algorithms/math/number_of_divisible_substrings.py +57 -0
- pydsa/algorithms/math/number_of_divisible_triplet_sums.py +79 -0
- pydsa/algorithms/math/number_of_effective_subsequences.py +78 -0
- pydsa/algorithms/math/number_of_even_and_odd_bits.py +48 -0
- pydsa/algorithms/math/number_of_integers_with_popcount_depth_equal_to_k_i.py +110 -0
- pydsa/algorithms/math/number_of_integers_with_popcount_depth_equal_to_k_ii.py +174 -0
- pydsa/algorithms/math/number_of_self_divisible_permutations.py +55 -0
- pydsa/algorithms/math/number_of_single_divisor_triplets.py +93 -0
- pydsa/algorithms/math/number_of_steps_to_reduce_a_number_to_zero.py +57 -0
- pydsa/algorithms/math/number_of_strings_which_can_be_rearranged_to_contain_substring.py +69 -0
- pydsa/algorithms/math/number_of_student_replacements.py +47 -0
- pydsa/algorithms/math/number_of_subsequences_with_odd_sum.py +70 -0
- pydsa/algorithms/math/number_of_transactions_per_visit.py +55 -0
- pydsa/algorithms/math/number_of_valid_clock_times.py +39 -0
- pydsa/algorithms/math/number_of_valid_move_combinations_on_chessboard.py +58 -0
- pydsa/algorithms/math/number_of_ways_to_buy_pens_and_pencils.py +64 -0
- pydsa/algorithms/math/number_of_ways_where_square_of_number_is_equal_to_product_of_two_numbers.py +63 -0
- pydsa/algorithms/math/optimal_division.py +46 -0
- pydsa/algorithms/math/page_recommendations.py +65 -0
- pydsa/algorithms/math/palindrome_number.py +49 -0
- pydsa/algorithms/math/parse_lisp_expression.py +122 -0
- pydsa/algorithms/math/partial_function_with_placeholders.py +93 -0
- pydsa/algorithms/math/partitioning_into_minimum_number_of_deci_binary_numbers.py +50 -0
- pydsa/algorithms/math/pascals_triangle.py +46 -0
- pydsa/algorithms/math/pascals_triangle_ii.py +46 -0
- pydsa/algorithms/math/pass_the_pillow.py +46 -0
- pydsa/algorithms/math/path_in_zigzag_labelled_binary_tree.py +77 -0
- pydsa/algorithms/math/percentage_of_users_attended_a_contest.py +69 -0
- pydsa/algorithms/math/perfect_number.py +52 -0
- pydsa/algorithms/math/perfect_rectangle.py +73 -0
- pydsa/algorithms/math/permutation_sequence.py +60 -0
- pydsa/algorithms/math/poor_pigs.py +71 -0
- pydsa/algorithms/math/pour_water_between_buckets_to_make_water_levels_equal.py +274 -0
- pydsa/algorithms/math/pow_x_n.py +52 -0
- pydsa/algorithms/math/power_of_three.py +39 -0
- pydsa/algorithms/math/powerful_integers.py +64 -0
- pydsa/algorithms/math/prime_arrangements.py +62 -0
- pydsa/algorithms/math/prime_pairs_with_target_sum.py +66 -0
- pydsa/algorithms/math/prime_palindrome.py +107 -0
- pydsa/algorithms/math/print_foobar_alternately.py +74 -0
- pydsa/algorithms/math/print_in_order.py +98 -0
- pydsa/algorithms/math/print_zero_even_odd.py +117 -0
- pydsa/algorithms/math/prison_cells_after_n_days.py +66 -0
- pydsa/algorithms/math/probability_of_a_two_boxes_having_the_same_number_of_distinct_balls.py +217 -0
- pydsa/algorithms/math/product_price_at_a_given_date.py +231 -0
- pydsa/algorithms/math/product_sales_analysis_i.py +45 -0
- pydsa/algorithms/math/product_sales_analysis_ii.py +53 -0
- pydsa/algorithms/math/product_sales_analysis_iii.py +68 -0
- pydsa/algorithms/math/products_with_three_or_more_orders_in_two_consecutive_years.py +66 -0
- pydsa/algorithms/math/products_worth_over_invoices.py +35 -0
- pydsa/algorithms/math/project_employees_i.py +71 -0
- pydsa/algorithms/math/project_employees_ii.py +45 -0
- pydsa/algorithms/math/project_employees_iii.py +64 -0
- pydsa/algorithms/math/projection_area_of_3d_shapes.py +43 -0
- pydsa/algorithms/math/queries_on_number_of_points_inside_a_circle.py +54 -0
- pydsa/algorithms/math/queries_quality_and_percentage.py +59 -0
- pydsa/algorithms/math/rabbits_in_forest.py +58 -0
- pydsa/algorithms/math/random_flip_matrix.py +99 -0
- pydsa/algorithms/math/random_pick_with_blacklist.py +100 -0
- pydsa/algorithms/math/random_point_in_non_overlapping_rectangles.py +209 -0
- pydsa/algorithms/math/range_addition_ii.py +50 -0
- pydsa/algorithms/math/range_sum_of_sorted_subarray_sums.py +59 -0
- pydsa/algorithms/math/rank_scores.py +43 -0
- pydsa/algorithms/math/reach_a_number.py +63 -0
- pydsa/algorithms/math/reaching_points.py +175 -0
- pydsa/algorithms/math/reconstruct_original_digits_from_english.py +293 -0
- pydsa/algorithms/math/rectangle_area.py +55 -0
- pydsa/algorithms/math/rectangle_overlap.py +58 -0
- pydsa/algorithms/math/rectangles_area.py +81 -0
- pydsa/algorithms/math/recyclable_and_low_fat_products.py +52 -0
- pydsa/algorithms/math/reformat_department_table.py +47 -0
- pydsa/algorithms/math/remove_9.py +56 -0
- pydsa/algorithms/math/remove_zeros_in_decimal_representation.py +44 -0
- pydsa/algorithms/math/reordered_power_of_2.py +49 -0
- pydsa/algorithms/math/report_contiguous_dates.py +61 -0
- pydsa/algorithms/math/reported_posts.py +58 -0
- pydsa/algorithms/math/reported_posts_ii.py +47 -0
- pydsa/algorithms/math/reverse_integer.py +59 -0
- pydsa/algorithms/math/reverse_subarray_to_maximize_array_value.py +97 -0
- pydsa/algorithms/math/right_triangles.py +62 -0
- pydsa/algorithms/math/rising_temperature.py +57 -0
- pydsa/algorithms/math/robot_bounded_in_circle.py +64 -0
- pydsa/algorithms/math/roman_to_integer.py +61 -0
- pydsa/algorithms/math/rotate_function.py +59 -0
- pydsa/algorithms/math/rotated_digits.py +50 -0
- pydsa/algorithms/math/running_total_for_different_genders.py +95 -0
- pydsa/algorithms/math/sales_person.py +63 -0
- pydsa/algorithms/math/second_degree_follower.py +89 -0
- pydsa/algorithms/math/second_highest_salary.py +56 -0
- pydsa/algorithms/math/second_highest_salary_ii.py +61 -0
- pydsa/algorithms/math/self_crossing.py +65 -0
- pydsa/algorithms/math/self_dividing_numbers.py +49 -0
- pydsa/algorithms/math/sell_diminishing_valued_colored_balls.py +96 -0
- pydsa/algorithms/math/selling_pieces_of_wood.py +127 -0
- pydsa/algorithms/math/semi_ordered_permutation.py +117 -0
- pydsa/algorithms/math/sequential_digits.py +52 -0
- pydsa/algorithms/math/shortest_distance_in_a_line.py +49 -0
- pydsa/algorithms/math/shortest_distance_in_a_plane.py +54 -0
- pydsa/algorithms/math/sign_of_the_product_of_an_array.py +52 -0
- pydsa/algorithms/math/similar_rgb_color.py +50 -0
- pydsa/algorithms/math/simplified_fractions.py +57 -0
- pydsa/algorithms/math/sleep.py +42 -0
- pydsa/algorithms/math/smallest_all_ones_multiple.py +78 -0
- pydsa/algorithms/math/smallest_divisible_digit_product_i.py +64 -0
- pydsa/algorithms/math/smallest_divisible_digit_product_ii.py +287 -0
- pydsa/algorithms/math/smallest_even_multiple.py +39 -0
- pydsa/algorithms/math/smallest_good_base.py +109 -0
- pydsa/algorithms/math/smallest_greater_multiple_made_of_two_digits.py +45 -0
- pydsa/algorithms/math/smallest_index_with_digit_sum_equal_to_index.py +54 -0
- pydsa/algorithms/math/smallest_integer_divisible_by_k.py +57 -0
- pydsa/algorithms/math/smallest_missing_integer_greater_than_sequential_prefix_sum.py +64 -0
- pydsa/algorithms/math/smallest_missing_multiple_of_k.py +62 -0
- pydsa/algorithms/math/smallest_number_with_all_set_bits.py +38 -0
- pydsa/algorithms/math/smallest_number_with_given_digit_product.py +67 -0
- pydsa/algorithms/math/smallest_range_i.py +45 -0
- pydsa/algorithms/math/smallest_value_after_replacing_with_sum_of_prime_factors.py +67 -0
- pydsa/algorithms/math/smallest_value_of_the_rearranged_number.py +261 -0
- pydsa/algorithms/math/solve_the_equation.py +94 -0
- pydsa/algorithms/math/sort_integers_by_binary_reflection.py +58 -0
- pydsa/algorithms/math/sort_integers_by_the_power_value.py +64 -0
- pydsa/algorithms/math/sorted_gcd_pair_queries.py +103 -0
- pydsa/algorithms/math/sparse_matrix_multiplication.py +54 -0
- pydsa/algorithms/math/squirrel_simulation.py +79 -0
- pydsa/algorithms/math/stone_removal_game.py +46 -0
- pydsa/algorithms/math/strictly_palindromic_number.py +47 -0
- pydsa/algorithms/math/strobogrammatic_number.py +55 -0
- pydsa/algorithms/math/students_and_examinations.py +73 -0
- pydsa/algorithms/math/students_report_by_geography.py +79 -0
- pydsa/algorithms/math/students_with_invalid_departments.py +62 -0
- pydsa/algorithms/math/subtract_product_and_sum.py +40 -0
- pydsa/algorithms/math/sum_game.py +59 -0
- pydsa/algorithms/math/sum_multiples.py +41 -0
- pydsa/algorithms/math/sum_of_digit_differences_of_all_pairs.py +50 -0
- pydsa/algorithms/math/sum_of_digits_in_base_k.py +45 -0
- pydsa/algorithms/math/sum_of_digits_in_the_minimum_number.py +56 -0
- pydsa/algorithms/math/sum_of_floored_pairs.py +72 -0
- pydsa/algorithms/math/sum_of_gcd_of_formed_pairs.py +70 -0
- pydsa/algorithms/math/sum_of_good_numbers.py +123 -0
- pydsa/algorithms/math/sum_of_k_digit_numbers_in_a_range.py +60 -0
- pydsa/algorithms/math/sum_of_k_mirror_numbers.py +65 -0
- pydsa/algorithms/math/sum_of_number_and_its_reverse.py +49 -0
- pydsa/algorithms/math/sum_of_numbers_with_units_digit_k.py +39 -0
- pydsa/algorithms/math/sum_of_primes_between_number_and_its_reverse.py +60 -0
- pydsa/algorithms/math/sum_of_sortable_integers.py +50 -0
- pydsa/algorithms/math/sum_of_square_numbers.py +57 -0
- pydsa/algorithms/math/sum_of_subsequence_widths.py +59 -0
- pydsa/algorithms/math/sum_of_values_at_indices_with_k_set_bits.py +46 -0
- pydsa/algorithms/math/super_palindromes.py +107 -0
- pydsa/algorithms/math/super_pow.py +63 -0
- pydsa/algorithms/math/surface_area_of_3d_shapes.py +58 -0
- pydsa/algorithms/math/swap_sex_of_employees.py +34 -0
- pydsa/algorithms/math/symmetric_coordinates.py +46 -0
- pydsa/algorithms/math/tasks_count_in_the_weekend.py +55 -0
- pydsa/algorithms/math/team_scores_in_football_tournament.py +61 -0
- pydsa/algorithms/math/the_dining_philosophers.py +112 -0
- pydsa/algorithms/math/the_kth_factor_of_n.py +55 -0
- pydsa/algorithms/math/the_number_of_full_rounds_you_have_played.py +44 -0
- pydsa/algorithms/math/the_score_of_students_solving_math_expression.py +59 -0
- pydsa/algorithms/math/the_time_when_the_network_becomes_idle.py +237 -0
- pydsa/algorithms/math/the_two_sneaky_numbers_of_digitville.py +49 -0
- pydsa/algorithms/math/three_divisors.py +49 -0
- pydsa/algorithms/math/three_equal_parts.py +49 -0
- pydsa/algorithms/math/time_taken_to_cross_the_door.py +45 -0
- pydsa/algorithms/math/toggle_light_bulbs.py +44 -0
- pydsa/algorithms/math/total_characters_in_string_after_transformations_i.py +59 -0
- pydsa/algorithms/math/total_characters_in_string_after_transformations_ii.py +106 -0
- pydsa/algorithms/math/total_distance_traveled.py +43 -0
- pydsa/algorithms/math/total_sales_amount_by_year.py +65 -0
- pydsa/algorithms/math/total_traveled_distance.py +57 -0
- pydsa/algorithms/math/total_waviness_of_numbers_in_range_i.py +82 -0
- pydsa/algorithms/math/total_waviness_of_numbers_in_range_ii.py +110 -0
- pydsa/algorithms/math/tournament_winners.py +157 -0
- pydsa/algorithms/math/traffic_light_controlled_intersection.py +67 -0
- pydsa/algorithms/math/traffic_signal_color.py +50 -0
- pydsa/algorithms/math/transform_to_chessboard.py +94 -0
- pydsa/algorithms/math/triangle_judgement.py +40 -0
- pydsa/algorithms/math/triples_with_bitwise_and_equal_to_zero.py +228 -0
- pydsa/algorithms/math/trips_and_users.py +68 -0
- pydsa/algorithms/math/type_of_triangle.py +52 -0
- pydsa/algorithms/math/ugly_number.py +46 -0
- pydsa/algorithms/math/unique_3_digit_even_numbers.py +63 -0
- pydsa/algorithms/math/unit_conversion_i.py +91 -0
- pydsa/algorithms/math/user_activity_for_the_past_30_days_i.py +64 -0
- pydsa/algorithms/math/user_activity_for_the_past_30_days_ii.py +76 -0
- pydsa/algorithms/math/user_purchase_platform.py +82 -0
- pydsa/algorithms/math/users_that_actively_request_confirmation_messages.py +80 -0
- pydsa/algorithms/math/valid_square.py +62 -0
- pydsa/algorithms/math/valid_tic_tac_toe_state.py +83 -0
- pydsa/algorithms/math/walking_robot_simulation_ii.py +100 -0
- pydsa/algorithms/math/water_and_jug_problem.py +56 -0
- pydsa/algorithms/math/water_bottles.py +48 -0
- pydsa/algorithms/math/water_bottles_ii.py +52 -0
- pydsa/algorithms/math/weather_type_country.py +68 -0
- pydsa/algorithms/math/winning_candidate.py +59 -0
- pydsa/algorithms/math/x_of_a_kind_in_a_deck_of_cards.py +57 -0
- pydsa/algorithms/math/xor_operation_in_an_array.py +35 -0
- pydsa/algorithms/math/year_on_year_growth_rate.py +55 -0
- pydsa/algorithms/sliding_window/__init__.py +0 -0
- pydsa/algorithms/sliding_window/alternating_groups_iii.py +136 -0
- pydsa/algorithms/sliding_window/binary_subarrays_with_sum.py +56 -0
- pydsa/algorithms/sliding_window/contains_duplicate_ii.py +55 -0
- pydsa/algorithms/sliding_window/contains_duplicate_iii.py +58 -0
- pydsa/algorithms/sliding_window/continuous_subarrays.py +67 -0
- pydsa/algorithms/sliding_window/count_complete_subarrays.py +74 -0
- pydsa/algorithms/sliding_window/count_good_subarrays.py +80 -0
- pydsa/algorithms/sliding_window/count_number_of_nice_subarrays.py +67 -0
- pydsa/algorithms/sliding_window/count_of_substrings_containing_every_vowel_and_k_consonants_i.py +305 -0
- pydsa/algorithms/sliding_window/count_of_substrings_containing_every_vowel_and_k_consonants_ii.py +54 -0
- pydsa/algorithms/sliding_window/count_subarrays_where_max_element_appears_at_least_k_times.py +83 -0
- pydsa/algorithms/sliding_window/count_subarrays_with_cost_less_than_or_equal_to_k.py +50 -0
- pydsa/algorithms/sliding_window/count_subarrays_with_fixed_bounds.py +64 -0
- pydsa/algorithms/sliding_window/count_subarrays_with_k_distinct_integers.py +64 -0
- pydsa/algorithms/sliding_window/count_subarrays_with_score_less_than_k.py +53 -0
- pydsa/algorithms/sliding_window/count_substrings_that_satisfy_k_constraint_i.py +139 -0
- pydsa/algorithms/sliding_window/count_substrings_that_satisfy_k_constraint_ii.py +67 -0
- pydsa/algorithms/sliding_window/count_substrings_with_k_frequency_characters_i.py +76 -0
- pydsa/algorithms/sliding_window/count_substrings_with_k_frequency_characters_ii.py +79 -0
- pydsa/algorithms/sliding_window/count_substrings_without_repeating_character.py +60 -0
- pydsa/algorithms/sliding_window/count_the_number_of_good_subarrays.py +69 -0
- pydsa/algorithms/sliding_window/count_the_number_of_incremovable_subarrays_i.py +257 -0
- pydsa/algorithms/sliding_window/count_the_number_of_incremovable_subarrays_ii.py +260 -0
- pydsa/algorithms/sliding_window/count_the_number_of_substrings_with_dominant_ones.py +230 -0
- pydsa/algorithms/sliding_window/design_hit_counter.py +94 -0
- pydsa/algorithms/sliding_window/diet_plan_performance.py +52 -0
- pydsa/algorithms/sliding_window/distinct_numbers_in_each_subarray.py +69 -0
- pydsa/algorithms/sliding_window/find_all_anagrams_in_a_string.py +69 -0
- pydsa/algorithms/sliding_window/find_k_length_substrings_with_no_repeated_characters.py +73 -0
- pydsa/algorithms/sliding_window/find_special_substring_of_length_k.py +64 -0
- pydsa/algorithms/sliding_window/find_subarray_with_bitwise_or_closest_to_k.py +161 -0
- pydsa/algorithms/sliding_window/find_the_longest_equal_subarray.py +200 -0
- pydsa/algorithms/sliding_window/find_the_power_of_k_size_subarrays_i.py +79 -0
- pydsa/algorithms/sliding_window/find_the_power_of_k_size_subarrays_ii.py +165 -0
- pydsa/algorithms/sliding_window/find_x_sum_of_all_k_long_subarrays_ii.py +87 -0
- pydsa/algorithms/sliding_window/frequency_of_the_most_frequent_element.py +54 -0
- pydsa/algorithms/sliding_window/fruit_into_baskets.py +59 -0
- pydsa/algorithms/sliding_window/get_equal_substrings_within_budget.py +90 -0
- pydsa/algorithms/sliding_window/grumpy_bookstore_owner.py +119 -0
- pydsa/algorithms/sliding_window/k_radius_subarray_averages.py +60 -0
- pydsa/algorithms/sliding_window/length_of_longest_subarray_with_at_most_k_frequency.py +67 -0
- pydsa/algorithms/sliding_window/longest_alternating_subarray_after_removing_at_most_one_element.py +82 -0
- pydsa/algorithms/sliding_window/longest_balanced_subarray_ii.py +63 -0
- pydsa/algorithms/sliding_window/longest_continuous_subarray_with_absolute_diff_less_than_or_equal_to_limit.py +67 -0
- pydsa/algorithms/sliding_window/longest_nice_subarray.py +51 -0
- pydsa/algorithms/sliding_window/longest_non_decreasing_subarray_after_replacing_at_most_one_element.py +79 -0
- pydsa/algorithms/sliding_window/longest_repeating_character_replacement.py +61 -0
- pydsa/algorithms/sliding_window/longest_semi_repeating_subarray.py +73 -0
- pydsa/algorithms/sliding_window/longest_subarray_of_1s_after_deleting_one_element.py +58 -0
- pydsa/algorithms/sliding_window/longest_substring_of_one_repeating_character.py +72 -0
- pydsa/algorithms/sliding_window/longest_substring_with_at_least_k_repeating_characters.py +51 -0
- pydsa/algorithms/sliding_window/longest_substring_with_at_most_k_distinct_characters.py +60 -0
- pydsa/algorithms/sliding_window/longest_substring_with_at_most_two_distinct_characters.py +58 -0
- pydsa/algorithms/sliding_window/longest_substring_without_repeating_characters.py +54 -0
- pydsa/algorithms/sliding_window/longest_turbulent_subarray.py +219 -0
- pydsa/algorithms/sliding_window/longest_well_performing_interval.py +62 -0
- pydsa/algorithms/sliding_window/max_consecutive_ones_ii.py +54 -0
- pydsa/algorithms/sliding_window/max_consecutive_ones_iii.py +53 -0
- pydsa/algorithms/sliding_window/max_occurrences_substring.py +57 -0
- pydsa/algorithms/sliding_window/max_vowels_in_substring.py +62 -0
- pydsa/algorithms/sliding_window/maximize_subarrays_after_removing_one_conflicting_pair.py +309 -0
- pydsa/algorithms/sliding_window/maximize_the_confusion_of_an_exam.py +59 -0
- pydsa/algorithms/sliding_window/maximum_and_minimum_sums_of_at_most_size_k_subarrays.py +124 -0
- pydsa/algorithms/sliding_window/maximum_average_subarray_i.py +62 -0
- pydsa/algorithms/sliding_window/maximum_erasure_value.py +50 -0
- pydsa/algorithms/sliding_window/maximum_frequency_after_subarray_operation.py +78 -0
- pydsa/algorithms/sliding_window/maximum_frequency_score_of_a_subarray.py +196 -0
- pydsa/algorithms/sliding_window/maximum_fruits_harvested_after_at_most_k_steps.py +78 -0
- pydsa/algorithms/sliding_window/maximum_length_of_semi_decreasing_subarrays.py +75 -0
- pydsa/algorithms/sliding_window/maximum_sum_of_almost_unique_subarray.py +56 -0
- pydsa/algorithms/sliding_window/maximum_sum_of_distinct_subarrays_with_length_k.py +59 -0
- pydsa/algorithms/sliding_window/maximum_sum_of_two_non_overlapping_subarrays.py +73 -0
- pydsa/algorithms/sliding_window/maximum_unique_subarray_sum_after_deletion.py +146 -0
- pydsa/algorithms/sliding_window/minimum_absolute_difference_in_sliding_submatrix.py +151 -0
- pydsa/algorithms/sliding_window/minimum_inversion_count_in_subarrays_of_fixed_length.py +97 -0
- pydsa/algorithms/sliding_window/minimum_length_of_anagram_concatenation.py +167 -0
- pydsa/algorithms/sliding_window/minimum_number_of_operations_to_make_array_continuous.py +66 -0
- pydsa/algorithms/sliding_window/minimum_operations_to_equalize_subarrays.py +139 -0
- pydsa/algorithms/sliding_window/minimum_operations_to_make_binary_array_elements_equal_to_one_ii.py +70 -0
- pydsa/algorithms/sliding_window/minimum_recolors_to_get_k_consecutive_black_blocks.py +51 -0
- pydsa/algorithms/sliding_window/minimum_size_subarray_in_infinite_array.py +64 -0
- pydsa/algorithms/sliding_window/minimum_size_subarray_sum.py +50 -0
- pydsa/algorithms/sliding_window/minimum_subarray_length_with_distinct_sum_at_least_k.py +62 -0
- pydsa/algorithms/sliding_window/minimum_swaps_to_group_all_1s_together.py +64 -0
- pydsa/algorithms/sliding_window/minimum_window_substring.py +87 -0
- pydsa/algorithms/sliding_window/moving_average_from_data_stream.py +82 -0
- pydsa/algorithms/sliding_window/moving_stones_until_consecutive_ii.py +227 -0
- pydsa/algorithms/sliding_window/number_of_centered_subarrays.py +76 -0
- pydsa/algorithms/sliding_window/number_of_sub_arrays_of_size_k_and_average_greater_than_or_equal_to_threshold.py +57 -0
- pydsa/algorithms/sliding_window/number_of_subarrays_with_bounded_maximum.py +59 -0
- pydsa/algorithms/sliding_window/number_of_substrings_containing_all_three_characters.py +58 -0
- pydsa/algorithms/sliding_window/number_of_substrings_with_fixed_ratio.py +68 -0
- pydsa/algorithms/sliding_window/permutation_in_string.py +62 -0
- pydsa/algorithms/sliding_window/repeated_dna_sequences.py +33 -0
- pydsa/algorithms/sliding_window/replace_the_substring_for_balanced_string.py +63 -0
- pydsa/algorithms/sliding_window/shortest_matching_substring.py +77 -0
- pydsa/algorithms/sliding_window/shortest_subarray_with_sum_at_least_k.py +60 -0
- pydsa/algorithms/sliding_window/sliding_subarray_beauty.py +55 -0
- pydsa/algorithms/sliding_window/sliding_window_maximum.py +62 -0
- pydsa/algorithms/sliding_window/sliding_window_median.py +131 -0
- pydsa/algorithms/sliding_window/smallest_range_covering_elements_from_k_lists.py +69 -0
- pydsa/algorithms/sliding_window/smallest_subarray_to_sort_in_every_sliding_window.py +275 -0
- pydsa/algorithms/sliding_window/smallest_subarrays_with_maximum_bitwise_or.py +62 -0
- pydsa/algorithms/sliding_window/smallest_unique_subarray.py +76 -0
- pydsa/algorithms/sliding_window/subarray_product_less_than_k.py +52 -0
- pydsa/algorithms/sliding_window/subarrays_distinct_element_sum_of_squares_i.py +65 -0
- pydsa/algorithms/sliding_window/subarrays_distinct_element_sum_of_squares_ii.py +488 -0
- pydsa/algorithms/sliding_window/subarrays_with_k_different_integers.py +67 -0
- pydsa/algorithms/sliding_window/substring_with_concatenation_of_all_words.py +76 -0
- pydsa/algorithms/sliding_window/sum_of_k_subarrays_with_length_at_least_m.py +74 -0
- pydsa/algorithms/sliding_window/swap_for_longest_repeated_character_substring.py +137 -0
- pydsa/algorithms/sliding_window/valid_subarrays_with_exactly_one_peak.py +233 -0
- pydsa/algorithms/sliding_window/ways_to_split_array_into_good_subarrays.py +251 -0
- pydsa/algorithms/stack/132_pattern.py +61 -0
- pydsa/algorithms/stack/__init__.py +0 -0
- pydsa/algorithms/stack/asteroid_collision.py +59 -0
- pydsa/algorithms/stack/backspace_string_compare.py +73 -0
- pydsa/algorithms/stack/baseball_game.py +51 -0
- pydsa/algorithms/stack/basic_calculator.py +73 -0
- pydsa/algorithms/stack/basic_calculator_ii.py +73 -0
- pydsa/algorithms/stack/basic_calculator_iii.py +89 -0
- pydsa/algorithms/stack/build_an_array_with_stack_operations.py +51 -0
- pydsa/algorithms/stack/car_fleet.py +59 -0
- pydsa/algorithms/stack/check_if_word_is_valid_after_substitutions.py +50 -0
- pydsa/algorithms/stack/daily_temperatures.py +52 -0
- pydsa/algorithms/stack/decode_string.py +66 -0
- pydsa/algorithms/stack/design_a_stack_with_increment_operation.py +96 -0
- pydsa/algorithms/stack/design_bounded_blocking_queue.py +106 -0
- pydsa/algorithms/stack/design_browser_history.py +96 -0
- pydsa/algorithms/stack/design_circular_deque.py +156 -0
- pydsa/algorithms/stack/dinner_plate_stacks.py +192 -0
- pydsa/algorithms/stack/evaluate_reverse_polish_notation.py +63 -0
- pydsa/algorithms/stack/exclusive_time_of_functions.py +64 -0
- pydsa/algorithms/stack/find_the_most_competitive_subsequence.py +48 -0
- pydsa/algorithms/stack/flatten_nested_list_iterator.py +86 -0
- pydsa/algorithms/stack/implement_queue_using_stacks.py +74 -0
- pydsa/algorithms/stack/implement_stack_using_queues.py +67 -0
- pydsa/algorithms/stack/largest_rectangle_in_histogram.py +62 -0
- pydsa/algorithms/stack/longest_absolute_file_path.py +57 -0
- pydsa/algorithms/stack/max_stack.py +152 -0
- pydsa/algorithms/stack/maximal_range_that_each_element_is_maximum_in_it.py +76 -0
- pydsa/algorithms/stack/maximum_frequency_stack.py +101 -0
- pydsa/algorithms/stack/maximum_width_ramp.py +56 -0
- pydsa/algorithms/stack/merge_adjacent_equal_elements.py +50 -0
- pydsa/algorithms/stack/min_stack.py +107 -0
- pydsa/algorithms/stack/mini_parser.py +107 -0
- pydsa/algorithms/stack/minimum_add_to_make_parentheses_valid.py +56 -0
- pydsa/algorithms/stack/minimum_cost_tree_from_leaf_values.py +58 -0
- pydsa/algorithms/stack/minimum_remove_to_make_valid_parentheses.py +65 -0
- pydsa/algorithms/stack/next_greater_element_i.py +50 -0
- pydsa/algorithms/stack/next_greater_element_ii.py +54 -0
- pydsa/algorithms/stack/next_greater_element_iv.py +93 -0
- pydsa/algorithms/stack/next_greater_node_in_linked_list.py +64 -0
- pydsa/algorithms/stack/number_of_recent_calls.py +82 -0
- pydsa/algorithms/stack/number_of_students_unable_to_eat_lunch.py +694 -0
- pydsa/algorithms/stack/number_of_valid_subarrays.py +62 -0
- pydsa/algorithms/stack/online_stock_span.py +89 -0
- pydsa/algorithms/stack/parsing_a_boolean_expression.py +76 -0
- pydsa/algorithms/stack/remove_all_adjacent_duplicates_in_string.py +42 -0
- pydsa/algorithms/stack/remove_all_adjacent_duplicates_in_string_ii.py +52 -0
- pydsa/algorithms/stack/remove_duplicate_letters.py +55 -0
- pydsa/algorithms/stack/remove_k_digits.py +57 -0
- pydsa/algorithms/stack/remove_outermost_parentheses.py +48 -0
- pydsa/algorithms/stack/reverse_substrings_between_each_pair_of_parentheses.py +86 -0
- pydsa/algorithms/stack/robot_collisions.py +74 -0
- pydsa/algorithms/stack/score_of_parentheses.py +60 -0
- pydsa/algorithms/stack/simplify_path.py +59 -0
- pydsa/algorithms/stack/sum_of_subarray_minimums.py +84 -0
- pydsa/algorithms/stack/tag_validator.py +83 -0
- pydsa/algorithms/stack/ternary_expression_parser.py +162 -0
- pydsa/algorithms/stack/valid_parentheses.py +62 -0
- pydsa/algorithms/stack/validate_stack_sequences.py +48 -0
- pydsa/algorithms/stack/verify_preorder_sequence_in_bst.py +57 -0
- pydsa/algorithms/stack/verify_preorder_serialization_of_a_binary_tree.py +58 -0
- pydsa/algorithms/string/__init__.py +0 -0
- pydsa/algorithms/string/find_kth_bit_in_nth_binary_string.py +66 -0
- pydsa/algorithms/strings/__init__.py +0 -0
- pydsa/algorithms/strings/add_bold_tag_in_string.py +69 -0
- pydsa/algorithms/strings/adding_spaces_to_a_string.py +56 -0
- pydsa/algorithms/strings/alphabet_board_path.py +265 -0
- pydsa/algorithms/strings/alt_and_tab_simulation.py +58 -0
- pydsa/algorithms/strings/ambiguous_coordinates.py +78 -0
- pydsa/algorithms/strings/append_characters_to_string_to_make_subsequence.py +53 -0
- pydsa/algorithms/strings/apply_bitwise_operations_to_make_strings_equal.py +81 -0
- pydsa/algorithms/strings/apply_operations_to_make_string_empty.py +75 -0
- pydsa/algorithms/strings/apply_operations_to_make_two_strings_equal.py +236 -0
- pydsa/algorithms/strings/apply_substitutions.py +54 -0
- pydsa/algorithms/strings/before_and_after_puzzle.py +55 -0
- pydsa/algorithms/strings/best_poker_hand.py +258 -0
- pydsa/algorithms/strings/better_compression_of_string.py +119 -0
- pydsa/algorithms/strings/binary_string_with_substrings_representing_1_to_n.py +72 -0
- pydsa/algorithms/strings/bind_function_to_context.py +53 -0
- pydsa/algorithms/strings/bold_words_in_string.py +87 -0
- pydsa/algorithms/strings/brace_expansion.py +434 -0
- pydsa/algorithms/strings/brace_expansion_ii.py +307 -0
- pydsa/algorithms/strings/break_a_palindrome.py +59 -0
- pydsa/algorithms/strings/buddy_strings.py +67 -0
- pydsa/algorithms/strings/bulls_and_cows.py +57 -0
- pydsa/algorithms/strings/calculate_digit_sum_of_a_string.py +42 -0
- pydsa/algorithms/strings/call_function_with_custom_context.py +79 -0
- pydsa/algorithms/strings/camelcase_matching.py +58 -0
- pydsa/algorithms/strings/can_convert_string_in_k_moves.py +59 -0
- pydsa/algorithms/strings/can_make_palindrome_from_substring.py +144 -0
- pydsa/algorithms/strings/capitalize_the_title.py +53 -0
- pydsa/algorithms/strings/cells_in_a_range_on_an_excel_sheet.py +73 -0
- pydsa/algorithms/strings/change_minimum_characters_to_satisfy_one_of_three_conditions.py +246 -0
- pydsa/algorithms/strings/check-if-string-is-transformable-with-substring-sort-operations.py +73 -0
- pydsa/algorithms/strings/check_balanced_string.py +75 -0
- pydsa/algorithms/strings/check_distances_between_same_letters.py +63 -0
- pydsa/algorithms/strings/check_if_a_parentheses_string_can_be_valid.py +70 -0
- pydsa/algorithms/strings/check_if_a_string_can_break_another_string.py +59 -0
- pydsa/algorithms/strings/check_if_a_string_contains_all_binary_codes_of_size_k.py +48 -0
- pydsa/algorithms/strings/check_if_a_string_is_an_acronym_of_words.py +45 -0
- pydsa/algorithms/strings/check_if_all_as_appears_before_all_bs.py +41 -0
- pydsa/algorithms/strings/check_if_all_characters_have_equal_number_of_occurrences.py +40 -0
- pydsa/algorithms/strings/check_if_an_original_string_exists_given_two_encoded_strings.py +81 -0
- pydsa/algorithms/strings/check_if_binary_string_has_at_most_one_segment_of_ones.py +47 -0
- pydsa/algorithms/strings/check_if_dfs_strings_are_palindromes.py +70 -0
- pydsa/algorithms/strings/check_if_digits_are_equal_in_string_after_operations_i.py +51 -0
- pydsa/algorithms/strings/check_if_digits_are_equal_in_string_after_operations_ii.py +72 -0
- pydsa/algorithms/strings/check_if_numbers_are_ascending_in_a_sentence.py +47 -0
- pydsa/algorithms/strings/check_if_object_instance_of_class.py +65 -0
- pydsa/algorithms/strings/check_if_one_string_swap_can_make_strings_equal.py +56 -0
- pydsa/algorithms/strings/check_if_string_is_a_prefix_of_array.py +57 -0
- pydsa/algorithms/strings/check_if_string_is_decomposable_into_value_equal_substrings.py +60 -0
- pydsa/algorithms/strings/check_if_strings_can_be_made_equal_with_operations_i.py +47 -0
- pydsa/algorithms/strings/check_if_strings_can_be_made_equal_with_operations_ii.py +57 -0
- pydsa/algorithms/strings/check_if_the_sentence_is_pangram.py +34 -0
- pydsa/algorithms/strings/check_if_two_string_arrays_are_equivalent.py +62 -0
- pydsa/algorithms/strings/check_if_word_can_be_placed_in_crossword.py +97 -0
- pydsa/algorithms/strings/check_if_word_equals_summation_of_two_words.py +46 -0
- pydsa/algorithms/strings/check_whether_two_strings_are_almost_equivalent.py +50 -0
- pydsa/algorithms/strings/circular_sentence.py +65 -0
- pydsa/algorithms/strings/clear_digits.py +41 -0
- pydsa/algorithms/strings/compact_object.py +40 -0
- pydsa/algorithms/strings/compare_version_numbers.py +55 -0
- pydsa/algorithms/strings/concatenate_the_name_and_the_profession.py +42 -0
- pydsa/algorithms/strings/concatenated_words.py +73 -0
- pydsa/algorithms/strings/consecutive_characters.py +51 -0
- pydsa/algorithms/strings/construct_k_palindrome_strings.py +363 -0
- pydsa/algorithms/strings/construct_string_with_minimum_cost.py +69 -0
- pydsa/algorithms/strings/construct_string_with_minimum_cost_easy.py +86 -0
- pydsa/algorithms/strings/construct_the_longest_new_string.py +65 -0
- pydsa/algorithms/strings/convert_callback_to_promise.py +73 -0
- pydsa/algorithms/strings/convert_date_format.py +59 -0
- pydsa/algorithms/strings/convert_date_to_binary.py +87 -0
- pydsa/algorithms/strings/convert_json_string_to_object.py +182 -0
- pydsa/algorithms/strings/convert_number_words_to_digits.py +56 -0
- pydsa/algorithms/strings/convert_object_to_json_string.py +67 -0
- pydsa/algorithms/strings/count_anagrams.py +97 -0
- pydsa/algorithms/strings/count_and_say.py +61 -0
- pydsa/algorithms/strings/count_asterisks.py +40 -0
- pydsa/algorithms/strings/count_beautiful_substrings_i.py +59 -0
- pydsa/algorithms/strings/count_beautiful_substrings_ii.py +269 -0
- pydsa/algorithms/strings/count_binary_substrings.py +47 -0
- pydsa/algorithms/strings/count_caesar_cipher_pairs.py +68 -0
- pydsa/algorithms/strings/count_common_words_with_one_occurrence.py +55 -0
- pydsa/algorithms/strings/count_complete_substrings.py +71 -0
- pydsa/algorithms/strings/count_mentions_per_user.py +50 -0
- pydsa/algorithms/strings/count_number_of_homogenous_substrings.py +68 -0
- pydsa/algorithms/strings/count_occurrences_in_text.py +103 -0
- pydsa/algorithms/strings/count_pairs_of_equal_substrings_with_minimum_difference.py +51 -0
- pydsa/algorithms/strings/count_pairs_of_similar_strings.py +51 -0
- pydsa/algorithms/strings/count_prefix_and_suffix_pairs_i.py +52 -0
- pydsa/algorithms/strings/count_prefix_and_suffix_pairs_ii.py +285 -0
- pydsa/algorithms/strings/count_prefixes_of_a_given_string.py +72 -0
- pydsa/algorithms/strings/count_substrings_divisible_by_last_digit.py +222 -0
- pydsa/algorithms/strings/count_substrings_starting_and_ending_with_given_character.py +46 -0
- pydsa/algorithms/strings/count_substrings_that_can_be_rearranged_to_contain_a_string_i.py +74 -0
- pydsa/algorithms/strings/count_substrings_that_can_be_rearranged_to_contain_a_string_ii.py +85 -0
- pydsa/algorithms/strings/count_substrings_that_differ_by_one_character.py +64 -0
- pydsa/algorithms/strings/count_the_number_of_consistent_strings.py +46 -0
- pydsa/algorithms/strings/count_the_number_of_special_characters_i.py +52 -0
- pydsa/algorithms/strings/count_the_number_of_vowel_strings_in_range.py +79 -0
- pydsa/algorithms/strings/count_the_repetitions.py +297 -0
- pydsa/algorithms/strings/count_unique_characters_of_all_substrings.py +66 -0
- pydsa/algorithms/strings/count_valid_word_occurrences.py +52 -0
- pydsa/algorithms/strings/count_vowel_substrings_of_a_string.py +103 -0
- pydsa/algorithms/strings/count_words_obtained_after_adding_a_letter.py +340 -0
- pydsa/algorithms/strings/counter.py +96 -0
- pydsa/algorithms/strings/counting_words_with_a_given_prefix.py +43 -0
- pydsa/algorithms/strings/coupon_code_validator.py +88 -0
- pydsa/algorithms/strings/crawler-log-folder.py +84 -0
- pydsa/algorithms/strings/create_hello_world_function.py +27 -0
- pydsa/algorithms/strings/custom_sort_string.py +53 -0
- pydsa/algorithms/strings/date_range_generator.py +48 -0
- pydsa/algorithms/strings/debounce.py +39 -0
- pydsa/algorithms/strings/decode_the_message.py +50 -0
- pydsa/algorithms/strings/decode_the_slanted_ciphertext.py +115 -0
- pydsa/algorithms/strings/decoded_string_at_index.py +79 -0
- pydsa/algorithms/strings/decremental_string_concatenation.py +82 -0
- pydsa/algorithms/strings/decrypt_string_from_alphabet_to_integer_mapping.py +53 -0
- pydsa/algorithms/strings/defanging_an_ip_address.py +43 -0
- pydsa/algorithms/strings/delete_characters_to_make_fancy_string.py +47 -0
- pydsa/algorithms/strings/design_a_text_editor.py +151 -0
- pydsa/algorithms/strings/design_compressed_string_iterator.py +72 -0
- pydsa/algorithms/strings/design_log_storage_system.py +89 -0
- pydsa/algorithms/strings/design_search_autocomplete_system.py +115 -0
- pydsa/algorithms/strings/design_sql.py +73 -0
- pydsa/algorithms/strings/detect_capital.py +47 -0
- pydsa/algorithms/strings/detect_pattern_of_length_m_repeated_k_or_more_times.py +65 -0
- pydsa/algorithms/strings/determine_if_string_halves_are_alike.py +59 -0
- pydsa/algorithms/strings/determine_if_two_strings_are_close.py +70 -0
- pydsa/algorithms/strings/differences_between_two_objects.py +63 -0
- pydsa/algorithms/strings/display_table_of_food_orders_in_a_restaurant.py +83 -0
- pydsa/algorithms/strings/distinct_echo_substrings.py +73 -0
- pydsa/algorithms/strings/distinct_points_reachable_after_substring_removal.py +70 -0
- pydsa/algorithms/strings/divide_a_string_into_groups_of_size_k.py +48 -0
- pydsa/algorithms/strings/dna_pattern_recognition.py +83 -0
- pydsa/algorithms/strings/encode_and_decode_strings.py +105 -0
- pydsa/algorithms/strings/encrypt_and_decrypt_strings.py +114 -0
- pydsa/algorithms/strings/equal_score_substrings.py +59 -0
- pydsa/algorithms/strings/equalize_strings_by_adding_or_removing_characters_at_ends.py +111 -0
- pydsa/algorithms/strings/evaluate_boolean_expression.py +180 -0
- pydsa/algorithms/strings/evaluate_the_bracket_pairs_of_a_string.py +67 -0
- pydsa/algorithms/strings/evaluate_valid_expressions.py +96 -0
- pydsa/algorithms/strings/event_emitter.py +107 -0
- pydsa/algorithms/strings/existence_of_a_substring_in_a_string_and_its_reverse.py +42 -0
- pydsa/algorithms/strings/expressive_words.py +79 -0
- pydsa/algorithms/strings/extract_kth_character_from_the_rope_tree.py +60 -0
- pydsa/algorithms/strings/faulty_keyboard.py +60 -0
- pydsa/algorithms/strings/filter_characters_by_frequency.py +50 -0
- pydsa/algorithms/strings/final_value_of_variable_after_performing_operations.py +40 -0
- pydsa/algorithms/strings/find_active_users.py +63 -0
- pydsa/algorithms/strings/find_all_unique_email_domains.py +43 -0
- pydsa/algorithms/strings/find_and_replace_in_string.py +122 -0
- pydsa/algorithms/strings/find_and_replace_pattern.py +65 -0
- pydsa/algorithms/strings/find_category_recommendation_pairs.py +63 -0
- pydsa/algorithms/strings/find_common_characters.py +53 -0
- pydsa/algorithms/strings/find_duplicate_file_in_system.py +55 -0
- pydsa/algorithms/strings/find_first_palindromic_string_in_the_array.py +43 -0
- pydsa/algorithms/strings/find_kth_character_in_expanded_string.py +48 -0
- pydsa/algorithms/strings/find_longest_awesome_substring.py +184 -0
- pydsa/algorithms/strings/find_longest_self_contained_substring.py +55 -0
- pydsa/algorithms/strings/find_longest_special_substring_that_occurs_thrice_i.py +134 -0
- pydsa/algorithms/strings/find_longest_special_substring_that_occurs_thrice_ii.py +154 -0
- pydsa/algorithms/strings/find_maximum_number_of_non_intersecting_substrings.py +58 -0
- pydsa/algorithms/strings/find_maximum_number_of_string_pairs.py +53 -0
- pydsa/algorithms/strings/find_mirror_score_of_a_string.py +58 -0
- pydsa/algorithms/strings/find_most_frequent_vowel_and_consonant.py +72 -0
- pydsa/algorithms/strings/find_overlapping_shifts.py +69 -0
- pydsa/algorithms/strings/find_overlapping_shifts_ii.py +81 -0
- pydsa/algorithms/strings/find_pattern_in_infinite_stream_i.py +109 -0
- pydsa/algorithms/strings/find_pattern_in_infinite_stream_ii.py +100 -0
- pydsa/algorithms/strings/find_resultant_array_after_removing_anagrams.py +50 -0
- pydsa/algorithms/strings/find_substring_with_given_hash_value.py +209 -0
- pydsa/algorithms/strings/find_the_difference.py +38 -0
- pydsa/algorithms/strings/find_the_divisibility_array_of_a_string.py +61 -0
- pydsa/algorithms/strings/find_the_encrypted_string.py +57 -0
- pydsa/algorithms/strings/find_the_index_of_the_first_occurrence_in_a_string.py +47 -0
- pydsa/algorithms/strings/find_the_length_of_the_longest_common_prefix.py +70 -0
- pydsa/algorithms/strings/find_the_lexicographically_largest_string_from_the_box_i.py +150 -0
- pydsa/algorithms/strings/find_the_lexicographically_largest_string_from_the_box_ii.py +165 -0
- pydsa/algorithms/strings/find_the_longest_balanced_substring_of_a_binary_string.py +88 -0
- pydsa/algorithms/strings/find_the_longest_semi_repetitive_substring.py +61 -0
- pydsa/algorithms/strings/find_the_longest_substring_containing_vowels_in_even_counts.py +64 -0
- pydsa/algorithms/strings/find_the_most_common_response.py +51 -0
- pydsa/algorithms/strings/find_the_occurrence_of_first_almost_equal_substring.py +109 -0
- pydsa/algorithms/strings/find_the_sequence_of_strings_appeared_on_the_screen.py +59 -0
- pydsa/algorithms/strings/find_the_string_with_lcp.py +106 -0
- pydsa/algorithms/strings/find_the_substring_with_maximum_cost.py +87 -0
- pydsa/algorithms/strings/find_trending_hashtags.py +55 -0
- pydsa/algorithms/strings/find_users_with_valid_e_mails.py +149 -0
- pydsa/algorithms/strings/find_valid_emails.py +59 -0
- pydsa/algorithms/strings/find_valid_pair_of_adjacent_digits_in_string.py +50 -0
- pydsa/algorithms/strings/find_words_containing_character.py +40 -0
- pydsa/algorithms/strings/find_words_that_can_be_formed_by_characters.py +54 -0
- pydsa/algorithms/strings/first_letter_capitalization.py +61 -0
- pydsa/algorithms/strings/first_letter_capitalization_ii.py +109 -0
- pydsa/algorithms/strings/first_letter_to_appear_twice.py +41 -0
- pydsa/algorithms/strings/first_matching_character_from_both_ends.py +54 -0
- pydsa/algorithms/strings/first_unique_character_in_a_string.py +41 -0
- pydsa/algorithms/strings/fix_names_in_a_table.py +53 -0
- pydsa/algorithms/strings/fix_product_name_format.py +46 -0
- pydsa/algorithms/strings/flip_game.py +44 -0
- pydsa/algorithms/strings/form_smallest_number_from_two_digit_arrays.py +69 -0
- pydsa/algorithms/strings/generate_a_string_with_characters_that_have_odd_counts.py +56 -0
- pydsa/algorithms/strings/generate_tag_for_video_caption.py +80 -0
- pydsa/algorithms/strings/goal_parser_interpretation.py +63 -0
- pydsa/algorithms/strings/goat_latin.py +49 -0
- pydsa/algorithms/strings/good_indices_in_a_digit_string.py +81 -0
- pydsa/algorithms/strings/greatest_common_divisor_of_strings.py +55 -0
- pydsa/algorithms/strings/greatest_english_letter_in_upper_and_lower_case.py +54 -0
- pydsa/algorithms/strings/group_anagrams.py +45 -0
- pydsa/algorithms/strings/group_shifted_strings.py +51 -0
- pydsa/algorithms/strings/group_sold_products_by_the_date.py +49 -0
- pydsa/algorithms/strings/groups_of_special_equivalent_strings.py +57 -0
- pydsa/algorithms/strings/groups_of_strings.py +44 -0
- pydsa/algorithms/strings/hash_divided_string.py +56 -0
- pydsa/algorithms/strings/html_entity_parser.py +73 -0
- pydsa/algorithms/strings/immutability_helper.py +126 -0
- pydsa/algorithms/strings/implement_magic_dictionary.py +91 -0
- pydsa/algorithms/strings/implement_trie_ii.py +111 -0
- pydsa/algorithms/strings/increasing_decreasing_string.py +74 -0
- pydsa/algorithms/strings/index_pairs_of_a_string.py +77 -0
- pydsa/algorithms/strings/infinite_method_object.py +56 -0
- pydsa/algorithms/strings/integer_to_english_words.py +83 -0
- pydsa/algorithms/strings/invalid_tweets.py +38 -0
- pydsa/algorithms/strings/invalid_tweets_ii.py +38 -0
- pydsa/algorithms/strings/is_object_empty.py +33 -0
- pydsa/algorithms/strings/isomorphic_strings.py +54 -0
- pydsa/algorithms/strings/jewels_and_stones.py +40 -0
- pydsa/algorithms/strings/json_deep_equal.py +174 -0
- pydsa/algorithms/strings/keyboard_row.py +47 -0
- pydsa/algorithms/strings/kth_distinct_string_in_an_array.py +52 -0
- pydsa/algorithms/strings/kth_smallest_instructions.py +62 -0
- pydsa/algorithms/strings/largest_3_same_digit_number_in_string.py +51 -0
- pydsa/algorithms/strings/largest_even_number.py +47 -0
- pydsa/algorithms/strings/largest_merge_of_two_strings.py +60 -0
- pydsa/algorithms/strings/largest_number_after_digit_swaps_by_parity.py +69 -0
- pydsa/algorithms/strings/largest_number_after_mutating_substring.py +50 -0
- pydsa/algorithms/strings/largest_odd_number_in_string.py +45 -0
- pydsa/algorithms/strings/largest_substring_between_two_equal_characters.py +48 -0
- pydsa/algorithms/strings/last_substring_in_lexicographical_order.py +62 -0
- pydsa/algorithms/strings/latest_time_you_can_obtain_after_replacing_characters.py +100 -0
- pydsa/algorithms/strings/leetflex_banned_accounts.py +45 -0
- pydsa/algorithms/strings/length_of_last_word.py +44 -0
- pydsa/algorithms/strings/length_of_the_longest_alphabetical_continuous_substring.py +56 -0
- pydsa/algorithms/strings/length_of_the_longest_valid_substring.py +58 -0
- pydsa/algorithms/strings/lexicographically_minimum_string_after_removing_stars.py +55 -0
- pydsa/algorithms/strings/lexicographically_smallest_beautiful_string.py +66 -0
- pydsa/algorithms/strings/lexicographically_smallest_generated_string.py +109 -0
- pydsa/algorithms/strings/lexicographically_smallest_palindrome.py +52 -0
- pydsa/algorithms/strings/lexicographically_smallest_palindromic_permutation_greater_than_target.py +358 -0
- pydsa/algorithms/strings/lexicographically_smallest_permutation_greater_than_target.py +113 -0
- pydsa/algorithms/strings/lexicographically_smallest_string_after_a_swap.py +84 -0
- pydsa/algorithms/strings/lexicographically_smallest_string_after_adjacent_removals.py +54 -0
- pydsa/algorithms/strings/lexicographically_smallest_string_after_applying_operations.py +89 -0
- pydsa/algorithms/strings/lexicographically_smallest_string_after_deleting_duplicate_characters.py +59 -0
- pydsa/algorithms/strings/lexicographically_smallest_string_after_operations_with_constraint.py +88 -0
- pydsa/algorithms/strings/lexicographically_smallest_string_after_reverse.py +98 -0
- pydsa/algorithms/strings/lexicographically_smallest_string_after_reverse_ii.py +62 -0
- pydsa/algorithms/strings/lexicographically_smallest_string_after_substring_operation.py +60 -0
- pydsa/algorithms/strings/license_key_formatting.py +55 -0
- pydsa/algorithms/strings/longer_contiguous_segments_of_ones_than_zeros.py +57 -0
- pydsa/algorithms/strings/longest_almost_palindromic_substring.py +144 -0
- pydsa/algorithms/strings/longest_balanced_substring_after_one_swap.py +79 -0
- pydsa/algorithms/strings/longest_balanced_substring_i.py +74 -0
- pydsa/algorithms/strings/longest_balanced_substring_ii.py +317 -0
- pydsa/algorithms/strings/longest_common_prefix.py +48 -0
- pydsa/algorithms/strings/longest_common_prefix_after_at_most_one_removal.py +91 -0
- pydsa/algorithms/strings/longest_common_prefix_between_adjacent_strings_after_removals.py +159 -0
- pydsa/algorithms/strings/longest_common_prefix_of_k_strings_after_removal.py +76 -0
- pydsa/algorithms/strings/longest_common_suffix_queries.py +208 -0
- pydsa/algorithms/strings/longest_duplicate_substring.py +99 -0
- pydsa/algorithms/strings/longest_happy_prefix.py +68 -0
- pydsa/algorithms/strings/longest_nice_substring.py +56 -0
- pydsa/algorithms/strings/longest_palindrome.py +50 -0
- pydsa/algorithms/strings/longest_palindrome_after_substring_concatenation_i.py +256 -0
- pydsa/algorithms/strings/longest_palindrome_after_substring_concatenation_ii.py +101 -0
- pydsa/algorithms/strings/longest_palindrome_by_concatenating_two_letter_words.py +81 -0
- pydsa/algorithms/strings/longest_repeating_substring.py +102 -0
- pydsa/algorithms/strings/longest_subsequence_repeated_k_times.py +93 -0
- pydsa/algorithms/strings/longest_substring_of_all_vowels_in_order.py +64 -0
- pydsa/algorithms/strings/longest_uncommon_subsequence_i.py +37 -0
- pydsa/algorithms/strings/longest_uncommon_subsequence_ii.py +78 -0
- pydsa/algorithms/strings/longest_unequal_adjacent_groups_subsequence_i.py +51 -0
- pydsa/algorithms/strings/longest_uploaded_prefix.py +68 -0
- pydsa/algorithms/strings/longest_word_in_dictionary_through_deleting.py +61 -0
- pydsa/algorithms/strings/longest_word_with_all_prefixes.py +83 -0
- pydsa/algorithms/strings/magical_string.py +72 -0
- pydsa/algorithms/strings/majority_frequency_characters.py +51 -0
- pydsa/algorithms/strings/make_number_of_distinct_characters_equal.py +260 -0
- pydsa/algorithms/strings/make_object_immutable.py +99 -0
- pydsa/algorithms/strings/make_string_a_subsequence_using_cyclic_increments.py +233 -0
- pydsa/algorithms/strings/make_string_anti_palindrome.py +40 -0
- pydsa/algorithms/strings/make_the_string_great.py +41 -0
- pydsa/algorithms/strings/make_three_strings_equal.py +57 -0
- pydsa/algorithms/strings/making_file_names_unique.py +62 -0
- pydsa/algorithms/strings/map_sum_pairs.py +83 -0
- pydsa/algorithms/strings/masking_personal_information.py +74 -0
- pydsa/algorithms/strings/match_substring_after_replacement.py +262 -0
- pydsa/algorithms/strings/maximum_binary_string_after_change.py +61 -0
- pydsa/algorithms/strings/maximum_deletions_on_a_string.py +127 -0
- pydsa/algorithms/strings/maximum_distance_between_unequal_words_in_array_ii.py +55 -0
- pydsa/algorithms/strings/maximum_length_substring_with_two_occurrences.py +53 -0
- pydsa/algorithms/strings/maximum_nesting_depth_of_the_parentheses.py +50 -0
- pydsa/algorithms/strings/maximum_number_of_balloons.py +57 -0
- pydsa/algorithms/strings/maximum_number_of_non_overlapping_palindrome_substrings.py +244 -0
- pydsa/algorithms/strings/maximum_number_of_non_overlapping_substrings.py +84 -0
- pydsa/algorithms/strings/maximum_number_of_subsequences_after_one_inserting.py +49 -0
- pydsa/algorithms/strings/maximum_number_of_words_found_in_sentences.py +42 -0
- pydsa/algorithms/strings/maximum_number_of_words_you_can_type.py +43 -0
- pydsa/algorithms/strings/maximum_palindromes_after_operations.py +271 -0
- pydsa/algorithms/strings/maximum_product_of_the_length_of_two_palindromic_substrings.py +104 -0
- pydsa/algorithms/strings/maximum_repeating_substring.py +45 -0
- pydsa/algorithms/strings/maximum_score_after_splitting_a_string.py +59 -0
- pydsa/algorithms/strings/maximum_score_from_removing_substrings.py +76 -0
- pydsa/algorithms/strings/maximum_substrings_with_distinct_start.py +75 -0
- pydsa/algorithms/strings/maximum_value_of_a_string_in_an_array.py +53 -0
- pydsa/algorithms/strings/merge_close_characters.py +103 -0
- pydsa/algorithms/strings/merge_strings_alternately.py +50 -0
- pydsa/algorithms/strings/minimize_string_length.py +52 -0
- pydsa/algorithms/strings/minimum_additions_to_make_valid_string.py +58 -0
- pydsa/algorithms/strings/minimum_changes_to_make_alternating_binary_string.py +48 -0
- pydsa/algorithms/strings/minimum_changes_to_make_k_semi_palindromes.py +199 -0
- pydsa/algorithms/strings/minimum_cost_to_convert_string_i.py +54 -0
- pydsa/algorithms/strings/minimum_cost_to_make_all_characters_equal.py +54 -0
- pydsa/algorithms/strings/minimum_cost_to_make_two_binary_strings_equal.py +56 -0
- pydsa/algorithms/strings/minimum_deletion_cost_to_make_all_characters_equal.py +64 -0
- pydsa/algorithms/strings/minimum_deletions_for_at_most_k_distinct_characters.py +65 -0
- pydsa/algorithms/strings/minimum_deletions_to_make_alternating_substring.py +45 -0
- pydsa/algorithms/strings/minimum_deletions_to_make_character_frequencies_unique.py +48 -0
- pydsa/algorithms/strings/minimum_deletions_to_make_string_balanced.py +55 -0
- pydsa/algorithms/strings/minimum_deletions_to_make_string_k_special.py +79 -0
- pydsa/algorithms/strings/minimum_flips_to_make_binary_string_coherent.py +69 -0
- pydsa/algorithms/strings/minimum_insertions_to_balance_a_parentheses_string.py +74 -0
- pydsa/algorithms/strings/minimum_length_of_string_after_deleting_similar_ends.py +56 -0
- pydsa/algorithms/strings/minimum_length_of_string_after_operations.py +65 -0
- pydsa/algorithms/strings/minimum_moves_to_convert_string.py +251 -0
- pydsa/algorithms/strings/minimum_number_of_changes_to_make_binary_string_beautiful.py +71 -0
- pydsa/algorithms/strings/minimum_number_of_flips_to_make_the_binary_string_alternating.py +78 -0
- pydsa/algorithms/strings/minimum_number_of_frogs_croaking.py +93 -0
- pydsa/algorithms/strings/minimum_number_of_steps_to_make_two_strings_anagram.py +52 -0
- pydsa/algorithms/strings/minimum_number_of_steps_to_make_two_strings_anagram_ii.py +56 -0
- pydsa/algorithms/strings/minimum_number_of_swaps_to_make_the_binary_string_alternating.py +86 -0
- pydsa/algorithms/strings/minimum_number_of_swaps_to_make_the_string_balanced.py +59 -0
- pydsa/algorithms/strings/minimum_operations_to_equalize_binary_string.py +53 -0
- pydsa/algorithms/strings/minimum_operations_to_make_binary_palindrome.py +49 -0
- pydsa/algorithms/strings/minimum_operations_to_make_character_frequencies_equal.py +90 -0
- pydsa/algorithms/strings/minimum_operations_to_sort_a_string.py +70 -0
- pydsa/algorithms/strings/minimum_operations_to_transform_string.py +64 -0
- pydsa/algorithms/strings/minimum_runes_to_add_to_cast_spell.py +51 -0
- pydsa/algorithms/strings/minimum_steps_to_convert_string_with_operations.py +69 -0
- pydsa/algorithms/strings/minimum_string_length_after_balanced_removals.py +100 -0
- pydsa/algorithms/strings/minimum_string_length_after_removing_substrings.py +57 -0
- pydsa/algorithms/strings/minimum_substring_partition_of_equal_character_frequency.py +63 -0
- pydsa/algorithms/strings/minimum_suffix_flips.py +62 -0
- pydsa/algorithms/strings/minimum_time_difference.py +56 -0
- pydsa/algorithms/strings/minimum_time_to_activate_string.py +63 -0
- pydsa/algorithms/strings/minimum_time_to_revert_word_to_initial_state_i.py +305 -0
- pydsa/algorithms/strings/minimum_time_to_revert_word_to_initial_state_ii.py +79 -0
- pydsa/algorithms/strings/mirror_frequency_distance.py +45 -0
- pydsa/algorithms/strings/most_common_word.py +35 -0
- pydsa/algorithms/strings/move_pieces_to_obtain_a_string.py +263 -0
- pydsa/algorithms/strings/naming_a_company.py +44 -0
- pydsa/algorithms/strings/next_closest_time.py +67 -0
- pydsa/algorithms/strings/number_of_atoms.py +84 -0
- pydsa/algorithms/strings/number_of_different_integers_in_a_string.py +52 -0
- pydsa/algorithms/strings/number_of_distinct_substrings_in_a_string.py +91 -0
- pydsa/algorithms/strings/number_of_equal_count_substrings.py +72 -0
- pydsa/algorithms/strings/number_of_good_ways_to_split_a_string.py +68 -0
- pydsa/algorithms/strings/number_of_lines_to_write_string.py +45 -0
- pydsa/algorithms/strings/number_of_matching_subsequences.py +76 -0
- pydsa/algorithms/strings/number_of_pairs_of_strings_with_concatenation_equal_to_target.py +51 -0
- pydsa/algorithms/strings/number_of_same_end_substrings.py +54 -0
- pydsa/algorithms/strings/number_of_segments_in_a_string.py +45 -0
- pydsa/algorithms/strings/number_of_strings_that_appear_as_substrings_in_word.py +67 -0
- pydsa/algorithms/strings/number_of_substrings_with_only_1s.py +42 -0
- pydsa/algorithms/strings/number_of_times_binary_string_is_prefix_aligned.py +52 -0
- pydsa/algorithms/strings/number_of_valid_words_in_a_sentence.py +83 -0
- pydsa/algorithms/strings/number_of_ways_to_split_a_string.py +64 -0
- pydsa/algorithms/strings/number_of_wonderful_substrings.py +232 -0
- pydsa/algorithms/strings/occurrences_after_bigram.py +41 -0
- pydsa/algorithms/strings/odd_string_difference.py +51 -0
- pydsa/algorithms/strings/one_edit_distance.py +60 -0
- pydsa/algorithms/strings/optimal_partition_of_string.py +50 -0
- pydsa/algorithms/strings/orderly_queue.py +51 -0
- pydsa/algorithms/strings/output_contest_matches.py +48 -0
- pydsa/algorithms/strings/palindrome_pairs.py +64 -0
- pydsa/algorithms/strings/palindrome_permutation.py +47 -0
- pydsa/algorithms/strings/palindrome_rearrangement_queries.py +63 -0
- pydsa/algorithms/strings/partition_string.py +52 -0
- pydsa/algorithms/strings/partition_string_into_minimum_beautiful_substrings.py +84 -0
- pydsa/algorithms/strings/password_strength.py +85 -0
- pydsa/algorithms/strings/percentage_of_letter_in_string.py +45 -0
- pydsa/algorithms/strings/perform_string_shifts.py +71 -0
- pydsa/algorithms/strings/permutation_difference_between_two_strings.py +47 -0
- pydsa/algorithms/strings/phone_number_prefix.py +75 -0
- pydsa/algorithms/strings/positions_of_large_groups.py +45 -0
- pydsa/algorithms/strings/prefix_and_suffix_search.py +94 -0
- pydsa/algorithms/strings/prefix_of_word_in_sentence.py +46 -0
- pydsa/algorithms/strings/print_words_vertically.py +58 -0
- pydsa/algorithms/strings/process_string_with_special_operations_i.py +56 -0
- pydsa/algorithms/strings/process_string_with_special_operations_ii.py +97 -0
- pydsa/algorithms/strings/push_dominoes.py +69 -0
- pydsa/algorithms/strings/rank_teams_by_votes.py +64 -0
- pydsa/algorithms/strings/ransom_note.py +53 -0
- pydsa/algorithms/strings/read_n_characters_given_read4.py +119 -0
- pydsa/algorithms/strings/read_n_characters_given_read4_ii.py +105 -0
- pydsa/algorithms/strings/rearrange-spaces-between-words.py +50 -0
- pydsa/algorithms/strings/rearrange_characters_to_make_target_string.py +52 -0
- pydsa/algorithms/strings/rearrange_k_substrings_to_form_target_string.py +51 -0
- pydsa/algorithms/strings/rearrange_words_in_sentence.py +48 -0
- pydsa/algorithms/strings/redistribute_characters_to_make_all_strings_equal.py +51 -0
- pydsa/algorithms/strings/reformat_date.py +39 -0
- pydsa/algorithms/strings/reformat_phone_number.py +62 -0
- pydsa/algorithms/strings/reformat_the_string.py +67 -0
- pydsa/algorithms/strings/remove_adjacent_almost_equal_characters.py +46 -0
- pydsa/algorithms/strings/remove_all_occurrences_of_a_substring.py +48 -0
- pydsa/algorithms/strings/remove_colored_pieces_if_both_neighbors_are_the_same_color.py +67 -0
- pydsa/algorithms/strings/remove_comments.py +95 -0
- pydsa/algorithms/strings/remove_digit_from_number_to_maximize_result.py +55 -0
- pydsa/algorithms/strings/remove_k_balanced_substrings.py +84 -0
- pydsa/algorithms/strings/remove_letter_to_equalize_frequency.py +88 -0
- pydsa/algorithms/strings/remove_methods_from_project.py +102 -0
- pydsa/algorithms/strings/remove_palindromic_subsequences.py +54 -0
- pydsa/algorithms/strings/remove_sub_folders_from_the_filesystem.py +59 -0
- pydsa/algorithms/strings/remove_trailing_zeros_from_a_string.py +41 -0
- pydsa/algorithms/strings/remove_vowels_from_a_string.py +39 -0
- pydsa/algorithms/strings/removing_stars_from_a_string.py +48 -0
- pydsa/algorithms/strings/reorder_data_in_log_files.py +79 -0
- pydsa/algorithms/strings/repeat_string.py +36 -0
- pydsa/algorithms/strings/repeated_string_match.py +89 -0
- pydsa/algorithms/strings/repeated_substring_pattern.py +41 -0
- pydsa/algorithms/strings/replace_all_digits_with_characters.py +47 -0
- pydsa/algorithms/strings/replace_all_qs_to_avoid_consecutive_repeating_characters.py +50 -0
- pydsa/algorithms/strings/replace_question_marks_in_string_to_minimize_its_value.py +107 -0
- pydsa/algorithms/strings/replace_words.py +78 -0
- pydsa/algorithms/strings/report_spam_message.py +79 -0
- pydsa/algorithms/strings/resulting_string_after_adjacent_removals.py +43 -0
- pydsa/algorithms/strings/return_length_of_arguments_passed.py +34 -0
- pydsa/algorithms/strings/reverse_degree_of_a_string.py +65 -0
- pydsa/algorithms/strings/reverse_letters_then_special_characters_in_a_string.py +58 -0
- pydsa/algorithms/strings/reverse_only_letters.py +63 -0
- pydsa/algorithms/strings/reverse_prefix_of_word.py +56 -0
- pydsa/algorithms/strings/reverse_string_ii.py +50 -0
- pydsa/algorithms/strings/reverse_string_prefix.py +49 -0
- pydsa/algorithms/strings/reverse_words_in_a_string.py +42 -0
- pydsa/algorithms/strings/reverse_words_in_a_string_ii.py +54 -0
- pydsa/algorithms/strings/reverse_words_in_a_string_iii.py +51 -0
- pydsa/algorithms/strings/reverse_words_with_same_vowel_count.py +86 -0
- pydsa/algorithms/strings/robot_return_to_origin.py +51 -0
- pydsa/algorithms/strings/rotate_string.py +57 -0
- pydsa/algorithms/strings/score_of_a_string.py +39 -0
- pydsa/algorithms/strings/search_suggestions_system.py +61 -0
- pydsa/algorithms/strings/second_largest_digit_in_a_string.py +50 -0
- pydsa/algorithms/strings/sender_with_largest_word_count.py +57 -0
- pydsa/algorithms/strings/sentence_similarity.py +53 -0
- pydsa/algorithms/strings/sentence_similarity_iii.py +63 -0
- pydsa/algorithms/strings/shift_distance_between_two_strings.py +48 -0
- pydsa/algorithms/strings/shifting_letters.py +57 -0
- pydsa/algorithms/strings/shifting_letters_ii.py +55 -0
- pydsa/algorithms/strings/short_encoding_of_words.py +284 -0
- pydsa/algorithms/strings/shortest_and_lexicographically_smallest_beautiful_string.py +41 -0
- pydsa/algorithms/strings/shortest_common_supersequence.py +75 -0
- pydsa/algorithms/strings/shortest_completing_word.py +64 -0
- pydsa/algorithms/strings/shortest_distance_to_target_string_in_a_circular_array.py +273 -0
- pydsa/algorithms/strings/shortest_palindrome.py +59 -0
- pydsa/algorithms/strings/shortest_string_contains_three_strings.py +104 -0
- pydsa/algorithms/strings/shortest_uncommon_substring_in_an_array.py +66 -0
- pydsa/algorithms/strings/shuffle_string.py +41 -0
- pydsa/algorithms/strings/single_row_keyboard.py +54 -0
- pydsa/algorithms/strings/smallest_k_length_subsequence_with_occurrences_of_a_letter.py +310 -0
- pydsa/algorithms/strings/smallest_palindromic_rearrangement_i.py +68 -0
- pydsa/algorithms/strings/smallest_palindromic_rearrangement_ii.py +137 -0
- pydsa/algorithms/strings/smallest_string_with_a_given_numeric_value.py +44 -0
- pydsa/algorithms/strings/smallest_subsequence_of_distinct_characters.py +54 -0
- pydsa/algorithms/strings/smallest_substring_with_identical_characters_i.py +61 -0
- pydsa/algorithms/strings/smallest_substring_with_identical_characters_ii.py +69 -0
- pydsa/algorithms/strings/sort_characters_by_frequency.py +56 -0
- pydsa/algorithms/strings/sort_vowels_by_frequency.py +63 -0
- pydsa/algorithms/strings/sort_vowels_in_a_string.py +52 -0
- pydsa/algorithms/strings/sorting_the_sentence.py +50 -0
- pydsa/algorithms/strings/special_binary_string.py +88 -0
- pydsa/algorithms/strings/split-a-string-into-the-max-number-of-unique-substrings.py +58 -0
- pydsa/algorithms/strings/split_concatenated_strings.py +73 -0
- pydsa/algorithms/strings/split_message_based_on_limit.py +70 -0
- pydsa/algorithms/strings/split_strings_by_separator.py +57 -0
- pydsa/algorithms/strings/split_two_strings_to_make_palindrome.py +75 -0
- pydsa/algorithms/strings/stream_of_characters.py +103 -0
- pydsa/algorithms/strings/string_compression.py +64 -0
- pydsa/algorithms/strings/string_compression_ii.py +134 -0
- pydsa/algorithms/strings/string_compression_iii.py +109 -0
- pydsa/algorithms/strings/string_matching_in_an_array.py +46 -0
- pydsa/algorithms/strings/string_to_integer_atoi.py +79 -0
- pydsa/algorithms/strings/string_transforms_into_another_string.py +78 -0
- pydsa/algorithms/strings/strings_differ_by_one_character.py +58 -0
- pydsa/algorithms/strings/strong_password_checker_ii.py +274 -0
- pydsa/algorithms/strings/student_attendance_record_i.py +37 -0
- pydsa/algorithms/strings/subdomain_visit_count.py +45 -0
- pydsa/algorithms/strings/substring_matching_pattern.py +71 -0
- pydsa/algorithms/strings/substring_with_largest_variance.py +332 -0
- pydsa/algorithms/strings/substring_xor_queries.py +45 -0
- pydsa/algorithms/strings/substrings_of_size_three_with_distinct_characters.py +50 -0
- pydsa/algorithms/strings/substrings_that_begin_and_end_with_the_same_letter.py +53 -0
- pydsa/algorithms/strings/sum_of_beauty_of_all_substrings.py +64 -0
- pydsa/algorithms/strings/sum_of_digits_of_string_after_convert.py +30 -0
- pydsa/algorithms/strings/sum_of_largest_prime_substrings.py +84 -0
- pydsa/algorithms/strings/sum_of_prefix_scores_of_strings.py +70 -0
- pydsa/algorithms/strings/sum_of_scores_of_built_strings.py +243 -0
- pydsa/algorithms/strings/take_k_of_each_character_from_left_and_right.py +56 -0
- pydsa/algorithms/strings/tenth_line.py +24 -0
- pydsa/algorithms/strings/text_justification.py +90 -0
- pydsa/algorithms/strings/the_kth_lexicographical_string_of_all_happy_strings_of_length_n.py +68 -0
- pydsa/algorithms/strings/the_wording_game.py +70 -0
- pydsa/algorithms/strings/thousand_separator.py +41 -0
- pydsa/algorithms/strings/timeout_cancellation.py +134 -0
- pydsa/algorithms/strings/to_be_or_not_to_be.py +31 -0
- pydsa/algorithms/strings/to_lower_case.py +29 -0
- pydsa/algorithms/strings/total_appeal_of_a_string.py +129 -0
- pydsa/algorithms/strings/trim_trailing_vowels.py +45 -0
- pydsa/algorithms/strings/truncate_sentence.py +47 -0
- pydsa/algorithms/strings/two_letter_card_game.py +49 -0
- pydsa/algorithms/strings/uncommon_words_from_two_sentences.py +41 -0
- pydsa/algorithms/strings/undefined_to_null.py +37 -0
- pydsa/algorithms/strings/unique_email_addresses.py +55 -0
- pydsa/algorithms/strings/unique_email_groups.py +55 -0
- pydsa/algorithms/strings/unique_length_3_palindromic_subsequences.py +61 -0
- pydsa/algorithms/strings/unique_morse_code_words.py +54 -0
- pydsa/algorithms/strings/unique_substrings_with_equal_digit_frequency.py +64 -0
- pydsa/algorithms/strings/unique_word_abbreviation.py +52 -0
- pydsa/algorithms/strings/using_a_robot_to_print_the_lexicographically_smallest_string.py +61 -0
- pydsa/algorithms/strings/valid_anagram.py +52 -0
- pydsa/algorithms/strings/valid_digit_number.py +90 -0
- pydsa/algorithms/strings/valid_number.py +124 -0
- pydsa/algorithms/strings/valid_palindrome_iv.py +77 -0
- pydsa/algorithms/strings/valid_phone_numbers.py +47 -0
- pydsa/algorithms/strings/valid_word.py +66 -0
- pydsa/algorithms/strings/valid_word_abbreviation.py +71 -0
- pydsa/algorithms/strings/validate_ip_address.py +81 -0
- pydsa/algorithms/strings/verifying_an_alien_dictionary.py +58 -0
- pydsa/algorithms/strings/vowel_consonant_score.py +67 -0
- pydsa/algorithms/strings/vowel_spellchecker.py +82 -0
- pydsa/algorithms/strings/vowels_game_in_a_string.py +50 -0
- pydsa/algorithms/strings/vowels_of_all_substrings.py +46 -0
- pydsa/algorithms/strings/weighted_word_mapping.py +57 -0
- pydsa/algorithms/strings/word_abbreviation.py +132 -0
- pydsa/algorithms/strings/word_frequency.py +114 -0
- pydsa/algorithms/strings/word_pattern.py +62 -0
- pydsa/algorithms/strings/word_subsets.py +56 -0
- pydsa/algorithms/strings/words_within_two_edits_of_dictionary.py +135 -0
- pydsa/algorithms/strings/zigzag_conversion.py +54 -0
- pydsa/algorithms/trees/__init__.py +0 -0
- pydsa/algorithms/trees/add_one_row_to_tree.py +227 -0
- pydsa/algorithms/trees/all_elements_in_two_binary_search_trees.py +78 -0
- pydsa/algorithms/trees/all_nodes_distance_k_in_binary_tree.py +60 -0
- pydsa/algorithms/trees/all_possible_full_binary_trees.py +48 -0
- pydsa/algorithms/trees/amount_of_time_for_binary_tree_to_be_infected.py +85 -0
- pydsa/algorithms/trees/average_of_levels_in_binary_tree.py +68 -0
- pydsa/algorithms/trees/balance_a_binary_search_tree.py +68 -0
- pydsa/algorithms/trees/balanced_binary_tree.py +68 -0
- pydsa/algorithms/trees/binary-search-tree-iterator-ii.py +76 -0
- pydsa/algorithms/trees/binary_search_tree_to_greater_sum_tree.py +57 -0
- pydsa/algorithms/trees/binary_tree_cameras.py +74 -0
- pydsa/algorithms/trees/binary_tree_coloring_game.py +99 -0
- pydsa/algorithms/trees/binary_tree_inorder_traversal.py +57 -0
- pydsa/algorithms/trees/binary_tree_level_order_traversal.py +65 -0
- pydsa/algorithms/trees/binary_tree_level_order_traversal_ii.py +64 -0
- pydsa/algorithms/trees/binary_tree_longest_consecutive_sequence.py +69 -0
- pydsa/algorithms/trees/binary_tree_longest_consecutive_sequence_ii.py +83 -0
- pydsa/algorithms/trees/binary_tree_maximum_path_sum.py +69 -0
- pydsa/algorithms/trees/binary_tree_nodes.py +46 -0
- pydsa/algorithms/trees/binary_tree_paths.py +49 -0
- pydsa/algorithms/trees/binary_tree_postorder_traversal.py +90 -0
- pydsa/algorithms/trees/binary_tree_preorder_traversal.py +46 -0
- pydsa/algorithms/trees/binary_tree_pruning.py +52 -0
- pydsa/algorithms/trees/binary_tree_right_side_view.py +71 -0
- pydsa/algorithms/trees/binary_tree_tilt.py +44 -0
- pydsa/algorithms/trees/binary_tree_upside_down.py +280 -0
- pydsa/algorithms/trees/binary_tree_vertical_order_traversal.py +73 -0
- pydsa/algorithms/trees/binary_tree_zigzag_level_order_traversal.py +73 -0
- pydsa/algorithms/trees/boundary_of_binary_tree.py +93 -0
- pydsa/algorithms/trees/bst_iterator.py +110 -0
- pydsa/algorithms/trees/build-binary-expression-tree-from-infix-expression.py +102 -0
- pydsa/algorithms/trees/ceo_subordinate_hierarchy.py +68 -0
- pydsa/algorithms/trees/change_the_root_of_a_binary_tree.py +96 -0
- pydsa/algorithms/trees/check_completeness_of_a_binary_tree.py +69 -0
- pydsa/algorithms/trees/check_if_a_string_is_a_valid_sequence_from_root_to_leaves_path_in_a_binary_tree.py +65 -0
- pydsa/algorithms/trees/check_if_two_expression_trees_are_equivalent.py +46 -0
- pydsa/algorithms/trees/clone_binary_tree_with_random_pointer.py +191 -0
- pydsa/algorithms/trees/clone_n_ary_tree.py +36 -0
- pydsa/algorithms/trees/closest_binary_search_tree_value.py +51 -0
- pydsa/algorithms/trees/closest_binary_search_tree_value_ii.py +76 -0
- pydsa/algorithms/trees/closest_leaf_in_a_binary_tree.py +88 -0
- pydsa/algorithms/trees/closest_nodes_queries_in_a_binary_search_tree.py +68 -0
- pydsa/algorithms/trees/closest_room.py +83 -0
- pydsa/algorithms/trees/complete_binary_tree_inserter.py +97 -0
- pydsa/algorithms/trees/construct_binary_search_tree_from_preorder_traversal.py +64 -0
- pydsa/algorithms/trees/construct_binary_tree_from_inorder_and_postorder_traversal.py +70 -0
- pydsa/algorithms/trees/construct_binary_tree_from_preorder_and_inorder_traversal.py +69 -0
- pydsa/algorithms/trees/construct_binary_tree_from_preorder_and_postorder.py +83 -0
- pydsa/algorithms/trees/construct_binary_tree_from_string.py +227 -0
- pydsa/algorithms/trees/construct_quad_tree.py +61 -0
- pydsa/algorithms/trees/construct_string_from_binary_tree.py +53 -0
- pydsa/algorithms/trees/convert_binary_search_tree_to_sorted_doubly_linked_list.py +81 -0
- pydsa/algorithms/trees/convert_bst_to_greater_tree.py +60 -0
- pydsa/algorithms/trees/convert_sorted_array_to_binary_search_tree.py +63 -0
- pydsa/algorithms/trees/convert_sorted_list_to_binary_search_tree.py +74 -0
- pydsa/algorithms/trees/correct_a_binary_tree.py +71 -0
- pydsa/algorithms/trees/count_complete_tree_nodes.py +71 -0
- pydsa/algorithms/trees/count_good_nodes_binary_tree.py +67 -0
- pydsa/algorithms/trees/count_nodes_equal_to_average_of_subtree.py +47 -0
- pydsa/algorithms/trees/count_nodes_equal_to_sum_of_descendants.py +66 -0
- pydsa/algorithms/trees/count_nodes_that_are_great_enough.py +71 -0
- pydsa/algorithms/trees/count_non_adjacent_subsets_in_a_rooted_tree.py +87 -0
- pydsa/algorithms/trees/count_number_of_possible_root_nodes.py +99 -0
- pydsa/algorithms/trees/count_paths_that_can_form_a_palindrome_in_a_tree.py +123 -0
- pydsa/algorithms/trees/count_subtrees_with_max_distance_between_cities.py +80 -0
- pydsa/algorithms/trees/count_the_number_of_good_nodes.py +67 -0
- pydsa/algorithms/trees/count_univalue_subtrees.py +67 -0
- pydsa/algorithms/trees/cousins_in_binary_tree.py +75 -0
- pydsa/algorithms/trees/cousins_in_binary_tree_ii.py +89 -0
- pydsa/algorithms/trees/create_binary_tree_from_descriptions.py +67 -0
- pydsa/algorithms/trees/deepest_leaves_sum.py +62 -0
- pydsa/algorithms/trees/delete_duplicate_folders_in_system.py +78 -0
- pydsa/algorithms/trees/delete_leaves_with_a_given_value.py +56 -0
- pydsa/algorithms/trees/delete_node_in_a_bst.py +66 -0
- pydsa/algorithms/trees/delete_nodes_and_return_forest.py +50 -0
- pydsa/algorithms/trees/delete_tree_nodes.py +67 -0
- pydsa/algorithms/trees/depth_of_bst_given_insertion_order.py +90 -0
- pydsa/algorithms/trees/design_add_and_search_words_data_structure.py +122 -0
- pydsa/algorithms/trees/design_an_expression_tree_with_evaluate_function.py +71 -0
- pydsa/algorithms/trees/design_file_system.py +97 -0
- pydsa/algorithms/trees/design_in_memory_file_system.py +142 -0
- pydsa/algorithms/trees/design_order_management_system.py +136 -0
- pydsa/algorithms/trees/diameter_of_binary_tree.py +43 -0
- pydsa/algorithms/trees/diameter_of_n_ary_tree.py +73 -0
- pydsa/algorithms/trees/distribute_coins_in_binary_tree.py +80 -0
- pydsa/algorithms/trees/encode_n_ary_tree_to_binary_tree.py +70 -0
- pydsa/algorithms/trees/equal_tree_partition.py +166 -0
- pydsa/algorithms/trees/evaluate_boolean_binary_tree.py +61 -0
- pydsa/algorithms/trees/even_odd_tree.py +73 -0
- pydsa/algorithms/trees/find_a_corresponding_node_of_a_binary_tree_in_a_clone_of_that_tree.py +60 -0
- pydsa/algorithms/trees/find_bottom_left_tree_value.py +62 -0
- pydsa/algorithms/trees/find_distance_in_a_binary_tree.py +85 -0
- pydsa/algorithms/trees/find_duplicate_subtrees.py +70 -0
- pydsa/algorithms/trees/find_elements_in_a_contaminated_binary_tree.py +58 -0
- pydsa/algorithms/trees/find_largest_value_in_each_tree_row.py +64 -0
- pydsa/algorithms/trees/find_leaves_of_binary_tree.py +75 -0
- pydsa/algorithms/trees/find_mode_in_binary_search_tree.py +62 -0
- pydsa/algorithms/trees/find_nearest_right_node_in_binary_tree.py +69 -0
- pydsa/algorithms/trees/find_number_of_coins_to_place_in_tree_nodes.py +104 -0
- pydsa/algorithms/trees/find_root_of_n_ary_tree.py +53 -0
- pydsa/algorithms/trees/find_subtree_sizes_after_changes.py +77 -0
- pydsa/algorithms/trees/find_the_last_marked_nodes_in_tree.py +112 -0
- pydsa/algorithms/trees/find_the_level_of_tree_with_minimum_sum.py +76 -0
- pydsa/algorithms/trees/find_the_minimum_and_maximum_number_of_nodes_between_critical_points.py +355 -0
- pydsa/algorithms/trees/find_weighted_median_node_in_tree.py +80 -0
- pydsa/algorithms/trees/flatten_binary_tree_to_linked_list.py +51 -0
- pydsa/algorithms/trees/flip_binary_tree_to_match_preorder_traversal.py +133 -0
- pydsa/algorithms/trees/flip_equivalent_binary_trees.py +56 -0
- pydsa/algorithms/trees/frog_position_after_t_seconds.py +140 -0
- pydsa/algorithms/trees/fruits_into_baskets_iii.py +89 -0
- pydsa/algorithms/trees/height_of_binary_tree_after_subtree_removal_queries.py +299 -0
- pydsa/algorithms/trees/height_of_special_binary_tree.py +75 -0
- pydsa/algorithms/trees/implement_trie_prefix_tree.py +90 -0
- pydsa/algorithms/trees/increasing_order_search_tree.py +46 -0
- pydsa/algorithms/trees/inorder_successor_in_bst.py +55 -0
- pydsa/algorithms/trees/inorder_successor_in_bst_ii.py +59 -0
- pydsa/algorithms/trees/insert_into_a_binary_search_tree.py +85 -0
- pydsa/algorithms/trees/insufficient_nodes_in_root_to_leaf_paths.py +60 -0
- pydsa/algorithms/trees/invert_binary_tree.py +68 -0
- pydsa/algorithms/trees/is_array_a_preorder_of_some_binary_tree.py +55 -0
- pydsa/algorithms/trees/kth_ancestor_of_a_tree_node.py +93 -0
- pydsa/algorithms/trees/kth_largest_perfect_subtree_size_in_binary_tree.py +97 -0
- pydsa/algorithms/trees/kth_largest_sum_in_a_binary_tree.py +78 -0
- pydsa/algorithms/trees/kth_smallest_element_in_a_bst.py +62 -0
- pydsa/algorithms/trees/largest_bst_subtree.py +80 -0
- pydsa/algorithms/trees/leaf_similar_trees.py +81 -0
- pydsa/algorithms/trees/linked_list_in_binary_tree.py +58 -0
- pydsa/algorithms/trees/logical_or_of_two_binary_grids_represented_as_quad_trees.py +69 -0
- pydsa/algorithms/trees/longest_special_path.py +109 -0
- pydsa/algorithms/trees/longest_univalue_path.py +72 -0
- pydsa/algorithms/trees/longest_word_in_dictionary.py +39 -0
- pydsa/algorithms/trees/longest_zigzag_path_in_a_binary_tree.py +95 -0
- pydsa/algorithms/trees/lowest_common_ancestor_of_a_binary_search_tree.py +59 -0
- pydsa/algorithms/trees/lowest_common_ancestor_of_a_binary_tree.py +59 -0
- pydsa/algorithms/trees/lowest_common_ancestor_of_a_binary_tree_ii.py +124 -0
- pydsa/algorithms/trees/lowest_common_ancestor_of_a_binary_tree_iii.py +107 -0
- pydsa/algorithms/trees/lowest_common_ancestor_of_a_binary_tree_iv.py +69 -0
- pydsa/algorithms/trees/lowest_common_ancestor_of_deepest_leaves.py +78 -0
- pydsa/algorithms/trees/make_costs_of_paths_equal_in_a_binary_tree.py +153 -0
- pydsa/algorithms/trees/maximum_average_subtree.py +71 -0
- pydsa/algorithms/trees/maximum_binary_tree.py +75 -0
- pydsa/algorithms/trees/maximum_binary_tree_ii.py +40 -0
- pydsa/algorithms/trees/maximum_depth_of_binary_tree.py +49 -0
- pydsa/algorithms/trees/maximum_depth_of_n_ary_tree.py +52 -0
- pydsa/algorithms/trees/maximum_difference_between_node_and_ancestor.py +60 -0
- pydsa/algorithms/trees/maximum_distinct_path_sum_in_a_binary_tree.py +368 -0
- pydsa/algorithms/trees/maximum_good_subtree_score.py +76 -0
- pydsa/algorithms/trees/maximum_level_sum_of_a_binary_tree.py +68 -0
- pydsa/algorithms/trees/maximum_product_of_splitted_binary_tree.py +83 -0
- pydsa/algorithms/trees/maximum_subtree_of_the_same_color.py +80 -0
- pydsa/algorithms/trees/maximum_sum_bst_in_binary_tree.py +81 -0
- pydsa/algorithms/trees/maximum_width_of_binary_tree.py +61 -0
- pydsa/algorithms/trees/maximum_xor_of_two_non_overlapping_subtrees.py +175 -0
- pydsa/algorithms/trees/median_of_a_binary_search_tree_level.py +74 -0
- pydsa/algorithms/trees/merge_bsts_to_create_single_bst.py +86 -0
- pydsa/algorithms/trees/merge_two_binary_trees.py +41 -0
- pydsa/algorithms/trees/minimum_absolute_difference_in_bst.py +67 -0
- pydsa/algorithms/trees/minimum_depth_of_binary_tree.py +68 -0
- pydsa/algorithms/trees/minimum_distance_between_bst_nodes.py +47 -0
- pydsa/algorithms/trees/minimum_flips_in_binary_tree_to_get_result.py +76 -0
- pydsa/algorithms/trees/minimum_increments_to_equalize_leaf_paths.py +81 -0
- pydsa/algorithms/trees/minimum_levels_to_gain_more_points.py +71 -0
- pydsa/algorithms/trees/minimum_number_of_operations_to_sort_a_binary_tree_by_level.py +93 -0
- pydsa/algorithms/trees/most_frequent_subtree_sum.py +54 -0
- pydsa/algorithms/trees/move_sub_tree_of_n_ary_tree.py +78 -0
- pydsa/algorithms/trees/n_ary_tree_level_order_traversal.py +64 -0
- pydsa/algorithms/trees/n_ary_tree_postorder_traversal.py +62 -0
- pydsa/algorithms/trees/n_ary_tree_preorder_traversal.py +52 -0
- pydsa/algorithms/trees/nested_list_weight_sum.py +43 -0
- pydsa/algorithms/trees/nested_list_weight_sum_ii.py +105 -0
- pydsa/algorithms/trees/number_of_good_leaf_nodes_pairs.py +78 -0
- pydsa/algorithms/trees/number_of_nodes_in_the_sub_tree_with_the_same_label.py +83 -0
- pydsa/algorithms/trees/number_of_nodes_with_value_one.py +63 -0
- pydsa/algorithms/trees/number_of_possible_sets_of_closing_branches.py +113 -0
- pydsa/algorithms/trees/number_of_ways_to_reorder_array_to_get_same_bst.py +75 -0
- pydsa/algorithms/trees/operations_on_tree.py +63 -0
- pydsa/algorithms/trees/palindromic_path_queries_in_a_tree.py +244 -0
- pydsa/algorithms/trees/path_sum.py +53 -0
- pydsa/algorithms/trees/path_sum_ii.py +64 -0
- pydsa/algorithms/trees/path_sum_iii.py +70 -0
- pydsa/algorithms/trees/path_sum_iv.py +68 -0
- pydsa/algorithms/trees/populating_next_right_pointers_in_each_node.py +65 -0
- pydsa/algorithms/trees/populating_next_right_pointers_in_each_node_ii.py +72 -0
- pydsa/algorithms/trees/print_binary_tree.py +271 -0
- pydsa/algorithms/trees/pseudo_palindromic_paths_binary_tree.py +60 -0
- pydsa/algorithms/trees/pythagorean_distance_nodes_in_a_tree.py +224 -0
- pydsa/algorithms/trees/range_sum_of_bst.py +39 -0
- pydsa/algorithms/trees/recover_a_tree_from_preorder_traversal.py +407 -0
- pydsa/algorithms/trees/recover_binary_search_tree.py +54 -0
- pydsa/algorithms/trees/reverse_odd_levels_of_binary_tree.py +78 -0
- pydsa/algorithms/trees/root_equals_sum_of_children.py +28 -0
- pydsa/algorithms/trees/same_tree.py +51 -0
- pydsa/algorithms/trees/search_in_a_binary_search_tree.py +37 -0
- pydsa/algorithms/trees/second_minimum_node_in_a_binary_tree.py +62 -0
- pydsa/algorithms/trees/sequentially_ordinal_rank_tracker.py +388 -0
- pydsa/algorithms/trees/serialize_and_deserialize_binary_tree.py +133 -0
- pydsa/algorithms/trees/serialize_and_deserialize_bst.py +120 -0
- pydsa/algorithms/trees/serialize_and_deserialize_n_ary_tree.py +65 -0
- pydsa/algorithms/trees/smallest_common_region.py +58 -0
- pydsa/algorithms/trees/smallest_missing_genetic_value_in_each_subtree.py +276 -0
- pydsa/algorithms/trees/smallest_string_starting_from_leaf.py +63 -0
- pydsa/algorithms/trees/smallest_subtree_with_all_the_deepest_nodes.py +76 -0
- pydsa/algorithms/trees/split_bst.py +54 -0
- pydsa/algorithms/trees/step_by_step_directions_from_a_binary_tree_node_to_another.py +89 -0
- pydsa/algorithms/trees/subtree_inversion_sum.py +214 -0
- pydsa/algorithms/trees/subtree_of_another_tree.py +72 -0
- pydsa/algorithms/trees/subtree_removal_game_with_fibonacci_tree.py +68 -0
- pydsa/algorithms/trees/sum_of_distances_in_tree.py +72 -0
- pydsa/algorithms/trees/sum_of_left_leaves.py +65 -0
- pydsa/algorithms/trees/sum_of_nodes_with_even_valued_grandparent.py +96 -0
- pydsa/algorithms/trees/sum_of_perfect_square_ancestors.py +69 -0
- pydsa/algorithms/trees/sum_of_root_to_leaf_binary_numbers.py +66 -0
- pydsa/algorithms/trees/sum_root_to_leaf_numbers.py +55 -0
- pydsa/algorithms/trees/symmetric_tree.py +59 -0
- pydsa/algorithms/trees/throne-inheritance.py +111 -0
- pydsa/algorithms/trees/tree_diameter.py +87 -0
- pydsa/algorithms/trees/tree_node.py +65 -0
- pydsa/algorithms/trees/trim_a_binary_search_tree.py +58 -0
- pydsa/algorithms/trees/two_sum_bsts.py +51 -0
- pydsa/algorithms/trees/two_sum_iv_input_is_a_bst.py +44 -0
- pydsa/algorithms/trees/unique_binary_search_trees_ii.py +78 -0
- pydsa/algorithms/trees/univalued_binary_tree.py +58 -0
- pydsa/algorithms/trees/validate_binary_search_tree.py +74 -0
- pydsa/algorithms/trees/vertical_order_traversal_of_a_binary_tree.py +98 -0
- pydsa/algorithms/trees/zigzag_level_sum_of_binary_tree.py +73 -0
- pydsa/algorithms/two_pointer/3sum.py +74 -0
- pydsa/algorithms/two_pointer/3sum_closest.py +63 -0
- pydsa/algorithms/two_pointer/3sum_smaller.py +56 -0
- pydsa/algorithms/two_pointer/3sum_with_multiplicity.py +179 -0
- pydsa/algorithms/two_pointer/4sum.py +83 -0
- pydsa/algorithms/two_pointer/__init__.py +0 -0
- pydsa/algorithms/two_pointer/all_valid_triplets_that_can_represent_a_country.py +51 -0
- pydsa/algorithms/two_pointer/circular_array_loop.py +93 -0
- pydsa/algorithms/two_pointer/container_with_most_water.py +58 -0
- pydsa/algorithms/two_pointer/count_pairs_of_points_with_distance_k.py +60 -0
- pydsa/algorithms/two_pointer/count_pairs_whose_sum_is_less_than_target.py +54 -0
- pydsa/algorithms/two_pointer/find_all_k_distant_indices_in_an_array.py +62 -0
- pydsa/algorithms/two_pointer/find_positive_integer_solution_for_a_given_equation.py +57 -0
- pydsa/algorithms/two_pointer/find_the_duplicate_number.py +52 -0
- pydsa/algorithms/two_pointer/find_the_number_of_ways_to_place_people_i.py +66 -0
- pydsa/algorithms/two_pointer/find_the_number_of_ways_to_place_people_ii.py +66 -0
- pydsa/algorithms/two_pointer/is_subsequence.py +44 -0
- pydsa/algorithms/two_pointer/long_pressed_name.py +50 -0
- pydsa/algorithms/two_pointer/longest_even_odd_subarray_with_threshold.py +59 -0
- pydsa/algorithms/two_pointer/longest_mountain_in_array.py +58 -0
- pydsa/algorithms/two_pointer/max_number_of_k_sum_pairs.py +47 -0
- pydsa/algorithms/two_pointer/maximum_matching_of_players_with_trainers.py +57 -0
- pydsa/algorithms/two_pointer/merge_sorted_array.py +62 -0
- pydsa/algorithms/two_pointer/minimum_average_of_smallest_and_largest_elements.py +51 -0
- pydsa/algorithms/two_pointer/minimum_common_value.py +51 -0
- pydsa/algorithms/two_pointer/minimum_number_of_moves_to_make_palindrome.py +67 -0
- pydsa/algorithms/two_pointer/minimum_swaps_to_move_zeros_to_end.py +51 -0
- pydsa/algorithms/two_pointer/move_zeroes.py +29 -0
- pydsa/algorithms/two_pointer/remove_duplicates_from_sorted_array.py +51 -0
- pydsa/algorithms/two_pointer/remove_duplicates_from_sorted_array_ii.py +55 -0
- pydsa/algorithms/two_pointer/remove_element.py +52 -0
- pydsa/algorithms/two_pointer/reverse_string.py +42 -0
- pydsa/algorithms/two_pointer/reverse_vowels_of_a_string.py +56 -0
- pydsa/algorithms/two_pointer/shortest_way_to_form_string.py +60 -0
- pydsa/algorithms/two_pointer/sort_array_by_parity.py +47 -0
- pydsa/algorithms/two_pointer/sort_array_by_parity_ii.py +36 -0
- pydsa/algorithms/two_pointer/sort_transformed_array.py +154 -0
- pydsa/algorithms/two_pointer/squares_of_a_sorted_array.py +50 -0
- pydsa/algorithms/two_pointer/swap_adjacent_in_lr_string.py +82 -0
- pydsa/algorithms/two_pointer/trapping_rain_water.py +63 -0
- pydsa/algorithms/two_pointer/two_sum_ii_sorted.py +53 -0
- pydsa/algorithms/two_pointer/two_sum_less_than_k.py +54 -0
- pydsa/algorithms/two_pointer/valid_palindrome.py +52 -0
- pydsa/algorithms/two_pointer/valid_palindrome_ii.py +52 -0
- pydsa/algorithms/two_pointer/valid_triangle_number.py +67 -0
- pydsa/api/server.py +43 -0
- pydsa/core/__init__.py +1 -0
- pydsa/core/engine.py +70 -0
- pydsa/core/exceptions.py +77 -0
- pydsa/core/models.py +87 -0
- pydsa/core/registry.py +188 -0
- pydsa/core/router.py +224 -0
- pydsa/core/tracer.py +39 -0
- pydsa/search/__init__.py +1 -0
- pydsa/search/embeddings.py +61 -0
- pydsa/search/vectors.npy +0 -0
- pydsa/tests/test_engine.py +31 -0
- pydsa_engine-0.1.0.dist-info/METADATA +26 -0
- pydsa_engine-0.1.0.dist-info/RECORD +3981 -0
- pydsa_engine-0.1.0.dist-info/WHEEL +5 -0
- pydsa_engine-0.1.0.dist-info/entry_points.txt +2 -0
- pydsa_engine-0.1.0.dist-info/top_level.txt +1 -0
pydsa/__init__.py
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pydsa
|
|
3
|
+
~~~~~
|
|
4
|
+
A semantic DSA execution engine.
|
|
5
|
+
|
|
6
|
+
Quickstart
|
|
7
|
+
----------
|
|
8
|
+
>>> from pydsa import solve, search, info
|
|
9
|
+
>>>
|
|
10
|
+
>>> # Solve by natural description
|
|
11
|
+
>>> result = solve("find maximum water between vertical lines", [1,8,6,2,5,4,8,3,7])
|
|
12
|
+
>>> print(result.answer) # 49
|
|
13
|
+
>>> print(result.time_complexity) # O(n)
|
|
14
|
+
>>>
|
|
15
|
+
>>> # Solve by exact problem id
|
|
16
|
+
>>> result = solve(11, [1,8,6,2,5,4,8,3,7])
|
|
17
|
+
>>>
|
|
18
|
+
>>> # Browse problems
|
|
19
|
+
>>> problems = search("sliding window")
|
|
20
|
+
>>> for p in problems:
|
|
21
|
+
... print(p.id, p.name)
|
|
22
|
+
>>>
|
|
23
|
+
>>> # Get metadata for a problem
|
|
24
|
+
>>> p = info("two sum")
|
|
25
|
+
>>> print(p.difficulty, p.tags)
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from __future__ import annotations
|
|
29
|
+
|
|
30
|
+
from typing import Any
|
|
31
|
+
|
|
32
|
+
from pydsa.core.models import Problem, Result
|
|
33
|
+
from pydsa.core.router import find, search as _search
|
|
34
|
+
from pydsa.core.engine import execute
|
|
35
|
+
from pydsa.core import registry as _registry
|
|
36
|
+
from pydsa.core.exceptions import (
|
|
37
|
+
PyDSAError,
|
|
38
|
+
ProblemNotFoundError,
|
|
39
|
+
AmbiguousQueryError,
|
|
40
|
+
InvalidInputError,
|
|
41
|
+
SolverError,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
__version__ = "0.1.0"
|
|
45
|
+
__all__ = [
|
|
46
|
+
"solve",
|
|
47
|
+
"search",
|
|
48
|
+
"info",
|
|
49
|
+
"list_problems",
|
|
50
|
+
"stats",
|
|
51
|
+
# models
|
|
52
|
+
"Problem",
|
|
53
|
+
"Result",
|
|
54
|
+
# exceptions
|
|
55
|
+
"PyDSAError",
|
|
56
|
+
"ProblemNotFoundError",
|
|
57
|
+
"AmbiguousQueryError",
|
|
58
|
+
"InvalidInputError",
|
|
59
|
+
"SolverError",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
# ── Core API ──────────────────────────────────────────────────────────────────
|
|
64
|
+
|
|
65
|
+
def solve(query: str | int, /, *args: Any, **kwargs: Any) -> Result:
|
|
66
|
+
"""
|
|
67
|
+
Find and execute the best-matching algorithm for the given query.
|
|
68
|
+
|
|
69
|
+
Parameters
|
|
70
|
+
----------
|
|
71
|
+
query : str | int
|
|
72
|
+
A natural-language description, problem name, alias, tag, slug,
|
|
73
|
+
or integer LeetCode problem id.
|
|
74
|
+
*args :
|
|
75
|
+
Input arguments forwarded directly to the solver function.
|
|
76
|
+
**kwargs :
|
|
77
|
+
Keyword arguments forwarded directly to the solver function.
|
|
78
|
+
|
|
79
|
+
Returns
|
|
80
|
+
-------
|
|
81
|
+
Result
|
|
82
|
+
Structured output with .answer, .time_complexity, .space_complexity,
|
|
83
|
+
.difficulty, .tags, .description.
|
|
84
|
+
|
|
85
|
+
Raises
|
|
86
|
+
------
|
|
87
|
+
ProblemNotFoundError
|
|
88
|
+
Query matched no known problem.
|
|
89
|
+
AmbiguousQueryError
|
|
90
|
+
Query matched multiple problems at similar confidence.
|
|
91
|
+
InvalidInputError
|
|
92
|
+
Input arguments are wrong for the matched solver.
|
|
93
|
+
SolverError
|
|
94
|
+
The solver raised an unexpected internal exception.
|
|
95
|
+
|
|
96
|
+
Examples
|
|
97
|
+
--------
|
|
98
|
+
>>> solve("two sum", [2, 7, 11, 15], 9)
|
|
99
|
+
Result(problem='Two Sum', answer=[0, 1], ...)
|
|
100
|
+
|
|
101
|
+
>>> solve(11, [1,8,6,2,5,4,8,3,7])
|
|
102
|
+
Result(problem='Container With Most Water', answer=49, ...)
|
|
103
|
+
|
|
104
|
+
>>> solve("rearrange array by sign", [3, 1, -2, -5, 2, -4])
|
|
105
|
+
Result(problem='Rearrange Array Elements by Sign', answer=[3,-2,1,-5,2,-4], ...)
|
|
106
|
+
"""
|
|
107
|
+
trace_flag = kwargs.pop("trace", False)
|
|
108
|
+
problem = find(query)
|
|
109
|
+
result = execute(problem, args, kwargs, trace=trace_flag)
|
|
110
|
+
result.match_score = 1.0 # exact or high-confidence fuzzy
|
|
111
|
+
return result
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def search(query: str, limit: int = 10) -> list[Problem]:
|
|
115
|
+
"""
|
|
116
|
+
Return up to `limit` problems matching the query, sorted by relevance.
|
|
117
|
+
|
|
118
|
+
Unlike ``solve()``, this never raises — returns [] if nothing matches.
|
|
119
|
+
Useful for autocomplete, exploration, and building UIs on top of pydsa.
|
|
120
|
+
|
|
121
|
+
Examples
|
|
122
|
+
--------
|
|
123
|
+
>>> results = search("sliding window")
|
|
124
|
+
>>> for p in results:
|
|
125
|
+
... print(p.id, p.name, p.difficulty)
|
|
126
|
+
"""
|
|
127
|
+
return _search(query, limit=limit)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def info(query: str | int) -> Problem:
|
|
131
|
+
"""
|
|
132
|
+
Return the Problem metadata for a query without executing the solver.
|
|
133
|
+
|
|
134
|
+
Examples
|
|
135
|
+
--------
|
|
136
|
+
>>> p = info("two sum")
|
|
137
|
+
>>> print(p.time_complexity) # O(n)
|
|
138
|
+
>>> print(p.tags) # ['hash_map', 'array']
|
|
139
|
+
"""
|
|
140
|
+
return find(query)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def list_problems(
|
|
144
|
+
category: str | None = None,
|
|
145
|
+
difficulty: str | None = None,
|
|
146
|
+
tag: str | None = None,
|
|
147
|
+
) -> list[Problem]:
|
|
148
|
+
"""
|
|
149
|
+
List all registered problems with optional filters.
|
|
150
|
+
|
|
151
|
+
Parameters
|
|
152
|
+
----------
|
|
153
|
+
category : filter by category (e.g. "arrays", "dp")
|
|
154
|
+
difficulty : filter by difficulty ("easy", "medium", "hard")
|
|
155
|
+
tag : filter by tag (e.g. "two_pointer", "bfs")
|
|
156
|
+
|
|
157
|
+
Examples
|
|
158
|
+
--------
|
|
159
|
+
>>> easy_dp = list_problems(category="dp", difficulty="easy")
|
|
160
|
+
"""
|
|
161
|
+
problems = _registry.all_problems()
|
|
162
|
+
if category:
|
|
163
|
+
problems = [p for p in problems if p.category == category.lower()]
|
|
164
|
+
if difficulty:
|
|
165
|
+
problems = [p for p in problems if p.difficulty == difficulty.lower()]
|
|
166
|
+
if tag:
|
|
167
|
+
t = tag.lower()
|
|
168
|
+
problems = [p for p in problems if t in p.tags]
|
|
169
|
+
return problems
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def stats() -> dict:
|
|
173
|
+
"""
|
|
174
|
+
Return a summary of the registry.
|
|
175
|
+
|
|
176
|
+
Examples
|
|
177
|
+
--------
|
|
178
|
+
>>> import pydsa
|
|
179
|
+
>>> pydsa.stats()
|
|
180
|
+
{'total': 3944, 'categories': {'arrays': 812, ...}, 'difficulty': {...}}
|
|
181
|
+
"""
|
|
182
|
+
return _registry.stats()
|
pydsa/__main__.py
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
import ast
|
|
4
|
+
import inspect
|
|
5
|
+
from rich.console import Console
|
|
6
|
+
from rich.syntax import Syntax
|
|
7
|
+
from rich.table import Table
|
|
8
|
+
from rich.panel import Panel
|
|
9
|
+
from rich import box
|
|
10
|
+
|
|
11
|
+
# Import the core engine you built
|
|
12
|
+
from pydsa import solve as _solve, search as _search, info as _info
|
|
13
|
+
from pydsa.core.exceptions import PyDSAError
|
|
14
|
+
|
|
15
|
+
def copy_to_clipboard(text: str):
|
|
16
|
+
"""Safely attempts to copy text to the system clipboard."""
|
|
17
|
+
try:
|
|
18
|
+
import pyperclip
|
|
19
|
+
pyperclip.copy(text)
|
|
20
|
+
console.print("[bold green]✓ Source code copied to clipboard![/bold green]\n")
|
|
21
|
+
except ImportError:
|
|
22
|
+
console.print("[yellow]💡 Tip: Run 'pip install pyperclip' to enable the --copy flag.[/yellow]\n")
|
|
23
|
+
except Exception as e:
|
|
24
|
+
console.print(f"[red]Failed to copy to clipboard: {e}[/red]\n")
|
|
25
|
+
|
|
26
|
+
# Initialize the Rich console for UI rendering
|
|
27
|
+
console = Console()
|
|
28
|
+
|
|
29
|
+
def get_difficulty_color(diff: str) -> str:
|
|
30
|
+
"""Helper to color-code LeetCode difficulties."""
|
|
31
|
+
d = diff.lower()
|
|
32
|
+
if d == "easy": return "[bold green]Easy[/bold green]"
|
|
33
|
+
if d == "medium": return "[bold yellow]Medium[/bold yellow]"
|
|
34
|
+
if d == "hard": return "[bold red]Hard[/bold red]"
|
|
35
|
+
return diff
|
|
36
|
+
|
|
37
|
+
def parse_cli_args(cli_args: list[str]) -> list:
|
|
38
|
+
"""Safely converts string inputs like '[1,2,3]' into actual Python lists."""
|
|
39
|
+
parsed = []
|
|
40
|
+
for arg in cli_args:
|
|
41
|
+
try:
|
|
42
|
+
parsed.append(ast.literal_eval(arg))
|
|
43
|
+
except (ValueError, SyntaxError):
|
|
44
|
+
parsed.append(arg) # Keep as string if it's not a list/dict/number
|
|
45
|
+
return parsed
|
|
46
|
+
|
|
47
|
+
def run_solve(args):
|
|
48
|
+
parsed_inputs = parse_cli_args(args.inputs)
|
|
49
|
+
|
|
50
|
+
# --- NEW LOGIC: Bypass execution if no inputs are provided ---
|
|
51
|
+
if not parsed_inputs:
|
|
52
|
+
if not args.show_code and not args.copy:
|
|
53
|
+
console.print("\n[bold red]Error:[/bold red] You must provide inputs to execute the algorithm, OR use [yellow]--show-code[/yellow] to view the source code.\n")
|
|
54
|
+
return
|
|
55
|
+
|
|
56
|
+
# Use the AI search to route the query to the best problem without executing it
|
|
57
|
+
with console.status(f"[bold cyan]Routing query '{args.query}'...", spinner="dots"):
|
|
58
|
+
problems = _search(args.query, limit=1)
|
|
59
|
+
|
|
60
|
+
if not problems:
|
|
61
|
+
console.print(f"\n[bold red]X[/bold red] No problems found matching '[yellow]{args.query}[/yellow]'.\n")
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
problem_obj = problems[0]
|
|
65
|
+
|
|
66
|
+
# Print Header & Code, then exit early!
|
|
67
|
+
console.print()
|
|
68
|
+
console.print(Panel(f"[bold white]{problem_obj.name}[/bold white] [dim]({problem_obj.category})[/dim]", expand=False, border_style="cyan"))
|
|
69
|
+
|
|
70
|
+
source_code = inspect.getsource(problem_obj.solver)
|
|
71
|
+
|
|
72
|
+
#COPY THE SOURCE CODE TO CLIPBOARD IF THE FLAG IS SET
|
|
73
|
+
if args.copy:
|
|
74
|
+
copy_to_clipboard(source_code)
|
|
75
|
+
if not args.show_code:
|
|
76
|
+
return
|
|
77
|
+
console.print()
|
|
78
|
+
console.print(Panel(f"[bold white]{problem_obj.name}[/bold white] [dim]({problem_obj.category})[/dim]", expand=False, border_style="cyan"))
|
|
79
|
+
|
|
80
|
+
syntax = Syntax(source_code, "python", theme="monokai", line_numbers=True)
|
|
81
|
+
|
|
82
|
+
console.print()
|
|
83
|
+
console.print(Panel(syntax, title=f"[bold green]Source Code: {problem_obj.name}[/bold green]", border_style="green", expand=False))
|
|
84
|
+
console.print()
|
|
85
|
+
return
|
|
86
|
+
# --- END NEW LOGIC ---
|
|
87
|
+
|
|
88
|
+
# The loading spinner! (Original execution logic resumes here)
|
|
89
|
+
with console.status(f"[bold cyan]Routing query '{args.query}' to the AI Brain...", spinner="dots"):
|
|
90
|
+
result = _solve(args.query, *parsed_inputs, trace=args.trace)
|
|
91
|
+
|
|
92
|
+
# 1. The Header Panel
|
|
93
|
+
console.print()
|
|
94
|
+
console.print(Panel(
|
|
95
|
+
f"[bold white]{result.problem}[/bold white] [dim]({result.category})[/dim]",
|
|
96
|
+
expand=False,
|
|
97
|
+
border_style="cyan"
|
|
98
|
+
))
|
|
99
|
+
|
|
100
|
+
# 2. The Complexity Table
|
|
101
|
+
table = Table(box=box.SIMPLE, show_header=False)
|
|
102
|
+
table.add_column("Metric", style="bold dim")
|
|
103
|
+
table.add_column("Value")
|
|
104
|
+
table.add_row("Difficulty", get_difficulty_color(result.difficulty))
|
|
105
|
+
table.add_row("Time Complexity", f"[magenta]{result.time_complexity}[/magenta]")
|
|
106
|
+
table.add_row("Space Complexity", f"[blue]{result.space_complexity}[/blue]")
|
|
107
|
+
console.print(table)
|
|
108
|
+
|
|
109
|
+
# 3. The Output Answer
|
|
110
|
+
console.print("[bold yellow]Result:[/bold yellow]")
|
|
111
|
+
console.print(result.answer)
|
|
112
|
+
|
|
113
|
+
# 4. (Optional) The Source Code Viewer
|
|
114
|
+
if args.show_code or args.copy:
|
|
115
|
+
# 1. Fetch the full Problem object using the exact name returned by the result
|
|
116
|
+
problem_obj = _info(result.problem)
|
|
117
|
+
|
|
118
|
+
# 2. Extract the raw source code of the function in memory
|
|
119
|
+
source_code = inspect.getsource(problem_obj.solver)
|
|
120
|
+
|
|
121
|
+
# --- ADD COPY LOGIC HERE ---
|
|
122
|
+
if args.copy:
|
|
123
|
+
copy_to_clipboard(source_code)
|
|
124
|
+
|
|
125
|
+
if args.show_code:
|
|
126
|
+
# 3. Render it beautifully with syntax highlighting
|
|
127
|
+
syntax = Syntax(source_code, "python", theme="monokai", line_numbers=True)
|
|
128
|
+
|
|
129
|
+
console.print()
|
|
130
|
+
console.print(Panel(
|
|
131
|
+
syntax,
|
|
132
|
+
title=f"[bold green]Source Code: {result.problem}[/bold green]",
|
|
133
|
+
border_style="green",
|
|
134
|
+
expand=False
|
|
135
|
+
))
|
|
136
|
+
console.print()
|
|
137
|
+
|
|
138
|
+
# 5. The Execution Trace
|
|
139
|
+
if args.trace and result.trace_history:
|
|
140
|
+
console.print(f"\n[bold magenta]🔍 Algorithm Execution Trace (First {len(result.trace_history)} steps)[/bold magenta]")
|
|
141
|
+
|
|
142
|
+
trace_table = Table(box=box.MINIMAL_DOUBLE_HEAD, show_lines=True)
|
|
143
|
+
trace_table.add_column("Step", justify="center", style="dim")
|
|
144
|
+
trace_table.add_column("Line No.", justify="center", style="cyan")
|
|
145
|
+
trace_table.add_column("Local Variables State", style="green")
|
|
146
|
+
|
|
147
|
+
for step, (line_no, variables) in enumerate(result.trace_history):
|
|
148
|
+
# Format the dictionary into a nice string: "i: 0 | target: 9 | map: {}"
|
|
149
|
+
var_str = "\n".join([f"[bold white]{k}[/bold white]: {v}" for k, v in variables.items()])
|
|
150
|
+
trace_table.add_row(str(step + 1), str(line_no), var_str)
|
|
151
|
+
|
|
152
|
+
console.print(trace_table)
|
|
153
|
+
console.print()
|
|
154
|
+
|
|
155
|
+
def run_search(args):
|
|
156
|
+
with console.status(f"[bold cyan]Searching registry for '{args.query}'...", spinner="dots"):
|
|
157
|
+
problems = _search(args.query, limit=args.limit)
|
|
158
|
+
|
|
159
|
+
if not problems:
|
|
160
|
+
console.print(f"\n[bold red]X[/bold red] No problems found matching '[yellow]{args.query}[/yellow]'.\n")
|
|
161
|
+
return
|
|
162
|
+
|
|
163
|
+
# Build the Search Results Table
|
|
164
|
+
table = Table(title=f"Search Results for '{args.query}'", box=box.ROUNDED, border_style="dim")
|
|
165
|
+
table.add_column("ID", justify="right", style="cyan", no_wrap=True)
|
|
166
|
+
table.add_column("Problem Name", style="bold white")
|
|
167
|
+
table.add_column("Difficulty")
|
|
168
|
+
table.add_column("Tags", style="dim")
|
|
169
|
+
|
|
170
|
+
for p in problems:
|
|
171
|
+
tags = ", ".join(p.tags[:3]) + ("..." if len(p.tags) > 3 else "")
|
|
172
|
+
table.add_row(str(p.id), p.name, get_difficulty_color(p.difficulty), tags)
|
|
173
|
+
|
|
174
|
+
console.print()
|
|
175
|
+
console.print(table)
|
|
176
|
+
console.print()
|
|
177
|
+
|
|
178
|
+
def main():
|
|
179
|
+
parser = argparse.ArgumentParser(prog="pydsa", description="A semantic DSA execution engine.")
|
|
180
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
181
|
+
|
|
182
|
+
# CLI Command: solve
|
|
183
|
+
solve_parser = subparsers.add_parser("solve", help="Solve a problem by description or ID")
|
|
184
|
+
solve_parser.add_argument("query", help="Natural language description or problem ID")
|
|
185
|
+
solve_parser.add_argument("inputs", nargs="*", help="The inputs to pass to the algorithm")
|
|
186
|
+
solve_parser.add_argument("--show-code", action="store_true", help="Display the Python source code of the solver")
|
|
187
|
+
solve_parser.add_argument("--copy", action="store_true", help="Copy the source code directly to your clipboard")
|
|
188
|
+
solve_parser.add_argument("--trace", action="store_true", help="Visualize variable state step-by-step")
|
|
189
|
+
|
|
190
|
+
# CLI Command: search
|
|
191
|
+
search_parser = subparsers.add_parser("search", help="Browse the algorithm registry")
|
|
192
|
+
search_parser.add_argument("query", help="Topic, tag, or keyword")
|
|
193
|
+
search_parser.add_argument("--limit", type=int, default=10, help="Max results to show")
|
|
194
|
+
|
|
195
|
+
# CLI Command: serve
|
|
196
|
+
serve_parser = subparsers.add_parser("serve", help="Start the FastAPI REST server")
|
|
197
|
+
serve_parser.add_argument("--port", type=int, default=8000, help="Port to run the server on")
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
args = parser.parse_args()
|
|
201
|
+
|
|
202
|
+
try:
|
|
203
|
+
if args.command == "solve":
|
|
204
|
+
run_solve(args)
|
|
205
|
+
elif args.command == "search":
|
|
206
|
+
run_search(args)
|
|
207
|
+
elif args.command == "serve":
|
|
208
|
+
# Start the web server!
|
|
209
|
+
import uvicorn
|
|
210
|
+
console.print(f"[bold green]Starting PyDSA API Server on http://127.0.0.1:{args.port}[/bold green]")
|
|
211
|
+
uvicorn.run("pydsa.api.server:app", host="127.0.0.1", port=args.port, reload=False)
|
|
212
|
+
|
|
213
|
+
except PyDSAError as e:
|
|
214
|
+
console.print(f"\n[bold red]Error:[/bold red] {e}\n")
|
|
215
|
+
sys.exit(1)
|
|
216
|
+
|
|
217
|
+
if __name__ == "__main__":
|
|
218
|
+
main()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
METADATA = {
|
|
2
|
+
"id": 717,
|
|
3
|
+
"name": "1-bit and 2-bit Characters",
|
|
4
|
+
"slug": "1_bit_and_2_bit_characters",
|
|
5
|
+
"category": "Algorithms",
|
|
6
|
+
"aliases": ["One Bit and Two Bit Characters"],
|
|
7
|
+
"tags": ["array", "greedy"],
|
|
8
|
+
"difficulty": "easy",
|
|
9
|
+
"time_complexity": "O(n)",
|
|
10
|
+
"space_complexity": "O(1)",
|
|
11
|
+
"description": "Determine whether the final character in a bit sequence is a 1-bit character.",
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def solve(bits: list[int]) -> bool:
|
|
16
|
+
"""Determine if the last character in the bit sequence is a 1-bit character.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
bits: A list of integers (0 or 1) representing the encoded characters.
|
|
20
|
+
The sequence always ends with a 0.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
True if the last character is a 1-bit character, False otherwise.
|
|
24
|
+
|
|
25
|
+
Examples:
|
|
26
|
+
>>> solve([1, 0, 0])
|
|
27
|
+
True
|
|
28
|
+
>>> solve([1, 1, 1, 0])
|
|
29
|
+
False
|
|
30
|
+
"""
|
|
31
|
+
index: int = 0
|
|
32
|
+
last_position: int = len(bits) - 1
|
|
33
|
+
|
|
34
|
+
# Walk through the array, skipping 1 step for '0' and 2 steps for '1'
|
|
35
|
+
while index < last_position:
|
|
36
|
+
if bits[index] == 0:
|
|
37
|
+
index += 1 # 1-bit character
|
|
38
|
+
else:
|
|
39
|
+
index += 2 # 2-bit character
|
|
40
|
+
|
|
41
|
+
# If we land exactly on the last element, it must be a 1-bit character
|
|
42
|
+
return index == last_position
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
METADATA = {
|
|
2
|
+
"id": 454,
|
|
3
|
+
"name": "4Sum II",
|
|
4
|
+
"slug": "4sum-ii",
|
|
5
|
+
"category": "Hash Table",
|
|
6
|
+
"aliases": [],
|
|
7
|
+
"tags": ["hash table", "array"],
|
|
8
|
+
"difficulty": "medium",
|
|
9
|
+
"time_complexity": "O(n^2)",
|
|
10
|
+
"space_complexity": "O(n^2)",
|
|
11
|
+
"description": "Given four integer arrays nums1, nums2, nums3, and nums4, return the number of tuples (i, j, k, l) such that nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0.",
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
def solve(nums1: list[int], nums2: list[int], nums3: list[int], nums4: list[int]) -> int:
|
|
15
|
+
"""
|
|
16
|
+
Calculates the number of tuples (i, j, k, l) such that the sum of elements
|
|
17
|
+
from the four arrays equals zero.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
nums1: First list of integers.
|
|
21
|
+
nums2: Second list of integers.
|
|
22
|
+
nums3: Third list of integers.
|
|
23
|
+
nums4: Fourth list of integers.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
The total count of tuples that sum to zero.
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
>>> solve([1, 2], [-2, -1], [-1, 2], [0, 2])
|
|
30
|
+
2
|
|
31
|
+
>>> solve([0, 1, 2], [-1, -2, -3], [1, 2, 3], [-1, -2, -3])
|
|
32
|
+
0
|
|
33
|
+
"""
|
|
34
|
+
# Map to store the frequency of sums from the first two arrays
|
|
35
|
+
# Key: sum (nums1[i] + nums2[j]), Value: count of occurrences
|
|
36
|
+
sum_counts: dict[int, int] = {}
|
|
37
|
+
|
|
38
|
+
# Step 1: Populate the hash map with all possible sums of pairs from nums1 and nums2
|
|
39
|
+
for val1 in nums1:
|
|
40
|
+
for val2 in nums2:
|
|
41
|
+
current_sum = val1 + val2
|
|
42
|
+
sum_counts[current_sum] = sum_counts.get(current_sum, 0) + 1
|
|
43
|
+
|
|
44
|
+
total_tuples = 0
|
|
45
|
+
|
|
46
|
+
# Step 2: Iterate through all possible sums of pairs from nums3 and nums4
|
|
47
|
+
# If the negative of the current sum exists in our map, it means
|
|
48
|
+
# (val1 + val2) + (val3 + val4) == 0
|
|
49
|
+
for val3 in nums3:
|
|
50
|
+
for val4 in nums4:
|
|
51
|
+
target = -(val3 + val4)
|
|
52
|
+
if target in sum_counts:
|
|
53
|
+
total_tuples += sum_counts[target]
|
|
54
|
+
|
|
55
|
+
return total_tuples
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
METADATA = {
|
|
2
|
+
"id": 3774,
|
|
3
|
+
"name": "Absolute Difference Between Maximum and Minimum K Elements",
|
|
4
|
+
"slug": "absolute-difference-between-maximum-and-minimum-k-elements",
|
|
5
|
+
"category": "Array",
|
|
6
|
+
"aliases": [],
|
|
7
|
+
"tags": ["sorting", "sliding_window"],
|
|
8
|
+
"difficulty": "easy",
|
|
9
|
+
"time_complexity": "O(n log n)",
|
|
10
|
+
"space_complexity": "O(1)",
|
|
11
|
+
"description": "Find the minimum absolute difference between the maximum and minimum elements in any subarray of size k after sorting.",
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
def solve(nums: list[int], k: int) -> int:
|
|
15
|
+
"""
|
|
16
|
+
Finds the minimum absolute difference between the maximum and minimum
|
|
17
|
+
elements in any subset of size k.
|
|
18
|
+
|
|
19
|
+
The problem asks for the minimum difference between the max and min of
|
|
20
|
+
k elements. To minimize this difference, we should pick k elements
|
|
21
|
+
that are closest to each other in value. Sorting the array allows us
|
|
22
|
+
to consider only contiguous windows of size k.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
nums: A list of integers.
|
|
26
|
+
k: The number of elements to select.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
The minimum absolute difference between the maximum and minimum
|
|
30
|
+
elements among any k elements.
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
>>> solve([10, 1, 5, 20, 15], 3)
|
|
34
|
+
5
|
|
35
|
+
>>> solve([1, 2, 3, 4], 2)
|
|
36
|
+
1
|
|
37
|
+
"""
|
|
38
|
+
n = len(nums)
|
|
39
|
+
if k <= 1:
|
|
40
|
+
return 0
|
|
41
|
+
|
|
42
|
+
# Sort the array to bring elements with similar values close to each other
|
|
43
|
+
nums.sort()
|
|
44
|
+
|
|
45
|
+
# Initialize min_diff with a very large value
|
|
46
|
+
min_diff = float('inf')
|
|
47
|
+
|
|
48
|
+
# Use a sliding window of size k.
|
|
49
|
+
# In a sorted array, for any window [i, i + k - 1],
|
|
50
|
+
# the minimum is nums[i] and the maximum is nums[i + k - 1].
|
|
51
|
+
for i in range(n - k + 1):
|
|
52
|
+
current_diff = nums[i + k - 1] - nums[i]
|
|
53
|
+
if current_diff < min_diff:
|
|
54
|
+
min_diff = current_diff
|
|
55
|
+
|
|
56
|
+
return int(min_diff)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
METADATA = {
|
|
2
|
+
"id": 2041,
|
|
3
|
+
"name": "Accepted Candidates From the Interviews",
|
|
4
|
+
"slug": "accepted_candidates_from_the_interviews",
|
|
5
|
+
"category": "array",
|
|
6
|
+
"aliases": [],
|
|
7
|
+
"tags": ["array", "prefix_sum"],
|
|
8
|
+
"difficulty": "easy",
|
|
9
|
+
"time_complexity": "O(n)",
|
|
10
|
+
"space_complexity": "O(1)",
|
|
11
|
+
"description": "Count candidates whose acceptance ratio is strictly greater than all previous candidates.",
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def solve(accepted: list[int], interviews: list[int]) -> int:
|
|
16
|
+
"""Count the number of candidates whose acceptance ratio is strictly greater than any
|
|
17
|
+
candidate before them.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
accepted: List of integers where accepted[i] is the number of accepted offers for
|
|
21
|
+
candidate i.
|
|
22
|
+
interviews: List of integers where interviews[i] is the total number of interviews
|
|
23
|
+
conducted for candidate i. Both lists have the same length.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
The count of candidates whose accepted[i] / interviews[i] ratio is strictly larger
|
|
27
|
+
than the maximum ratio observed among all previous candidates.
|
|
28
|
+
|
|
29
|
+
Examples:
|
|
30
|
+
>>> solve([2, 1, 3, 4], [2, 2, 4, 5])
|
|
31
|
+
3
|
|
32
|
+
>>> solve([1, 2, 3], [1, 2, 3])
|
|
33
|
+
1
|
|
34
|
+
"""
|
|
35
|
+
if not accepted or not interviews or len(accepted) != len(interviews):
|
|
36
|
+
return 0
|
|
37
|
+
|
|
38
|
+
count_of_good_candidates = 0
|
|
39
|
+
max_accepted = 0
|
|
40
|
+
max_interviews = 1 # avoid division by zero; ratio = 0 initially
|
|
41
|
+
|
|
42
|
+
for idx in range(len(accepted)):
|
|
43
|
+
current_accepted = accepted[idx]
|
|
44
|
+
current_interviews = interviews[idx]
|
|
45
|
+
|
|
46
|
+
# Compare fractions without floating point: a/b > c/d <=> a*d > c*b
|
|
47
|
+
if current_accepted * max_interviews > max_accepted * current_interviews:
|
|
48
|
+
count_of_good_candidates += 1
|
|
49
|
+
max_accepted = current_accepted
|
|
50
|
+
max_interviews = current_interviews
|
|
51
|
+
|
|
52
|
+
return count_of_good_candidates
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
METADATA = {
|
|
2
|
+
"id": 2066,
|
|
3
|
+
"name": "Account Balance",
|
|
4
|
+
"slug": "account-balance",
|
|
5
|
+
"category": "Simulation",
|
|
6
|
+
"aliases": [],
|
|
7
|
+
"tags": ["simulation", "array"],
|
|
8
|
+
"difficulty": "easy",
|
|
9
|
+
"time_complexity": "O(n)",
|
|
10
|
+
"space_complexity": "O(1)",
|
|
11
|
+
"description": "Calculate the final account balance by summing all transaction amounts in a list.",
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
def solve(transactions: list[int]) -> int:
|
|
15
|
+
"""
|
|
16
|
+
Calculates the final account balance after a series of transactions.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
transactions: A list of integers representing transaction amounts.
|
|
20
|
+
Positive values are deposits, negative values are withdrawals.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
The final balance after all transactions have been processed.
|
|
24
|
+
|
|
25
|
+
Examples:
|
|
26
|
+
>>> solve([10, -5, 20, -10])
|
|
27
|
+
15
|
|
28
|
+
>>> solve([-5, -5, -5])
|
|
29
|
+
-15
|
|
30
|
+
>>> solve([])
|
|
31
|
+
0
|
|
32
|
+
"""
|
|
33
|
+
current_balance = 0
|
|
34
|
+
|
|
35
|
+
# Iterate through each transaction and update the running total
|
|
36
|
+
for amount in transactions:
|
|
37
|
+
current_balance += amount
|
|
38
|
+
|
|
39
|
+
return current_balance
|