├── README.md ├── algo ├── algo-implementation │ ├── BellManFord.cpp │ ├── BipartiteGraph.cpp │ ├── BridgesInGraph.cpp │ ├── Dinics.java │ ├── FloydWarshal.cpp │ ├── KAHNsAlogTOPOSORTbfs.cpp │ ├── KMPalgo.cpp │ ├── KargersAlgo.cpp │ ├── LCABinaryLifting_O(LogN).cpp │ ├── MPM_max_flow.java │ ├── MaxFlowDFS_Brute_force.cpp │ ├── MaxFlowDFS_Fast.cpp │ ├── MosAlgoSqrtDecomposition.cpp │ ├── TSP_APPROX.cpp │ ├── Zalgorithm.cpp │ ├── detectCycleInDirectedGraph.cpp │ ├── detectCycleInUNDIRECTEDGraph.cpp │ ├── fft_simple.cpp │ ├── huffmanDecodingAlgorithm.cpp │ ├── jarvis_march_convex_hull.cpp │ ├── kadane'salgo.cpp │ ├── kosarajuToFindAllSCC.cpp │ ├── kosarajuToFindNumberOfSCC.cpp │ ├── kruskal.cpp │ ├── manachersAlgoToFindLongestPalindromicSubstr.cpp │ ├── maximum_subarray_sum_range.cpp │ ├── mcoloring_graph.cpp │ ├── mincut_maxflow_using_random_karger.cpp │ ├── rabin_karp_algo.cpp │ ├── simplex_tabular_algo.cpp │ ├── tarjansAlgoToFindSCC.cpp │ └── topoSortDFS.cpp └── practise-problems │ ├── kadene │ ├── flipping_game.cpp │ ├── max_subarray_sum_circular.cpp │ └── max_sum_on_even_positions.cpp │ └── kmp │ └── password.cpp ├── deprecated ├── 1INTERVIEW_PREPERATION │ ├── AMAZON │ │ ├── ARRAYS │ │ │ └── convert_array_into_zig_zag.cpp │ │ ├── DIVIDE_AND_CONQUER │ │ │ └── BINARY_SEARCH │ │ │ │ └── search_in_rotated_array.cpp │ │ ├── Dynamic Programming │ │ │ └── jump_game.cpp │ │ ├── GRAPH │ │ │ ├── course_shedule.cpp │ │ │ ├── detect_cycle_in_directed_graph.cpp │ │ │ └── steps_by_knight.cpp │ │ ├── HASHING │ │ │ ├── largest_subarray_with_0_sum.cpp │ │ │ ├── print_anagrams_together.cpp │ │ │ ├── set_matrix_zeros.cpp │ │ │ └── smallest_window_in_a_string_containing_all_characters_of_other_string.cpp │ │ ├── LINKED_LIST │ │ │ ├── merge_k_sorted_linked_list.cpp │ │ │ ├── remove_zero_sum_sublists.cpp │ │ │ └── rotate_list.cpp │ │ ├── MATH │ │ │ └── missing_number.cpp │ │ ├── PREFIX_SUM │ │ │ └── equibrium_point.cpp │ │ ├── SLIDING_WINDOW │ │ │ └── subarray_with_given_sum.cpp │ │ ├── STACK │ │ │ ├── ASTEROID_COLLISION.cpp │ │ │ ├── NEXT_GREATER_ELEMENT.cpp │ │ │ ├── NEXT_GREATER_ELEMENT_2_STACK_QUEUE.cpp │ │ │ ├── NEXT_GREATER_ELEMENT_BACKWARD_STACK.cpp │ │ │ └── NEXT_GREATER_ELEMENT_i.cpp │ │ ├── STRING │ │ │ ├── NEXT_GREATER_ELEMENT_III.cpp │ │ │ └── ZIG_ZAG_CONVERSION.cpp │ │ ├── TREE │ │ │ ├── BINARY_TREE │ │ │ │ ├── binary_tree_to_dll.cpp │ │ │ │ ├── boundary_order_traversal_of_binary_tree.cpp │ │ │ │ ├── clone_a_binary_tree_with_random_pointers.cpp │ │ │ │ └── is_binary_tree_a_heap.cpp │ │ │ └── BST │ │ │ │ ├── check_for_bst.cpp │ │ │ │ ├── inorder_successor_in_bst.cpp │ │ │ │ ├── remove_bst_keys_outside_given_range.cpp │ │ │ │ └── validate_bst.cpp │ │ ├── binaryTreeToDll.py │ │ └── pythagorian_triple.py │ ├── CODENATION │ │ └── Painters_Partition_problem.cpp │ ├── LEETCODE │ │ └── GOOGLE │ │ │ ├── BIT_MANIPULATION │ │ │ └── finding_unique_binary_string.cpp │ │ │ ├── Dynamic Programming │ │ │ ├── ONES_AND_ZEROS.cpp │ │ │ ├── count_number_of_teams.cpp │ │ │ ├── count_square_submatrices_with_all_ones.cpp │ │ │ ├── counting_bits.cpp │ │ │ ├── longestPalindromicSubstring.cpp │ │ │ ├── longest_increasing_path_in_matrix.cpp │ │ │ ├── longest_valid_paranthesis_(STACK_APPROACH).cpp │ │ │ ├── palindromic_substrings.cpp │ │ │ ├── partition_array_for_maximum_sum.cpp │ │ │ ├── sort_integers_by_their_power_values.cpp │ │ │ ├── unique_paths_ii.cpp │ │ │ ├── word_break.cpp │ │ │ └── word_break2.cpp │ │ │ ├── GREEDY │ │ │ └── SORTING │ │ │ │ └── contains_duplicate_III.cpp │ │ │ ├── Hashing │ │ │ ├── append_k_integers_with_minimal_sum.cpp │ │ │ ├── contains_duplicate.cpp │ │ │ ├── find_all_duplicates_in_array.cpp │ │ │ ├── find_all_numbers_disappering_in_an_array.cpp │ │ │ ├── first_missing_positive_number.cpp │ │ │ └── valid_sudoku.py │ │ │ ├── LRU_CACHE.py │ │ │ ├── MATH │ │ │ └── FIND_FIRST_MISSING_NUMBER.cpp │ │ │ ├── PERMUTATION.cpp │ │ │ ├── Tree │ │ │ └── find_elements_in_contaminated_tree.cpp │ │ │ ├── binary_search │ │ │ └── min_eating_speed.cpp │ │ │ ├── find_duplicate_number.cpp │ │ │ ├── graph │ │ │ ├── Articulation │ │ │ │ └── CriticalConnections_in_Network.cpp │ │ │ └── dijkstra │ │ │ │ ├── network_delay_time.cpp │ │ │ │ └── shortest_path_in_binary_matrix.cpp │ │ │ ├── minimum_falling_path_sum.cpp │ │ │ ├── prefix_suffix │ │ │ └── string │ │ │ │ └── numSplits.cpp │ │ │ ├── random_pick_index.cpp │ │ │ ├── search_in_2d_matrix_ii.cpp │ │ │ ├── sort_list_insertion_sort.cpp │ │ │ └── sort_list_merge_sort.cpp │ ├── MICROSOFT │ │ └── MEDIUM │ │ │ ├── add_binary_numbers.cpp │ │ │ ├── first_missing_positive.cpp │ │ │ ├── kth_last_node_of_linked_list.cpp │ │ │ ├── number_of_islands.cpp │ │ │ ├── sentence_reversal.cpp │ │ │ └── subtree.cpp │ ├── STRIVER_SDE_SHEET │ │ └── ARRAYS │ │ │ ├── best_time_to_buy_sell_stocks.cpp │ │ │ ├── count_inversions.cpp │ │ │ ├── find_the_duplicate_number.cpp │ │ │ ├── maximum_subarray_sum_KADENE.cpp │ │ │ ├── merge_intervals.cpp │ │ │ ├── merge_sorted_arrays.cpp │ │ │ ├── merge_sorted_arrays_(CONSTANT_SPACE).cpp │ │ │ ├── next_permutation.cpp │ │ │ ├── pascal.cpp │ │ │ ├── pascal_leetcode.cpp │ │ │ ├── repeat_and_missing_number.cpp │ │ │ ├── rotate_image.cpp │ │ │ └── sort_colors.cpp │ └── TOPIC_WISE │ │ └── HEAP │ │ └── maximum_score_from_removing_stones.cpp ├── Algorithms implementation │ ├── BellManFord.cpp │ ├── BipartiteGraph.cpp │ ├── BridgesInGraph.cpp │ ├── Dinics.java │ ├── FloydWarshal.cpp │ ├── KAHNsAlogTOPOSORTbfs.cpp │ ├── KMPalgo.cpp │ ├── KargersAlgo.cpp │ ├── LCABinaryLifting_O(LogN).cpp │ ├── MPM_max_flow.java │ ├── MaxFlowDFS_Brute_force.cpp │ ├── MaxFlowDFS_Fast.cpp │ ├── MosAlgoSqrtDecomposition.cpp │ ├── TSP_APPROX.cpp │ ├── Zalgorithm.cpp │ ├── detectCycleInDirectedGraph.cpp │ ├── detectCycleInUNDIRECTEDGraph.cpp │ ├── fft_simple.cpp │ ├── jarvis_march_convex_hull.cpp │ ├── kadane'salgo.cpp │ ├── kosarajuToFindAllSCC.cpp │ ├── kosarajuToFindNumberOfSCC.cpp │ ├── kruskal.cpp │ ├── manachersAlgoToFindLongestPalindromicSubstr.cpp │ ├── mcoloring_graph.cpp │ ├── mincut_maxflow_using_random_karger.cpp │ ├── rabin_karp_algo.cpp │ ├── simplex_tabular_algo.cpp │ ├── tarjansAlgoToFindSCC.cpp │ └── topoSortDFS.cpp ├── C++-tricks │ ├── for-each-iteration.cpp │ └── handling-pointers.cpp ├── DSA_JAVA │ ├── GRAPH │ │ └── readme.md │ └── readme.md ├── PYTHON_MODULES │ ├── IO │ │ └── ip.py │ ├── advance_ds │ │ ├── bitwiseOrSegTree.py │ │ ├── disjointSet.py │ │ ├── fenwickTree.py │ │ └── rangeSumSegmentTree.py │ ├── algo │ │ ├── dijkstra.py │ │ ├── kruskal.py │ │ └── prims.py │ ├── math │ │ ├── catalan.py │ │ ├── ncr.py │ │ └── primeModule │ │ │ └── isPrimeSimple.py │ └── template │ │ └── basic.py ├── Roadmap │ ├── 16471439270966898721512438247614.jpg │ └── readme.md ├── STL │ ├── readme.md │ └── vector │ │ ├── append_vector.cpp │ │ ├── initializingVectorMatrix.cpp │ │ ├── nested_vector_init_method.cpp │ │ ├── subVector.cpp │ │ └── vector_initialization_with_constant_space.cpp ├── TLE │ ├── longest_increasing_subsequence_2.cpp │ └── serga_and_brackets.cpp ├── WORKSPACE │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ ├── E.cpp │ ├── F.cpp │ ├── G.cpp │ ├── om.cpp │ └── readme.md ├── advancedDataStructureImplementation │ ├── MosAlgoSqrtDecomposition.cpp │ ├── Or-XorSegmentTree.cpp │ ├── Trie.cpp │ ├── centroid_decomposition.cpp │ ├── disjointSet.cpp │ ├── fenwickTree.cpp │ ├── segmentTree.cpp │ ├── sparseTable.cpp │ └── sqrtDecomposition.cpp ├── algo_topics │ ├── kadene │ │ └── flipping_game.cpp │ └── kmp │ │ └── password.cpp ├── compiler │ ├── mingw-get-setup (1).exe │ └── readme.md ├── constantSpaceProblems │ └── frequencyOfLimitedRange.cpp ├── contests │ ├── codechef │ │ ├── dduap0003 │ │ │ ├── balanced_brackets.cpp │ │ │ └── vowels_and_consonants.cpp │ │ ├── dduap0004 │ │ │ ├── abassyal_stones.cpp │ │ │ └── students_heights_iqs.cpp │ │ ├── ddupp0001 │ │ │ ├── chopsticks.cpp │ │ │ ├── max_mex.cpp │ │ │ ├── maximise_the_subsequence.cpp │ │ │ ├── maximum_weight_difference.cpp │ │ │ └── racing_horses.cpp │ │ ├── ddupp0003 │ │ │ ├── BonAppeitit.cpp │ │ │ ├── SnakesMongoosesandtheUltimateElection.cpp │ │ │ ├── evenVsOdd.cpp │ │ │ ├── littleElephantAndMusic.cpp │ │ │ ├── readme.md │ │ │ └── rohanAndSticks.cpp │ │ ├── ddupp0004 │ │ │ ├── billiards.cpp │ │ │ ├── chefAndFrogs.cpp │ │ │ ├── countKprimes.cpp │ │ │ ├── countSubarrays.cpp │ │ │ ├── ipl.cpp │ │ │ └── readme.md │ │ ├── ddupp0005 │ │ │ ├── Gravity_Guy.cpp │ │ │ ├── break_up.cpp │ │ │ ├── chef_and_good_subseq.cpp │ │ │ ├── kfib.cpp │ │ │ ├── lis_digit.cpp │ │ │ └── readme.md │ │ ├── ddupp0007 │ │ │ └── road_decoration.py │ │ ├── infinity_2021_div_2 │ │ │ ├── solved_problems.md │ │ │ └── submissions │ │ │ │ ├── dalgona_treat.cpp │ │ │ │ ├── marbles.cpp │ │ │ │ └── tug_of_war.cpp │ │ └── readme.md │ ├── codeforces │ │ ├── 820_div_3 │ │ │ ├── decode_strings.cpp │ │ │ ├── friends_and_resaurant.cpp │ │ │ ├── jumping_on_tiles.cpp │ │ │ └── two_elevators.cpp │ │ └── codeforces_global_round_18 │ │ │ ├── solved_problems.md │ │ │ └── submissions │ │ │ ├── and_it_is_not_zero.cpp │ │ │ └── closing_the_gap.cpp │ ├── leetcode │ │ └── weekly │ │ │ └── 310 │ │ │ ├── divide_intervals_into_minimum_number_of_groups.cpp │ │ │ ├── most_frequent_even_element.cpp │ │ │ └── optimal_partition_of_a_string.cpp │ └── readme.md ├── cp topics │ ├── back-tracking │ │ ├── hamilton_cycle.cpp │ │ ├── mcoloring_graph.cpp │ │ ├── nQueens.cpp │ │ ├── reachTarget.cpp │ │ └── replaceDigitsPermutations.cpp │ ├── binary search │ │ ├── solved_problems.md │ │ └── submissions │ │ │ ├── Search in rotated array.cpp │ │ │ ├── bear_and_house.py │ │ │ ├── books.cpp │ │ │ ├── chat_ban.cpp │ │ │ ├── distinct_dilemma.py │ │ │ ├── divide_intervals_into_minimum_number_of_groups.cpp │ │ │ ├── find_first_and_last_position_in_array.cpp │ │ │ ├── interesting_drink.py │ │ │ ├── kth_not_divisible_by_n.py │ │ │ ├── mark_and_his_unfinished_array.cpp │ │ │ ├── min_max_array_transformation.cpp │ │ │ ├── minimum_number_of_operations_to_make_array_continuous.cpp │ │ │ ├── minimum_size_subarray_sum.cpp │ │ │ ├── new_year_and_hurry.py │ │ │ ├── number-of-weak-chars-in-game.cpp │ │ │ ├── number_of_pairs.cpp │ │ │ ├── pair_topics.cpp │ │ │ ├── vanya_and_lanterns.py │ │ │ └── worms.cpp │ ├── bit_manip │ │ ├── and_sequences.cpp │ │ ├── array_elimination.cpp │ │ ├── binary_string_xor.py │ │ ├── bitwise_and_of_numbers_range.cpp │ │ ├── box_fitting.cpp │ │ ├── brutal_xors.cpp │ │ ├── cirnos_perfect_bitmask_classroom.cpp │ │ ├── co-growing_subsequence.cpp │ │ ├── concatenation_of_consecutive_binary_numbers.cpp │ │ ├── even_odd_xor.cpp │ │ ├── geek_and_code.cpp │ │ ├── geek_and_function.cpp │ │ ├── geek_and_subset_sum.cpp │ │ ├── good_permutation.py │ │ ├── hammingDistance.py │ │ ├── hammingWeight.py │ │ ├── longest_nice_subarray.cpp │ │ ├── magical_flips.cpp │ │ ├── mainak_and_interesting_sequence.cpp │ │ ├── maximal_and.cpp │ │ ├── non_zero_xor.cpp │ │ ├── or_tuples.cpp │ │ ├── reverseBits.py │ │ └── special_numbers.cpp │ ├── bitmask │ │ ├── solved_problems.md │ │ └── submissions │ │ │ └── and_it_is_not_zero.md │ ├── brute_force │ │ ├── add_to_neighbour_and_remove.cpp │ │ ├── boats_competition.cpp │ │ ├── charmed_by_the_game.cpp │ │ ├── increase_subarray_sums.cpp │ │ ├── minimize_the_thickness.cpp │ │ ├── nastia_and_good_array.cpp │ │ ├── reverse_string.cpp │ │ └── sequence_with_digits.cpp │ ├── constructive │ │ ├── divine_array.cpp │ │ ├── madoka_and_childish_pranks.cpp │ │ ├── moderate_modular_mode.cpp │ │ ├── okea.cpp │ │ └── red_versus_blue.cpp │ ├── coordinate_compression │ │ └── enemy_is_weak.cpp │ ├── data structures │ │ └── binary tree │ │ │ ├── solved_problems.md │ │ │ └── submissions │ │ │ └── Shortest Paths in binary Tree.cpp │ ├── disjointSetUnion │ │ ├── blue_red_permutation.cpp │ │ ├── jeopardy_of_dropped_balls.cpp │ │ ├── knighTournament.py │ │ ├── little_alawns_puzzle.cpp │ │ └── mocha_and_diana_easy_version.cpp │ ├── divide_and_conquer │ │ ├── merge_sort │ │ │ └── Maximum_crossing.cpp │ │ ├── solved_problems.md │ │ └── submissions │ │ │ ├── count_range_sum.cpp │ │ │ ├── euron_problem.cpp │ │ │ ├── maximum_subarray_divide_and_conquery.cpp │ │ │ ├── maximum_subarray_linear_approach.cpp │ │ │ ├── search_in_2d_matrix.cpp │ │ │ ├── search_in_2d_matrix_ii.cpp │ │ │ └── super_pow.cpp │ ├── edge_cases │ │ ├── awoos_favourite_problem.cpp │ │ └── dorminant_character.cpp │ ├── fenwickTree │ │ ├── enemy_is_weak.cpp │ │ └── pashmak_and_praminda.cpp │ ├── games │ │ ├── charmed_by_the_game.cpp │ │ └── palindrome_game.cpp │ ├── geometry │ │ ├── color_the_picture.cpp │ │ ├── easy_assembly.cpp │ │ ├── minimum_lines_to_represent_line_chart.cpp │ │ ├── pashmak_and_gardern.cpp │ │ └── point_grid.py │ ├── greedy │ │ ├── solved_problems.md │ │ └── submissions │ │ │ ├── A-B-C_sort.cpp │ │ │ ├── Ceil and Receipt.cpp │ │ │ ├── Subturtle_substring_subtraction.cpp │ │ │ ├── a_perfectly_balanced_string.cpp │ │ │ ├── activitySelection.cpp │ │ │ ├── alternating_subsequence.cpp │ │ │ ├── and_it_is_no_zero.md │ │ │ ├── array_balancing.cpp │ │ │ ├── close_the_gap.md │ │ │ ├── college_life_5.py │ │ │ ├── even_odd_game.cpp │ │ │ ├── fair_elections.cpp │ │ │ ├── find_the_array.cpp │ │ │ ├── find_valid_matrix_given_row_and_column_sums.cpp │ │ │ ├── insert_a_progression.cpp │ │ │ ├── interesting_xor.cpp │ │ │ ├── max_increase_to_keep_city_skyline.cpp │ │ │ ├── maximum_number_of_coins_you_get.cpp │ │ │ ├── maximum_number_of_distinct_element.cpp │ │ │ ├── minimum_add_to_make_paranthesis_valid.cpp │ │ │ ├── mix_the_colors.cpp │ │ │ ├── partitioning_into_minimum_number_of_deci-binary_numbers.cpp │ │ │ ├── phonix_and_beauty.cpp │ │ │ ├── saving_the_city.cpp │ │ │ ├── score_after_flipping_matrix.cpp │ │ │ └── table_decoration.cpp │ ├── implementation │ │ ├── binary_strings_to_subsequences.cpp │ │ ├── busy_robot.cpp │ │ ├── len_and_sum_of_digits.cpp │ │ └── wonderful_coloring_2.cpp │ ├── linear search │ │ ├── solved_problems.md │ │ └── unsolved_problems.md │ ├── math │ │ ├── AP │ │ │ └── optimal_path.cpp │ │ ├── MATRIX_EXPONENTIATION │ │ │ └── easy_tiling.cpp │ │ ├── array_and_operations.cpp │ │ ├── ball_and_boxes.cpp │ │ ├── binomial_coef │ │ │ └── ncr_%_mod.cpp │ │ ├── catalanNumber.cpp │ │ ├── chat_ban.cpp │ │ ├── chewbacca_and_number.cpp │ │ ├── combinatorics │ │ │ ├── and_sequences.cpp │ │ │ ├── ball_in_berland.cpp │ │ │ └── two_round_dances.cpp │ │ ├── delicious_queries.cpp │ │ ├── digit_problems │ │ │ ├── concatenated_sums.cpp │ │ │ ├── decrease_sum_of_digits.cpp │ │ │ └── make_power_of_two.cpp │ │ ├── dungeon.cpp │ │ ├── euler_totient │ │ │ └── basic_euler_totient_&_sieve_problem_example.cpp │ │ ├── even_odd │ │ │ ├── Patchouli's_Magical_Talisman.cpp │ │ │ ├── odd_selection.cpp │ │ │ └── parity_suffle_sorting.cpp │ │ ├── factorial │ │ │ └── drazil_and_factorial.cpp │ │ ├── factorization_lcm_gcd_problems │ │ │ ├── berland_regionals.cpp │ │ │ └── fadi_and_lcm.cpp │ │ ├── game_of_ball_passing.cpp │ │ ├── geometry │ │ │ └── amr_and_pins.cpp │ │ ├── kTh_Smallest_factors.cpp │ │ ├── largestPrimeFactor.cpp │ │ ├── lcm_gcd.cpp │ │ ├── lcm_gcd │ │ │ ├── Playing_with_gcd.java │ │ │ ├── all_are_same.cpp │ │ │ ├── anti-knapsack.cpp │ │ │ ├── array_elimination.cpp │ │ │ ├── divisible_confusion.cpp │ │ │ ├── lcm_challange.cpp │ │ │ ├── mere_array.cpp │ │ │ ├── minimum_number.cpp │ │ │ ├── orac_and_lcm.cpp │ │ │ ├── two_numbers.cpp │ │ │ └── x_magic_pair.cpp │ │ ├── least_prime_factor.cpp │ │ ├── max_buy_apartment.cpp │ │ ├── mean │ │ │ ├── every_thing_every_where_all_but_one.cpp │ │ │ └── mean_and_median.cpp │ │ ├── median │ │ │ ├── mean_and_median.cpp │ │ │ └── nice_matrix.cpp │ │ ├── missing_number.py │ │ ├── moderate_modular_mode.cpp │ │ ├── modulo_arithmetic │ │ │ ├── beautiful_array.cpp │ │ │ ├── continuous_subarray_sum.cpp │ │ │ ├── little_alawns_puzzle.cpp │ │ │ ├── make_equal_with_mod.cpp │ │ │ ├── modular_exponentiation │ │ │ │ └── super_pow.cpp │ │ │ ├── plus_and_multiply.cpp │ │ │ └── readme.md │ │ ├── paprika_and_permutation.cpp │ │ ├── parity │ │ │ └── same_parity_summands.cpp │ │ ├── possible_victory.py │ │ ├── power_of_two │ │ │ └── make_power_of_two.cpp │ │ ├── readme.md │ │ ├── reduce_to_1.cpp │ │ ├── seive_approach │ │ │ └── make_them_equal.cpp │ │ ├── server_trouble.py │ │ ├── sieveOfErasthenes.cpp │ │ ├── sieve_primality_problems │ │ │ ├── T-primes.cpp │ │ │ ├── almost_prime.cpp │ │ │ ├── complex_market_analysis.cpp │ │ │ └── nold_bach.cpp │ │ ├── spreadsheet.cpp │ │ ├── sumOfFactors.cpp │ │ ├── sum_of_substrings.cpp │ │ ├── ternary_xor.cpp │ │ ├── two_buttons.cpp │ │ └── vasya_and_coins.cpp │ ├── moduloArithmetic │ │ ├── division II.cpp │ │ ├── little_alawns_puzzle.cpp │ │ └── modularMultiplicativeInverse.cpp │ ├── observations │ │ ├── cannine_poetry.cpp │ │ ├── corners.cpp │ │ ├── element_extermination.cpp │ │ ├── fighting_tournament.cpp │ │ ├── knapsack.cpp │ │ ├── madoka_and_formal_stmt.cpp │ │ ├── manipulating_history.cpp │ │ ├── nastia_and_good_array.cpp │ │ ├── omkar_and_basketball.cpp │ │ ├── omkar_and_heavenly_tree.cpp │ │ ├── orac_and_lcm.cpp │ │ ├── palindrome_number.cpp │ │ └── rule_of_league.cpp │ ├── palindrome │ │ └── nice_matrix.cpp │ ├── parity │ │ └── take_your_places.cpp │ ├── permutation │ │ ├── build_permutation.cpp │ │ ├── element_extermination.cpp │ │ ├── paprika_and_permutation.cpp │ │ ├── rotation_matching.cpp │ │ └── special_permutation.cpp │ ├── prefix_suffix │ │ ├── array │ │ │ ├── berland_regionals.cpp │ │ │ ├── continuous_subarray_sum.cpp │ │ │ ├── delicious_queries.cpp │ │ │ ├── inflanation.cpp │ │ │ ├── kuriyama_mirayis_stones.cpp │ │ │ ├── line.cpp │ │ │ ├── minimum_operations_to_reduce_x_to_zero.cpp │ │ │ ├── subarray_sum_equals_k.cpp │ │ │ └── swaps.cpp │ │ └── string │ │ │ └── numSplits.cpp │ ├── roadmap.md │ ├── segmentTree │ │ ├── orac_and_lcm.cpp │ │ └── xenia-and-xor-bit.cpp │ ├── simulation │ │ └── average_waiting_time.cpp │ ├── sliding window │ │ ├── solved_problems.md │ │ ├── submissions │ │ │ ├── Longest substring without repeating characters.cpp │ │ │ ├── Substring of Size Three with Distinct Characters.cpp │ │ │ ├── add_to_neighbour_and_remove.cpp │ │ │ ├── binary_mismatch.py │ │ │ ├── longestSubarrayWithAtmost_K_evens.cpp │ │ │ ├── maximum_length_of_repeating_subarray.cpp │ │ │ ├── minimize_distance.cpp │ │ │ ├── ternary_string.cpp │ │ │ └── vasya and string.cpp │ │ └── unsolved_problems.md │ ├── sorting │ │ ├── berland_regionals.cpp │ │ ├── deep_down_below.cpp │ │ ├── exams.cpp │ │ ├── hemose_shopping.cpp │ │ ├── knapsack.cpp │ │ ├── less_or_equal.cpp │ │ ├── mere_array.cpp │ │ ├── minimum_notation.cpp │ │ ├── negative_prefixes.cpp │ │ ├── paprika_and_permutation.cpp │ │ ├── phoenix_and_distribution.cpp │ │ └── young_explorers.cpp │ ├── special │ │ └── fibonacci_words.cpp │ ├── string │ │ ├── binary_string │ │ │ └── one_zero_swaps.py │ │ ├── broken_life.py │ │ ├── largestGoodInteger.cpp │ │ ├── palindrome │ │ │ ├── cannine_poetry.cpp │ │ │ └── palindrome_games.cpp │ │ ├── phoenix_and_distribution.cpp │ │ ├── reverse_string.cpp │ │ ├── reverse_words_in_string_3.cpp │ │ ├── subsequence_hate.cpp │ │ └── unstable_string.cpp │ ├── string_and_pattern_matching │ │ ├── longestCommonPrefix.py │ │ ├── prefix_function │ │ │ └── password.cpp │ │ ├── readme.md │ │ └── searchPatternZalgo.cpp │ └── two_pointer │ │ ├── accurate_lee.cpp │ │ ├── arranging_the_sheep.cpp │ │ ├── array_and_operations.cpp │ │ ├── bag_of_tokens.cpp │ │ ├── bersu_ball.cpp │ │ ├── build_permutation.cpp │ │ ├── longest_nice_subarray.cpp │ │ ├── make_it_good.cpp │ │ ├── sorted_adjacent_differences.cpp │ │ ├── tokitsukaze_and_strange_inequality.cpp │ │ ├── unstable_string.cpp │ │ └── xxxxx.cpp ├── data structure contribution │ ├── ALOGRITHMS │ │ └── huffmanDecodingAlgorithm.cpp │ ├── ARRAY │ │ ├── average_waiting_time.cpp │ │ ├── fin.cpp │ │ ├── findDuplicates_in_array.cpp │ │ ├── findDuplicates_in_array_betterApproach.cpp │ │ ├── global_and_local_inversions.cpp │ │ ├── max_Subarray_Sum_MOST_EFFICIENT_(OPTIMUM).cpp │ │ ├── maximum_points_you_can_obtain.cpp │ │ ├── sum_of_even_numbers_after_queries.cpp │ │ └── topK_frequent_elements.cpp │ ├── GRAPH │ │ ├── CriticalConnections_in_Network.cpp │ │ ├── DFS_BFS_Graph.cpp │ │ ├── cloneGraph.cpp │ │ ├── detection_of_cycle_in_a_graph.cpp │ │ ├── find_Center_Of_Star_Graph.cpp │ │ ├── find_Judge.cpp │ │ ├── find_smallest_set_of_vertices.cpp │ │ ├── is_bipartite.cpp │ │ ├── minimal_travel_time.py │ │ ├── network_delay_time.cpp │ │ └── shortest_path_in_binary_matrix.cpp │ ├── LINKED LIST │ │ ├── MERGE_SORT_SINGLY_LL_LOG_N_TIME___O_1_SPACE_.exe │ │ ├── best ones │ │ │ └── MERGE_SORT_SINGLY_LL_LOG_N_TIME___O_1_SPACE_.cpp │ │ ├── circularly_linked_list.cpp │ │ ├── circularly_linked_list.exe │ │ ├── detection_of_cycle_in_linked_list.cpp │ │ ├── get_random_node_in_a_linked_list.cpp │ │ ├── intersection_point_of_two_linked_list.cpp │ │ ├── introduction.txt │ │ ├── is_Palindrome.cpp │ │ ├── linked_list_CE122_om_soni.c │ │ ├── middle_of_singly_linked_list.cpp │ │ ├── remove_duplicates_from_sorted_LL_1_EASY_INLINEcpp.cpp │ │ ├── remove_duplicates_from_sorted_LL_2.cpp │ │ ├── reorder_linked_list.cpp │ │ ├── reverse_only_some_part_of_linked_list.cpp │ │ ├── reverse_singly_linked_list_recursion.cpp │ │ └── swap_nodes_in_singly_linked_list.cpp │ ├── MATRIX │ │ ├── corners.cpp │ │ ├── count_unguarded_cells_in_array.cpp │ │ ├── madoka_and_childish_pranks.cpp │ │ ├── nice_matrix.cpp │ │ └── same_count_ones.cpp │ ├── QUEUE │ │ └── impletent_Queue_Using_Stacks.cpp │ ├── Recursion │ │ └── generate_Paranthesis.cpp │ ├── STACK │ │ ├── PRACTICE_PROBLEMS_STACK │ │ │ ├── boats_competition.cpp │ │ │ └── longest_valid_paranthesis_(STACK_APPROACH).cpp │ │ ├── impletent_Queue_Using_Stacks.cpp │ │ ├── jatayu_and_bracket_sequence.cpp │ │ └── validateParanthesis.py │ ├── STRING │ │ ├── reverse_words_in_string_3.cpp │ │ └── sortCharacters_by_frequency.cpp │ ├── Sliding Window │ │ ├── containsDuplicate.cpp │ │ └── containsNearByDuplicates.cpp │ ├── TREE │ │ ├── BST │ │ │ ├── CONSTRUCT_BINARY_TREE_FROM_INORDER_AND_PREORDER_TRAVERSAL.cpp │ │ │ ├── LCAofBST.cpp │ │ │ ├── all_elements_in_two_bst.cpp │ │ │ ├── balance_A_BST.cpp │ │ │ ├── bst_to_gst.cpp │ │ │ ├── construct_BST_FROM_preorder.cpp │ │ │ ├── convertBSTtoGREATER_Tree.cpp │ │ │ ├── convertSortedArrayIntoBST.cpp │ │ │ ├── convertSortedArrayToBst.py │ │ │ ├── deleteNodeFromBST.cpp │ │ │ ├── increasingOrderSearchTree.cpp │ │ │ ├── insertNodeInBST.cpp │ │ │ ├── kthSmallestElemIn_BST.cpp │ │ │ ├── minDiffInBST.cpp │ │ │ ├── rangeBasedSumInBST.cpp │ │ │ ├── recoverBST.cpp │ │ │ ├── searchBST.cpp │ │ │ ├── sortedListToBST.cpp │ │ │ ├── trimBST.cpp │ │ │ ├── validateBST.cpp │ │ │ └── validate_bst_O(n).py │ │ ├── CONSTRUCT_BINARY_TREE_FROM_INORDER_AND_PREORDER_TRAVERSAL.cpp │ │ ├── LCA_BinaryTree.cpp │ │ ├── N_ARY │ │ │ └── maxDepthOfN-AryTree.cpp │ │ ├── addOneRowInBinaryTree.cpp │ │ ├── allPathsOfTree.cpp │ │ ├── averageOfLevelsInBinaryTree.cpp │ │ ├── binaryTreeTILT.cpp │ │ ├── binaryTreeToDll.py │ │ ├── binary_tree_maximum_path_sum.cpp │ │ ├── constructBinaryTreeFromInorder_and_Postorder_Traversal.cpp │ │ ├── constructMaximumBinaryTree.cpp │ │ ├── copyTree.cpp │ │ ├── countAlmost_Complete_(complete)_TreeNodes_O(LOG(N)).cpp │ │ ├── count_nodes_equals_average_of_subtree.cpp │ │ ├── cousings_in_binary_tree.cpp │ │ ├── deepestLeavesSum.cpp │ │ ├── deleteInSufficientNodesIn_ROOT_TO_LEAF_Path in binary tree.cpp │ │ ├── diameterOfBinaryTree.cpp │ │ ├── diameterOfBinaryTreeEfficient.cpp │ │ ├── diameterOfBinaryTreeEfficientApproach.cpp │ │ ├── findFrequentSumInTree.cpp │ │ ├── findModeInBinaryTreeTWO.cpp │ │ ├── findTheBottomLeftTreeValueIN_Binary_Tree.cpp │ │ ├── find_corresponding_node_of_binary_tree_in_clone_of_that_tree.cpp │ │ ├── flattenTree.cpp │ │ ├── flipEquivalenTrees.cpp │ │ ├── huffmanDecodingAlgorithm.cpp │ │ ├── largestValueInEachRowOfBinaryTree.cpp │ │ ├── levelOrderTraversal.cpp │ │ ├── linked_list_in_binary_tree.cpp │ │ ├── maxLevelSumInBinaryTree.cpp │ │ ├── maxPathSumInBinaryTree.cpp │ │ ├── mergeTwoTrees.cpp │ │ ├── minDephthOfTree.cpp │ │ ├── path_sum_2.cpp │ │ ├── pathsWithGivenSumInBinaryTree.cpp │ │ ├── populatingNextRightPointersInEachNodeOfBinaryTree.cpp │ │ ├── populatingNextRightPointersInEachNodeOfBinaryTreeBETTER_APPROACH.cpp │ │ ├── recoverTreeFromPreOrderTraversal.cpp │ │ ├── reverseLevelOrderTraversalInBinaryTree.cpp │ │ ├── rightSideViewOfBinaryTree.cpp │ │ ├── sprial_order_traversal.java │ │ ├── subTreeOfAnotherTree.cpp │ │ ├── sumOfLeftLeavesInTree.cpp │ │ ├── tree2str.cpp │ │ ├── treeToLeafPathsWithGivenSumInBinaryTree.cpp │ │ ├── tree_for_cp │ │ │ ├── kefa_and_trees.cpp │ │ │ ├── linova_and_kingdom.cpp │ │ │ ├── omkar_and_heavenly_tree.cpp │ │ │ ├── party.cpp │ │ │ ├── readme.md │ │ │ ├── vertical_paths.cpp │ │ │ ├── white_black_subtrees.cpp │ │ │ └── yet_another_cart_deck_brute_force.cpp │ │ ├── vertical_order_traversal_in_Binary_Tree.cpp │ │ └── zigzagOrderTraversal.cpp │ ├── disjointSet │ │ ├── maximum_no_of_events.cpp │ │ └── readme.md │ ├── dp │ │ ├── best_team_with_no_conflicts.cpp │ │ ├── best_time_to_buy_sell_stocks_IV.cpp │ │ ├── best_time_to_sell_stocks_2_(memo).cpp │ │ ├── binaryTreesWithFactor.java │ │ ├── binary_tree_maximum_path_sum.cpp │ │ ├── canJump-III-MEMO.cpp │ │ ├── climb_Stairs_memo.cpp │ │ ├── climb_Stairs_tabulation.cpp │ │ ├── combination_sum.cpp │ │ ├── concatenation_of_consecutive_binary_numbers.cpp │ │ ├── decode_ways_MEMO.cpp │ │ ├── fibonacci_memo.cpp │ │ ├── fibonacci_tab.cpp │ │ ├── get_Max_Genereated.cpp │ │ ├── lcs.cpp │ │ ├── longest_Increasing_Subsequence.cpp │ │ ├── longest_Increasing_Subsequence_LOG(N) approach.cpp │ │ ├── making_towers.cpp │ │ ├── max_Subarray_Sum.cpp │ │ ├── max_Subarray_Sum_MOST_EFFICIENT_(OPTIMUM).cpp │ │ ├── max_Subarray_Sum_MoreEfficient.cpp │ │ ├── max_Subarray_Sum_MoreEfficient2.cpp │ │ ├── min_Cost_Climbing_Stairs.cpp │ │ ├── min_Path_Sum.cpp │ │ ├── min_Steps_required_To_jump_TAB.cpp │ │ ├── number-of-people-aware-of-a-secret.cpp │ │ ├── pascal_Traingle.cpp │ │ ├── pascal_triangle2_using_map_memo.cpp │ │ ├── readme.md │ │ ├── sending_sequence_over_a_network.cpp │ │ ├── test.cpp │ │ ├── triangle_(minimum_top_to_bottom_SUM)_MEMO.cpp │ │ ├── unique_Paths_With_Obstacles_tab.cpp │ │ └── unique_Paths_tab.cpp │ └── heap │ │ ├── constructing_the_array.cpp │ │ ├── klargetstElems.py │ │ ├── maximum_bags_with_full_capacity_of_rocks.cpp │ │ ├── maximum_product_after_k_increments.cpp │ │ ├── phoneix_and_towers.cpp │ │ ├── potions_hard_version.cpp │ │ ├── productive_meeting.cpp │ │ ├── stdHeapClass.cpp │ │ └── virus.cpp ├── dynamic programming │ ├── 3Fibonacci.cpp │ ├── Boredom.cpp │ ├── Gravity_Game.cpp │ ├── ONES_AND_ZEROS.cpp │ ├── basket_ball_exercise.cpp │ ├── best_team_with_no_conflicts.cpp │ ├── best_time_to_buy_sell_stocks_IV.cpp │ ├── best_time_to_sell_stocks_2_(memo).cpp │ ├── binaryTreesWithFactor.java │ ├── binary_tree_maximum_path_sum.cpp │ ├── canJump-III-MEMO.cpp │ ├── climb_Stairs_memo.cpp │ ├── climb_Stairs_tabulation.cpp │ ├── combination_sum.cpp │ ├── concatenation_of_consecutive_binary_numbers.cpp │ ├── count_number_of_teams.cpp │ ├── decode_ways_MEMO.cpp │ ├── fence.cpp │ ├── fibonacci_memo.cpp │ ├── fibonacci_tab.cpp │ ├── find_the_spruce.cpp │ ├── get_Max_Genereated.cpp │ ├── good_subarrays.cpp │ ├── good_subarrays_easy_version.java │ ├── hasValidPath.cpp │ ├── houseRobber.py │ ├── k-tree.py │ ├── lcs.cpp │ ├── longestPalindromicSubstring.cpp │ ├── longest_Increasing_Subsequence.cpp │ ├── longest_Increasing_Subsequence_LOG(N) approach.cpp │ ├── longest_increasing_path_in_matrix.cpp │ ├── longest_palindromic_subseq.py │ ├── longest_valid_paranthesis_(STACK_APPROACH).cpp │ ├── making_towers.cpp │ ├── max_Subarray_Sum.cpp │ ├── max_Subarray_Sum_MOST_EFFICIENT_(OPTIMUM).cpp │ ├── max_Subarray_Sum_MoreEfficient.cpp │ ├── max_Subarray_Sum_MoreEfficient2.cpp │ ├── min_Cost_Climbing_Stairs.cpp │ ├── min_Path_Sum.cpp │ ├── min_Steps_required_To_jump_TAB.cpp │ ├── number-of-people-aware-of-a-secret.cpp │ ├── palindrome_basis.cpp │ ├── palindromic_substrings.cpp │ ├── partition_array_for_maximum_sum.cpp │ ├── pascal_Traingle.cpp │ ├── pascal_triangle2_using_map_memo.cpp │ ├── perfect_square.cpp │ ├── readme.md │ ├── sending_sequence_over_a_network.cpp │ ├── sort_integers_by_their_power_values.cpp │ ├── test.cpp │ ├── the_Greater_Julya_Calander.cpp │ ├── tokitsukaze_and_strange_inequality.cpp │ ├── total_appeal_of_a_string.cpp │ ├── triangle_(minimum_top_to_bottom_SUM)_MEMO.cpp │ ├── unique_Paths_With_Obstacles_tab.cpp │ ├── unique_Paths_tab.cpp │ ├── vacations.cpp │ ├── word_break.cpp │ └── word_break2.cpp ├── java_modules │ ├── Codechef.java │ ├── Main.java │ ├── com │ │ └── library │ │ │ ├── algo │ │ │ ├── BinarySearch.java │ │ │ └── LIS.java │ │ │ ├── bitmanip │ │ │ └── KerninghanAlgo.java │ │ │ ├── conversion │ │ │ └── Convertor.java │ │ │ ├── customds │ │ │ ├── BitSet.java │ │ │ ├── LangUtil.java │ │ │ ├── MyPair.java │ │ │ ├── Pair.java │ │ │ └── StringUtil.java │ │ │ ├── ds │ │ │ └── graph │ │ │ │ ├── flow │ │ │ │ ├── Dinic.java │ │ │ │ ├── MPM$FlowEdge.class │ │ │ │ ├── MPM.class │ │ │ │ └── MPM.java │ │ │ │ └── lca │ │ │ │ └── LCABinaryLifting.java │ │ │ ├── heavyds │ │ │ ├── DisjointSet.java │ │ │ ├── FenwickTree.java │ │ │ └── segtree │ │ │ │ └── SegmentTree.java │ │ │ ├── io │ │ │ ├── FastScanner.java │ │ │ └── Printer.java │ │ │ └── mathlib │ │ │ ├── ChineseRemainder.java │ │ │ ├── Factorization.java │ │ │ ├── LcmGcd.java │ │ │ ├── Quadratic.java │ │ │ └── moduloarithmetic │ │ │ ├── Modulo.java │ │ │ └── ModuloStatic.java │ └── starter_template │ │ └── Main.java ├── local_machine_stuff │ ├── codeforces │ │ ├── 121 │ │ │ ├── A.cpp │ │ │ ├── A.exe │ │ │ ├── B.cpp │ │ │ ├── C.cpp │ │ │ ├── D.cpp │ │ │ ├── E.cpp │ │ │ ├── F.cpp │ │ │ ├── G.cpp │ │ │ ├── error.txt │ │ │ ├── input.txt │ │ │ └── output.txt │ │ ├── 761 │ │ │ ├── A.cpp │ │ │ ├── A.exe │ │ │ ├── inputf.in │ │ │ └── outputf.in │ │ └── contestTemplet │ │ │ ├── A.cpp │ │ │ ├── B.cpp │ │ │ ├── C.cpp │ │ │ ├── D.cpp │ │ │ └── E.cpp │ └── readme.md ├── math │ ├── AP_GP │ │ └── LOST_ARITHMATIC_PROGRESSION.cpp │ ├── binomial_coef │ │ └── ncr_%_mod.cpp │ ├── chineseRemainderThm.cpp │ ├── eulerTotient │ │ └── basic_euler_totient_&_sieve_example.cpp │ ├── euler_totient.cpp │ ├── findAllFactors.cpp │ ├── game_of_ball_passing.cpp │ ├── gcd_lcm.cpp │ ├── isPrime.cpp │ ├── moduloArithmetic.cpp │ ├── readme.md │ ├── roundOfInPowerOf2.cpp │ └── seive_Erathosthenes.cpp ├── modules │ ├── ADVANCED_DS │ │ ├── FFT │ │ │ └── fft_simple.cpp │ │ ├── Lazy_Segment_Tree │ │ │ └── Lazy_Segment_Tree.cpp │ │ ├── MosAlgoSqrtDecomposition.cpp │ │ ├── Or-XorSegmentTree.cpp │ │ ├── SEGMENT_TREE │ │ │ ├── ADVANCED_SEGMENT_TREE_TEMPLATE_RANGE_MIN_MAX.cpp │ │ │ ├── ALL_IN_ONE_GENERALIZED_SEGMENTTREE_+_GCD_+_LCM.cpp │ │ │ ├── Binary_Segment_Tree.cpp │ │ │ ├── FIND_INDEX_WHOSE_PREFIX_GREATER_THAN_X_SEGMENT_TREE.cpp │ │ │ ├── GCD_LCM_RANGE_SEGMENT_TREE.cpp │ │ │ ├── LAZY_PROPOGATION_ULTIMATE_SEGMENT_TREE.cpp │ │ │ ├── RANGE_MIN_MAX_+_HASHING.cpp │ │ │ ├── TEMPLATE_SEGMENTTREE.cpp │ │ │ ├── UPDATE_RANGE_MIN_MAX_+_HASHING.cpp │ │ │ ├── UPDATE_SEG_INDEX_ADVANCED_TEMPLATE_SEGMENT_TREE.cpp │ │ │ ├── find_kth_zero_pos_update_count_SEGMENT_TREE.cpp │ │ │ └── kth_zero_build_update_count_SEGMENT_TREE.cpp │ │ ├── Trie.cpp │ │ ├── centroid_decomposition.cpp │ │ ├── disjointSet.cpp │ │ ├── fenwickTree.cpp │ │ ├── lazy_segment_propogation_tree.cpp │ │ ├── segmentTree.cpp │ │ ├── sparseTable.cpp │ │ └── sqrtDecomposition.cpp │ ├── AdvancedTricks │ │ ├── CordinateCompression.cpp │ │ └── CountInversions.cpp │ ├── DS │ │ └── Minimum_Stack.cpp │ ├── IO │ │ ├── printingModule.cpp │ │ └── scanningModule.cpp │ ├── LANG_UTILITY │ │ ├── lang_util_oop.cpp │ │ └── transformer_oop.cpp │ ├── LINEAR_PROGRAMMING │ │ └── simlex.cpp │ ├── MACROS │ │ └── macros.cpp │ ├── MATH │ │ ├── BigOperation │ │ │ └── BigAdder.cpp │ │ ├── Calc │ │ │ └── calc_oop.cpp │ │ ├── EulerTotient.cpp │ │ ├── LinearDiophantineEquation.cpp │ │ ├── ModuloArithmetic │ │ │ └── modulo_arithmetic_oop.cpp │ │ ├── Permutation_combination_binomial_coef │ │ │ ├── Factorial_Modulo.cpp │ │ │ ├── NCR_%_mod_Efficiently.cpp │ │ │ └── NCR_binomial_coef.cpp │ │ ├── chineseRemainderThm.cpp │ │ ├── factorization.cpp │ │ ├── fibonacciModule │ │ │ └── fib_In_LOGN_(matrix_exp).cpp │ │ ├── lcm_gcd.cpp │ │ ├── matrixModule │ │ │ ├── matrixExponentiation.cpp │ │ │ ├── matrixMultiply.cpp │ │ │ └── printMatrix.cpp │ │ ├── modularArithmeticModule.cpp │ │ ├── palindrome_numbers │ │ │ ├── isPalindromNumber.cpp │ │ │ ├── palindrom_factors_module.cpp │ │ │ └── palindrome_factors_runtime.cpp │ │ ├── primeModule.cpp │ │ ├── sieve │ │ │ ├── seive_with_lp_and_prime_factorization.cpp │ │ │ └── sieve_simple.cpp │ │ └── typeConversion │ │ │ ├── Convertor.cpp │ │ │ └── stringToInt.cpp │ ├── NP_HARD_APPROX │ │ ├── GraphColoring.cpp │ │ ├── LOAD_BALANCING_APPROAX_GREEDY_+_RANDOM.cpp │ │ ├── METRIC_TSP.cpp │ │ └── VERTEX_COVER_APPROAX_by_2.cpp │ ├── RANDOM_NUMBER │ │ ├── Random_Engine.cpp │ │ └── random_number.cpp │ ├── STRING_&_PATTERN_MATCHING.cpp │ ├── STRING_&_PATTERN_MATCHING │ │ ├── KMP_oop.cpp │ │ ├── KMPalgo.cpp │ │ ├── Zalgorithm.cpp │ │ ├── horsepool.cpp │ │ ├── manachersAlgoToFindLongestPalindromicSubstr.cpp │ │ └── rabin_karp_algo.cpp │ ├── TIME │ │ ├── checkTimeout.cpp │ │ └── longestIncreasingSubseqModule.cpp │ ├── geometry │ │ ├── Convex_hull_jarvis_(2).cpp │ │ ├── Line_intersect.cpp │ │ └── jarvis_march_convex_hull.cpp │ ├── graph_module │ │ ├── LCABinaryLifting_O(LogN).cpp │ │ ├── graph.cpp │ │ ├── heavyLightDecomposition.cpp │ │ └── max_flow │ │ │ ├── Dinics.java │ │ │ └── MPM_max_flow.java │ └── starterTemplete.cpp ├── popularProblems │ ├── LRU_CACHE.py │ ├── activitySelection.cpp │ ├── logestIncreasingSubseq.cpp │ ├── nQueens.cpp │ └── pascalsTriangle.py ├── starterTemplate │ ├── advanceStarterTemplate.cpp │ ├── advanceStarterTemplate2.cpp │ ├── advanceStarterTemplate4.cpp │ ├── advancedStarterTemplate3.cpp │ ├── checkTimeOut.cpp │ ├── hello.cpp │ ├── hello2.cpp │ ├── hello3.cpp │ ├── hello4.cpp │ ├── hello5_advanced.cpp │ ├── hello6_advanced.cpp │ ├── namespaced1.cpp │ ├── oop_starter.cpp │ ├── premium_starter_template.cpp │ ├── printingModules.cpp │ ├── read_pair_template.cpp │ ├── scanningModules.cpp │ ├── segStarter.cpp │ ├── segStarter2.cpp │ └── starter.cpp ├── test.cpp ├── upsolved_all │ ├── cf_790.PNG │ └── readme.md └── vim │ ├── hello.cpp │ └── readme.md ├── modules ├── atcoder_library │ ├── atcoder │ │ ├── LICENSE │ │ ├── all │ │ ├── convolution │ │ ├── convolution.hpp │ │ ├── dsu │ │ ├── dsu.hpp │ │ ├── fenwicktree │ │ ├── fenwicktree.hpp │ │ ├── internal_bit │ │ ├── internal_bit.hpp │ │ ├── internal_math │ │ ├── internal_math.hpp │ │ ├── internal_queue │ │ ├── internal_queue.hpp │ │ ├── internal_scc │ │ ├── internal_scc.hpp │ │ ├── internal_type_traits │ │ ├── internal_type_traits.hpp │ │ ├── lazysegtree │ │ ├── lazysegtree.hpp │ │ ├── math │ │ ├── math.hpp │ │ ├── maxflow │ │ ├── maxflow.hpp │ │ ├── mincostflow │ │ ├── mincostflow.hpp │ │ ├── modint │ │ ├── modint.hpp │ │ ├── scc │ │ ├── scc.hpp │ │ ├── segtree │ │ ├── segtree.hpp │ │ ├── string │ │ ├── string.hpp │ │ ├── twosat │ │ └── twosat.hpp │ ├── document_en │ │ ├── appendix.html │ │ ├── convolution.html │ │ ├── dsu.html │ │ ├── fenwicktree.html │ │ ├── index.html │ │ ├── lazysegtree.html │ │ ├── math.html │ │ ├── maxflow.html │ │ ├── mincostflow.html │ │ ├── modint.html │ │ ├── scc.html │ │ ├── segtree.html │ │ ├── string.html │ │ └── twosat.html │ ├── document_ja │ │ ├── appendix.html │ │ ├── convolution.html │ │ ├── dsu.html │ │ ├── fenwicktree.html │ │ ├── index.html │ │ ├── lazysegtree.html │ │ ├── math.html │ │ ├── maxflow.html │ │ ├── mincostflow.html │ │ ├── modint.html │ │ ├── scc.html │ │ ├── segtree.html │ │ ├── string.html │ │ └── twosat.html │ └── expander.py ├── cpp-modules │ ├── DS │ │ └── Minimum_Stack.cpp │ ├── INTERACTIVE_JUDGE │ │ └── InteractiveJudge.cpp │ ├── IO │ │ ├── printingModule.cpp │ │ └── scanningModule.cpp │ ├── LANG_UTILITY │ │ ├── lang_util_oop.cpp │ │ └── transformer_oop.cpp │ ├── LINEAR_PROGRAMMING │ │ └── simlex.cpp │ ├── MACROS │ │ └── macros.cpp │ ├── MATH │ │ ├── BigOperation │ │ │ └── BigAdder.cpp │ │ ├── Calc │ │ │ └── calc_oop.cpp │ │ ├── EulerTotient.cpp │ │ ├── LinearDiophantineEquation.cpp │ │ ├── ModuloArithmetic │ │ │ ├── modulo_arithmetic_oop.cpp │ │ │ └── namespace_mod_arithmatic.cpp │ │ ├── Permutation_combination_binomial_coef │ │ │ ├── Factorial_Modulo.cpp │ │ │ ├── NCR_%_mod_Efficiently.cpp │ │ │ └── NCR_binomial_coef.cpp │ │ ├── chineseRemainderThm.cpp │ │ ├── factorization.cpp │ │ ├── fibonacciModule │ │ │ └── fib_In_LOGN_(matrix_exp).cpp │ │ ├── kthRoot.cpp │ │ ├── lcm_gcd.cpp │ │ ├── matrixModule │ │ │ ├── matrixExponentiation.cpp │ │ │ ├── matrixMultiply.cpp │ │ │ └── printMatrix.cpp │ │ ├── modularArithmeticModule.cpp │ │ ├── palindrome_numbers │ │ │ ├── isPalindromNumber.cpp │ │ │ ├── palindrom_factors_module.cpp │ │ │ └── palindrome_factors_runtime.cpp │ │ ├── primeModule.cpp │ │ ├── sieve │ │ │ ├── seive_with_lp_and_prime_factorization.cpp │ │ │ └── sieve_simple.cpp │ │ └── typeConversion │ │ │ ├── Convertor.cpp │ │ │ └── stringToInt.cpp │ ├── NP_HARD_APPROX │ │ ├── GraphColoring.cpp │ │ ├── LOAD_BALANCING_APPROAX_GREEDY_+_RANDOM.cpp │ │ ├── METRIC_TSP.cpp │ │ └── VERTEX_COVER_APPROAX_by_2.cpp │ ├── RANDOM_NUMBER │ │ ├── Random_Engine.cpp │ │ └── random_number.cpp │ ├── STL_Util │ │ └── STLUtilNamespace.cpp │ ├── STRING_&_PATTERN_MATCHING.cpp │ ├── STRING_&_PATTERN_MATCHING │ │ ├── KMP_oop.cpp │ │ ├── KMPalgo.cpp │ │ ├── Rolling_Hash.cpp │ │ ├── Zalgorithm.cpp │ │ ├── horsepool.cpp │ │ ├── kmp_on_vector.cpp │ │ ├── manachersAlgoToFindLongestPalindromicSubstr.cpp │ │ └── rabin_karp_algo.cpp │ ├── TIME │ │ ├── checkTimeout.cpp │ │ └── longestIncreasingSubseqModule.cpp │ ├── advanced_data_structures │ │ ├── FFT │ │ │ └── fft_simple.cpp │ │ ├── MERGE_SORT_TREE │ │ │ ├── MergeSortSumTree.cpp │ │ │ ├── MergeSortTreeGT.cpp │ │ │ └── merge_sort_tree.cpp │ │ ├── MosAlgoSqrtDecomposition.cpp │ │ ├── Or-XorSegmentTree.cpp │ │ ├── Rolling_Median.cpp │ │ ├── SEGMENT_TREE │ │ │ ├── ADVANCED_SEGMENT_TREE_TEMPLATE_RANGE_MIN_MAX.cpp │ │ │ ├── ALL_IN_ONE_GENERALIZED_SEGMENTTREE_+_GCD_+_LCM.cpp │ │ │ ├── Binary_Segment_Tree.cpp │ │ │ ├── FIND_INDEX_WHOSE_PREFIX_GREATER_THAN_X_SEGMENT_TREE.cpp │ │ │ ├── GCD_LCM_RANGE_SEGMENT_TREE.cpp │ │ │ ├── LAZY_PROPOGATION_ULTIMATE_SEGMENT_TREE.cpp │ │ │ ├── Lazy_Segment_Tree │ │ │ │ ├── AndLazySegmentTree.cpp │ │ │ │ ├── BinarySegmentTree.cpp │ │ │ │ ├── LazySegmentTreeWithSetUpdate.cpp │ │ │ │ ├── LazySumXorSegmentTree.cpp │ │ │ │ ├── Lazy_Segment_Tree.cpp │ │ │ │ ├── MaxLazySegmentTree.cpp │ │ │ │ └── OrLazySegmentTree.cpp │ │ │ ├── RANGE_MIN_MAX_+_HASHING.cpp │ │ │ ├── TEMPLATE_SEGMENTTREE.cpp │ │ │ ├── UPDATE_RANGE_MIN_MAX_+_HASHING.cpp │ │ │ ├── UPDATE_SEG_INDEX_ADVANCED_TEMPLATE_SEGMENT_TREE.cpp │ │ │ ├── find_kth_zero_pos_update_count_SEGMENT_TREE.cpp │ │ │ └── kth_zero_build_update_count_SEGMENT_TREE.cpp │ │ ├── Trie.cpp │ │ ├── centroid_decomposition.cpp │ │ ├── disjointSet.cpp │ │ ├── fenwickTree.cpp │ │ ├── lazy_segment_propogation_tree.cpp │ │ ├── segmentTree.cpp │ │ ├── sparseTable.cpp │ │ └── sqrtDecomposition.cpp │ ├── advanced_techniques │ │ ├── BalancedHeaps.cpp │ │ ├── CordinateCompression.cpp │ │ └── CountInversions.cpp │ ├── geometry │ │ ├── Convex_hull_jarvis_(2).cpp │ │ ├── Line_intersect.cpp │ │ └── jarvis_march_convex_hull.cpp │ ├── graph_module │ │ ├── LCABinaryLifting_O(LogN).cpp │ │ ├── graph.cpp │ │ ├── heavyLightDecomposition.cpp │ │ └── max_flow │ │ │ ├── Dinics.java │ │ │ └── MPM_max_flow.java │ └── starterTemplete.cpp ├── java-modules │ ├── Codechef.java │ ├── Main$1.class │ ├── Main$FastScanner.class │ ├── Main$Printer.class │ ├── Main.class │ ├── Main.java │ ├── ShreepadAllInOne.java │ ├── com │ │ └── library │ │ │ ├── algo │ │ │ ├── BinarySearch.java │ │ │ └── LIS.java │ │ │ ├── bitmanip │ │ │ └── KerninghanAlgo.java │ │ │ ├── conversion │ │ │ └── Convertor.java │ │ │ ├── customds │ │ │ ├── BitSet.java │ │ │ ├── LangUtil.java │ │ │ ├── MyPair.java │ │ │ ├── Pair.java │ │ │ └── StringUtil.java │ │ │ ├── ds │ │ │ └── graph │ │ │ │ ├── flow │ │ │ │ ├── Dinic.java │ │ │ │ ├── MPM$FlowEdge.class │ │ │ │ ├── MPM.class │ │ │ │ └── MPM.java │ │ │ │ └── lca │ │ │ │ └── LCABinaryLifting.java │ │ │ ├── heavyds │ │ │ ├── DisjointSet.java │ │ │ ├── FenwickTree.java │ │ │ └── segtree │ │ │ │ └── SegmentTree.java │ │ │ ├── io │ │ │ ├── FastScanner.java │ │ │ └── Printer.java │ │ │ └── mathlib │ │ │ ├── ChineseRemainder.java │ │ │ ├── Factorization.java │ │ │ ├── LcmGcd.java │ │ │ ├── Quadratic.java │ │ │ └── moduloarithmetic │ │ │ ├── Modulo.java │ │ │ └── ModuloStatic.java │ └── starter_template │ │ └── Main.java └── python-modules │ ├── IO │ └── ip.py │ ├── advance_ds │ ├── bitwiseOrSegTree.py │ ├── disjointSet.py │ ├── fenwickTree.py │ └── rangeSumSegmentTree.py │ ├── algo │ ├── dijkstra.py │ ├── kruskal.py │ └── prims.py │ ├── math │ ├── catalan.py │ ├── ncr.py │ └── primeModule │ │ └── isPrimeSimple.py │ └── template │ └── basic.py ├── notes └── string_transformation_trick.md ├── problemset ├── company_wise_problems │ ├── AMAZON │ │ ├── ARRAYS │ │ │ └── convert_array_into_zig_zag.cpp │ │ ├── DIVIDE_AND_CONQUER │ │ │ └── BINARY_SEARCH │ │ │ │ └── search_in_rotated_array.cpp │ │ ├── Dynamic Programming │ │ │ └── jump_game.cpp │ │ ├── GRAPH │ │ │ ├── course_shedule.cpp │ │ │ ├── detect_cycle_in_directed_graph.cpp │ │ │ └── steps_by_knight.cpp │ │ ├── HASHING │ │ │ ├── largest_subarray_with_0_sum.cpp │ │ │ ├── print_anagrams_together.cpp │ │ │ ├── set_matrix_zeros.cpp │ │ │ └── smallest_window_in_a_string_containing_all_characters_of_other_string.cpp │ │ ├── LINKED_LIST │ │ │ ├── merge_k_sorted_linked_list.cpp │ │ │ ├── remove_zero_sum_sublists.cpp │ │ │ └── rotate_list.cpp │ │ ├── MATH │ │ │ └── missing_number.cpp │ │ ├── PREFIX_SUM │ │ │ └── equibrium_point.cpp │ │ ├── SLIDING_WINDOW │ │ │ └── subarray_with_given_sum.cpp │ │ ├── STACK │ │ │ ├── ASTEROID_COLLISION.cpp │ │ │ ├── NEXT_GREATER_ELEMENT.cpp │ │ │ ├── NEXT_GREATER_ELEMENT_2_STACK_QUEUE.cpp │ │ │ ├── NEXT_GREATER_ELEMENT_BACKWARD_STACK.cpp │ │ │ └── NEXT_GREATER_ELEMENT_i.cpp │ │ ├── STRING │ │ │ ├── NEXT_GREATER_ELEMENT_III.cpp │ │ │ └── ZIG_ZAG_CONVERSION.cpp │ │ ├── TREE │ │ │ ├── BINARY_TREE │ │ │ │ ├── binary_tree_to_dll.cpp │ │ │ │ ├── boundary_order_traversal_of_binary_tree.cpp │ │ │ │ ├── clone_a_binary_tree_with_random_pointers.cpp │ │ │ │ └── is_binary_tree_a_heap.cpp │ │ │ └── BST │ │ │ │ ├── check_for_bst.cpp │ │ │ │ ├── inorder_successor_in_bst.cpp │ │ │ │ ├── remove_bst_keys_outside_given_range.cpp │ │ │ │ └── validate_bst.cpp │ │ ├── binaryTreeToDll.py │ │ └── pythagorian_triple.py │ ├── CODENATION │ │ └── Painters_Partition_problem.cpp │ ├── GOOGLE │ │ ├── BIT_MANIPULATION │ │ │ └── finding_unique_binary_string.cpp │ │ ├── Dynamic Programming │ │ │ ├── ONES_AND_ZEROS.cpp │ │ │ ├── count_number_of_teams.cpp │ │ │ ├── count_square_submatrices_with_all_ones.cpp │ │ │ ├── counting_bits.cpp │ │ │ ├── longestPalindromicSubstring.cpp │ │ │ ├── longest_increasing_path_in_matrix.cpp │ │ │ ├── longest_valid_paranthesis_(STACK_APPROACH).cpp │ │ │ ├── palindromic_substrings.cpp │ │ │ ├── partition_array_for_maximum_sum.cpp │ │ │ ├── sort_integers_by_their_power_values.cpp │ │ │ ├── unique_paths_ii.cpp │ │ │ ├── word_break.cpp │ │ │ └── word_break2.cpp │ │ ├── GREEDY │ │ │ └── SORTING │ │ │ │ └── contains_duplicate_III.cpp │ │ ├── Hashing │ │ │ ├── append_k_integers_with_minimal_sum.cpp │ │ │ ├── contains_duplicate.cpp │ │ │ ├── find_all_duplicates_in_array.cpp │ │ │ ├── find_all_numbers_disappering_in_an_array.cpp │ │ │ ├── first_missing_positive_number.cpp │ │ │ └── valid_sudoku.py │ │ ├── LRU_CACHE.py │ │ ├── MATH │ │ │ └── FIND_FIRST_MISSING_NUMBER.cpp │ │ ├── PERMUTATION.cpp │ │ ├── Tree │ │ │ └── find_elements_in_contaminated_tree.cpp │ │ ├── binary_search │ │ │ └── min_eating_speed.cpp │ │ ├── find_duplicate_number.cpp │ │ ├── graph │ │ │ ├── Articulation │ │ │ │ └── CriticalConnections_in_Network.cpp │ │ │ └── dijkstra │ │ │ │ ├── network_delay_time.cpp │ │ │ │ └── shortest_path_in_binary_matrix.cpp │ │ ├── minimum_falling_path_sum.cpp │ │ ├── prefix_suffix │ │ │ └── string │ │ │ │ └── numSplits.cpp │ │ ├── random_pick_index.cpp │ │ ├── search_in_2d_matrix_ii.cpp │ │ ├── sort_list_insertion_sort.cpp │ │ └── sort_list_merge_sort.cpp │ ├── MICROSOFT │ │ └── MEDIUM │ │ │ ├── add_binary_numbers.cpp │ │ │ ├── first_missing_positive.cpp │ │ │ ├── kth_last_node_of_linked_list.cpp │ │ │ ├── number_of_islands.cpp │ │ │ ├── sentence_reversal.cpp │ │ │ └── subtree.cpp │ └── STRIVER_SDE_SHEET │ │ └── ARRAYS │ │ ├── best_time_to_buy_sell_stocks.cpp │ │ ├── count_inversions.cpp │ │ ├── find_the_duplicate_number.cpp │ │ ├── maximum_subarray_sum_KADENE.cpp │ │ ├── merge_intervals.cpp │ │ ├── merge_sorted_arrays.cpp │ │ ├── merge_sorted_arrays_(CONSTANT_SPACE).cpp │ │ ├── next_permutation.cpp │ │ ├── pascal.cpp │ │ ├── pascal_leetcode.cpp │ │ ├── repeat_and_missing_number.cpp │ │ ├── rotate_image.cpp │ │ └── sort_colors.cpp ├── data_structure_problems │ ├── array │ │ ├── average_waiting_time.cpp │ │ ├── fin.cpp │ │ ├── findDuplicates_in_array.cpp │ │ ├── findDuplicates_in_array_betterApproach.cpp │ │ ├── global_and_local_inversions.cpp │ │ ├── max_Subarray_Sum_MOST_EFFICIENT_(OPTIMUM).cpp │ │ ├── maximum_points_you_can_obtain.cpp │ │ ├── sum_of_even_numbers_after_queries.cpp │ │ └── topK_frequent_elements.cpp │ ├── dsu │ │ ├── maximum_no_of_events.cpp │ │ ├── min_deletion_to_make_freq_uniq.cpp │ │ ├── min_max_sort.cpp │ │ └── readme.md │ ├── graph │ │ ├── CriticalConnections_in_Network.cpp │ │ ├── DFS_BFS_Graph.cpp │ │ ├── cloneGraph.cpp │ │ ├── detection_of_cycle_in_a_graph.cpp │ │ ├── find_Center_Of_Star_Graph.cpp │ │ ├── find_Judge.cpp │ │ ├── find_smallest_set_of_vertices.cpp │ │ ├── is_bipartite.cpp │ │ ├── minimal_travel_time.py │ │ ├── network_delay_time.cpp │ │ └── shortest_path_in_binary_matrix.cpp │ ├── heap │ │ ├── balanced_heap │ │ │ ├── sliding_cost.cpp │ │ │ └── sliding_median.cpp │ │ ├── constructing_the_array.cpp │ │ ├── find_subseq_of_len_k_with_largest_sum.cpp │ │ ├── klargetstElems.py │ │ ├── maximum_bags_with_full_capacity_of_rocks.cpp │ │ ├── maximum_product_after_k_increments.cpp │ │ ├── maximum_score_from_removing_stones.cpp │ │ ├── maximum_subarray_sum_2.cpp │ │ ├── minimum_difference_after_removal_of_elements.cpp │ │ ├── phoneix_and_towers.cpp │ │ ├── potions_hard_version.cpp │ │ ├── productive_meeting.cpp │ │ ├── stdHeapClass.cpp │ │ └── virus.cpp │ ├── linked_list │ │ ├── MERGE_SORT_SINGLY_LL_LOG_N_TIME___O_1_SPACE_.exe │ │ ├── best ones │ │ │ └── MERGE_SORT_SINGLY_LL_LOG_N_TIME___O_1_SPACE_.cpp │ │ ├── circularly_linked_list.cpp │ │ ├── circularly_linked_list.exe │ │ ├── detection_of_cycle_in_linked_list.cpp │ │ ├── get_random_node_in_a_linked_list.cpp │ │ ├── intersection_point_of_two_linked_list.cpp │ │ ├── introduction.txt │ │ ├── is_Palindrome.cpp │ │ ├── linked_list_CE122_om_soni.c │ │ ├── middle_of_singly_linked_list.cpp │ │ ├── remove_duplicates_from_sorted_LL_1_EASY_INLINEcpp.cpp │ │ ├── remove_duplicates_from_sorted_LL_2.cpp │ │ ├── reorder_linked_list.cpp │ │ ├── reverse_only_some_part_of_linked_list.cpp │ │ ├── reverse_singly_linked_list_recursion.cpp │ │ └── swap_nodes_in_singly_linked_list.cpp │ ├── matrix │ │ ├── corners.cpp │ │ ├── count_unguarded_cells_in_array.cpp │ │ ├── find-winner-of-tic-tac-toe.cpp │ │ ├── flood-fill.cpp │ │ ├── madoka_and_childish_pranks.cpp │ │ ├── maximal_square.cpp │ │ ├── nice_matrix.cpp │ │ ├── palindrome │ │ │ ├── nice_matrix.cpp │ │ │ └── palindromic_paths.cpp │ │ └── same_count_ones.cpp │ ├── policy_based_data_structures │ │ ├── salary_queries.cpp │ │ └── sliding_median.cpp │ ├── queue │ │ └── impletent_Queue_Using_Stacks.cpp │ ├── stack │ │ ├── PRACTICE_PROBLEMS_STACK │ │ │ ├── boats_competition.cpp │ │ │ └── longest_valid_paranthesis_(STACK_APPROACH).cpp │ │ ├── impletent_Queue_Using_Stacks.cpp │ │ ├── jatayu_and_bracket_sequence.cpp │ │ ├── min_time_to_make_rope_colorful.cpp │ │ ├── monotonic_stack │ │ │ └── nearest_smaller_values.cpp │ │ ├── remove_all_adjacent_characters_2.cpp │ │ └── validateParanthesis.py │ ├── string │ │ ├── reverse_words_in_string_3.cpp │ │ └── sortCharacters_by_frequency.cpp │ └── tree │ │ ├── BST │ │ ├── CONSTRUCT_BINARY_TREE_FROM_INORDER_AND_PREORDER_TRAVERSAL.cpp │ │ ├── LCAofBST.cpp │ │ ├── all_elements_in_two_bst.cpp │ │ ├── balance_A_BST.cpp │ │ ├── bst_to_gst.cpp │ │ ├── construct_BST_FROM_preorder.cpp │ │ ├── convertBSTtoGREATER_Tree.cpp │ │ ├── convertSortedArrayIntoBST.cpp │ │ ├── convertSortedArrayToBst.py │ │ ├── deleteNodeFromBST.cpp │ │ ├── increasingOrderSearchTree.cpp │ │ ├── insertNodeInBST.cpp │ │ ├── kthSmallestElemIn_BST.cpp │ │ ├── minDiffInBST.cpp │ │ ├── rangeBasedSumInBST.cpp │ │ ├── recoverBST.cpp │ │ ├── searchBST.cpp │ │ ├── sortedListToBST.cpp │ │ ├── trimBST.cpp │ │ ├── validateBST.cpp │ │ └── validate_bst_O(n).py │ │ ├── CONSTRUCT_BINARY_TREE_FROM_INORDER_AND_PREORDER_TRAVERSAL.cpp │ │ ├── LCA_BinaryTree.cpp │ │ ├── N_ARY │ │ └── maxDepthOfN-AryTree.cpp │ │ ├── addOneRowInBinaryTree.cpp │ │ ├── allPathsOfTree.cpp │ │ ├── averageOfLevelsInBinaryTree.cpp │ │ ├── binaryTreeTILT.cpp │ │ ├── binaryTreeToDll.py │ │ ├── binary_tree_maximum_path_sum.cpp │ │ ├── constructBinaryTreeFromInorder_and_Postorder_Traversal.cpp │ │ ├── constructMaximumBinaryTree.cpp │ │ ├── copyTree.cpp │ │ ├── countAlmost_Complete_(complete)_TreeNodes_O(LOG(N)).cpp │ │ ├── count_nodes_equals_average_of_subtree.cpp │ │ ├── cousings_in_binary_tree.cpp │ │ ├── deepestLeavesSum.cpp │ │ ├── deleteInSufficientNodesIn_ROOT_TO_LEAF_Path in binary tree.cpp │ │ ├── diameterOfBinaryTree.cpp │ │ ├── diameterOfBinaryTreeEfficient.cpp │ │ ├── diameterOfBinaryTreeEfficientApproach.cpp │ │ ├── findFrequentSumInTree.cpp │ │ ├── findModeInBinaryTreeTWO.cpp │ │ ├── findTheBottomLeftTreeValueIN_Binary_Tree.cpp │ │ ├── find_corresponding_node_of_binary_tree_in_clone_of_that_tree.cpp │ │ ├── flattenTree.cpp │ │ ├── flipEquivalenTrees.cpp │ │ ├── huffmanDecodingAlgorithm.cpp │ │ ├── largestValueInEachRowOfBinaryTree.cpp │ │ ├── levelOrderTraversal.cpp │ │ ├── linked_list_in_binary_tree.cpp │ │ ├── maxLevelSumInBinaryTree.cpp │ │ ├── maxPathSumInBinaryTree.cpp │ │ ├── mergeTwoTrees.cpp │ │ ├── minDephthOfTree.cpp │ │ ├── path_sum_2.cpp │ │ ├── pathsWithGivenSumInBinaryTree.cpp │ │ ├── populatingNextRightPointersInEachNodeOfBinaryTree.cpp │ │ ├── populatingNextRightPointersInEachNodeOfBinaryTreeBETTER_APPROACH.cpp │ │ ├── recoverTreeFromPreOrderTraversal.cpp │ │ ├── reverseLevelOrderTraversalInBinaryTree.cpp │ │ ├── rightSideViewOfBinaryTree.cpp │ │ ├── sprial_order_traversal.java │ │ ├── subTreeOfAnotherTree.cpp │ │ ├── sumOfLeftLeavesInTree.cpp │ │ ├── tree2str.cpp │ │ ├── treeToLeafPathsWithGivenSumInBinaryTree.cpp │ │ ├── tree_for_cp │ │ ├── Shortest Paths in binary Tree.cpp │ │ ├── kefa_and_trees.cpp │ │ ├── linova_and_kingdom.cpp │ │ ├── minimal_height_tree.cpp │ │ ├── omkar_and_heavenly_tree.cpp │ │ ├── party.cpp │ │ ├── readme.md │ │ ├── vertical_paths.cpp │ │ ├── white_black_subtrees.cpp │ │ └── yet_another_cart_deck_brute_force.cpp │ │ ├── vertical_order_traversal_in_Binary_Tree.cpp │ │ └── zigzagOrderTraversal.cpp ├── misc │ ├── const-space-problems │ │ ├── frequencyOfLimitedRange.cpp │ │ └── remove_duplicates_from_string_in_constanct_space.cpp │ └── popular-problems │ │ ├── LRU_CACHE.py │ │ ├── activitySelection.cpp │ │ ├── logestIncreasingSubseq.cpp │ │ ├── nQueens.cpp │ │ └── pascalsTriangle.py ├── topic_wise_problems │ ├── back-tracking │ │ ├── hamilton_cycle.cpp │ │ ├── mcoloring_graph.cpp │ │ ├── nQueens.cpp │ │ ├── reachTarget.cpp │ │ └── replaceDigitsPermutations.cpp │ ├── binary search │ │ ├── Search in rotated array.cpp │ │ ├── bear_and_house.py │ │ ├── binary_search_on_answer │ │ │ ├── array_division.cpp │ │ │ ├── factory_machines.cpp │ │ │ └── minimizing_difference.cpp │ │ ├── books.cpp │ │ ├── chat_ban.cpp │ │ ├── constant_palindrome_sum.cpp │ │ ├── contains_duplicate_3.cpp │ │ ├── disjoint_data_intervals.cpp │ │ ├── distinct_dilemma.py │ │ ├── divide_intervals_into_minimum_number_of_groups.cpp │ │ ├── find_first_and_last_position_in_array.cpp │ │ ├── find_kth_smallest_pair_diff.cpp │ │ ├── find_min_element_in_rotated_sorted_array.cpp │ │ ├── get_equal_substrings_within_budget.cpp │ │ ├── interesting_drink.py │ │ ├── is_perfect_square.cpp │ │ ├── kth_not_divisible_by_n.py │ │ ├── kth_smallest_prime_fractions.cpp │ │ ├── mark_and_his_unfinished_array.cpp │ │ ├── min_absolute_sum_diff.cpp │ │ ├── min_arrow_shots_to_burst_ballons.cpp │ │ ├── min_max_array_transformation.cpp │ │ ├── minimum_number_of_operations_to_make_array_continuous.cpp │ │ ├── minimum_size_subarray_sum.cpp │ │ ├── movie_festival.cpp │ │ ├── new_year_and_hurry.py │ │ ├── non_overlapping_intervals.cpp │ │ ├── number-of-weak-chars-in-game.cpp │ │ ├── number_of_pairs.cpp │ │ ├── pair_topics.cpp │ │ ├── search_in_rotated_array_2.cpp │ │ ├── to_become_max.cpp │ │ ├── vanya_and_lanterns.py │ │ └── worms.cpp │ ├── binary_lifting │ │ └── tree_queries.cpp │ ├── bit_manip │ │ ├── and_sequences.cpp │ │ ├── array_elimination.cpp │ │ ├── binary_string_xor.py │ │ ├── bitwise_and_of_numbers_range.cpp │ │ ├── box_fitting.cpp │ │ ├── brutal_xors.cpp │ │ ├── cirnos_perfect_bitmask_classroom.cpp │ │ ├── co-growing_subsequence.cpp │ │ ├── concatenation_of_consecutive_binary_numbers.cpp │ │ ├── even_odd_xor.cpp │ │ ├── geek_and_code.cpp │ │ ├── geek_and_function.cpp │ │ ├── geek_and_subset_sum.cpp │ │ ├── good_permutation.py │ │ ├── hammingDistance.py │ │ ├── hammingWeight.py │ │ ├── longest_nice_subarray.cpp │ │ ├── magical_flips.cpp │ │ ├── mainak_and_interesting_sequence.cpp │ │ ├── maximal_and.cpp │ │ ├── non_zero_xor.cpp │ │ ├── or_tuples.cpp │ │ ├── reverseBits.py │ │ ├── sort_integers_by_number_of_set_bits.cpp │ │ ├── special_numbers.cpp │ │ └── two_numbers_with_odd_occurances.cpp │ ├── bitmask │ │ ├── and_it_is_not_zero.cpp │ │ └── boboniu_and_bit_operations.cpp │ ├── brute_force │ │ ├── add_to_neighbour_and_remove.cpp │ │ ├── boats_competition.cpp │ │ ├── boboniu_and_bit_operations.cpp │ │ ├── charmed_by_the_game.cpp │ │ ├── coordinate_with_maximum_nw_quality.cpp │ │ ├── increase_subarray_sums.cpp │ │ ├── minimize_the_thickness.cpp │ │ ├── nastia_and_good_array.cpp │ │ ├── reverse_string.cpp │ │ └── sequence_with_digits.cpp │ ├── constructive │ │ ├── divine_array.cpp │ │ ├── madoka_and_childish_pranks.cpp │ │ ├── moderate_modular_mode.cpp │ │ ├── okea.cpp │ │ └── red_versus_blue.cpp │ ├── coordinate_compression │ │ └── enemy_is_weak.cpp │ ├── disjoint_set_union │ │ ├── blue_red_permutation.cpp │ │ ├── jeopardy_of_dropped_balls.cpp │ │ ├── knighTournament.py │ │ ├── little_alawns_puzzle.cpp │ │ └── mocha_and_diana_easy_version.cpp │ ├── divide_and_conquer │ │ ├── count_range_sum.cpp │ │ ├── euron_problem.cpp │ │ ├── maximum_subarray_divide_and_conquery.cpp │ │ ├── maximum_subarray_linear_approach.cpp │ │ ├── merge_sort_problems │ │ │ └── Maximum_crossing.cpp │ │ ├── search_in_2d_matrix.cpp │ │ ├── search_in_2d_matrix_ii.cpp │ │ └── super_pow.cpp │ ├── dp │ │ ├── 2D_dp │ │ │ ├── max_sum_of_products.cpp │ │ │ ├── rectangle_cutting.cpp │ │ │ └── removal_game.cpp │ │ ├── 3D_dp │ │ │ └── min-cost-to-cut-stick.cpp │ │ ├── 3Fibonacci.cpp │ │ ├── Boredom.cpp │ │ ├── Gravity_Game.cpp │ │ ├── ONES_AND_ZEROS.cpp │ │ ├── basket_ball_exercise.cpp │ │ ├── best_team_with_no_conflicts.cpp │ │ ├── best_time_to_buy_sell_stocks_IV.cpp │ │ ├── best_time_to_sell_stocks_2_(memo).cpp │ │ ├── binaryTreesWithFactor.java │ │ ├── binary_tree_maximum_path_sum.cpp │ │ ├── canJump-III-MEMO.cpp │ │ ├── car_pooling.cpp │ │ ├── climb_Stairs_memo.cpp │ │ ├── climb_Stairs_tabulation.cpp │ │ ├── combination_sum.cpp │ │ ├── concatenation_of_consecutive_binary_numbers.cpp │ │ ├── consecutive_sequence.cpp │ │ ├── count_number_of_teams.cpp │ │ ├── decode_ways_MEMO.cpp │ │ ├── fence.cpp │ │ ├── fibonacci_memo.cpp │ │ ├── fibonacci_tab.cpp │ │ ├── find_the_spruce.cpp │ │ ├── get_Max_Genereated.cpp │ │ ├── good_subarrays.cpp │ │ ├── good_subarrays_easy_version.java │ │ ├── hasValidPath.cpp │ │ ├── houseRobber.py │ │ ├── k-tree.py │ │ ├── lcs.cpp │ │ ├── length_of_longest_increasing_fib_seq.cpp │ │ ├── longestPalindromicSubstring.cpp │ │ ├── longest_Increasing_Subsequence.cpp │ │ ├── longest_Increasing_Subsequence_LOG(N) approach.cpp │ │ ├── longest_increasing_path_in_matrix.cpp │ │ ├── longest_palindromic_subseq.py │ │ ├── longest_valid_paranthesis_(STACK_APPROACH).cpp │ │ ├── making_towers.cpp │ │ ├── max_Subarray_Sum.cpp │ │ ├── max_Subarray_Sum_MOST_EFFICIENT_(OPTIMUM).cpp │ │ ├── max_Subarray_Sum_MoreEfficient.cpp │ │ ├── max_Subarray_Sum_MoreEfficient2.cpp │ │ ├── max_earning_from_taxi.cpp │ │ ├── max_events_can_be_attended.cpp │ │ ├── max_subarray_sum_circular.cpp │ │ ├── max_sum_on_even_positions.cpp │ │ ├── max_time_to_buy_sell_stocks_3.cpp │ │ ├── max_width_ramp.cpp │ │ ├── maximal_square.cpp │ │ ├── meeting_rooms_3.cpp │ │ ├── min_Cost_Climbing_Stairs.cpp │ │ ├── min_Path_Sum.cpp │ │ ├── min_Steps_required_To_jump_TAB.cpp │ │ ├── minimum-increment-subarray-to-make-target.cpp │ │ ├── minimum_difference_after_removal_of_elements.cpp │ │ ├── movie_festival.cpp │ │ ├── non_overlapping_intervals.cpp │ │ ├── number-of-people-aware-of-a-secret.cpp │ │ ├── palindrome_basis.cpp │ │ ├── palindromic_substrings.cpp │ │ ├── partition_array_for_maximum_sum.cpp │ │ ├── pascal_Traingle.cpp │ │ ├── pascal_triangle2_using_map_memo.cpp │ │ ├── perfect_square.cpp │ │ ├── readme.md │ │ ├── remove_one_element.cpp │ │ ├── sending_sequence_over_a_network.cpp │ │ ├── sort_integers_by_their_power_values.cpp │ │ ├── split_array_largest_sum.cpp │ │ ├── test.cpp │ │ ├── the_Greater_Julya_Calander.cpp │ │ ├── tokitsukaze_and_strange_inequality.cpp │ │ ├── total_appeal_of_a_string.cpp │ │ ├── triangle_(minimum_top_to_bottom_SUM)_MEMO.cpp │ │ ├── two_best_non_overlapping_events.cpp │ │ ├── unique_Paths_With_Obstacles_tab.cpp │ │ ├── unique_Paths_tab.cpp │ │ ├── vacations.cpp │ │ ├── word_break.cpp │ │ └── word_break2.cpp │ ├── edge_cases │ │ ├── awoos_favourite_problem.cpp │ │ └── dorminant_character.cpp │ ├── games │ │ ├── charmed_by_the_game.cpp │ │ ├── deleting_divisors.cpp │ │ ├── palindrome_game.cpp │ │ └── removal_game.cpp │ ├── geometry │ │ ├── check_if_it_is_straight_line.cpp │ │ ├── color_the_picture.cpp │ │ ├── easy_assembly.cpp │ │ ├── han_solo_and_lazer_gun.cpp │ │ ├── minimum_lines_to_represent_line_chart.cpp │ │ ├── pashmak_and_gardern.cpp │ │ └── point_grid.py │ ├── greedy │ │ ├── A-B-C_sort.cpp │ │ ├── Ceil and Receipt.cpp │ │ ├── Subturtle_substring_subtraction.cpp │ │ ├── a_perfectly_balanced_string.cpp │ │ ├── activitySelection.cpp │ │ ├── alternating_subsequence.cpp │ │ ├── and_it_is_no_zero.cpp │ │ ├── array_balancing.cpp │ │ ├── close_the_gap.cpp │ │ ├── college_life_5.py │ │ ├── even_odd_game.cpp │ │ ├── fair_elections.cpp │ │ ├── find_the_array.cpp │ │ ├── find_valid_matrix_given_row_and_column_sums.cpp │ │ ├── insert_a_progression.cpp │ │ ├── interesting_xor.cpp │ │ ├── max_increase_to_keep_city_skyline.cpp │ │ ├── maximum_number_of_coins_you_get.cpp │ │ ├── maximum_number_of_distinct_element.cpp │ │ ├── minimum_add_to_make_paranthesis_valid.cpp │ │ ├── mix_the_colors.cpp │ │ ├── partitioning_into_minimum_number_of_deci-binary_numbers.cpp │ │ ├── phonix_and_beauty.cpp │ │ ├── saving_the_city.cpp │ │ ├── score_after_flipping_matrix.cpp │ │ ├── table_decoration.cpp │ │ └── taxi.cpp │ ├── hashing │ │ ├── 4_sum_2.cpp │ │ ├── array_of_doubled_pairs.cpp │ │ ├── contains_duplicate_1.cpp │ │ ├── contains_duplicate_2.cpp │ │ ├── contains_duplicate_3.cpp │ │ ├── find-all-duplicates_in_array.cpp │ │ ├── find-the-longest-substring-containing-vowels-in-even-counts.cpp │ │ ├── find_all_anagrams_in_string.cpp │ │ ├── find_longest_awesome_substring.cpp │ │ ├── find_subarrays_with_equal_sum.cpp │ │ ├── fixed_prefix_permutations.cpp │ │ ├── fox_and_box_accumulation.cpp │ │ ├── group_special_equvivalent_strings.cpp │ │ ├── max_repeating_elements.cpp │ │ ├── palindromic_paths.cpp │ │ ├── permutation_in_string.cpp │ │ ├── remove_duplicates.cpp │ │ ├── subarray_divisibility.cpp │ │ ├── two_repeated_elements.cpp │ │ ├── verifying_alien_dict.cpp │ │ └── word_subsets.cpp │ ├── implementation │ │ ├── binary_strings_to_subsequences.cpp │ │ ├── busy_robot.cpp │ │ ├── len_and_sum_of_digits.cpp │ │ └── wonderful_coloring_2.cpp │ ├── interactive │ │ ├── more_wrong.cpp │ │ └── odd_or_even.cpp │ ├── linear search │ │ ├── hexadecimal_numbers.cpp │ │ └── special_shop.cpp │ ├── math │ │ ├── combinatorics │ │ │ ├── binomial_coef │ │ │ │ └── ncr_%_mod.cpp │ │ │ ├── factorial │ │ │ │ └── drazil_and_factorial.cpp │ │ │ └── misc │ │ │ │ ├── and_sequences.cpp │ │ │ │ ├── ball_in_berland.cpp │ │ │ │ └── two_round_dances.cpp │ │ ├── geometry │ │ │ └── amr_and_pins.cpp │ │ ├── math_templates │ │ │ ├── chineseRemainderThm.cpp │ │ │ ├── euler_totient.cpp │ │ │ ├── findAllFactors.cpp │ │ │ ├── game_of_ball_passing.cpp │ │ │ ├── gcd_lcm.cpp │ │ │ ├── isPrime.cpp │ │ │ ├── moduloArithmetic.cpp │ │ │ ├── readme.md │ │ │ ├── roundOfInPowerOf2.cpp │ │ │ └── seive_Erathosthenes.cpp │ │ ├── matrix_exponentiation │ │ │ └── easy_tiling.cpp │ │ ├── misc │ │ │ ├── array_and_operations.cpp │ │ │ ├── ball_and_boxes.cpp │ │ │ ├── catalanNumber.cpp │ │ │ ├── chat_ban.cpp │ │ │ ├── chewbacca_and_number.cpp │ │ │ ├── delicious_queries.cpp │ │ │ ├── dungeon.cpp │ │ │ ├── game_of_ball_passing.cpp │ │ │ ├── kTh_Smallest_factors.cpp │ │ │ ├── largestPrimeFactor.cpp │ │ │ ├── lcm_gcd.cpp │ │ │ ├── least_prime_factor.cpp │ │ │ ├── max_buy_apartment.cpp │ │ │ ├── missing_number.py │ │ │ ├── moderate_modular_mode.cpp │ │ │ ├── paprika_and_permutation.cpp │ │ │ ├── possible_victory.py │ │ │ ├── readme.md │ │ │ ├── reduce_to_1.cpp │ │ │ ├── server_trouble.py │ │ │ ├── sieveOfErasthenes.cpp │ │ │ ├── spreadsheet.cpp │ │ │ ├── sumOfFactors.cpp │ │ │ ├── sum_of_substrings.cpp │ │ │ ├── ternary_xor.cpp │ │ │ ├── two_buttons.cpp │ │ │ ├── vasya_and_coins.cpp │ │ │ └── zero_array.cpp │ │ ├── number_theory │ │ │ ├── AP │ │ │ │ └── optimal_path.cpp │ │ │ ├── digit_problems │ │ │ │ ├── concatenated_sums.cpp │ │ │ │ ├── decrease_sum_of_digits.cpp │ │ │ │ ├── interesting_function.cpp │ │ │ │ └── make_power_of_two.cpp │ │ │ ├── euler_totient │ │ │ │ └── basic_euler_totient_&_sieve_problem_example.cpp │ │ │ ├── even_odd │ │ │ │ ├── Patchouli's_Magical_Talisman.cpp │ │ │ │ ├── odd_selection.cpp │ │ │ │ └── parity_suffle_sorting.cpp │ │ │ ├── factorization_lcm_gcd_problems │ │ │ │ ├── almost_all_divisors.cpp │ │ │ │ ├── berland_regionals.cpp │ │ │ │ └── fadi_and_lcm.cpp │ │ │ ├── lcm_gcd │ │ │ │ ├── Playing_with_gcd.java │ │ │ │ ├── all_are_same.cpp │ │ │ │ ├── anti-knapsack.cpp │ │ │ │ ├── array_elimination.cpp │ │ │ │ ├── divisible_confusion.cpp │ │ │ │ ├── find_gcd_of_array.cpp │ │ │ │ ├── gcd_partition.cpp │ │ │ │ ├── lcm_challange.cpp │ │ │ │ ├── mere_array.cpp │ │ │ │ ├── minimum_number.cpp │ │ │ │ ├── orac_and_lcm.cpp │ │ │ │ ├── row_gcd.cpp │ │ │ │ ├── two_numbers.cpp │ │ │ │ └── x_magic_pair.cpp │ │ │ ├── mean │ │ │ │ ├── every_thing_every_where_all_but_one.cpp │ │ │ │ └── mean_and_median.cpp │ │ │ ├── median │ │ │ │ ├── mean_and_median.cpp │ │ │ │ └── nice_matrix.cpp │ │ │ ├── misc │ │ │ │ └── strictly_palindrome.cpp │ │ │ ├── modulo_arithmetic │ │ │ │ ├── beautiful_array.cpp │ │ │ │ ├── continuous_subarray_sum.cpp │ │ │ │ ├── division II.cpp │ │ │ │ ├── little_alawns_puzzle.cpp │ │ │ │ ├── make_equal_with_mod.cpp │ │ │ │ ├── modularMultiplicativeInverse.cpp │ │ │ │ ├── modular_exponentiation │ │ │ │ │ └── super_pow.cpp │ │ │ │ ├── plus_and_multiply.cpp │ │ │ │ └── readme.md │ │ │ ├── power_of_two │ │ │ │ └── make_power_of_two.cpp │ │ │ ├── seive_approach │ │ │ │ ├── make_them_equal.cpp │ │ │ │ └── maximum_value.cpp │ │ │ └── sieve_primality_problems │ │ │ │ ├── T-primes.cpp │ │ │ │ ├── almost_prime.cpp │ │ │ │ ├── complex_market_analysis.cpp │ │ │ │ └── nold_bach.cpp │ │ └── parity │ │ │ └── same_parity_summands.cpp │ ├── observations │ │ ├── cannine_poetry.cpp │ │ ├── corners.cpp │ │ ├── element_extermination.cpp │ │ ├── fighting_tournament.cpp │ │ ├── knapsack.cpp │ │ ├── madoka_and_formal_stmt.cpp │ │ ├── manipulating_history.cpp │ │ ├── nastia_and_good_array.cpp │ │ ├── omkar_and_basketball.cpp │ │ ├── omkar_and_heavenly_tree.cpp │ │ ├── orac_and_lcm.cpp │ │ ├── palindrome_number.cpp │ │ └── rule_of_league.cpp │ ├── offline-query-processing │ │ └── building-blocks.cpp │ ├── parity │ │ └── take_your_places.cpp │ ├── permutation │ │ ├── build_permutation.cpp │ │ ├── element_extermination.cpp │ │ ├── paprika_and_permutation.cpp │ │ ├── permutation_sequence.cpp │ │ ├── rotation_matching.cpp │ │ └── special_permutation.cpp │ ├── prefix_suffix │ │ ├── array │ │ │ ├── berland_regionals.cpp │ │ │ ├── continuous_subarray_sum.cpp │ │ │ ├── delicious_queries.cpp │ │ │ ├── inflanation.cpp │ │ │ ├── kuriyama_mirayis_stones.cpp │ │ │ ├── line.cpp │ │ │ ├── maximum_subarray_sum_2.cpp │ │ │ ├── minimum_operations_to_reduce_x_to_zero.cpp │ │ │ ├── subarray_sum_equals_k.cpp │ │ │ └── swaps.cpp │ │ └── string │ │ │ └── numSplits.cpp │ ├── range_queries │ │ ├── fenwickTree │ │ │ ├── enemy_is_weak.cpp │ │ │ ├── find_median_from_data_stream.cpp │ │ │ └── pashmak_and_praminda.cpp │ │ ├── mergeSortTree │ │ │ ├── KQUERY.cpp │ │ │ └── curious_queries.cpp │ │ ├── misc │ │ │ └── salary_queries.cpp │ │ └── segmentTree │ │ │ ├── orac_and_lcm.cpp │ │ │ ├── prefix_sum_queries.cpp │ │ │ └── xenia-and-xor-bit.cpp │ ├── recursion │ │ └── generate_Paranthesis.cpp │ ├── roadmap.md │ ├── simulation │ │ └── average_waiting_time.cpp │ ├── sliding window │ │ ├── Longest substring without repeating characters.cpp │ │ ├── Substring of Size Three with Distinct Characters.cpp │ │ ├── add_to_neighbour_and_remove.cpp │ │ ├── binary_mismatch.py │ │ ├── containsDuplicate.cpp │ │ ├── containsNearByDuplicates.cpp │ │ ├── k_radius_avg_subarr.cpp │ │ ├── longestSubarrayWithAtmost_K_evens.cpp │ │ ├── max_avg_subarr_1.cpp │ │ ├── maximum_length_of_repeating_subarray.cpp │ │ ├── maximum_subarray_sum_2.cpp │ │ ├── minimize_distance.cpp │ │ ├── sliding_median.cpp │ │ ├── subarray_distinct_elems.cpp │ │ ├── ternary_string.cpp │ │ └── vasya and string.cpp │ ├── sorting │ │ ├── berland_regionals.cpp │ │ ├── deep_down_below.cpp │ │ ├── exams.cpp │ │ ├── hemose_shopping.cpp │ │ ├── knapsack.cpp │ │ ├── less_or_equal.cpp │ │ ├── mere_array.cpp │ │ ├── minimum_notation.cpp │ │ ├── negative_prefixes.cpp │ │ ├── nested_ranges_check.cpp │ │ ├── nested_ranges_count.cpp │ │ ├── paprika_and_permutation.cpp │ │ ├── phoenix_and_distribution.cpp │ │ ├── rationalee.cpp │ │ ├── take_not_less.cpp │ │ └── young_explorers.cpp │ ├── special │ │ └── fibonacci_words.cpp │ ├── string │ │ ├── binary_string │ │ │ └── one_zero_swaps.py │ │ ├── palindrome │ │ │ ├── cannine_poetry.cpp │ │ │ ├── k_complete_word.cpp │ │ │ └── palindrome_games.cpp │ │ ├── string_and_pattern_matching │ │ │ ├── camel_case_matching.cpp │ │ │ ├── longestCommonPrefix.py │ │ │ ├── prefix_function │ │ │ │ ├── form_arrays_by_concatenating_arrays_of_subarray.cpp │ │ │ │ ├── longest_happy_prefix.cpp │ │ │ │ └── password.cpp │ │ │ ├── readme.md │ │ │ ├── repeated_string_match.cpp │ │ │ └── searchPatternZalgo.cpp │ │ └── string_misc │ │ │ ├── broken_life.py │ │ │ ├── equal_freq.cpp │ │ │ ├── find_gcd_of_strings.cpp │ │ │ ├── largestGoodInteger.cpp │ │ │ ├── number_of_strings_appear_as_substring_in_word.cpp │ │ │ ├── phoenix_and_distribution.cpp │ │ │ ├── remove_all_adjacent_duplicate_in_string1.cpp │ │ │ ├── remove_all_occurances_of_a_substr.cpp │ │ │ ├── remove_consecutive_same_elements.cpp │ │ │ ├── reverse_only_letters.cpp │ │ │ ├── reverse_string.cpp │ │ │ ├── reverse_words_in_string_3.cpp │ │ │ ├── subsequence_hate.cpp │ │ │ └── unstable_string.cpp │ └── two_pointer │ │ ├── accurate_lee.cpp │ │ ├── arranging_the_sheep.cpp │ │ ├── array_and_operations.cpp │ │ ├── bag_of_tokens.cpp │ │ ├── bersu_ball.cpp │ │ ├── build_permutation.cpp │ │ ├── longest_nice_subarray.cpp │ │ ├── make_it_good.cpp │ │ ├── min_max_sort.cpp │ │ ├── minimum_difference_after_removal_of_elements.cpp │ │ ├── removing_min_and_max_from_array.cpp │ │ ├── sorted_adjacent_differences.cpp │ │ ├── tokitsukaze_and_strange_inequality.cpp │ │ ├── unstable_string.cpp │ │ └── xxxxx.cpp └── very_different_problems │ └── string │ └── recover_an_RBS.cpp ├── readme-old.md ├── template ├── LatestCppTemplate_08_06_2023.cpp ├── advanceStarterTemplate.cpp ├── advanceStarterTemplate2.cpp ├── advanceStarterTemplate4.cpp ├── advancedStarterTemplate3.cpp ├── checkTimeOut.cpp ├── hello.cpp ├── hello2.cpp ├── hello3.cpp ├── hello4.cpp ├── hello5_advanced.cpp ├── hello6_advanced.cpp ├── namespaced1.cpp ├── oop_starter.cpp ├── premium_starter_template.cpp ├── printingModules.cpp ├── read_pair_template.cpp ├── scanningModules.cpp ├── segStarter.cpp ├── segStarter2.cpp └── starter.cpp └── workspace ├── comfort ├── BinarySearch.class ├── CollectionUtil.class ├── CordinateCompressor.class ├── DiffieHellman.cpp ├── DisjointSet.class ├── EulerTotient.class ├── FenwickTree.class ├── Fibonacci.class ├── First_Circular_tour.class ├── GFG$1.class ├── GFG$FastReader.class ├── GFG$TrieNode.class ├── GFG.class ├── GFG.java ├── GfG$Trie.class ├── GraphUtil.class ├── IntArray.class ├── IntMatrix.class ├── Intersect.class ├── LCABinaryLifting.class ├── LIS.class ├── Main$1.class ├── Main$BinarySearch.class ├── Main$ChineseRemainder.class ├── Main$CommonUtil.class ├── Main$DisjointSet.class ├── Main$FastScanner.class ├── Main$FenwickTree.class ├── Main$LazySegmentTree.class ├── Main$ModuloArithmetic.class ├── Main$NCRefficientMod.class ├── Main$Printer.class ├── Main$SegmentTree.class ├── Main$Sieve.class ├── Main.class ├── Main.java ├── MathUtil.class ├── MatrixExp.class ├── ModuloArithmetic.class ├── NCRefficient.class ├── NCRefficientMod.class ├── Node.class ├── ReplaceClass.class ├── ReplaceClass.java ├── SetLazySegmentTree.cpp ├── Shreepad$1.class ├── Shreepad$DisjointSet.class ├── Shreepad$FastScanner.class ├── Shreepad$GraphUtil.class ├── Shreepad$MathUtil.class ├── Shreepad$ModuloArithmetic.class ├── Shreepad$Printer.class ├── Shreepad.class ├── Shreepad.java ├── ShreepadAllInOne.class ├── ShreepadAllInOne.java ├── Sieve.class ├── Sol.class ├── Solution$1.class ├── Solution$CommonUtil.class ├── Solution$FastScanner.class ├── Solution$GraphUtil.class ├── Solution$ModuloArithmetic.class ├── Solution$Printer.class ├── Solution$Sieve.class ├── Solution$Trie.class ├── Solution$TrieNode.class ├── Solution.class ├── Solution.java ├── Sorting.class ├── SqrtDecomp.class ├── Transformer.class ├── TranspositionCipher.cpp ├── Tree.class ├── Trie.class ├── TrieNode.class ├── UniqueRows.class ├── a.exe ├── atcoder.cpp ├── backup.cpp ├── clean.cpp ├── clean.exe ├── command.txt ├── considerations.txt ├── datt.cpp ├── des.cpp ├── des2.cpp ├── ecc_elgaml.cpp ├── ecc_point_generation.cpp ├── error.txt ├── gfg.cpp ├── gfg.exe ├── input.txt ├── oop.cpp ├── output.txt ├── research.py ├── settings2json.jsonc ├── shreepad.cpp ├── shreepad.exe ├── shreepad.o ├── shreepad.py ├── temp.cpp ├── temp.exe ├── trial.cpp ├── variance.cpp ├── winner.exe └── winner.py └── contest ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── a.exe ├── backup.cpp └── cc.cpp /deprecated/1INTERVIEW_PREPERATION/AMAZON/Dynamic Programming/jump_game.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/jump-game/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | bool canJump(vector& nums) { 7 | int n=nums.size(); 8 | vector v(n,false); 9 | v[n-1]=true; 10 | int next=n-1; 11 | for(int i=n-2;i>=0;i--){ 12 | int limit=min(n-1,i+nums[i]); 13 | if(limit>=next){ 14 | next=i; 15 | v[i]=true; 16 | } 17 | } 18 | return v[0]; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /deprecated/1INTERVIEW_PREPERATION/LEETCODE/GOOGLE/Hashing/contains_duplicate.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/contains-duplicate/ 2 | // solution : below code 3 | 4 | 5 | class Solution { 6 | public: 7 | bool containsDuplicate(vector& nums) { 8 | map hash; 9 | for(auto num:nums) hash[num]++; 10 | for(auto pr:hash) if(pr.second>1) return true; 11 | return false; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /deprecated/1INTERVIEW_PREPERATION/LEETCODE/GOOGLE/Hashing/find_all_duplicates_in_array.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | vector findDuplicates(vector& nums) { 7 | vector dups; 8 | map mp; 9 | for(auto num:nums){ 10 | mp[num]++; 11 | } 12 | for(auto &pr:mp){ 13 | if(pr.second>1) dups.push_back(pr.first); 14 | } 15 | return dups; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /deprecated/1INTERVIEW_PREPERATION/LEETCODE/GOOGLE/Hashing/find_all_numbers_disappering_in_an_array.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | vector findDisappearedNumbers(vector& nums) { 7 | int n=nums.size()+1; 8 | vector v(n,false); 9 | for(auto num:nums) v[num]=true; 10 | vector missing; 11 | for(int i=1;i& nums) { 7 | int n=nums.size()+2; 8 | vector v(n,false); 9 | for(auto num:nums) if(num>0 && num& nums) { 8 | ll n=nums.size(); 9 | ll sm=accumulate(begin(nums),end(nums),0LL); 10 | ll total=(n*(n+1))/2; 11 | return total-sm; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /deprecated/1INTERVIEW_PREPERATION/LEETCODE/GOOGLE/find_duplicate_number.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/find-the-duplicate-number/ 2 | // solution : below code 3 | class Solution { 4 | public: 5 | int findDuplicate(vector& nums,int i=0) { 6 | vector container(nums.size(),false); 7 | for(auto num:nums){ 8 | if(container[num]) return num; 9 | container[num]=true; 10 | } 11 | return -1; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /deprecated/1INTERVIEW_PREPERATION/MICROSOFT/MEDIUM/kth_last_node_of_linked_list.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://binarysearch.com/problems/Kth-Last-Node-of-a-Linked-List 2 | // solution : below code 3 | 4 | /** 5 | * class LLNode { 6 | * public: 7 | * int val; 8 | * LLNode *next; 9 | * }; 10 | */ 11 | int solve(LLNode* node, int k) { 12 | int index=0; 13 | LLNode* fast=node; 14 | while(indexnext; 17 | } 18 | LLNode* curr=node; 19 | while(fast->next){ 20 | curr=curr->next; 21 | fast=fast->next; 22 | } 23 | return curr->val; 24 | } 25 | -------------------------------------------------------------------------------- /deprecated/1INTERVIEW_PREPERATION/STRIVER_SDE_SHEET/ARRAYS/best_time_to_buy_sell_stocks.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | int maxProfit(vector& prices) { 7 | int mx=0; 8 | int profit=0; 9 | int n=prices.size(); 10 | for(int i=n-1;i>=0;i--){ 11 | profit=max(profit,mx-prices[i]); 12 | mx=max(mx,prices[i]); 13 | } 14 | return profit; 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /deprecated/1INTERVIEW_PREPERATION/STRIVER_SDE_SHEET/ARRAYS/find_the_duplicate_number.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/find-the-duplicate-number/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | int findDuplicate(vector& nums) { 7 | long long n=nums.size(); 8 | vector v(n,false); 9 | for(auto num:nums){ 10 | if(v[num]) return num; 11 | v[num]=true; 12 | } 13 | return -1; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /deprecated/1INTERVIEW_PREPERATION/STRIVER_SDE_SHEET/ARRAYS/maximum_subarray_sum_KADENE.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/maximum-subarray/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | int maxSubArray(vector& nums) { 7 | int mx_sum=-1; 8 | int sum_upto=-1; 9 | int mx=*max_element(nums.begin(),nums.end()); 10 | for(auto num:nums){ 11 | sum_upto=max(num+sum_upto,num); 12 | mx_sum=max(mx_sum,sum_upto); 13 | } 14 | if(mx<0) return mx; 15 | return mx_sum; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /deprecated/1INTERVIEW_PREPERATION/STRIVER_SDE_SHEET/ARRAYS/rotate_image.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/rotate-image/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | void rotate(vector>& matrix) { 7 | int n=matrix.size(); 8 | int m=matrix.back().size(); 9 | for(int i=0;i0: 4 | for index in range(start,start+domain): 5 | seg[index]=(seg[int(2*index) + 1] | seg[int(2*index) + 2]) 6 | domain=domain//2;start=domain-1 7 | def segUpdate(seg,pos,val): 8 | domain=int(2**ceil(log2(pos)));pos-=1 9 | mypos=pos+ len(seg)//2 10 | seg[mypos]=val 11 | print(mypos) 12 | while mypos>0: 13 | mypos=mypos//2 14 | print(mypos) 15 | seg[mypos]=(seg[int(2*mypos) + 1] | seg[int(2*mypos) + 2]) 16 | -------------------------------------------------------------------------------- /deprecated/PYTHON_MODULES/advance_ds/fenwickTree.py: -------------------------------------------------------------------------------- 1 | 2 | def fenwickGet(ump,index): 3 | n=len(ump);sm=ump[0] 4 | while index>0: 5 | sm+=ump[index] 6 | index-=(index&(-index)) 7 | return sm 8 | pass 9 | def fenwickUpdate(ump,index,delta): 10 | n=len(ump) 11 | if index==0:ump[index]+=delta;return 12 | while index=int(p*p): 7 | if n%p==0:return False 8 | else: p+=1 9 | else:return True 10 | return True 11 | -------------------------------------------------------------------------------- /deprecated/Roadmap/16471439270966898721512438247614.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/om-ashish-soni/Competitive-Programming/9ea864f7588ba9dbe80ccaef8009f9ffd40f9f7f/deprecated/Roadmap/16471439270966898721512438247614.jpg -------------------------------------------------------------------------------- /deprecated/Roadmap/readme.md: -------------------------------------------------------------------------------- 1 | # roadmap 2 | -------------------------------------------------------------------------------- /deprecated/STL/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /deprecated/STL/vector/append_vector.cpp: -------------------------------------------------------------------------------- 1 | template 2 | void appendVector(vector& v,vector& w){ 3 | v.insert(v.end(),w.begin(),w.end()); 4 | } 5 | -------------------------------------------------------------------------------- /deprecated/STL/vector/initializingVectorMatrix.cpp: -------------------------------------------------------------------------------- 1 | vector> mymat{{1,0,0},{0,1,0},{0,0,1}}; 2 | -------------------------------------------------------------------------------- /deprecated/STL/vector/nested_vector_init_method.cpp: -------------------------------------------------------------------------------- 1 | class MatrixExp{ 2 | public : 3 | int n; 4 | vector>& mat; 5 | MatrixExp(int N,vector> &vmat):n(N),mat(vmat){} 6 | MatrixExp(int N):n(N),mat(*new vector>{{1,1},{1,0}}){} 7 | void print(){ 8 | for(auto &row:mat){ 9 | for(auto elem:row) cout< 2 | vector getSubvector(vector& v,int first,int last){ 3 | vector vector(v.begin()+first,v.begin()+last+1); 4 | return vector; 5 | } 6 | -------------------------------------------------------------------------------- /deprecated/STL/vector/vector_initialization_with_constant_space.cpp: -------------------------------------------------------------------------------- 1 | vector vs = vector(5); 2 | vector vi{vector(5,0)}; 3 | 4 | // You can initialize the data members at the point of declaration, but not with () brackets: 5 | 6 | class Foo { 7 | vector name = vector(5); 8 | vector val{vector(5,0)}; 9 | }; 10 | 11 | // Before C++11, you need to declare them first, then initialize them e.g in a contructor 12 | 13 | class Foo { 14 | vector name; 15 | vector val; 16 | public: 17 | Foo() : name(5), val(5,0) {} 18 | }; 19 | -------------------------------------------------------------------------------- /deprecated/WORKSPACE/readme.md: -------------------------------------------------------------------------------- 1 | ## THIS WILL BE MY WORKSPACE 2 | -------------------------------------------------------------------------------- /deprecated/compiler/mingw-get-setup (1).exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/om-ashish-soni/Competitive-Programming/9ea864f7588ba9dbe80ccaef8009f9ffd40f9f7f/deprecated/compiler/mingw-get-setup (1).exe -------------------------------------------------------------------------------- /deprecated/compiler/readme.md: -------------------------------------------------------------------------------- 1 | # install file named *mingw-set-up-(1).exe* 2 | 3 | Uploading .exe file only to avoid inconsistency in installing g++ gnu compiler 4 | 5 | copyright : g++ gnu compiler collections 6 | -------------------------------------------------------------------------------- /deprecated/contests/codechef/ddupp0001/chopsticks.cpp: -------------------------------------------------------------------------------- 1 | // Problem link : https://www.codechef.com/DDUPP0001/problems/TACHSTCK 2 | #include 3 | #define int long long int 4 | #define endl "\n" 5 | using namespace std; 6 | int32_t main() { 7 | int n,k; 8 | cin>>n>>k; 9 | int arr[n]; 10 | for(int i=0;i>arr[i]; 12 | } 13 | sort(arr,arr+n); 14 | int pr=0; 15 | for(int i=0;i 3 | #define int long long 4 | using namespace std; 5 | void solve(){ 6 | int n; 7 | cin>>n; 8 | int arr[n]; 9 | for(int i=0;i>arr[i]; 10 | sort(arr,arr+n); 11 | int mn=LLONG_MAX; 12 | for(int i=1;i>t; 20 | while(t--){ 21 | solve(); 22 | } 23 | // your code goes here 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /deprecated/contests/codechef/ddupp0003/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /deprecated/contests/codechef/ddupp0003/rohanAndSticks.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main1(void) { 4 | int n,m; 5 | scanf("%d %d",&n,&m); 6 | int mn=10000; 7 | 8 | if(n>m) mn=m; 9 | else mn=n; 10 | if(mn%2==0) printf("Kshitij"); 11 | else printf("Rohan"); 12 | printf("\n"); 13 | return 0; 14 | } 15 | int main(){ 16 | int t; 17 | scanf("%d",&t); 18 | while(t--) main1(); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /deprecated/contests/codechef/ddupp0004/readme.md: -------------------------------------------------------------------------------- 1 | # please don't ask me if you are not getting how code works , just search on stack overflow, geeksforgeeks for more details .. 2 | -------------------------------------------------------------------------------- /deprecated/contests/codechef/ddupp0005/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | # DISCLAIMER : 3 | ## DO NOT COPY CODE, JUST TRY TO UNDER STAND LOGIC ... 4 | --- 5 | -------------------------------------------------------------------------------- /deprecated/contests/codechef/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | # DISCLAIMER : 3 | ## DO NOT COPY CODE, JUST TRY TO UNDER STAND LOGIC ... 4 | --- 5 | -------------------------------------------------------------------------------- /deprecated/contests/codeforces/820_div_3/two_elevators.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1729/problem/A 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int a,b,c; 7 | read(a,b,c); 8 | int first=abs(a-1); 9 | int second=abs(b-c)+abs(c-1); 10 | if(first& nums) { 7 | map mp; 8 | for(auto num:nums){ 9 | if(num%2==0) mp[num]++; 10 | } 11 | int mx=-1; 12 | int freq=0; 13 | for(auto &pr:mp){ 14 | if(freq mp; 8 | int ctr=1; 9 | for(auto c:s){ 10 | if(mp.count(c)){ 11 | ctr++; 12 | mp.clear(); 13 | } 14 | mp[c]=true; 15 | } 16 | return ctr; 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /deprecated/contests/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /deprecated/cp topics/binary search/submissions/books.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/279/B 2 | // solution : below code 3 | #include 4 | #define int long long 5 | using namespace std; 6 | 7 | signed main() { 8 | int n,m;cin>>n>>m; 9 | int pref[n+1]; 10 | pref[0]=0; 11 | for(int i=1;i<=n;i++){ 12 | cin>>pref[i]; 13 | pref[i]+=pref[i-1]; 14 | } 15 | int mx=0; 16 | for(int i=1;i<=n;i++){ 17 | int stop=upper_bound(pref+i,pref+n+1,m+pref[i-1])-(pref+i); 18 | mx=max(mx,stop); 19 | } 20 | cout<>n; 9 | int arr[n]; 10 | read(arr,n); 11 | int m;read(m); 12 | int b[m];read(b,m); 13 | F(i,1,n) arr[i]+=arr[i-1]; 14 | // println(arr,n); 15 | F(i,0,m){ 16 | int num=b[i]; 17 | int index=lower_bound(arr,arr+n,num)-arr; 18 | cout<0 && (right&mul)>0){ 13 | ans+=mul; 14 | } 15 | } 16 | mul<<=1; 17 | } 18 | return ans; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /deprecated/cp topics/bit_manip/cirnos_perfect_bitmask_classroom.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1688/problem/A 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | read(n); 8 | bitset<64> bs(n); 9 | int m=0,one=0; 10 | if(n==1){ 11 | cout<<3< match; 15 | F(i,0,64){ 16 | if(bs[i]==1){ 17 | match.pb(i); 18 | } 19 | } 20 | 21 | int ans=(1LL<1){ 23 | cout<>n; 7 | bitset<32> bs(n); 8 | cout<>n>>k; 6 | 7 | int num=n; 8 | for(int i=1;;i++){ 9 | num=(num xor (num%10)); 10 | if(i==k){ 11 | cout<>n>>k; 6 | int arr[n]; 7 | scan(arr,n); 8 | string s; 9 | for(int i=0;i int: 5 | bit=0;ctr=0 6 | while bit<32: 7 | if x%2 != y%2: ctr+=1 8 | x>>=1;y>>=1 9 | bit+=1 10 | return ctr 11 | -------------------------------------------------------------------------------- /deprecated/cp topics/bit_manip/hammingWeight.py: -------------------------------------------------------------------------------- 1 | # problem link : https://leetcode.com/explore/interview/card/top-interview-questions-easy/99/others/565/ 2 | # solution : below code 3 | class Solution: 4 | def hammingWeight(self, n: int) -> int: 5 | bit=0;ctr=0 6 | while bit<32: 7 | ctr+=(n%2) 8 | n>>=1 9 | bit+=1 10 | return ctr 11 | -------------------------------------------------------------------------------- /deprecated/cp topics/bit_manip/non_zero_xor.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://www.codechef.com/submit/NZXOR 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | read(n); 8 | vi v(n); 9 | readv(v); 10 | int key=0; 11 | map mp; 12 | mp[0]++; 13 | int ctr=0; 14 | FEACH(num,v){ 15 | key=(key ^ num); 16 | if(mp.count(key)){ 17 | ctr++; 18 | mp.clear(); 19 | } 20 | mp[key]++; 21 | } 22 | println(ctr); 23 | 24 | 25 | // print answers here 26 | 27 | } 28 | -------------------------------------------------------------------------------- /deprecated/cp topics/bit_manip/or_tuples.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://www.codechef.com/submit/ORTUPLES 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | vi v(3); 7 | readv(v); 8 | SORT(v); 9 | int key=(v[0] & v[1] & v[2]); 10 | bitset<32> bs(key); 11 | int ctr=bs.count(); 12 | vi bits(32,0); 13 | FEACH(num,v){ 14 | bitset<32> mybs(num); 15 | F(k,0,32){ 16 | if(mybs[k]==1) bits[k]++; 17 | } 18 | } 19 | F(k,0,32){ 20 | if(bits[k]==1){ 21 | cout<<0< int: 5 | mask=[];bit=0 6 | while bit<32: 7 | mask.append(n%2) 8 | n>>=1 9 | bit+=1 10 | mask=mask[::-1] 11 | rev=0;mul=1 12 | for digit in mask: 13 | rev+=int(mul*digit) 14 | mul<<=1 15 | return rev 16 | -------------------------------------------------------------------------------- /deprecated/cp topics/bitmask/solved_problems.md: -------------------------------------------------------------------------------- 1 | # And it is not zero 2 | Problem link : https://codeforces.com/contest/1615/problem/B 3 | 4 | Solution : https://github.com/om-ashish-soni/Competitive-Programming/blob/main/cp%20topics/bitmask/submissions/and_it_is_not_zero.md 5 | -------------------------------------------------------------------------------- /deprecated/cp topics/bitmask/submissions/and_it_is_not_zero.md: -------------------------------------------------------------------------------- 1 | # Solution : 2 | https://github.com/om-ashish-soni/Competitive-Programming/blob/main/contests/codeforces/codeforces_global_round_18/submissions/and_it_is_not_zero.cpp 3 | -------------------------------------------------------------------------------- /deprecated/cp topics/brute_force/sequence_with_digits.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1355/A 2 | // solution : below code 3 | 4 | int calcaddon(int n){ 5 | int mx=0,mn=9; 6 | while(n){ 7 | int digit=n%10; 8 | mx=max(mx,digit); 9 | mn=min(mn,digit); 10 | n/=10; 11 | } 12 | return mx*mn; 13 | } 14 | void solve(int t){ 15 | //shree ganeshay namah 16 | int n,k; 17 | read(n,k); 18 | k--; 19 | while(k--){ 20 | int addon=calcaddon(n); 21 | if(addon==0) break; 22 | n+=addon; 23 | } 24 | println(n); 25 | } 26 | -------------------------------------------------------------------------------- /deprecated/cp topics/constructive/moderate_modular_mode.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1603/problem/B 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | // println("shree ganeshay namah"); 7 | int a,b; 8 | read(a,b); 9 | if(a>b){ 10 | cout<>n>>k; 6 | if(n&1){ 7 | if(k==1){ 8 | print(true); 9 | for(int i=0;i>& matrix, int target) { 6 | int m=matrix.size(),n=matrix[0].size(); 7 | int i=0,j=n-1; 8 | while(i=0){ 9 | if(matrix[i][j]==target) return true; 10 | if(matrix[i][j]bp) println("BOB"); 25 | else println("ALICE"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /deprecated/cp topics/greedy/submissions/alternating_subsequence.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1343/C 2 | // solution : below code 3 | // time taken : 4 m 17 s 4 | 5 | void solve(int t){ 6 | //shree ganeshay namah 7 | int n; 8 | cin>>n; 9 | int arr[n]; 10 | read(arr,n); 11 | int sm=0; 12 | vi v; 13 | v.pb(arr[0]); 14 | F(i,0,n){ 15 | if(v.back()>0 && arr[i]>0){ 16 | v.back()=max(v.back(),arr[i]); 17 | } 18 | else if(v.back()<0 && arr[i]<0){ 19 | v.back()=max(v.back(),arr[i]); 20 | } 21 | else{ 22 | v.pb(arr[i]); 23 | } 24 | } 25 | FEACH(num,v){ 26 | sm+=num; 27 | } 28 | println(sm); 29 | } 30 | -------------------------------------------------------------------------------- /deprecated/cp topics/greedy/submissions/and_it_is_no_zero.md: -------------------------------------------------------------------------------- 1 | # Solution : 2 | https://github.com/om-ashish-soni/Competitive-Programming/blob/main/contests/codeforces/codeforces_global_round_18/submissions/and_it_is_not_zero.cpp 3 | -------------------------------------------------------------------------------- /deprecated/cp topics/greedy/submissions/close_the_gap.md: -------------------------------------------------------------------------------- 1 | # Solution : 2 | https://github.com/om-ashish-soni/Competitive-Programming/blob/main/contests/codeforces/codeforces_global_round_18/submissions/closing_the_gap.cpp 3 | -------------------------------------------------------------------------------- /deprecated/cp topics/greedy/submissions/find_the_array.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1463/problem/B 2 | // solution : below code 3 | 4 | void solve(){ 5 | int n;cin>>n;int arr[n];scan(arr,n); 6 | int b[n]; 7 | int c[n]; 8 | 9 | int db=0,dc=0,sm=0; 10 | for(int i=0;i& piles) { 6 | sort(piles.begin(),piles.end()); 7 | int sum=0; 8 | int left=0,right=piles.size()-1; 9 | while(left stk; 7 | int moves=0; 8 | for(char c:s){ 9 | if(c=='('){ 10 | stk.push(c); 11 | }else{ 12 | if(stk.size()>0){ 13 | stk.pop(); 14 | }else moves++; 15 | } 16 | } 17 | moves+=stk.size(); 18 | return moves; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /deprecated/cp topics/greedy/submissions/partitioning_into_minimum_number_of_deci-binary_numbers.cpp: -------------------------------------------------------------------------------- 1 | // Problem link : https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers/ 2 | // Problem type : greedy 3 | class Solution { 4 | public: 5 | int minPartitions(string s) { 6 | int ans=(int)(*max_element(s.begin(),s.end())-48); 7 | return ans; 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /deprecated/cp topics/greedy/submissions/table_decoration.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/478/C 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | // println("shree ganeshay namah"); 7 | // println("shreepad rajam sharanam prapadhye"); 8 | 9 | vector v(3); 10 | readv(v); 11 | SORT(v); 12 | REVERSE(v); 13 | if(v[0]>=2*(v[1]+v[2])){ 14 | cout<=(k*(k+1))/2)); 11 | return; 12 | 13 | 14 | // print answers here 15 | 16 | } 17 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/chewbacca_and_number.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/514/A 2 | // solution : below code 3 | // time taken : 5 m 32 s 4 | 5 | void solve(int t){ 6 | //shree ganeshay namah 7 | string s;read(s); 8 | if(s[0]=='9' || s[0]<='4') ; 9 | else s[0]='0'+'9'-s[0]; 10 | int n=s.size(); 11 | F(i,1,n){ 12 | if(s[i]>'4'){ 13 | s[i]='0'+('9'-s[i]); 14 | } 15 | } 16 | println(s); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/combinatorics/ball_in_berland.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1475/C 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | // println("shree ganeshay namah"); 7 | int x,y,k; 8 | read(x,y,k); 9 | vi a(k),b(k); 10 | readv(a); 11 | readv(b); 12 | map mp1,mp2; 13 | F(i,0,k){ 14 | mp1[a[i]]++; 15 | mp2[b[i]]++; 16 | } 17 | int ctr=0; 18 | F(i,0,k){ 19 | int addon=k-mp1[a[i]]-mp2[b[i]]+1; 20 | ctr+=addon; 21 | } 22 | ctr/=2; 23 | println(ctr); 24 | 25 | // print answers here 26 | 27 | } 28 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/dungeon.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1463/problem/A 2 | // solution : below code 3 | 4 | void solve(){ 5 | int a,b,c;cin>>a>>b>>c; 6 | int mn=min(a,min(b,c)); 7 | int total=a+b+c; 8 | return print((total%9==0)&&(mn>=total/9)); 9 | } 10 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/even_odd/odd_selection.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1363/A 2 | // solution : below code 3 | // time taken : 22 m 37 s 4 | 5 | void solve(int t){ 6 | //shree ganeshay namah 7 | int n,x; 8 | cin>>n>>x; 9 | int arr[n]; 10 | read(arr,n); 11 | int odd=0,even=0; 12 | F(i,0,n){ 13 | if(arr[i]%2 == 1) odd++; 14 | else even++; 15 | } 16 | if(odd==0) YESNO2(false); 17 | else{ 18 | odd--; 19 | x--; 20 | int cap=(odd/2)*2; 21 | if(x%2==0) x=max(0LL,x-cap); 22 | else x=max(1LL,x-cap); 23 | x-=even; 24 | if(x<=0) YESNO2(true); 25 | else{ 26 | YESNO2(false); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/geometry/amr_and_pins.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/507/B 2 | // solution : below code 3 | #include 4 | #define int long long 5 | using namespace std; 6 | 7 | 8 | void solve(){ 9 | int r,a,b,c,d; 10 | cin>>r>>a>>b>>c>>d; 11 | double numer=sqrt(((c-a)*(c-a) + (d-b)*(d-b))); 12 | cout<>t; 17 | while(t--){ 18 | solve(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/lcm_gcd/all_are_same.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1593/D1 2 | // solution : below code 3 | 4 | 5 | #define GCD(a,b) (__gcd((a),(b))) 6 | void reject(){ 7 | cout<<-1<>n>>k; 6 | int start=2; 7 | while(k%start==0){ 8 | start++; 9 | } 10 | int num=start; 11 | for(int i=0;i &arr){ 7 | int hcf=0; 8 | FEACH(num,arr){ 9 | hcf=GCD(hcf,num); 10 | } 11 | return hcf; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/lcm_gcd/two_numbers.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://www.codechef.com/problems/TWONUMBERS 2 | // solution : below code 3 | 4 | int gcdlcmdiff(int a,int b){ 5 | return LCM(a,b)-GCD(a,b); 6 | } 7 | void solve(int t){ 8 | //shree ganeshay namah 9 | int n;read(n); 10 | if(n<=2){ 11 | cout<<0< mp; 10 | F(i,0,n){ 11 | sm+=arr[i]; 12 | // mp[arr[i]]=true; 13 | } 14 | bool flag=false; 15 | // cout< int: 5 | sm=sum(nums) 6 | n=len(nums) 7 | total=(n*(n+1))//2 8 | return total-sm 9 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/moderate_modular_mode.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1603/problem/B 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | // println("shree ganeshay namah"); 7 | int a,b; 8 | read(a,b); 9 | if(a>b){ 10 | cout<r-c: 7 | print("YES") 8 | else:print("NO") 9 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/server_trouble.py: -------------------------------------------------------------------------------- 1 | # problem link : https://www.codechef.com/START2B/problems/SVRT 2 | # solution : below code 3 | 4 | from sys import stdin,stdout 5 | from math import log2,ceil,floor 6 | input=stdin.readline 7 | def printend(*argv): 8 | output="" 9 | for arg in argv: output+=str(arg)+" " 10 | stdout.write(output) 11 | def print(*argv): 12 | output="" 13 | for arg in argv: output+=str(arg)+" " 14 | stdout.write(output+"\n") 15 | # for _ in range(1): 16 | for _ in range(int(input())): 17 | n,m=map(int,input().split()) 18 | mod=n%m 19 | if mod==0:mod=m 20 | print(ceil(n/m),mod) 21 | 22 | 23 | -------------------------------------------------------------------------------- /deprecated/cp topics/math/ternary_xor.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1328/C 2 | // solution : below code 3 | // time taken : 8 m 11 s 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | string s; 8 | read(n); 9 | read(s); 10 | int index=n; 11 | string a,b; 12 | F(i,0,n) a+='0'; 13 | F(i,0,n) b+='0'; 14 | F(i,0,n){ 15 | if(s[i]=='1'){ 16 | index=i; 17 | a[i]='1'; 18 | break; 19 | } 20 | } 21 | for(int i=0;i 4 | using namespace std; 5 | 6 | int main() { 7 | int n,m;cin>>n>>m; 8 | int steps=0; 9 | while(m>n && m>1){ 10 | if(m%2) m+=1; 11 | else m/=2; 12 | steps++; 13 | } 14 | steps+=(n-m); 15 | cout< ump; 11 | vc singles; 12 | F(i,0,n){ 13 | read(v[i]); 14 | if(v[i].size()==1){ 15 | singles.pb(v[i][0]); 16 | } 17 | FEACH(c,v[i]){ 18 | ump[c]++; 19 | } 20 | } 21 | FEACH(c,singles){ 22 | if(ump[c] % 2==1){ 23 | println(c);return; 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /deprecated/cp topics/permutation/element_extermination.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1375/C 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | read(n); 8 | int a[n]; 9 | read(a,n); 10 | if(a[0]& nums, int k) { 7 | int n=nums.size(); 8 | int ctr=0; 9 | unordered_map hash; 10 | hash[0]=1; 11 | int sm=0; 12 | for(int i=0;imn){ 14 | char c=s[i]; 15 | if(c<'9') c++; 16 | op+=c; 17 | } 18 | else{ 19 | op+=s[i]; 20 | mn=min(mn,s[i]); 21 | } 22 | } 23 | SORT(op); 24 | println(op); 25 | // print answers here 26 | 27 | } 28 | -------------------------------------------------------------------------------- /deprecated/cp topics/sorting/young_explorers.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1355/B 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | read(n); 8 | int a[n]; 9 | read(a,n); 10 | SORTA(a,n); 11 | int group=0; 12 | int index=0; 13 | int content=0; 14 | F(i,0,n){ 15 | if(content+1>=a[i]){ 16 | group++; 17 | content=0; 18 | }else{ 19 | content++; 20 | } 21 | } 22 | println(group); 23 | } 24 | -------------------------------------------------------------------------------- /deprecated/cp topics/special/fibonacci_words.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1505/C 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | // println("shree ganeshay namah"); 7 | string s; 8 | read(s); 9 | int n=s.size(); 10 | F(i,2,n){ 11 | char a=s[i-2]; 12 | char b=s[i-1]; 13 | char c=(a-'A'+b-'A')%26+'A'; 14 | // cout<bp) println("BOB"); 25 | else println("ALICE"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /deprecated/cp topics/string_and_pattern_matching/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /deprecated/cp topics/two_pointer/make_it_good.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1385/C 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n,x; 7 | read(n); 8 | int a[n]; 9 | read(a,n); 10 | vi v(n,0); 11 | int peak=n-1; 12 | int r=n-1; 13 | int l=n-1; 14 | for(int i=n-2;i>=0;i--){ 15 | if(a[i]>=a[i+1]){ 16 | peak=i; 17 | }else break; 18 | } 19 | l=peak; 20 | for(int i=peak-1;i>=0;i--){ 21 | if(a[i]<=a[i+1]){ 22 | l=i; 23 | }else break; 24 | } 25 | println(l); 26 | } 27 | -------------------------------------------------------------------------------- /deprecated/cp topics/two_pointer/sorted_adjacent_differences.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1339/B 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n,x; 7 | read(n); 8 | int a[n]; 9 | read(a,n); 10 | SORTA(a,n); 11 | int l=0,r=n-1; 12 | vi v(n); 13 | F(i,0,n){ 14 | if(i%2 == 0){ 15 | // print(a[l]);l++; 16 | v[i]=a[l];l++; 17 | }else{ 18 | // print(a[r]);r--; 19 | v[i]=a[r];r--; 20 | } 21 | } 22 | // println(""); 23 | reverse(ALL(v)); 24 | printv(v); 25 | } 26 | -------------------------------------------------------------------------------- /deprecated/data structure contribution/ARRAY/fin.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findDuplicate(vector& nums,int i=0) { 4 | if(!i) sort(nums.begin(),nums.end()); 5 | return (nums[i] == nums[i+1])?(nums[i]):(findDuplicate(nums,1+i)); 6 | } 7 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/ARRAY/findDuplicates_in_array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findDuplicate(vector& nums) { 4 | unordered_map freq; 5 | int occurance; 6 | 7 | for(auto num:nums){ 8 | occurance=++freq[num]; 9 | if(occurance-1) return num; 10 | } 11 | return occurance;//this will not be executed any more 12 | } 13 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/ARRAY/findDuplicates_in_array_betterApproach.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findDuplicate(vector& nums,int i=0) { 4 | if(!i) sort(nums.begin(),nums.end()); 5 | return (nums[i] == nums[i+1])?(nums[i]):(findDuplicate(nums,1+i)); 6 | } 7 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/ARRAY/global_and_local_inversions.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/global-and-local-inversions/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | bool isIdealPermutation(vector& nums) { 7 | int n=nums.size(); 8 | for(int i=0;inums[i+1]){ 10 | swap(nums[i],nums[i+1]); 11 | i++; 12 | } 13 | } 14 | 15 | for(int i=0;inums[i+1]) return false; 17 | } 18 | return true; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /deprecated/data structure contribution/ARRAY/max_Subarray_Sum_MOST_EFFICIENT_(OPTIMUM).cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int maxSubArray(vector& nums) { 5 | int mx=0,mn=INT_MIN; 6 | mn=max(mn,*(nums.end()-1)); 7 | mx=max(mx,*(nums.end()-1)); 8 | for(int i=nums.size()-2;i>=0;i--){ 9 | mn=max(mn,nums[i]); 10 | nums[i]+=max(0,nums[i+1]); 11 | mx=max(mx,nums[i]); 12 | } 13 | if(mn<1) return mn; 14 | if(mx==0 && mn<0) mx=mn; 15 | return mx; 16 | } 17 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/ARRAY/topK_frequent_elements.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector topKFrequent(vector& nums, int k) { 4 | unordered_map ump; 5 | set> s; 6 | stack stk; 7 | vector v; 8 | for(auto num:nums) ump[num]++; 9 | for(auto it=ump.begin();it!=ump.end();it++) s.insert({it->second,it->first}); 10 | for(auto it=s.begin();it!=s.end();++it) stk.push(it->second); 11 | while(k--){ 12 | int top=stk.top(); 13 | stk.pop(); 14 | v.push_back(top); 15 | } 16 | return v; 17 | } 18 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/GRAPH/find_Center_Of_Star_Graph.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findCenter(vector>& edges) { 4 | vector center(edges.size()+2,0); 5 | for(auto &v:edges){ center[v[0]]++,center[v[1]]++; } 6 | for(int i=1;i<=edges.size()+1;i++) if(center[i]==edges.size()) return i; 7 | return 0; 8 | } 9 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/GRAPH/find_Judge.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findJudge(int n, vector>& trust) { 4 | vector follower(n+1,0),following(n+1,0); 5 | for(auto &v:trust){ 6 | follower[v[1]]++; 7 | following[v[0]]++; 8 | } 9 | for(int i=1;i<=n;i++){ 10 | if(following[i]== 0 && follower[i] == n-1) return i; 11 | } 12 | return -1; 13 | } 14 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/GRAPH/find_smallest_set_of_vertices.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector findSmallestSetOfVertices(int n, vector>& edges) { 4 | vector v1(n,1),v2; 5 | for(auto &v:edges){ 6 | v1[v[1]]=0; 7 | } 8 | for(int i=0;inext) return false; 13 | ListNode* slow,*fast; 14 | fast=slow=head; 15 | while(fast && fast->next){ 16 | slow=slow->next; 17 | fast=fast->next->next; 18 | if(slow == fast) return true; 19 | } 20 | return false; 21 | } 22 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/STACK/validateParanthesis.py: -------------------------------------------------------------------------------- 1 | # problem link : https://leetcode.com/explore/interview/card/top-interview-questions-easy/99/others/721/ 2 | # solution : below code 3 | class Solution: 4 | def isValid(self, s: str) -> bool: 5 | couple={} 6 | couple[')']='(' 7 | couple[']']='[' 8 | couple['}']='{' 9 | stk=[] 10 | for ch in s: 11 | if ch in couple: 12 | if len(stk)>0 and stk[-1]==couple[ch]:stk.pop() 13 | else: return False 14 | else: 15 | stk.append(ch) 16 | return len(stk)==0 17 | -------------------------------------------------------------------------------- /deprecated/data structure contribution/STRING/sortCharacters_by_frequency.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | static bool comp(pair p1,pair p2){ 4 | return p1.first>p2.first; 5 | } 6 | string frequencySort(string s) { 7 | unordered_map ump; 8 | vector> v; 9 | for(int i=0;isecond,it->first}); 11 | sort(v.begin(),v.end(),comp); 12 | s=""; 13 | for(auto elem:v) for(int i=0;i& nums) { 4 | unordered_map ump; 5 | for(auto &num:nums){ 6 | if(ump[num]) return true; 7 | ump[num]=true; 8 | } 9 | return false; 10 | } 11 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/Sliding Window/containsNearByDuplicates.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool containsNearbyDuplicate(vector& nums, int k) { 4 | unordered_map> ump; 5 | int index=0; 6 | for(auto &num:nums) ump[num].push_back(index++); 7 | for(auto &num:nums){ 8 | vector &v=ump[num]; 9 | for(int j=1;jval=root->val; 5 | newTree->left=copyTree(root->left,newTree->left); 6 | newTree->right=copyTree(root->right,newTree->right); 7 | return newTree; 8 | } -------------------------------------------------------------------------------- /deprecated/data structure contribution/TREE/tree_for_cp/readme.md: -------------------------------------------------------------------------------- 1 | # these problems are tree for cp on the sites like codeforces 2 | -------------------------------------------------------------------------------- /deprecated/data structure contribution/disjointSet/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | ## ds is verry nice concept , used in kruskal , job seq and so on , sometimes in bit manip also 3 | --- 4 | -------------------------------------------------------------------------------- /deprecated/data structure contribution/dp/climb_Stairs_memo.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int climbStairs1(int n,int memo[]){ 4 | if(n==0) return 0; 5 | if(0 != memo[n]) return memo[n]; 6 | memo[n]=climbStairs1(n-1,memo)+climbStairs1(n-2,memo); 7 | return memo[n]; 8 | } 9 | int climbStairs(int n) { 10 | int memo[46]={0}; 11 | memo[1]=1; 12 | memo[2]=2; 13 | return climbStairs1(n,memo); 14 | } 15 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/dp/fibonacci_memo.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int fib(int n,int *memo=NULL) { 4 | if(n==0 || n==1) return n; 5 | if(!memo) memo=(int *)calloc(n+1,sizeof(int)); 6 | if(memo[n] != 0) return memo[n]; 7 | memo[n]=fib(n-1,memo)+fib(n-2,memo); 8 | return memo[n]; 9 | } 10 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/dp/longest_Increasing_Subsequence_LOG(N) approach.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int lengthOfLIS(vector& nums) { 5 | vector memo; 6 | for(auto num:nums){ 7 | auto found=lower_bound(memo.begin(),memo.end(),num); 8 | if(found==memo.end()) memo.push_back(num); 9 | else *found=num; 10 | } 11 | return memo.size(); 12 | } 13 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/dp/max_Subarray_Sum_MOST_EFFICIENT_(OPTIMUM).cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int maxSubArray(vector& nums) { 5 | int mx=0,mn=INT_MIN; 6 | mn=max(mn,*(nums.end()-1)); 7 | mx=max(mx,*(nums.end()-1)); 8 | for(int i=nums.size()-2;i>=0;i--){ 9 | mn=max(mn,nums[i]); 10 | nums[i]+=max(0,nums[i+1]); 11 | mx=max(mx,nums[i]); 12 | } 13 | if(mn<1) return mn; 14 | if(mx==0 && mn<0) mx=mn; 15 | return mx; 16 | } 17 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/dp/min_Steps_required_To_jump_TAB.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int jump(vector& nums) { 4 | vector v(nums.size(),INT_MAX); 5 | v[0]=0; 6 | for(int i=0;i,int> &memo){ 4 | if(r==0 || r==n) return 1; 5 | if(memo[{n,r}]) return memo[{n,r}]; 6 | memo[{n,r}]=ncr(n-1,r-1,memo)+ncr(n-1,r,memo); 7 | return memo[{n,r}]; 8 | } 9 | vector getRow(int rowIndex) { 10 | map,int> memo; 11 | vector v; 12 | for(int i=0;i<=rowIndex;i++){ 13 | v.push_back(ncr(rowIndex,i,memo)); 14 | } 15 | return v; 16 | } 17 | }; -------------------------------------------------------------------------------- /deprecated/data structure contribution/dp/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /deprecated/data structure contribution/dp/test.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int fib(int n,int *memo=NULL) { 4 | if(n==0 || n==1) return n; 5 | int *tab=(int *)calloc(n+2,sizeof(int)); 6 | tab[0]=0; 7 | tab[1]=1; 8 | for(int i=0;i>n; 7 | string s;cin>>s; 8 | int sm=0; 9 | map mp; 10 | for(int i=0;i int: 6 | if len(nums)==1: return nums[0] 7 | if len(nums)==2: return max(nums) 8 | dp=copy.deepcopy(nums) 9 | dp[2]+=dp[0] 10 | n=len(nums) 11 | for index in range(3,n): 12 | dp[index]+=max(dp[index-2],dp[index-3]) 13 | return max(dp) 14 | -------------------------------------------------------------------------------- /deprecated/dynamic programming/longest_Increasing_Subsequence_LOG(N) approach.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int lengthOfLIS(vector& nums) { 5 | vector memo; 6 | for(auto num:nums){ 7 | auto found=lower_bound(memo.begin(),memo.end(),num); 8 | if(found==memo.end()) memo.push_back(num); 9 | else *found=num; 10 | } 11 | return memo.size(); 12 | } 13 | }; -------------------------------------------------------------------------------- /deprecated/dynamic programming/max_Subarray_Sum_MOST_EFFICIENT_(OPTIMUM).cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int maxSubArray(vector& nums) { 5 | int mx=0,mn=INT_MIN; 6 | mn=max(mn,*(nums.end()-1)); 7 | mx=max(mx,*(nums.end()-1)); 8 | for(int i=nums.size()-2;i>=0;i--){ 9 | mn=max(mn,nums[i]); 10 | nums[i]+=max(0,nums[i+1]); 11 | mx=max(mx,nums[i]); 12 | } 13 | if(mn<1) return mn; 14 | if(mx==0 && mn<0) mx=mn; 15 | return mx; 16 | } 17 | }; -------------------------------------------------------------------------------- /deprecated/dynamic programming/min_Cost_Climbing_Stairs.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minCostClimbingStairs(vector& cost) { 4 | vector costs; 5 | costs.push_back(0); 6 | for(auto money:cost) costs.push_back(money); 7 | costs.push_back(0); 8 | vector v(costs.size(),INT_MAX); 9 | v[0]=0; 10 | for(int i=0;i& nums) { 4 | vector v(nums.size(),INT_MAX); 5 | v[0]=0; 6 | for(int i=0;i,int> &memo){ 4 | if(r==0 || r==n) return 1; 5 | if(memo[{n,r}]) return memo[{n,r}]; 6 | memo[{n,r}]=ncr(n-1,r-1,memo)+ncr(n-1,r,memo); 7 | return memo[{n,r}]; 8 | } 9 | vector getRow(int rowIndex) { 10 | map,int> memo; 11 | vector v; 12 | for(int i=0;i<=rowIndex;i++){ 13 | v.push_back(ncr(rowIndex,i,memo)); 14 | } 15 | return v; 16 | } 17 | }; -------------------------------------------------------------------------------- /deprecated/dynamic programming/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /deprecated/dynamic programming/test.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int fib(int n,int *memo=NULL) { 4 | if(n==0 || n==1) return n; 5 | int *tab=(int *)calloc(n+2,sizeof(int)); 6 | tab[0]=0; 7 | tab[1]=1; 8 | for(int i=0;i segTree; 7 | List arr; 8 | int n; 9 | // public SegmentTree(L) 10 | } 11 | -------------------------------------------------------------------------------- /deprecated/java_modules/com/library/mathlib/Quadratic.java: -------------------------------------------------------------------------------- 1 | package com.library.mathlib; 2 | 3 | public class Quadratic{ 4 | public static double[] solve(int a,int b,int c){ 5 | double dr=Math.sqrt(b*b-4*a*c); 6 | double[] roots={ 7 | (-b + dr )/ 2 * a, 8 | (-b - dr )/ 2 * a 9 | }; 10 | return roots; 11 | } 12 | } -------------------------------------------------------------------------------- /deprecated/local_machine_stuff/codeforces/121/A.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/om-ashish-soni/Competitive-Programming/9ea864f7588ba9dbe80ccaef8009f9ffd40f9f7f/deprecated/local_machine_stuff/codeforces/121/A.exe -------------------------------------------------------------------------------- /deprecated/local_machine_stuff/codeforces/121/error.txt: -------------------------------------------------------------------------------- 1 | time taken : 0.016 secs 2 | -------------------------------------------------------------------------------- /deprecated/local_machine_stuff/codeforces/121/input.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 4 3 | 3 1 2 1 4 | 6 5 | 2 2 2 1 1 1 6 | 8 7 | 6 3 6 3 6 3 6 6 8 | 1 9 | 1 -------------------------------------------------------------------------------- /deprecated/local_machine_stuff/codeforces/121/output.txt: -------------------------------------------------------------------------------- 1 | 0 2 | 2 3 | 0 4 | 0 5 | -------------------------------------------------------------------------------- /deprecated/local_machine_stuff/codeforces/761/A.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/om-ashish-soni/Competitive-Programming/9ea864f7588ba9dbe80ccaef8009f9ffd40f9f7f/deprecated/local_machine_stuff/codeforces/761/A.exe -------------------------------------------------------------------------------- /deprecated/local_machine_stuff/codeforces/761/inputf.in: -------------------------------------------------------------------------------- 1 | 7 2 | abacaba 3 | abc 4 | cccba 5 | acb 6 | dbsic 7 | bac 8 | abracadabra 9 | abc 10 | dddddddddddd 11 | cba 12 | bbc 13 | abc 14 | ac 15 | abc 16 | -------------------------------------------------------------------------------- /deprecated/local_machine_stuff/codeforces/761/outputf.in: -------------------------------------------------------------------------------- 1 | aaaacbb 2 | abccc 3 | bcdis 4 | aaaaacbbdrr 5 | dddddddddddd 6 | bbc 7 | ac 8 | -------------------------------------------------------------------------------- /deprecated/local_machine_stuff/readme.md: -------------------------------------------------------------------------------- 1 | ## THIS IS MY LOCAL MACHINE CP STUFF 2 | -------------------------------------------------------------------------------- /deprecated/math/chineseRemainderThm.cpp: -------------------------------------------------------------------------------- 1 | int chineseRem(int arr[],int rem[],int n){ 2 | int prod=1,res=0; 3 | for(int i=0;i totient; 6 | EulerTotient(int N){ 7 | this->n=N+1; 8 | totient.resize(n); 9 | for(int i=0;i& factors){ 3 | double sqroot=sqrt(n); 4 | factors.push_back(1); 5 | for(int i=2;i<=sqroot;i++){ 6 | if(n%i == 0){ 7 | factors.push_back(i); 8 | if(n/i != i){ 9 | factors.push_back(n/i); 10 | } 11 | } 12 | } 13 | factors.push_back(n); 14 | sort(factors.begin(),factors.end()); 15 | } 16 | -------------------------------------------------------------------------------- /deprecated/math/gcd_lcm.cpp: -------------------------------------------------------------------------------- 1 | //lcm and gcd 2 | pair extended_gcd(int a,int b){ 3 | if(b==0) return{1,1}; 4 | pair pr=extended_gcd(b,a%b); 5 | return {pr.second,pr.first-(a/b)*pr.second}; 6 | } 7 | int hcf(int a,int b){ 8 | if(a==0 || b==0) return max(a,b); 9 | pair pr=extended_gcd(a,b); 10 | return (a*pr.first + b*pr.second); 11 | } 12 | int lcm(int a,int b){ 13 | return (a*b)/(__gcd(a,b)); 14 | } 15 | int gcd(int a,int b){ 16 | return __gcd(a,b); 17 | } 18 | -------------------------------------------------------------------------------- /deprecated/math/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | ## good to know 3 | - at max a number can have O(2*sqrt(n)-1) factors , which number of factors' upper bound . 4 | --- 5 | -------------------------------------------------------------------------------- /deprecated/math/roundOfInPowerOf2.cpp: -------------------------------------------------------------------------------- 1 | // roundOf 2 | int roundOf(int n){ 3 | return (int)pow(2,floor(log2(n))); 4 | } 5 | -------------------------------------------------------------------------------- /deprecated/modules/LANG_UTILITY/transformer_oop.cpp: -------------------------------------------------------------------------------- 1 | class Transformer{ 2 | public: 3 | static int ctoi(char c){ 4 | return c-'0'; 5 | } 6 | static char itoc(int i){ 7 | return i-0+'0'; 8 | } 9 | static char tolower(char c){ 10 | int ascii=(int)(c-'A'); 11 | char c1=(char)(ascii+'a'); 12 | return c1; 13 | } 14 | static char toupper(char c){ 15 | int ascii=(int)(c-'a'); 16 | char c1=(char)(ascii+'A'); 17 | return c1; 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /deprecated/modules/MATH/Calc/calc_oop.cpp: -------------------------------------------------------------------------------- 1 | class Calc{ 2 | public: 3 | static double eval(double a,double b,char op){ 4 | double res=0.0; 5 | if(op=='+') res=a+b; 6 | else if(op=='-') res=a-b; 7 | else if(op=='*') res=a*b; 8 | else if(op=='/') res=a/b; 9 | 10 | return res; 11 | } 12 | static int modulo(int a,int b){ 13 | return a%b; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /deprecated/modules/MATH/EulerTotient.cpp: -------------------------------------------------------------------------------- 1 | 2 | class EulerTotient{ 3 | public : 4 | int n; 5 | vector totient; 6 | EulerTotient(int N){ 7 | this->n=N+1; 8 | totient.resize(n); 9 | for(int i=0;i fact; 4 | long long mod=(1e9)+7; 5 | long long sz=0; 6 | Factorial(long long n,long long mod=(int)(1e9+7)){ 7 | this->sz=n+10; 8 | this->fact.resize(sz); 9 | this->mod=mod; 10 | init(); 11 | } 12 | void init(){ 13 | fact[0]=1; 14 | for(int i=1;ifact[n]; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /deprecated/modules/MATH/chineseRemainderThm.cpp: -------------------------------------------------------------------------------- 1 | int chineseRem(int arr[],int rem[],int n){ 2 | int prod=1,res=0; 3 | for(int i=0;i& factors){ 3 | double sqroot=sqrt(n); 4 | factors.push_back(1); 5 | for(int i=2;i<=sqroot;i++){ 6 | if(n%i == 0){ 7 | factors.push_back(i); 8 | if(n/i != i){ 9 | factors.push_back(n/i); 10 | } 11 | } 12 | } 13 | factors.push_back(n); 14 | sort(factors.begin(),factors.end()); 15 | } -------------------------------------------------------------------------------- /deprecated/modules/MATH/lcm_gcd.cpp: -------------------------------------------------------------------------------- 1 | //lcm and gcd 2 | pair extended_gcd(int a,int b){ 3 | if(b==0) return{1,1}; 4 | pair pr=extended_gcd(b,a%b); 5 | return {pr.second,pr.first-(a/b)*pr.second}; 6 | } 7 | int hcf(int a,int b){ 8 | if(a==0 || b==0) return max(a,b); 9 | pair pr=extended_gcd(a,b); 10 | return (a*pr.first + b*pr.second); 11 | } 12 | int lcm(int a,int b){ 13 | return (a*b)/(__gcd(a,b)); 14 | } 15 | int gcd(int a,int b){ 16 | return __gcd(a,b); 17 | } -------------------------------------------------------------------------------- /deprecated/modules/MATH/matrixModule/printMatrix.cpp: -------------------------------------------------------------------------------- 1 | void printMatrix(vector>& vmatrix){ 2 | for(auto &rowv:vmatrix){ 3 | for(auto elem:rowv) cout< pals; 2 | bool isPalindrome(string &s){ 3 | string copy=s; 4 | reverse(begin(copy),end(copy)); 5 | return s==copy; 6 | } 7 | string intToString(int n){ 8 | ostringstream ostr; 9 | ostr<>num; 5 | return num; 6 | } 7 | -------------------------------------------------------------------------------- /deprecated/modules/RANDOM_NUMBER/random_number.cpp: -------------------------------------------------------------------------------- 1 | // This header file is 2 | // for time 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | // Using the constructor to 11 | // initialize with a seed value 12 | mt19937 mt(time(nullptr)); 13 | 14 | // Operator() is used to 15 | // generate random numbers 16 | cout << mt() << '\n'; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /deprecated/modules/TIME/checkTimeout.cpp: -------------------------------------------------------------------------------- 1 | // check timeout 2 | void checkTimeout(){ 3 | double tm=(float)clock()/CLOCKS_PER_SEC; 4 | if(tm>=2){ 5 | cerr<<"Time limit exeeded"< List[List[int]]: 5 | lst=[[1]];numRows-=1 6 | while numRows>0: 7 | prev=lst[-1] 8 | curr=[1] 9 | for index in range(1,len(prev)): 10 | curr.append(prev[index]+prev[index-1]) 11 | curr.append(1) 12 | lst.append(curr) 13 | numRows-=1 14 | return lst 15 | -------------------------------------------------------------------------------- /deprecated/starterTemplate/checkTimeOut.cpp: -------------------------------------------------------------------------------- 1 | // check timeout 2 | void checkTimeout(){ 3 | double tm=(float)clock()/CLOCKS_PER_SEC; 4 | if(tm>=2){ 5 | cerr<<"Time limit exeeded"< 2 | using namespace std; 3 | int main(){ 4 | cout<<"on github, praying ssv"< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/convolution: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/dsu: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/fenwicktree: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/internal_bit: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/internal_math: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/internal_queue: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/internal_scc: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/internal_type_traits: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/lazysegtree: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/math: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/maxflow: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/mincostflow: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/modint: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/scc: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/segtree: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/string: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/atcoder_library/atcoder/twosat: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /modules/cpp-modules/LANG_UTILITY/transformer_oop.cpp: -------------------------------------------------------------------------------- 1 | class Transformer{ 2 | public: 3 | static int ctoi(char c){ 4 | return c-'0'; 5 | } 6 | static char itoc(int i){ 7 | return i-0+'0'; 8 | } 9 | static char tolower(char c){ 10 | int ascii=(int)(c-'A'); 11 | char c1=(char)(ascii+'a'); 12 | return c1; 13 | } 14 | static char toupper(char c){ 15 | int ascii=(int)(c-'a'); 16 | char c1=(char)(ascii+'A'); 17 | return c1; 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /modules/cpp-modules/MATH/Calc/calc_oop.cpp: -------------------------------------------------------------------------------- 1 | class Calc{ 2 | public: 3 | static double eval(double a,double b,char op){ 4 | double res=0.0; 5 | if(op=='+') res=a+b; 6 | else if(op=='-') res=a-b; 7 | else if(op=='*') res=a*b; 8 | else if(op=='/') res=a/b; 9 | 10 | return res; 11 | } 12 | static int modulo(int a,int b){ 13 | return a%b; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /modules/cpp-modules/MATH/EulerTotient.cpp: -------------------------------------------------------------------------------- 1 | 2 | class EulerTotient{ 3 | public : 4 | int n; 5 | vector totient; 6 | EulerTotient(int N){ 7 | this->n=N+1; 8 | totient.resize(n); 9 | for(int i=0;i fact; 4 | long long mod=(1e9)+7; 5 | long long sz=0; 6 | Factorial(long long n,long long mod=(int)(1e9+7)){ 7 | this->sz=n+10; 8 | this->fact.resize(sz); 9 | this->mod=mod; 10 | init(); 11 | } 12 | void init(){ 13 | fact[0]=1; 14 | for(int i=1;ifact[n]; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /modules/cpp-modules/MATH/chineseRemainderThm.cpp: -------------------------------------------------------------------------------- 1 | int chineseRem(int arr[],int rem[],int n){ 2 | int prod=1,res=0; 3 | for(int i=0;i& factors){ 3 | double sqroot=sqrt(n); 4 | factors.push_back(1); 5 | for(int i=2;i<=sqroot;i++){ 6 | if(n%i == 0){ 7 | factors.push_back(i); 8 | if(n/i != i){ 9 | factors.push_back(n/i); 10 | } 11 | } 12 | } 13 | factors.push_back(n); 14 | sort(factors.begin(),factors.end()); 15 | } -------------------------------------------------------------------------------- /modules/cpp-modules/MATH/kthRoot.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int kthRoot(int n, int k) 4 | { 5 | int l = 0; 6 | int r = n; 7 | int ans = 0; 8 | while (l <= r) 9 | { 10 | int mid = l + (r - l) / 2; 11 | if (pow(mid, k) > n) 12 | { 13 | r = mid - 1; 14 | } 15 | else 16 | { 17 | ans = mid; 18 | l = mid + 1; 19 | } 20 | } 21 | return ans; 22 | } -------------------------------------------------------------------------------- /modules/cpp-modules/MATH/lcm_gcd.cpp: -------------------------------------------------------------------------------- 1 | //lcm and gcd 2 | pair extended_gcd(int a,int b){ 3 | if(b==0) return{1,1}; 4 | pair pr=extended_gcd(b,a%b); 5 | return {pr.second,pr.first-(a/b)*pr.second}; 6 | } 7 | int hcf(int a,int b){ 8 | if(a==0 || b==0) return max(a,b); 9 | pair pr=extended_gcd(a,b); 10 | return (a*pr.first + b*pr.second); 11 | } 12 | int lcm(int a,int b){ 13 | return (a*b)/(__gcd(a,b)); 14 | } 15 | int gcd(int a,int b){ 16 | return __gcd(a,b); 17 | } -------------------------------------------------------------------------------- /modules/cpp-modules/MATH/matrixModule/printMatrix.cpp: -------------------------------------------------------------------------------- 1 | void printMatrix(vector>& vmatrix){ 2 | for(auto &rowv:vmatrix){ 3 | for(auto elem:rowv) cout< pals; 2 | bool isPalindrome(string &s){ 3 | string copy=s; 4 | reverse(begin(copy),end(copy)); 5 | return s==copy; 6 | } 7 | string intToString(int n){ 8 | ostringstream ostr; 9 | ostr<>num; 5 | return num; 6 | } 7 | -------------------------------------------------------------------------------- /modules/cpp-modules/RANDOM_NUMBER/random_number.cpp: -------------------------------------------------------------------------------- 1 | // This header file is 2 | // for time 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | // Using the constructor to 11 | // initialize with a seed value 12 | mt19937 mt(time(nullptr)); 13 | 14 | // Operator() is used to 15 | // generate random numbers 16 | cout << mt() << '\n'; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /modules/cpp-modules/STL_Util/STLUtilNamespace.cpp: -------------------------------------------------------------------------------- 1 | namespace STLUtil { 2 | template void remove_duplicates_and_sort_vector(vector& v){ 3 | set s(v.begin(),v.end()); 4 | v.assign(s.begin(),s.end()); 5 | } 6 | }; // STLUtil 7 | -------------------------------------------------------------------------------- /modules/cpp-modules/TIME/checkTimeout.cpp: -------------------------------------------------------------------------------- 1 | // check timeout 2 | void checkTimeout(){ 3 | double tm=(float)clock()/CLOCKS_PER_SEC; 4 | if(tm>=2){ 5 | cerr<<"Time limit exeeded"< segTree; 7 | List arr; 8 | int n; 9 | // public SegmentTree(L) 10 | } 11 | -------------------------------------------------------------------------------- /modules/java-modules/com/library/mathlib/Quadratic.java: -------------------------------------------------------------------------------- 1 | package com.library.mathlib; 2 | 3 | public class Quadratic{ 4 | public static double[] solve(int a,int b,int c){ 5 | double dr=Math.sqrt(b*b-4*a*c); 6 | double[] roots={ 7 | (-b + dr )/ 2 * a, 8 | (-b - dr )/ 2 * a 9 | }; 10 | return roots; 11 | } 12 | } -------------------------------------------------------------------------------- /modules/python-modules/IO/ip.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import copy 3 | import math 4 | isIo=True 5 | 6 | sys.setrecursionlimit(10**6) 7 | if(isIo): 8 | sys.stdin = open('input.txt', 'r') 9 | sys.stdout = open('output.txt', 'w') 10 | isTakeTestCase=False 11 | def scanIntList(): 12 | return map(int,input().split()) 13 | def printList(lst): 14 | for elem in lst: 15 | print(elem,end=" ") 16 | print() 17 | 18 | -------------------------------------------------------------------------------- /modules/python-modules/advance_ds/bitwiseOrSegTree.py: -------------------------------------------------------------------------------- 1 | def segBuild(seg,n): 2 | domain=n;start=domain-1 3 | while domain>0: 4 | for index in range(start,start+domain): 5 | seg[index]=(seg[int(2*index) + 1] | seg[int(2*index) + 2]) 6 | domain=domain//2;start=domain-1 7 | def segUpdate(seg,pos,val): 8 | domain=int(2**ceil(log2(pos)));pos-=1 9 | mypos=pos+ len(seg)//2 10 | seg[mypos]=val 11 | print(mypos) 12 | while mypos>0: 13 | mypos=mypos//2 14 | print(mypos) 15 | seg[mypos]=(seg[int(2*mypos) + 1] | seg[int(2*mypos) + 2]) 16 | -------------------------------------------------------------------------------- /modules/python-modules/advance_ds/fenwickTree.py: -------------------------------------------------------------------------------- 1 | 2 | def fenwickGet(ump,index): 3 | n=len(ump);sm=ump[0] 4 | while index>0: 5 | sm+=ump[index] 6 | index-=(index&(-index)) 7 | return sm 8 | pass 9 | def fenwickUpdate(ump,index,delta): 10 | n=len(ump) 11 | if index==0:ump[index]+=delta;return 12 | while index=int(p*p): 7 | if n%p==0:return False 8 | else: p+=1 9 | else:return True 10 | return True 11 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/AMAZON/Dynamic Programming/jump_game.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/jump-game/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | bool canJump(vector& nums) { 7 | int n=nums.size(); 8 | vector v(n,false); 9 | v[n-1]=true; 10 | int next=n-1; 11 | for(int i=n-2;i>=0;i--){ 12 | int limit=min(n-1,i+nums[i]); 13 | if(limit>=next){ 14 | next=i; 15 | v[i]=true; 16 | } 17 | } 18 | return v[0]; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/GOOGLE/Dynamic Programming/counting_bits.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/counting-bits/ 2 | // solution : below code 3 | 4 | 5 | const int M=1e5 + 10; 6 | vector dp(M,0); 7 | bool isDpDone=false; 8 | 9 | int getBits(int num){ 10 | bitset<20> bs(num); 11 | return bs.count(); 12 | } 13 | void countBitsDp(){ 14 | isDpDone=true; 15 | for(int i=0;i countBits(int n) { 22 | if(isDpDone==false) countBitsDp(); 23 | return vector(dp.begin(),dp.begin()+n+1); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/GOOGLE/Hashing/contains_duplicate.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/contains-duplicate/ 2 | // solution : below code 3 | 4 | 5 | class Solution { 6 | public: 7 | bool containsDuplicate(vector& nums) { 8 | map hash; 9 | for(auto num:nums) hash[num]++; 10 | for(auto pr:hash) if(pr.second>1) return true; 11 | return false; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/GOOGLE/Hashing/find_all_duplicates_in_array.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | vector findDuplicates(vector& nums) { 7 | vector dups; 8 | map mp; 9 | for(auto num:nums){ 10 | mp[num]++; 11 | } 12 | for(auto &pr:mp){ 13 | if(pr.second>1) dups.push_back(pr.first); 14 | } 15 | return dups; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/GOOGLE/Hashing/find_all_numbers_disappering_in_an_array.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | vector findDisappearedNumbers(vector& nums) { 7 | int n=nums.size()+1; 8 | vector v(n,false); 9 | for(auto num:nums) v[num]=true; 10 | vector missing; 11 | for(int i=1;i& nums) { 7 | int n=nums.size()+2; 8 | vector v(n,false); 9 | for(auto num:nums) if(num>0 && num& nums) { 8 | ll n=nums.size(); 9 | ll sm=accumulate(begin(nums),end(nums),0LL); 10 | ll total=(n*(n+1))/2; 11 | return total-sm; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/GOOGLE/find_duplicate_number.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/find-the-duplicate-number/ 2 | // solution : below code 3 | class Solution { 4 | public: 5 | int findDuplicate(vector& nums,int i=0) { 6 | vector container(nums.size(),false); 7 | for(auto num:nums){ 8 | if(container[num]) return num; 9 | container[num]=true; 10 | } 11 | return -1; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/MICROSOFT/MEDIUM/kth_last_node_of_linked_list.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://binarysearch.com/problems/Kth-Last-Node-of-a-Linked-List 2 | // solution : below code 3 | 4 | /** 5 | * class LLNode { 6 | * public: 7 | * int val; 8 | * LLNode *next; 9 | * }; 10 | */ 11 | int solve(LLNode* node, int k) { 12 | int index=0; 13 | LLNode* fast=node; 14 | while(indexnext; 17 | } 18 | LLNode* curr=node; 19 | while(fast->next){ 20 | curr=curr->next; 21 | fast=fast->next; 22 | } 23 | return curr->val; 24 | } 25 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/STRIVER_SDE_SHEET/ARRAYS/best_time_to_buy_sell_stocks.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/best-time-to-buy-and-sell-stock/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | int maxProfit(vector& prices) { 7 | int mx=0; 8 | int profit=0; 9 | int n=prices.size(); 10 | for(int i=n-1;i>=0;i--){ 11 | profit=max(profit,mx-prices[i]); 12 | mx=max(mx,prices[i]); 13 | } 14 | return profit; 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/STRIVER_SDE_SHEET/ARRAYS/find_the_duplicate_number.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/find-the-duplicate-number/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | int findDuplicate(vector& nums) { 7 | long long n=nums.size(); 8 | vector v(n,false); 9 | for(auto num:nums){ 10 | if(v[num]) return num; 11 | v[num]=true; 12 | } 13 | return -1; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/STRIVER_SDE_SHEET/ARRAYS/maximum_subarray_sum_KADENE.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/maximum-subarray/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | int maxSubArray(vector& nums) { 7 | int mx_sum=-1; 8 | int sum_upto=-1; 9 | int mx=*max_element(nums.begin(),nums.end()); 10 | for(auto num:nums){ 11 | sum_upto=max(num+sum_upto,num); 12 | mx_sum=max(mx_sum,sum_upto); 13 | } 14 | if(mx<0) return mx; 15 | return mx_sum; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /problemset/company_wise_problems/STRIVER_SDE_SHEET/ARRAYS/rotate_image.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/rotate-image/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | void rotate(vector>& matrix) { 7 | int n=matrix.size(); 8 | int m=matrix.back().size(); 9 | for(int i=0;i& nums,int i=0) { 4 | if(!i) sort(nums.begin(),nums.end()); 5 | return (nums[i] == nums[i+1])?(nums[i]):(findDuplicate(nums,1+i)); 6 | } 7 | }; -------------------------------------------------------------------------------- /problemset/data_structure_problems/array/findDuplicates_in_array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findDuplicate(vector& nums) { 4 | unordered_map freq; 5 | int occurance; 6 | 7 | for(auto num:nums){ 8 | occurance=++freq[num]; 9 | if(occurance-1) return num; 10 | } 11 | return occurance;//this will not be executed any more 12 | } 13 | }; -------------------------------------------------------------------------------- /problemset/data_structure_problems/array/findDuplicates_in_array_betterApproach.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findDuplicate(vector& nums,int i=0) { 4 | if(!i) sort(nums.begin(),nums.end()); 5 | return (nums[i] == nums[i+1])?(nums[i]):(findDuplicate(nums,1+i)); 6 | } 7 | }; -------------------------------------------------------------------------------- /problemset/data_structure_problems/array/global_and_local_inversions.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/global-and-local-inversions/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | bool isIdealPermutation(vector& nums) { 7 | int n=nums.size(); 8 | for(int i=0;inums[i+1]){ 10 | swap(nums[i],nums[i+1]); 11 | i++; 12 | } 13 | } 14 | 15 | for(int i=0;inums[i+1]) return false; 17 | } 18 | return true; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /problemset/data_structure_problems/array/max_Subarray_Sum_MOST_EFFICIENT_(OPTIMUM).cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int maxSubArray(vector& nums) { 5 | int mx=0,mn=INT_MIN; 6 | mn=max(mn,*(nums.end()-1)); 7 | mx=max(mx,*(nums.end()-1)); 8 | for(int i=nums.size()-2;i>=0;i--){ 9 | mn=max(mn,nums[i]); 10 | nums[i]+=max(0,nums[i+1]); 11 | mx=max(mx,nums[i]); 12 | } 13 | if(mn<1) return mn; 14 | if(mx==0 && mn<0) mx=mn; 15 | return mx; 16 | } 17 | }; -------------------------------------------------------------------------------- /problemset/data_structure_problems/array/topK_frequent_elements.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector topKFrequent(vector& nums, int k) { 4 | unordered_map ump; 5 | set> s; 6 | stack stk; 7 | vector v; 8 | for(auto num:nums) ump[num]++; 9 | for(auto it=ump.begin();it!=ump.end();it++) s.insert({it->second,it->first}); 10 | for(auto it=s.begin();it!=s.end();++it) stk.push(it->second); 11 | while(k--){ 12 | int top=stk.top(); 13 | stk.pop(); 14 | v.push_back(top); 15 | } 16 | return v; 17 | } 18 | }; -------------------------------------------------------------------------------- /problemset/data_structure_problems/dsu/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | ## ds is verry nice concept , used in kruskal , job seq and so on , sometimes in bit manip also 3 | --- 4 | -------------------------------------------------------------------------------- /problemset/data_structure_problems/graph/find_Center_Of_Star_Graph.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findCenter(vector>& edges) { 4 | vector center(edges.size()+2,0); 5 | for(auto &v:edges){ center[v[0]]++,center[v[1]]++; } 6 | for(int i=1;i<=edges.size()+1;i++) if(center[i]==edges.size()) return i; 7 | return 0; 8 | } 9 | }; -------------------------------------------------------------------------------- /problemset/data_structure_problems/graph/find_Judge.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int findJudge(int n, vector>& trust) { 4 | vector follower(n+1,0),following(n+1,0); 5 | for(auto &v:trust){ 6 | follower[v[1]]++; 7 | following[v[0]]++; 8 | } 9 | for(int i=1;i<=n;i++){ 10 | if(following[i]== 0 && follower[i] == n-1) return i; 11 | } 12 | return -1; 13 | } 14 | }; -------------------------------------------------------------------------------- /problemset/data_structure_problems/graph/find_smallest_set_of_vertices.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector findSmallestSetOfVertices(int n, vector>& edges) { 4 | vector v1(n,1),v2; 5 | for(auto &v:edges){ 6 | v1[v[1]]=0; 7 | } 8 | for(int i=0;inext) return false; 13 | ListNode* slow,*fast; 14 | fast=slow=head; 15 | while(fast && fast->next){ 16 | slow=slow->next; 17 | fast=fast->next->next; 18 | if(slow == fast) return true; 19 | } 20 | return false; 21 | } 22 | }; -------------------------------------------------------------------------------- /problemset/data_structure_problems/matrix/palindrome/palindromic_paths.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1366/C 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | int n,m; 6 | read(n,m); 7 | vvi v(n,vi(m)); 8 | readm(v); 9 | int sz=n-1+m-1+1; 10 | vector> mp(sz,vector(2,0)); 11 | F(i,0,n){ 12 | F(j,0,m){ 13 | mp[i+j][v[i][j]]++; 14 | } 15 | } 16 | int ctr=0; 17 | for(int i=0;i bool: 5 | couple={} 6 | couple[')']='(' 7 | couple[']']='[' 8 | couple['}']='{' 9 | stk=[] 10 | for ch in s: 11 | if ch in couple: 12 | if len(stk)>0 and stk[-1]==couple[ch]:stk.pop() 13 | else: return False 14 | else: 15 | stk.append(ch) 16 | return len(stk)==0 17 | -------------------------------------------------------------------------------- /problemset/data_structure_problems/string/sortCharacters_by_frequency.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | static bool comp(pair p1,pair p2){ 4 | return p1.first>p2.first; 5 | } 6 | string frequencySort(string s) { 7 | unordered_map ump; 8 | vector> v; 9 | for(int i=0;isecond,it->first}); 11 | sort(v.begin(),v.end(),comp); 12 | s=""; 13 | for(auto elem:v) for(int i=0;ival=root->val; 5 | newTree->left=copyTree(root->left,newTree->left); 6 | newTree->right=copyTree(root->right,newTree->right); 7 | return newTree; 8 | } -------------------------------------------------------------------------------- /problemset/data_structure_problems/tree/tree_for_cp/readme.md: -------------------------------------------------------------------------------- 1 | # these problems are tree for cp on the sites like codeforces 2 | -------------------------------------------------------------------------------- /problemset/misc/popular-problems/pascalsTriangle.py: -------------------------------------------------------------------------------- 1 | # problem link: https://leetcode.com/explore/interview/card/top-interview-questions-easy/99/others/601/ 2 | # solution : below code 3 | class Solution: 4 | def generate(self, numRows: int) -> List[List[int]]: 5 | lst=[[1]];numRows-=1 6 | while numRows>0: 7 | prev=lst[-1] 8 | curr=[1] 9 | for index in range(1,len(prev)): 10 | curr.append(prev[index]+prev[index-1]) 11 | curr.append(1) 12 | lst.append(curr) 13 | numRows-=1 14 | return lst 15 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/binary search/books.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/279/B 2 | // solution : below code 3 | #include 4 | #define int long long 5 | using namespace std; 6 | 7 | signed main() { 8 | int n,m;cin>>n>>m; 9 | int pref[n+1]; 10 | pref[0]=0; 11 | for(int i=1;i<=n;i++){ 12 | cin>>pref[i]; 13 | pref[i]+=pref[i-1]; 14 | } 15 | int mx=0; 16 | for(int i=1;i<=n;i++){ 17 | int stop=upper_bound(pref+i,pref+n+1,m+pref[i-1])-(pref+i); 18 | mx=max(mx,stop); 19 | } 20 | cout<>n; 9 | int arr[n]; 10 | read(arr,n); 11 | int m;read(m); 12 | int b[m];read(b,m); 13 | F(i,1,n) arr[i]+=arr[i-1]; 14 | // println(arr,n); 15 | F(i,0,m){ 16 | int num=b[i]; 17 | int index=lower_bound(arr,arr+n,num)-arr; 18 | cout<0 && (right&mul)>0){ 13 | ans+=mul; 14 | } 15 | } 16 | mul<<=1; 17 | } 18 | return ans; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/bit_manip/cirnos_perfect_bitmask_classroom.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1688/problem/A 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | read(n); 8 | bitset<64> bs(n); 9 | int m=0,one=0; 10 | if(n==1){ 11 | cout<<3< match; 15 | F(i,0,64){ 16 | if(bs[i]==1){ 17 | match.pb(i); 18 | } 19 | } 20 | 21 | int ans=(1LL<1){ 23 | cout<>n; 7 | bitset<32> bs(n); 8 | cout<>n>>k; 6 | 7 | int num=n; 8 | for(int i=1;;i++){ 9 | num=(num xor (num%10)); 10 | if(i==k){ 11 | cout<>n>>k; 6 | int arr[n]; 7 | scan(arr,n); 8 | string s; 9 | for(int i=0;i int: 5 | bit=0;ctr=0 6 | while bit<32: 7 | if x%2 != y%2: ctr+=1 8 | x>>=1;y>>=1 9 | bit+=1 10 | return ctr 11 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/bit_manip/hammingWeight.py: -------------------------------------------------------------------------------- 1 | # problem link : https://leetcode.com/explore/interview/card/top-interview-questions-easy/99/others/565/ 2 | # solution : below code 3 | class Solution: 4 | def hammingWeight(self, n: int) -> int: 5 | bit=0;ctr=0 6 | while bit<32: 7 | ctr+=(n%2) 8 | n>>=1 9 | bit+=1 10 | return ctr 11 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/bit_manip/non_zero_xor.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://www.codechef.com/submit/NZXOR 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | read(n); 8 | vi v(n); 9 | readv(v); 10 | int key=0; 11 | map mp; 12 | mp[0]++; 13 | int ctr=0; 14 | FEACH(num,v){ 15 | key=(key ^ num); 16 | if(mp.count(key)){ 17 | ctr++; 18 | mp.clear(); 19 | } 20 | mp[key]++; 21 | } 22 | println(ctr); 23 | 24 | 25 | // print answers here 26 | 27 | } 28 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/bit_manip/or_tuples.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://www.codechef.com/submit/ORTUPLES 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | vi v(3); 7 | readv(v); 8 | SORT(v); 9 | int key=(v[0] & v[1] & v[2]); 10 | bitset<32> bs(key); 11 | int ctr=bs.count(); 12 | vi bits(32,0); 13 | FEACH(num,v){ 14 | bitset<32> mybs(num); 15 | F(k,0,32){ 16 | if(mybs[k]==1) bits[k]++; 17 | } 18 | } 19 | F(k,0,32){ 20 | if(bits[k]==1){ 21 | cout<<0< int: 5 | mask=[];bit=0 6 | while bit<32: 7 | mask.append(n%2) 8 | n>>=1 9 | bit+=1 10 | mask=mask[::-1] 11 | rev=0;mul=1 12 | for digit in mask: 13 | rev+=int(mul*digit) 14 | mul<<=1 15 | return rev 16 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/brute_force/sequence_with_digits.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1355/A 2 | // solution : below code 3 | 4 | int calcaddon(int n){ 5 | int mx=0,mn=9; 6 | while(n){ 7 | int digit=n%10; 8 | mx=max(mx,digit); 9 | mn=min(mn,digit); 10 | n/=10; 11 | } 12 | return mx*mn; 13 | } 14 | void solve(int t){ 15 | //shree ganeshay namah 16 | int n,k; 17 | read(n,k); 18 | k--; 19 | while(k--){ 20 | int addon=calcaddon(n); 21 | if(addon==0) break; 22 | n+=addon; 23 | } 24 | println(n); 25 | } 26 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/constructive/moderate_modular_mode.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1603/problem/B 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | // println("shree ganeshay namah"); 7 | int a,b; 8 | read(a,b); 9 | if(a>b){ 10 | cout<>n>>k; 6 | if(n&1){ 7 | if(k==1){ 8 | print(true); 9 | for(int i=0;i>& matrix, int target) { 6 | int m=matrix.size(),n=matrix[0].size(); 7 | int i=0,j=n-1; 8 | while(i=0){ 9 | if(matrix[i][j]==target) return true; 10 | if(matrix[i][j]>n; 7 | string s;cin>>s; 8 | int sm=0; 9 | map mp; 10 | for(int i=0;i int: 6 | if len(nums)==1: return nums[0] 7 | if len(nums)==2: return max(nums) 8 | dp=copy.deepcopy(nums) 9 | dp[2]+=dp[0] 10 | n=len(nums) 11 | for index in range(3,n): 12 | dp[index]+=max(dp[index-2],dp[index-3]) 13 | return max(dp) 14 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/dp/longest_Increasing_Subsequence_LOG(N) approach.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int lengthOfLIS(vector& nums) { 5 | vector memo; 6 | for(auto num:nums){ 7 | auto found=lower_bound(memo.begin(),memo.end(),num); 8 | if(found==memo.end()) memo.push_back(num); 9 | else *found=num; 10 | } 11 | return memo.size(); 12 | } 13 | }; -------------------------------------------------------------------------------- /problemset/topic_wise_problems/dp/max_Subarray_Sum_MOST_EFFICIENT_(OPTIMUM).cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | 4 | int maxSubArray(vector& nums) { 5 | int mx=0,mn=INT_MIN; 6 | mn=max(mn,*(nums.end()-1)); 7 | mx=max(mx,*(nums.end()-1)); 8 | for(int i=nums.size()-2;i>=0;i--){ 9 | mn=max(mn,nums[i]); 10 | nums[i]+=max(0,nums[i+1]); 11 | mx=max(mx,nums[i]); 12 | } 13 | if(mn<1) return mn; 14 | if(mx==0 && mn<0) mx=mn; 15 | return mx; 16 | } 17 | }; -------------------------------------------------------------------------------- /problemset/topic_wise_problems/dp/min_Cost_Climbing_Stairs.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minCostClimbingStairs(vector& cost) { 4 | vector costs; 5 | costs.push_back(0); 6 | for(auto money:cost) costs.push_back(money); 7 | costs.push_back(0); 8 | vector v(costs.size(),INT_MAX); 9 | v[0]=0; 10 | for(int i=0;i& nums) { 4 | vector v(nums.size(),INT_MAX); 5 | v[0]=0; 6 | for(int i=0;i& target) { 7 | int n=target.size(); 8 | int last=0; 9 | int ctr=0; 10 | for(int i=0;i,int> &memo){ 4 | if(r==0 || r==n) return 1; 5 | if(memo[{n,r}]) return memo[{n,r}]; 6 | memo[{n,r}]=ncr(n-1,r-1,memo)+ncr(n-1,r,memo); 7 | return memo[{n,r}]; 8 | } 9 | vector getRow(int rowIndex) { 10 | map,int> memo; 11 | vector v; 12 | for(int i=0;i<=rowIndex;i++){ 13 | v.push_back(ncr(rowIndex,i,memo)); 14 | } 15 | return v; 16 | } 17 | }; -------------------------------------------------------------------------------- /problemset/topic_wise_problems/dp/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/dp/test.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int fib(int n,int *memo=NULL) { 4 | if(n==0 || n==1) return n; 5 | int *tab=(int *)calloc(n+2,sizeof(int)); 6 | tab[0]=0; 7 | tab[1]=1; 8 | for(int i=0;ibp) println("BOB"); 25 | else println("ALICE"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/greedy/alternating_subsequence.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1343/C 2 | // solution : below code 3 | // time taken : 4 m 17 s 4 | 5 | void solve(int t){ 6 | //shree ganeshay namah 7 | int n; 8 | cin>>n; 9 | int arr[n]; 10 | read(arr,n); 11 | int sm=0; 12 | vi v; 13 | v.pb(arr[0]); 14 | F(i,0,n){ 15 | if(v.back()>0 && arr[i]>0){ 16 | v.back()=max(v.back(),arr[i]); 17 | } 18 | else if(v.back()<0 && arr[i]<0){ 19 | v.back()=max(v.back(),arr[i]); 20 | } 21 | else{ 22 | v.pb(arr[i]); 23 | } 24 | } 25 | FEACH(num,v){ 26 | sm+=num; 27 | } 28 | println(sm); 29 | } 30 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/greedy/find_the_array.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1463/problem/B 2 | // solution : below code 3 | 4 | void solve(){ 5 | int n;cin>>n;int arr[n];scan(arr,n); 6 | int b[n]; 7 | int c[n]; 8 | 9 | int db=0,dc=0,sm=0; 10 | for(int i=0;i& piles) { 6 | sort(piles.begin(),piles.end()); 7 | int sum=0; 8 | int left=0,right=piles.size()-1; 9 | while(left stk; 7 | int moves=0; 8 | for(char c:s){ 9 | if(c=='('){ 10 | stk.push(c); 11 | }else{ 12 | if(stk.size()>0){ 13 | stk.pop(); 14 | }else moves++; 15 | } 16 | } 17 | moves+=stk.size(); 18 | return moves; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/greedy/partitioning_into_minimum_number_of_deci-binary_numbers.cpp: -------------------------------------------------------------------------------- 1 | // Problem link : https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers/ 2 | // Problem type : greedy 3 | class Solution { 4 | public: 5 | int minPartitions(string s) { 6 | int ans=(int)(*max_element(s.begin(),s.end())-48); 7 | return ans; 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/greedy/table_decoration.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/478/C 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | // println("shree ganeshay namah"); 7 | // println("shreepad rajam sharanam prapadhye"); 8 | 9 | vector v(3); 10 | readv(v); 11 | SORT(v); 12 | REVERSE(v); 13 | if(v[0]>=2*(v[1]+v[2])){ 14 | cout<& nums) { 7 | unordered_map hashmap; 8 | for(auto num:nums){ 9 | if(hashmap.count(num)) return true; 10 | hashmap[num]=true; 11 | } 12 | return false; 13 | } 14 | }; -------------------------------------------------------------------------------- /problemset/topic_wise_problems/hashing/contains_duplicate_2.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/contains-duplicate-ii/description/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | bool containsNearbyDuplicate(vector& nums, int k) { 7 | unordered_map hashmap; 8 | for(int i=0;i& nums) { 7 | #define map unordered_map 8 | map mp; 9 | int n=nums.size(); 10 | for(int i=0;i> mp(sz,vector(2,0)); 11 | F(i,0,n){ 12 | F(j,0,m){ 13 | mp[i+j][v[i][j]]++; 14 | } 15 | } 16 | int ctr=0; 17 | for(int i=0;i mp1,mp2; 13 | F(i,0,k){ 14 | mp1[a[i]]++; 15 | mp2[b[i]]++; 16 | } 17 | int ctr=0; 18 | F(i,0,k){ 19 | int addon=k-mp1[a[i]]-mp2[b[i]]+1; 20 | ctr+=addon; 21 | } 22 | ctr/=2; 23 | println(ctr); 24 | 25 | // print answers here 26 | 27 | } 28 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/geometry/amr_and_pins.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/507/B 2 | // solution : below code 3 | #include 4 | #define int long long 5 | using namespace std; 6 | 7 | 8 | void solve(){ 9 | int r,a,b,c,d; 10 | cin>>r>>a>>b>>c>>d; 11 | double numer=sqrt(((c-a)*(c-a) + (d-b)*(d-b))); 12 | cout<>t; 17 | while(t--){ 18 | solve(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/math_templates/chineseRemainderThm.cpp: -------------------------------------------------------------------------------- 1 | int chineseRem(int arr[],int rem[],int n){ 2 | int prod=1,res=0; 3 | for(int i=0;i totient; 6 | EulerTotient(int N){ 7 | this->n=N+1; 8 | totient.resize(n); 9 | for(int i=0;i& factors){ 3 | double sqroot=sqrt(n); 4 | factors.push_back(1); 5 | for(int i=2;i<=sqroot;i++){ 6 | if(n%i == 0){ 7 | factors.push_back(i); 8 | if(n/i != i){ 9 | factors.push_back(n/i); 10 | } 11 | } 12 | } 13 | factors.push_back(n); 14 | sort(factors.begin(),factors.end()); 15 | } 16 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/math_templates/gcd_lcm.cpp: -------------------------------------------------------------------------------- 1 | //lcm and gcd 2 | pair extended_gcd(int a,int b){ 3 | if(b==0) return{1,1}; 4 | pair pr=extended_gcd(b,a%b); 5 | return {pr.second,pr.first-(a/b)*pr.second}; 6 | } 7 | int hcf(int a,int b){ 8 | if(a==0 || b==0) return max(a,b); 9 | pair pr=extended_gcd(a,b); 10 | return (a*pr.first + b*pr.second); 11 | } 12 | int lcm(int a,int b){ 13 | return (a*b)/(__gcd(a,b)); 14 | } 15 | int gcd(int a,int b){ 16 | return __gcd(a,b); 17 | } 18 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/math_templates/readme.md: -------------------------------------------------------------------------------- 1 | --- 2 | ## good to know 3 | - at max a number can have O(2*sqrt(n)-1) factors , which number of factors' upper bound . 4 | --- 5 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/math_templates/roundOfInPowerOf2.cpp: -------------------------------------------------------------------------------- 1 | // roundOf 2 | int roundOf(int n){ 3 | return (int)pow(2,floor(log2(n))); 4 | } 5 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/misc/ball_and_boxes.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://www.codechef.com/submit/BALLBOX 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | read(n); 8 | int k; 9 | read(k); 10 | YESNO1((n>=(k*(k+1))/2)); 11 | return; 12 | 13 | 14 | // print answers here 15 | 16 | } 17 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/misc/chewbacca_and_number.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/514/A 2 | // solution : below code 3 | // time taken : 5 m 32 s 4 | 5 | void solve(int t){ 6 | //shree ganeshay namah 7 | string s;read(s); 8 | if(s[0]=='9' || s[0]<='4') ; 9 | else s[0]='0'+'9'-s[0]; 10 | int n=s.size(); 11 | F(i,1,n){ 12 | if(s[i]>'4'){ 13 | s[i]='0'+('9'-s[i]); 14 | } 15 | } 16 | println(s); 17 | } 18 | 19 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/misc/dungeon.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1463/problem/A 2 | // solution : below code 3 | 4 | void solve(){ 5 | int a,b,c;cin>>a>>b>>c; 6 | int mn=min(a,min(b,c)); 7 | int total=a+b+c; 8 | return print((total%9==0)&&(mn>=total/9)); 9 | } 10 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/misc/missing_number.py: -------------------------------------------------------------------------------- 1 | # problem link : https://leetcode.com/explore/interview/card/top-interview-questions-easy/99/others/722/ 2 | # solution : below code 3 | class Solution: 4 | def missingNumber(self, nums: List[int]) -> int: 5 | sm=sum(nums) 6 | n=len(nums) 7 | total=(n*(n+1))//2 8 | return total-sm 9 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/misc/moderate_modular_mode.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/contest/1603/problem/B 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | // println("shree ganeshay namah"); 7 | int a,b; 8 | read(a,b); 9 | if(a>b){ 10 | cout<r-c: 7 | print("YES") 8 | else:print("NO") 9 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/misc/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/misc/ternary_xor.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1328/C 2 | // solution : below code 3 | // time taken : 8 m 11 s 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | string s; 8 | read(n); 9 | read(s); 10 | int index=n; 11 | string a,b; 12 | F(i,0,n) a+='0'; 13 | F(i,0,n) b+='0'; 14 | F(i,0,n){ 15 | if(s[i]=='1'){ 16 | index=i; 17 | a[i]='1'; 18 | break; 19 | } 20 | } 21 | for(int i=0;i 4 | using namespace std; 5 | 6 | int main() { 7 | int n,m;cin>>n>>m; 8 | int steps=0; 9 | while(m>n && m>1){ 10 | if(m%2) m+=1; 11 | else m/=2; 12 | steps++; 13 | } 14 | steps+=(n-m); 15 | cout<>n>>k; 6 | int start=2; 7 | while(k%start==0){ 8 | start++; 9 | } 10 | int num=start; 11 | for(int i=0;i& nums) { 11 | int mn=INT_MAX; 12 | int mx=INT_MIN; 13 | for(auto num:nums){ 14 | mn=min(mn,num); 15 | mx=max(mx,num); 16 | } 17 | int hcf=gcd(mn,mx); 18 | return hcf; 19 | } 20 | }; -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/number_theory/lcm_gcd/minimum_number.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://practice.geeksforgeeks.org/contest/interview-series-67/problems/# 2 | // solution : below code 3 | 4 | class Solution{ 5 | public: 6 | int minimumNumber(int n,vector &arr){ 7 | int hcf=0; 8 | FEACH(num,arr){ 9 | hcf=GCD(hcf,num); 10 | } 11 | return hcf; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/math/number_theory/lcm_gcd/two_numbers.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://www.codechef.com/problems/TWONUMBERS 2 | // solution : below code 3 | 4 | int gcdlcmdiff(int a,int b){ 5 | return LCM(a,b)-GCD(a,b); 6 | } 7 | void solve(int t){ 8 | //shree ganeshay namah 9 | int n;read(n); 10 | if(n<=2){ 11 | cout<<0< mp; 10 | F(i,0,n){ 11 | sm+=arr[i]; 12 | // mp[arr[i]]=true; 13 | } 14 | bool flag=false; 15 | // cout< ump; 11 | vc singles; 12 | F(i,0,n){ 13 | read(v[i]); 14 | if(v[i].size()==1){ 15 | singles.pb(v[i][0]); 16 | } 17 | FEACH(c,v[i]){ 18 | ump[c]++; 19 | } 20 | } 21 | FEACH(c,singles){ 22 | if(ump[c] % 2==1){ 23 | println(c);return; 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/permutation/element_extermination.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1375/C 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | read(n); 8 | int a[n]; 9 | read(a,n); 10 | if(a[0]& nums) { 4 | unordered_map ump; 5 | for(auto &num:nums){ 6 | if(ump[num]) return true; 7 | ump[num]=true; 8 | } 9 | return false; 10 | } 11 | }; -------------------------------------------------------------------------------- /problemset/topic_wise_problems/sliding window/containsNearByDuplicates.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool containsNearbyDuplicate(vector& nums, int k) { 4 | unordered_map> ump; 5 | int index=0; 6 | for(auto &num:nums) ump[num].push_back(index++); 7 | for(auto &num:nums){ 8 | vector &v=ump[num]; 9 | for(int j=1;jmn){ 14 | char c=s[i]; 15 | if(c<'9') c++; 16 | op+=c; 17 | } 18 | else{ 19 | op+=s[i]; 20 | mn=min(mn,s[i]); 21 | } 22 | } 23 | SORT(op); 24 | println(op); 25 | // print answers here 26 | 27 | } 28 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/sorting/young_explorers.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1355/B 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n; 7 | read(n); 8 | int a[n]; 9 | read(a,n); 10 | SORTA(a,n); 11 | int group=0; 12 | int index=0; 13 | int content=0; 14 | F(i,0,n){ 15 | if(content+1>=a[i]){ 16 | group++; 17 | content=0; 18 | }else{ 19 | content++; 20 | } 21 | } 22 | println(group); 23 | } 24 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/special/fibonacci_words.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1505/C 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | // println("shree ganeshay namah"); 7 | string s; 8 | read(s); 9 | int n=s.size(); 10 | F(i,2,n){ 11 | char a=s[i-2]; 12 | char b=s[i-1]; 13 | char c=(a-'A'+b-'A')%26+'A'; 14 | // cout<bp) println("BOB"); 25 | else println("ALICE"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/string/string_and_pattern_matching/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/string/string_misc/number_of_strings_appear_as_substring_in_word.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://leetcode.com/problems/number-of-strings-that-appear-as-substrings-in-word/description/ 2 | // solution : below code 3 | 4 | class Solution { 5 | public: 6 | int numOfStrings(vector& patterns, string word) { 7 | int ctr=0; 8 | for(auto & s:patterns){ 9 | if(word.find(s) != string::npos){ 10 | ctr++; 11 | } 12 | } 13 | return ctr; 14 | } 15 | }; -------------------------------------------------------------------------------- /problemset/topic_wise_problems/two_pointer/make_it_good.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1385/C 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n,x; 7 | read(n); 8 | int a[n]; 9 | read(a,n); 10 | vi v(n,0); 11 | int peak=n-1; 12 | int r=n-1; 13 | int l=n-1; 14 | for(int i=n-2;i>=0;i--){ 15 | if(a[i]>=a[i+1]){ 16 | peak=i; 17 | }else break; 18 | } 19 | l=peak; 20 | for(int i=peak-1;i>=0;i--){ 21 | if(a[i]<=a[i+1]){ 22 | l=i; 23 | }else break; 24 | } 25 | println(l); 26 | } 27 | -------------------------------------------------------------------------------- /problemset/topic_wise_problems/two_pointer/sorted_adjacent_differences.cpp: -------------------------------------------------------------------------------- 1 | // problem link : https://codeforces.com/problemset/problem/1339/B 2 | // solution : below code 3 | 4 | void solve(int t){ 5 | //shree ganeshay namah 6 | int n,x; 7 | read(n); 8 | int a[n]; 9 | read(a,n); 10 | SORTA(a,n); 11 | int l=0,r=n-1; 12 | vi v(n); 13 | F(i,0,n){ 14 | if(i%2 == 0){ 15 | // print(a[l]);l++; 16 | v[i]=a[l];l++; 17 | }else{ 18 | // print(a[r]);r--; 19 | v[i]=a[r];r--; 20 | } 21 | } 22 | // println(""); 23 | reverse(ALL(v)); 24 | printv(v); 25 | } 26 | -------------------------------------------------------------------------------- /template/checkTimeOut.cpp: -------------------------------------------------------------------------------- 1 | // check timeout 2 | void checkTimeout(){ 3 | double tm=(float)clock()/CLOCKS_PER_SEC; 4 | if(tm>=2){ 5 | cerr<<"Time limit exeeded"< output.txt 3 | python : 4 | python winner.py < input.txt > output.txt -------------------------------------------------------------------------------- /workspace/comfort/considerations.txt: -------------------------------------------------------------------------------- 1 | 3 2 | 3 | 4 | 2xyz = n ( xy + yz + zx ) 5 | 6 | 2 * x2y2 = n ( xy + xy2 + x2y) 7 | 8 | 2 * xy = n ( 1 + y + x) 9 | 10 | nx + ny + n = 2xy 11 | 12 | x= n 13 | y= 2n 14 | z= 3n 15 | 16 | (2 + 6 + 3) / (6)(n) 17 | 18 | (xy + yz + zx) = 2xyz 19 | 20 | 1/x + 1/y + 1/z = 2 21 | 22 | 23 | 24 | 2/ n = 1/x + 1/y + 1/z 25 | 26 | 27 | 1/3 + 1/6 28 | 29 | 30 | 1/2 + 1/4 + 1/56 31 | 32 | 3/4 + 1/56 33 | 34 | 172 / (56*4) -------------------------------------------------------------------------------- /workspace/comfort/error.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/om-ashish-soni/Competitive-Programming/9ea864f7588ba9dbe80ccaef8009f9ffd40f9f7f/workspace/comfort/error.txt -------------------------------------------------------------------------------- /workspace/comfort/gfg.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/om-ashish-soni/Competitive-Programming/9ea864f7588ba9dbe80ccaef8009f9ffd40f9f7f/workspace/comfort/gfg.exe -------------------------------------------------------------------------------- /workspace/comfort/input.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 6 3 9 3 | 3 7 3 5 2 4 4 | 8 3 5 5 | 1 1 4 6 | 4 7 | 2 8 | 2 2 1 9 | 1 1 10 | 1 1 11 | 5 5 5 12 | 3 4 3 4 3 13 | 4 5 4 5 4 -------------------------------------------------------------------------------- /workspace/comfort/oop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class P{ 5 | public: 6 | void abc(){ 7 | cout<<"abc in P"<