- [x ][ greedy ] weighted_job_scheduling
- [x ][ usuage_of_structure_with_vector]
- cutting a rod to maximize reward
- maximum sum problem
- kth smallest element
- minimum jump required
- count bits 11 making a meal
- count bit difference
- swap two nibbles in a byte
- Please do it, count no ofoccurance of digit in a range
- [tree ] count no of unique binary tree
-
[x ][ bit-manipulation ] rotate_bit_of_a_number
-
[x ][ array ] pythagorean_triplets(https://practice.geeksforgeeks.org/problems/triplet-sum-in-array/0/?ref=self)
-
[x ][ array ] candies_distributions
-
[x ][ array ] zigzag_fashion_arrangement(https://practice.geeksforgeeks.org/problems/convert-array-into-zig-zag-fashion/0)
-
[greedy] fitting shelves problem
-
[greedy] water connection problem
-
find squares and rectangles on a chess board(https://practice.geeksforgeeks.org/problems/squares-in-nn-chessboard/0)
-
[greedy] huffman_coding
-
[priority queue test for min and max heap]
-
[not optimal] row with max 1's
-
[x ][ array,matrix ] search_element_in_sorted_matrix
-
[nested function]
-
count-negative-numbers-in-a-column-wise-row-wise-sorted-matrix
-
[2d_vector testing]
-
[greedy] maximum flow problem
-
[greedy ][ tree ] count no of subtree with given sum
-
[linked list implementation]
-
[count trailing zeros in factorial]
-
[math ][ rounding_a_no_to_k_decimal_places]
- https://www.geeksforgeeks.org/combinational-sum/
- https://www.geeksforgeeks.org/find-all-combinations-that-adds-upto-given-number-2/
-
[x ][ stack ] infix_to_postfix
-
[why unorderd_map of struct node is not working] detect_loop_in_linked_list
-
[tree ] print_all_paths_of_binary_tree
-
[ ][ tree ][ binary search on unsorted array]
-
[tree ][ cartesian_tree]
-
[ ] ncr
- [MS ][ stickler_thief ] Maximum sum such that no two elements are adjacent
- [MS ] Binary_representation
- [MS ] print_uncommon_element_from_2_arrays
- [tree ] left_right_view_of_tree (https://practice.geeksforgeeks.org/problems/right-view-of-binary-tree/1/?ref=self)
- [very-imp ] minimum_cost_to_make_2_strings_identical
- [math ] power_ab_in_logb_time
- [math ] check_if_no_is_power_of_another_number
- [string ] count_the_reversals
- [math ][ chinese_theorm]
- x_total_shapes
- [graph ][ disjoint_set_data_structure]
- [x ][ graph ] detect_cycle_in_directed_graph(dfs)
- [graph ] detect_cycle_in_directed_graph(disjointSet)
- [ ][ Sigtop error ][ greedy ][ IPC Trainer ] lecture arrangement to reduce sadness level
- [tree ] inorder_successor_in_BST
- [x ][ string ][ split_string_by_white_spaces]
- [string ] multiply_two_very_large_number
- [string ] sum_of_very_large_numbers
- circular_linked_list_transversal
- [ ][ delete at first node cause error ] delete_n_nodes_after_m_nodes_of_linked_list
- [ ][ first node insert is creating problem ] inserting_in_sorted_circular_linked_list
- reverse_a_linked_list
- modify_linked_list (https://www.interviewbit.com/problems/subtract/)
-
find_insert_position_in_sorted_array(https://www.interviewbit.com/help_requests/29770/)
-
count and say(https://practice.geeksforgeeks.org/problems/decode-the-pattern/0)
-
[x ] amazing_subarray
-
[x ][ string ] length_of_last_word
-
[x ][ string ] pallindrome_string
-
[x ][ string ] zig_zag_fashion_arrangement_of_string
-
[x ][ string ] find_length_of_prefix_is_same_as_suffix(KMP)(https://www.interviewbit.com/problems/minimum-characters-required-to-make-a-string-palindromic/)
-
pretty json (http://qa.geeksforgeeks.org/3734/qa.geeksforgeeks.org/3734/print-the-pretty-json-strings-facebook-microsoft.html)
-
[intersetction_of_two_sorted_arary]
-
[x ][ stack,deque ] simplifying_directory_path
-
[x ][ stack,array ] rain_water_trapping (https://leetcode.com/problems/trapping-rain-water/)
-
[2 sum] sum_of_pairs
-
[x ][ linked list ] intersection_of_two_nodes
-
[x ][ array,hash ] largest_continuous_seq_with_zero_sum
-
generate_all_parenthesis (https://leetcode.com/problems/generate-parentheses/)
-
[most-imp ][ string ][ backtrack ] pallindromic_partitioning (https://www.geeksforgeeks.org/given-a-string-print-all-possible-palindromic-partition/)
-
[x ][ math,hashing ] fraction_again
-
[x ][ math ] points_on_same_straight_line
-
[x ][ design ] min_stack (https://practice.geeksforgeeks.org/problems/special-stack/1)
-
[Tree ] next_greatest_number_in_bst
-
[x ][ Tree ] balanced_height_tree(https://leetcode.com/problems/balanced-binary-tree/)
-
[Tree ] identical_binary_tree
-
[x ][ Tree ] mirror_tree (https://practice.geeksforgeeks.org/problems/mirror-tree/1)
-
[x ][ Tree ] path_sum little different
-
[x ][ Tree ] sorted_array_to_BST_series(https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/)
-
[x ][ Tree ] kth_smallest_element_of_bst
-
[Tree ] BST_iterator ref solution
-
[x ][ array,string ] sorted_permutation_rank
-
[x ][ dp ] minimum_cost_path
-
[x ][ dp ] jump_game_array(https://leetcode.com/problems/jump-game/)
-
[x ][ dp ] count_minimum_number_of_jumps
-
[dp ] coins_in_a_line (https://practice.geeksforgeeks.org/problems/pots-of-gold-game/1)
-
[x ][ dp ][ tree ] count_unique_binary_search_tree
-
[ ][ dp ] maximum_sum_increasing_subsequence
-
[ ][ dp ] cutting_rod_to_minimize_cost
-
[ ][ dp ] count_sub_matrix_with_sum_0
-
[count_sub_array_with_sum_0]
-
[maximum_sum_submatrix]
-
[dp ] kingdome_war
-
[x ][ dp ] minimum_sum_path_in_rectangle
-
[dp ] dungen_princess
-
[x ][ greedy ] count_minimum_flips_to_turns_all_bulbs
-
[x ][ greedy ] highest_product of triplet
-
[imp ][ gredy ][ seats ] minimum_cost_to_arrange_seat_in_adjacent_order
-
[greedy ] distribute_candies
-
[x ][ greedy ] assign_mice_to_holes
-
[x ][ tree ] find_all_root_to_leaf_paths_with_given_sum(https://www.interviewbit.com/problems/sum-root-to-leaf-numbers/)
- [Algo Advances])(https://www.cs.rit.edu/~ib/#teach)(https://www.cs.rit.edu/~ib/Classes/CSCI261_01_Fall17-18/assignments.html)
- Algo Lecture MIT
- Analysis Algo
- Design Algo Good
- june_cookoff_multiple_choice_exam
- june_cookoff_eat_twice
- [ ] june_cookoff_drink_slush
- [ ] may_cookoff_recover_sequence
- april_lunchtime_fast_food
- april_lunchtime_attendance
- The Indian Job
- making anagram
- [ ][ Tree ] huffman-decoding
- [MS ] consecutive_1s_in_binary_represntation
- [ ][ heap ] queries_on_heap
- [ ][ hard ][ heap ] minimum_average_waiting_time
- [x ][ stack ] balanced_brackets
- [stack ][ easy ] equal_stack
- [ ][ queue ] queries_with_fixed_length
- [ ][ dp ][ queue ][ hard ] down_to_zero_11
- [greedy ][ easy ] luck_balance
- [x ][ medium ][ greedy ] greedy_florist
- game_of_digits
- [ ] next_in_series
- [tree ] sum_of_binary_tree
- [tree ]
- [x ][ tree ] sum_of_all_left_leaf_nodes
- [tree ] sum_of_nodes_of_longest_path_from_root_to_leaf
- [tree ] sum_of_leaf_nodes
- [tree ] find_closest_neighbour_in_bst
- [tree ] nodes_at_odd_level
- [tree ] delete_leaf_nodes_with_value_k
- [tree ] print_all_nodes_with_no_siblings
- [tree ][ ] find_max_path_sum_in_binary_tree
- [tree ][ medium ] construct_binary_tree_from_inorder_transversal
- [tree ][ medium ] binary_tree_pruning
- [x ][ tree ][ medium ] distribute_coins_in_binary_tree
- [tree ][ medium ] find_largest_value_in_each_row
- [tree ] find_bottom_left_most_tree_value
- [tree ] flip_equivalent_binary_tree
- [x ][ tree ] path_sum_ii
- [tree ] max_diff_between_nodes_and_ancestor
- [tree ] Insufficient_node_in_binary_tree
- [matrix ] minimum_path_sum
- [x ][ graph ] count_friend_circle
- [heap ] top_k_frequent_elements
- [x ][ array,heap ] k_closest_points_to_origin
- [imp ][ heap ] find_k_pairs_with_smallest_sum
- [string ] custom_sort_string
- [string ] reverse_words_in_string_in_constant_space
- [imp ][ dp ] predict_the_winner
- [hard ] swapping_2_nodes_in_bst (https://leetcode.com/problems/recover-binary-search-tree/submissions/)
- [dp ] filling_book_shelves
- [tree ] paths_in_zigzag_labelled_tree
- [hard ][ string ] parsing_a_boolean_expression
- [greedy ] mishka_and_last_exam
- [greedy ] score_after_flipping_matrix
- [greedy ] car_pooling
- [greedy ] queue_reconstruct_by_height
- [dp ] house_robber
- [dp ][ array ] house_robber_2
- [imp ][ dp ][ tree ] house_robber_3
- [array ][ range-query ] (https://practice.geeksforgeeks.org/problems/mountain-subarray-problem/1)
- [dp ][ series_of_stock_buy_and_sell_question_dp]
- [x ][ design ] design_circular_queue_2
- [x ][ queue ] moving_average_from_data
- [x ][ imp ][ array ] find_pivot_index_where_sum_on_left_and_right_is_equal
- [hard ][ design ] design_ds_for_all_operation_in_costant_time(https://www.geeksforgeeks.org/design-a-data-structure-that-supports-insert-delete-search-and-getrandom-in-constant-time/)
-
[tree ] check_if_tree_is_balanced_or_not
-
[hard ][ divide-conquer ] painters_partition_problem
-
[medium ][ divide-conquer ][ backtrack ] partition_to_k_equal_sum_subset
-
[easy ][ string ] time_conversion
-
[ ][ medium ][ balanced-tree ] self_balancing_tree
-
[easy ][ array ] min_diff_between_max_min_of_k_size_subset
-
https://www.leetfree.com/problems/construct-binary-tree-from-string.html
-
https://www.geeksforgeeks.org/represent-n-as-the-sum-of-exactly-k-powers-of-two-set-2/
-
https://www.geeksforgeeks.org/smallest-difference-triplet-from-three-arrays/
- [x ][ easy ][ linked-list ] middle_of_linked_list
- [easy ][ linked-list ] pallindromic_linked_list
- [easy ][ linked-list ] reverse_list
- [x ][ medium ][ linked-list ] rotate_list
- [x ][ medium ][ linked-list ] remove_nth_node_from_end
- [easy ][ array ] merge_2_sorted_array_with_no_extra_space (https://practice.geeksforgeeks.org/problems/merge-two-sorted-arrays/0)
- [x ][ medium ][ linked-list ] reverse_list_2 (https://www.interviewbit.com/problems/reverse-link-list-ii/)
- [imp ][ easy ][ string ] minimum_index_sum_of_two_list
- [x ][ medium ] find_merge_point_of_two_list (https://www.hackerrank.com/challenges/find-the-merge-point-of-two-joined-linked-lists/problem)
- [design ] design_linked_list
- [medium ][ tree ] delete_node_in_bst
- [x ][ easy ][ linked-list ] detect_cycle_in_list
- [easy ][ array ][ range-query ] range_sum_query_immutable
- [medium ][ range-query ] range_sum_query_muttable
- [easy ][ design ] design_queue_using_stacks
- [x ][ imp ][ easy ][ design ] design_stack_using_queues
- [imp ][ stack ][ medium ] exclusive_time_in_cpu_execution
- [range-query ] segment_tree
- [x ][ medium ][ tree ] sum_root_to_leaf_numbers
- [x ][ easy ][ greedy ] minimum_energy_to_cross_streat
- [medium ][ array ] minimum_swaps_required_to_groups_all_1s
- [imp ][ tree ][ medium ] deepest_node_in_binary_tree
- delete_node_and_return_forest
- [imp ][ medium ] continuous_array
- [x ][ math ][ easy ] count_prime_no (https://www.geeksforgeeks.org/sieve-of-eratosthenes/)
- [easy ][ imp ] happy_number
- [medium ][ math ] ugly_number_2
- [medium ][ math ] super_ugly_number
- [easy ] leetcode_contest_103
- [imp ] range_Addition
- [imp ] intersection_of_two_array_2 (https://leetcode.com/problems/intersection-of-two-arrays/)
- [easy ] smallest_range_1_2
- range_addition
- range_addition_2
- [x ] meeting_room_1
- meeting_room_2
- [x ][ imp ][ medium ][ array,heap ] merge_interval
- [imp ][ hard ] interval_list_intersections
- [hard ] insert_interval
- interval_list_intersection
- employees_free_time
- [hard ][ graph,disjoint-set ] minimize_malware_spread
- [x ][ easy ] lemonade_changes
- [medium ] minimum_cost_tree_from_leaf_values
- [medium ][ graph ] all_path_from_source_to_target
- [easy ] assign_cookies
- [medium ][ graph ] kth_symbol_in_grammar
- [imp ][ medium ] decode_string
- [x ][ medium ][ hash ] brick_wall
- [medium ][ tree ] populating_next_right_pointers
- [imp ][ math ][ medium ] increasing_triplet_subsequence
- [x ][ medium ][ backtrack ] letter_phone_combination
- [x ][ medium ] kth_largest_element_in_array
- [x ][ string ] group_anagram
- [x ][ matrix,graph ] number_of_island (https://www.geeksforgeeks.org/islands-in-a-graph-using-bfs/
- [easy ][ matrix ] island_perimeter
- [imp ][ hard ][ dp,string ] regular_exp_matching
- [imp ][ hard ][ dp ] wildcard_matching
- [x ][ imp ][ graph ] topological_sort
- [x ][ imp ][ graph ] course_schedule_12(https://leetcode.com/problems/course-schedule-ii/)
- [medium ][ imp,tree ] flatten_binary_tree_to_linked_list
- [x ][ easy ][ tree,string ] construct_string_from_tree
- [medium ][ tree ] check_if_subtree_matches
- [easy ][ tree ] subtree_of_another_tree
- [medium ][ greedy ] leetcode_contest_112
- [medium ][ stack ] leetcode_contest_112
- [medium ][ math,array ] leetcode_contest_112
- [ ][ medium ][ DFS,disjoint ] leetcode_contest_112
- [medium ][ array ] leetcode_contest_113
- [medium ][ tree ] leetcode_contest_113
- [ ][ hard ][ graph,disjoint ] leetcode_contest_113
- [easy ][ imp ][ math ] leetcode_contest_113
- [hard ][ string,dp,hash ] longest_string_chain
- [medium ][ tree ] maximum_binary_tree
- [medium ][ tree ][ ]
- [ ][ hard ][ most imp ][ graph,topological_sort ] biweekly_contest_5
- [medium ][ math,string ] valid_tic_tac_toe
- [x ][ array ] valid_sudoku
- [graph ] deep_clone_a_graph
- [x ][ array,matrix ] largest_square_in_binary_matrix (https://leetcode.com/problems/maximal-square/)
- [x ][ linked-list ] deep_clone_of_list(https://leetcode.com/problems/copy-list-with-random-pointer/)
- [x ][ hard ][ graph ] shortest_path_dijkstra
- [x ][ hard ][ graph ] prims_algorithm_mst
- [x ][ medium ][ graph ] shortest_path_using_bfs
- [x ][ medium ][ graph,disjointSet ] connect_cities_with_libraries
- [medium ][ array ] minimum_swaps_to_sort_array
- [medium ][ linked-list ] odd_even_linked_list
- [medium ][ linked-list ] linked_list_components
- [medium ][ linked-list ] erase_element_and_duplicates_from_list
- [easy ][ linked-list ] reverse_a_doubly_linked_list
- [x ][ medium ][ array ] random_pick_index
- [x ][ medium ][ array ] random_pick_with_weights
- [medium ][ search ] minimum_loss
- [x ][ medium ][ stack ] largest_rectangle_in_histogram
- [medium ][ stack ] simple_text_editor
- [easy ][ tree ] top
- [x ][ medium ][ tree ] right_side_view
- [linked-list ] sort_list_in_nlogn_time_with_constant_space
- [x ][ linked-list ] merge_sort_on_linked_list(https://www.hackerrank.com/challenges/merge-two-sorted-linked-lists/problem)
- [x ][ linked-list ] merge_k_sorted_list_2_method
- [ ][ hard ][ divide-conquer ][ binary-index-tree ] count_of_smaller_after_self
- [ ][ graph ] minimum_height_tree
- [ ]
- [ ] segment_tree(https://cp-algorithms.com/data_structures/segment_tree.html)
- [ ][ tree ] boundary_order_transversal(https://www.geeksforgeeks.org/boundary-traversal-of-binary-tree/)
- [ ][ design ] design_circular_queue to understand look into this
- [ ][ tree ][ medium ] find_smallest_subtree_with_deep_level
- [x ][ medium ][ string ] next_lexiographical_string
- [medium ][ sort,string ] counting_sort_special
- [x ][ medium ][ string ] count_all_possible_anagramic_substring
- [medium ][ algorithm ] gaming_array
- [x ][ medium ][ string ] password_cracker
- [x ][ medium ][ graph,bfs ] knight_on_chessboard
- [ ][ medium ][ array ]
- [x ][ medium ][ array ] flipping_the_matrix
- [medium ][ dp,array ] maximize_profit_stock_price
- [ ][ medium ][ backtrack ] power_sum
- [x ][ hard ][ array ] range_max
- [x ][ hard ][ greedy ] truck_tour_problem (https://practice.geeksforgeeks.org/problems/circular-tour/1/?ref=self)
- [medium ][ BST,DP ] generate_all_possible_BST
- [tree ] sum of nodes at maximum height
- [x ][ easy ][ array,hash ] two_sum_2_in_sorted_array
- [easy ][ array ] best_time_to_buy_ans_sell_stock
- [easy ][ binary-search ] search_insert_position
- [x ][ imp ][ medium ][ array ] majority_element_1_2(https://www.interviewbit.com/problems/majority-element/)
- [ ][ binary_search_on_values_in_increasing_order]
- [imp ][ binary-search ] search_element_in_rotated_array(https://leetcode.com/problems/search-in-rotated-sorted-array/)
- [x ][ tree ] minimum_depth_of_tree(https://www.interviewbit.com/problems/min-depth-of-binary-tree/)
- [imp ][ dp,tree ] maximum_path_sum_in_binary_tree
- [x ][ tree ] maximum_depth_in_m_ary_tree
- [easy ][ binary-search ] first_bad_version
- [imp ][ medium ][ binary-search ] koko_eating_bananas
- [x][most-imp ][ medium ][ binary-search ] find_first_and_last_position_of_element
- [most-imp ][ medium ][ binary-search ] find_k_closest_point
- [medium ][ dp,array ] triangle
- [medium ][ tree ] vertical_order_transversal
- [imp ][ medium ][ tree ][ populating_next_right_pointers]
- [medium ][ linked-list ] swap_list_nodes_in_pair
- [hashing ] pairs_with_given_difference
- [hashing ] anagram_pairs_of_string_array
- [x ][ Queues ] sliding_window_maximum
- [x ][ hard ][ queues ] queries_with_fixed_length
- [x ][ medium ][ Stacks And Queues ] redundant_braces
- [x ][ array,heap ][ hard ] find_median_of_running_stream_of_integers(https://leetcode.com/problems/find-median-from-data-stream/submissions/)
- [string ] length_of_longest_substring_with_consecutive_characters
- [x ][ hashing ] length_of_longest_substring_with_non_repeating_character
- [backtrack ] combinations_of_k_digit
- [backtrack ] combinational_sum
- [hard ][ dp,string ] longest_valid_parentheses(https://leetcode.com/problems/longest-valid-parentheses/)
- [dp ] decode_ways_1_2(https://leetcode.com/problems/decode-ways-ii/)(https://www.interviewbit.com/problems/ways-to-decode/)
- [x ][ dp ] minimum_edit_distance(https://www.interviewbit.com/problems/edit-distance/)
- [x ][ hard ][ dp,matrix ] unique_path_count
- [x ][ hard ][ dp ] unique_path_count_2
- [x ][ stack ] nearest_smallest_element
- [x ][ backtrack ] combinational_sum_2
- [x ][ backtrack ] combinations_sum_1_2(https://leetcode.com/problems/combination-sum-ii/)
- [Backtracking ] gray_code_sequence
- [ ][ very weird ] matrix_median_with_no_extra_space
- [x ][ hard ][ dp ] maximal_rectangle(https://www.interviewbit.com/problems/max-rectangle-in-binary-matrix/)
- [x ][ easy ][ dp ] climbing_stairs
- [data-structure-design ] climbing_the_leaderboard
- [imp ][ easy ] missing_number
- [x ][ backtrack ] permutations
- [x ][ backtrack ] permutations_1_2(https://leetcode.com/problems/permutations-ii/)
- [x ][ imp ][ bit-manipulation ] reverse_bits
- [imp ][ bit-manipulation ] sum_of_two_integer_without_operator
- [imp ][ bit-manipulation ] power_of_two_three_four
- [x ][ bit-manipulation,string ] letter_case_permuatations
- [x ][ bit-manipulation, dp ] counting_bits
- [medium ][ graph ] bfs_shortest_path
- [medium ][ graph ] kruskal_mst
- [x ][ medium ][ graph ] components_in_graph
- [x ][ hard ][ graph ] merging_communities
- [medium ][ tree ] preorder_transversal_iteratively
- [medium ][ tree ] inorder_transversal_iteratively
- [medium ][ tree ] lowest_common_ancestor_in_binary_tree
- [x ][ medium ][ tree ] lowest_common_ancestor_in_bst
-
[x ][ medium ][ dp ] coin_change
-
[medium ][ array ] max_sub_array_and_sub_seq
-
[medium ][ backtrack ] word_search
-
[ ][ medium ][ graph ] cut_the_tree
-
[ ][ medium ][ greedy ] install_transmitter_inhackerland
-
[x ][ easy ][ greedy ] mark_and_toys
-
[easy ][ greedy ] jim_and_orders
-
[easy ][ greedy ] permuting_two_array
-
[easy ][ greedy ] largest_permutation
-
[queue ][ greedy ] task_scheduler
-
[x ][ easy ][ greedy ] grid_challenge
-
[flipkart-2018 ] count_derangement
-
[BNY-Mellon-2018 ] huffman_decoding
-
[flipkart-2018 ] travelling_is_fun
-
[hackerrank ] elevator_travel
- [x ][ medium ][ array ] subarray_sum_equals_k
- [x ][ greedy ] maximum_product_subarray
- [imp ][ array ] maximum_product_of_three_number
- [medium ][ array ] subarray_product_less_than_k
- [medium ][ array ] product_of_array_except_self
- [medium ][ array ] count_subarray_with_even_sum
-
[medium ][ tree ] serialize_and_deserialize_BST
-
[medium ][ tree ] serialize_and_deserialize_binary_tree
-
[medium ][ tree ] find_duplicate_subtree
-
[x ][ medium ][ dp,string ] longest_pallindrome_substring(https://www.interviewbit.com/problems/longest-palindromic-substring/)
-
[x ][ medium ][ dp,string ] count_all_pallindromic_substring
-
[x ][ medium ][ dp ] maximum_sum_continuous_subarray
-
[medium ][ dp ] longest_turbulent_subarray
-
[medium ][ dp ] delete_operation_for_two_strings
-
[medium ][ graph ] cheapest_flights_within_k_stops
-
[x ][ easy ][ bit-manipulation ] find_the_difference
-
[medium ][ graph ][ graph_coloring_problem]
- [imp ][ easy ][ dp ] min_cost_climbing_stairs
- [medium ][ trie ] replace_words
- [medium ][ trie ] trie_implementation
- [medium ][ linked-list ] add_two_numbers
- [medium ][ linked-list ] add_two_numbers_2
- [medium ][ linked-list ] swap_pairs
- [x ][ medium ][ tree ] zigzag_level_order_tranversal
- [easy ][ string ] unique_morse_code
- [easy ][ string,stack ] remove_parentheses
- [medium ][ string ] vowel_spell_checker
- [easy ][ imp ][ array ] n_repeated_element_search
- [x ][ easy ][ graph ] employee_importance
- [easy ][ bit-manipulation ] binary_number_with_alternating_bits
- [easy ][ bit-manipulation ] number_complement
- [easy ][ bit-manipulation ] binary_watch
- [imp ][ easy ][ greedy ] two_city_scheduling
- [imp ][ medium ][ greedy ] partition_labels
- [array ] find_peak_element
- [x ][ dp ] longest_increasing_subsequence(https://www.interviewbit.com/problems/longest-increasing-subsequence/)
- [imp ][ greedy ] maximum_length_of_pair_chain
- [array ] two_sum_series(https://leetcode.com/problems/two-sum-iv-input-is-a-bst/)
- [x ][ imp ][ bit-manipulation ] number_of_one_bits
- [x ][ trie,hash ] contacts
- [x ][ imp ][ stack,heap ] maximum_freq_stack
- [x ][ array ] largest_number
- [x ][ imp ][ array,stack ] maximum_width_ramp
- [x ][ dp ] minimum_jump_game
- [math ] reach_a_number
- [x ][ graph ] valid_path
- [x ][ array ] relative_sorting
- [x ][ array ] flatten_2d_vector
- [x ][ imp ][ array ] first_missing_positive
- [x ][ imp ][ bit-manipulation ] single_number_1_2(https://www.interviewbit.com/problems/single-number-ii/)(https://leetcode.com/problems/single-number-ii/)
- [x ][ imp ][ bit-manipulation ] pairwise_hamming_distance(https://www.interviewbit.com/problems/different-bits-sum-pairwise/)
- [ ][ stack,queue ] min_max_riddle
- [dp ] candies_distribution
- [ ][ linked-list ] mail_system_design
- [x ][ bst ] linked_list_to_bst
- [x ][ stack,queue ] evaluate_expression
- [ ][ string ] text_encription
- [x ][ greedy ] minimum_number_of_shots_to_burst_ballons
- [x ][ bit-manipulation ] swap_all_odd_and_even_bits
- [x ][ array ] array_partition_1
- [ ][ array ] partiton_array_to_maximize_sum
- [x ][ backtrack ] path_with_maximum_gold
- [x ][ dp ] count_vowel_permutation
- [ ][ dp ] queen_attack
- [ ][ dp ] word_break
- [x ][ easy ][ string ] urlify_of_string
- [x ][ medium ][ array ] count_inversions
- [x ][ array ] hotel_booking_possible
- [x ][ array ] min_steps_in_infinite_grid
- [x ][ imp ][ array ] maximum_absolute_distance (https://www.geeksforgeeks.org/maximum-absolute-difference-value-index-sums/)
- [ ][ graph,tree ] redundant_connection
- [x ][ imp ][ string,backtrack ] valid_ip_address
- [x ][ linked-list ] partiton_list
- [x ][ graph ] journey_to_the_moon
- [ ][ v.imp ][ array ] count_subarray_with_sum_in_given_range
- [x ][ v-imp ][ array ] max_distance
- [input_using_string_stream]
- [x ][ math ] largest_prime_factor
- [x ][ math ] count_distinct_coprime_factor_in_given_range
- [ ][ string ] roll_the_character_of_string
- [x ][ v-imp ][ array ] count_subarray_sum_divisible_by_k
- [x ][ imp ][ dp ] path_in_the_grid
- [hard ][ honeywell ][ graph,tree ][ undirected_graph_to_string_while_root_is_unknown]
- [string ] find_sequence_in_string
- [hard ][ imp ][ dp ] collect_all_coins_in_minimum_steps
- [x ][ array ] remove_duplicate_from_array
- [x ][ imp ] pallindromic_partition_1
- [x ][ array ] minimize_the_absolute_difference
- [x ][ dp ] count_ways_to_reach
- [x ][ bit-manipulation ] maximum_xor_in_given_range
- [x ][ backtrack ] beautiful_arrangement
- [x ][ graph,dfs ] find_path_in_grid
- [x ][ string ] minimum_adjacent_swap_to_make_pallindrome(https://www.geeksforgeeks.org/minimum-number-of-adjacent-swaps-to-convert-a-string-into-its-given-anagram/)
- [x ][ backtrack,dfs ] rat_in_a_maze
- [x ] check_if_valid_pangram
- [x ][ array,two-pointer ] max_cont_series_of_1s_with_k_0s
- [x ][ array,two-pointer ] container_with_most_water
- [x ][ array ] sort_by_color
- [x ][ graph ] check_bipartite_graph(2-color-problem)
- [ ][ graph ] detect_cycle_in_undirected_graph(https://www.geeksforgeeks.org/detect-cycle-undirected-graph/) (https://www.geeksforgeeks.org/detect-cycle-in-an-undirected-graph-using-bfs/)
- [x ][ graph ] dijkstra_algo_using_adjacency_matrix_in_c
- [ ][ bfs,dfs,graph ] word_boggle
- [imp ][ array ] maximize_size_of_consecutive_number
- [tree ] preorder_to_postorder
- [ ][ imp ][ array ]
- [imp ][ hard ][ dp ] cherry_pickup
- [dp,backtrack ] interleaved_strings
- [x ][ easy ][ array ] boolean_matrix
- [ ][ bit-manipulation ] bleak_number
- [x ][ math ] lcm_and_gcd
- [dp ] count_palindromic_subsequence
- [medium ][ graph ] minimum_penalty_path
- [graph ] even_tree
- [x ][ tree ] find_closest_element_in_bst
- [x ][ tree ] add_all_greater_values_to_very_node_in_bst
- [tree,greedy ] binary_tree_cameras
- [math ] modular_exponential_power
- [array ] pallindromic_array
- [dp ] max_sum_without_adjacent_elements
- [imp ][ array,heap ] kth_largest_element_in_stream
- [easy ][ string ] min_manipulations_to_make_strings_anagram
- [dp,string ] minimum_cost_to_make_two_string_equal
- [imp ][ string ] count_no_of_unique_substring_in_nlogn
- [math ] excel_column_number
- [math ] excel_column_title (https://practice.geeksforgeeks.org/problems/column-name-from-a-given-column-number/0/?ref=self)
- [math ] rearrange_array
- [array,bfs ] min_time_to_rot_all_oranges
- [queue ] first_non_repeating_char_in_a_stream
- [dp ] max_diff_of_zeros_and_ones_in_binary_string
- [array ] max_distinct_element_after_removing_k_elements
- [hard ][ stack ] poisonous_plants
- [medium ][ dp ] perfect_squares
- [hash,graph ] verify_alien_dictionary
- [graph ] alien_dictioanry
- [tree ] shortest_unique_prefix
- [easy ][ tree ] diameter_of_binary_tree
- [tree ] cartesian_tree
- [dp ] dice_throws
- [dp ] count_of_dearrangements
- [string ] window_string
- [dp ] total_decode_message
- [math ] integral_points_in_triangle
- [imp ][ dp ] max_abs_diff_of_sum_of_two_continuous_subarray
- [array,bit-manipulation ] min_abs_diff_of_xor_of_subarray
- [math ] euler_totient
- [ ][ string ] smallest_distant_window
- [dp ] minimum_number_of_coins
- [tree ] fendwick_tree
- [ tree ]find_bottom_left_tree_value
- [ array ]sort_an_array
- [ tree ]sum_of_left_leafs
- [ binary-search ]binary_search
- [ stack ]evaluate_postfix_expression
- [ array ]single_element_in_sorted_array
- [ bit-manipulation ]single_number_3
-
[x ][ array ] lower_bound_algo
-
[x ][ array ] count_distinct_element_in_window
-
[x ][ linked-list ] k_reverse_linked_list
-
[ ][ kth smallest element with linear time ] kth_smallest_element_in_unsorted_array_in_constant_space (https://www.geeksforgeeks.org/kth-smallestlargest-element-unsorted-array-set-2-expected-linear-time/) (https://www.geeksforgeeks.org/kth-smallestlargest-element-unsorted-array-set-3-worst-case-linear-time/)
-
[ ][ array ] median_of_two_array
-
[string ] longest_prefix_suffix(KMP)
-
[dp ] box_satcking
-
[linked-list ] compare_two_linked_list
-
[external_merge_sort]
-
[design ] LRU_design(https://leetcode.com/problems/lru-cache/)
-
[ ][ easy ] maximum_element_from_stack
-
[ ][ medium ][ queue ] minimum_moves_to_reach_the_destination
-
[ ][ inheritances_in_c++]
-
[DP] longest arithmatic progression(https://practice.geeksforgeeks.org/problems/longest-arithmetic-progression/0)(https://www.youtube.com/watch?v=hw8pXjHcV2s)
-
[ ] triplet sum
-
[ ] occurance of 2 as digit (https://math.stackexchange.com/questions/47477/number-of-occurrences-of-the-digit-1-in-the-numbers-from-0-to-n) (https://www.geeksforgeeks.org/number-of-occurrences-of-2-as-a-digit-in-numbers-from-0-to-n/)
-
all possible combination of a number with number smaller than that
-
[ ] max rectangle
-
[pointer_tutorials.cpp]
-
[tree ] search a node in binary tree
-
[ ][ tree ] kth ancestor node in binary tree
- [ ][ hard ]
- [medium ][ ] // https://leetcode.com/problems/maximum-subarray/discuss/20200/Share-my-solutions-both-greedy-and-divide-and-conquer
https://leetcode.com/articles/sum-of-distances-in-tree/# https://www.hackerrank.com/contests/test-contest-27/challenges/paintwall/problem https://www.geeksforgeeks.org/painting-fence-algorithm/ https://www.geeksforgeeks.org/painters-partition-problem/ https://www.geeksforgeeks.org/m-coloring-problem-backtracking-5/
-
[medium ][ array ] rotate_image
-
[x ][ greedy ] job_sequencing_problem
-
[greedy ][ disjoint_set ] job_sequencing_problem_using_disjoint_set
-
[ ][ hard ][ graph ] maximum_cost_queries
-
[ ] next permutation
-
[ ][ dp ][ backtrack ] summing_pieces
-
[ ] gridland_metro
-
[ ] count_luck
-
[ ][ hard ][ string ] longest_valid_parentheses
-
[ ] shuffling data
-
[ ] dp
-
[ ][ array ] find_element_bitonic_array
-
[ ][ design ] design_ds_for_all_operation_in_costant_time_2
-
[ ][ dp ] best_time_to_buy_and_sell_stock
-
[ ][ queue ][ greedy ] reorganize_string
-
[ ][ dp ] minimum_cost_for_tickets
-
[ ][ imp ][ dp ] can_i_win
-
[ ][ ncr_using_dp]
-
[ ] smallest_window_in_String_contain_another_strings_character(https://practice.geeksforgeeks.org/problems/smallest-window-in-a-string-containing-all-the-characters-of-another-string/0)
-
[optimize code] [4 sum] find_sequence_of_4_with_given_sum (https://practice.geeksforgeeks.org/problems/find-all-four-sum-numbers/0)
-
[ ][ tree ][ hard ] sum_of_distance_in_tree
-
[ ][ tree ][ hard ] binary_tree_cameras
-
[ ][ string ][ Longest Substring with At Most K Distinct Characters]
-
[ ][ string ][ Longest Substring with At Most Two Distinct Characters]
-
[ ][ dp ][ graph ] network_delay_time
-
[ ][ most important set of problem ][ partition_problem]
-
[ ][ most important set of problem ][ find/count subarray/subsequence with given sum/product]
-
[ ][ most important set of problem ][ longest substrings/subsequence]
-
[ ][ hard ] smallest_range_free_time
-
[ ][ medium ][ bit ] winning_lottery_ticket
https://leetcode.com/problems/largest-plus-sign/ https://leetcode.com/problems/coloring-a-border/ https://www.geeksforgeeks.org/given-matrix-o-x-find-largest-subsquare-surrounded-x/ https://leetcode.com/problems/largest-1-bordered-square/ https://leetcode.com/problems/minimum-area-rectangle-ii/ https://www.geeksforgeeks.org/maximum-size-rectangle-binary-sub-matrix-1s/ https://leetcode.com/problems/construct-the-rectangle https://leetcode.com/problems/minimum-area-rectangle/
- [ ][ medium ][ graph ] lonely_pixel_1
- http://buttercola.blogspot.com/2016/01/leetcode-maximum-size-subarray-sum.html
- https://www.leetfree.com/problems/add-bold-tag-in-string.html
- interview prepration site
- https://www.youtube.com/playlist?list=PLyvBGMFYV3auVdxQ1-88ivNFpmUEy-U3M
- https://www.youtube.com/playlist?list=PLRFPL_aa_SLVjQn93cUGZaKZVGr_80vYv
- https://www.youtube.com/playlist?list=PL9426FE14B809CC41
- https://www.youtube.com/playlist?list=PL52484DF04A264E59
struct myData{
string key, value;
};
struct compare{
bool operator()(const myData &lhs, const myData &rhs) const{
return lhs.key < rhs.key;
}
};
set<myData, compare> mySet;
mySet.insert(myData{"Hii"})sort(begin(cs), end(cs), [](vector<int> &v1, vector<int> &v2) {
return (v1[0] - v1[1] < v2[0] - v2[1]);
});- Modulo Operator for output ((a-b)%m = (a%m - b%m + m)%m)
consider this: (14-1)%7. If you just do ((14%7 - 1%7)%7), you will get -1(considering implementation in C/C++). That's why add divisor before final division. (14%7 - 1%7 + 7)%7 = 6 which is the expected answer. And when the result of first two modular divions is non-negative adding divisor won't affect the result which is easy to prove. Hope you get the logic.
- Init struct
struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };Input: logs = ["0:start:0","1:start:2","1:end:5","0:end:6"]
struct Log {
int id;
string status;
int timestamp;
};
for(string log: logs) {
stringstream ss(log);
string temp, temp2, temp3;
getline(ss, temp, ':');
getline(ss, temp2, ':');
getline(ss, temp3, ':');
Log item = {stoi(temp), temp2, stoi(temp3)};
- Pass Struct Node as reference
void call_func(TreeNode* &root){
root->left = new TreeNode(10); // we access orig node, which is passed as pointer in call_func function.
}
void main()
{
TreeNode* root = NULL;
call_func(root);
}- Class Constructor in one line
Rectangle (int x, int y) : width(x), height(y) { }
- String to int (STL):
1. Use C++ standard library std::stringstream.
#include <sstream>
#include <string>
std::string text = "123";
int number;
std::istringstream iss (text);
iss >> number;
if (iss.fail()) {
// something wrong happened
}
2. Use std::stoi() function from C++ standard library since C++11.
#include <iostream>
#include <string>
int main ()
{
std::string str("123");
int n = std::stoi(str);
std::cout << str << " --> " << n << std::endl;
return 0;
}- Easy method to return vector
return vector<int> ({1,2});
or
return {1,2};
- No control tranfer
- copy the function in the place where it is called at compile time.
n & (n-1)drops lowest set bit- to count all set bit: use
while (n) { n &= (n - 1); count++; }
A simple example using std::sort
struct MyStruct{
int key;
std::string stringValue;
MyStruct(int k, const std::string& s) : key(k), stringValue(s) {}
};
struct less_than_key{
inline bool operator() (const MyStruct& struct1, const MyStruct& struct2){
return (struct1.key < struct2.key);
}
};
std::vector < MyStruct > vec;
vec.push_back(MyStruct(4, "test"));
vec.push_back(MyStruct(3, "a"));
vec.push_back(MyStruct(2, "is"));
vec.push_back(MyStruct(1, "this"));
std::sort(vec.begin(), vec.end(), less_than_key());
Edit: As Kirill V. Lyadvinsky pointed out, instead of supplying a sort predicate, you can implement the operator< for MyStruct:
struct MyStruct
{
int key;
std::string stringValue;
MyStruct(int k, const std::string& s) : key(k), stringValue(s) {}
bool operator < (const MyStruct& str) const
{
return (key < str.key);
}
};
Using this method means you can simply sort the vector as follows:
std::sort(vec.begin(), vec.end());
Edit2: As Kappa suggests you can also sort the vector in the descending order by overloading a > operator and changing call of sort a bit:
struct MyStruct
{
int key;
std::string stringValue;
MyStruct(int k, const std::string& s) : key(k), stringValue(s) {}
bool operator > (const MyStruct& str) const
{
return (key > str.key);
}
};
And you should call sort as:
std::sort(vec.begin(), vec.end(),greater<MyStruct>());
Note: unordered_map is hash, that throw error with key as pair, there exist a method, by overloading size operator and redefine template using hash function. But simple is following Alterning:
map<pair<int, int>, int> vis;
for(int i=0; i<10; i++){
vis[{i,i}] = i;
}
for(auto c : vis){
cout<<c.first.first<<" "<<c.first.second<<" "<<c.second<<endl;
}
// if(Vis.count(mpa(x, y)))
// continue;
// Vis[mpa(x, y)] = true;
class Node {
public:
int val;
Node* next;
Node* random;
Node() {}
Node(int _val, Node* _next, Node* _random) {
val = _val;
next = _next;
random = _random;
}
};class custom_pq{
public:
int d, x, y;
custom_pq(int d_, int x_, int y_):
d(d_), x(x_), y(y_){}
};
bool operator<(const custom_pq &p1, const custom_pq &p2){
return (p1.d > p2.d);
}
priority_queue<custom_pq> pq;struct custom_pq{
int d, x, y;
custom_pq(int d_, int x_, int y_):
d(d_), x(x_), y(y_){}
};
struct custom_sort{
bool operator()(const custom_pq &p1, const custom_pq &p2){
return (p1.d > p2.d);
}
};
priority_queue<custom_pq, vector<custom_pq>, custom_sort> pq;#define ll long long int
#define mod 1000000007
typedef long long int ll;
- use
statickeyword
int* topoSort(int V, vector<int> adj[]){
static int ans[max_size];
return ans;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
multimap<int,int> map;
map.insert({1,204});
map.insert({1,202});
map.insert({1,201});
map.insert({2,200});
map.insert({2,290});
typedef std::multimap<int, int>::iterator MMAPIterator;
// It returns a pair representing the range of elements with key equal to 'c'
std::pair<MMAPIterator, MMAPIterator> result = map.equal_range(1);
for (MMAPIterator it = result.first; it != result.second; it++)
std::cout << it->second << std::endl;
}
string s(1, ch);string s; s.push_back(ch);s = c;string s; s += c;
istringstream ss(s);
string word;
while(ss >> word){
cout<<word<<"\t";
}
char ch[] ={'a','b','a','e','d'};
set<char> vis;
unordered_set<char> visi;
Output:
a b d e :: sorted and order maintain according to first unique value
d e a b :: not sorted and order is maintained in reverse order#include <bits/stdc++.h>
using namespace std;
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
int main()
{
int a, b;
a = 1000;
b = 3;
float c = a/(b*1.0);
cout<<c<<endl;;
// cout<<fixed<<setprecision(2)<<c<<endl;
cout<<FIXED_FLOAT(c)<<endl;
cout<<c<<endl;
cout<<a<<endl;
cout<<b<<endl;
cout<<1.2345<<endl;
// simple trick, convert it manually, using multiplication and division
float ans = (int(c*10))*1.0/10.0;
cout<<ans<<endl;
return 0;
}char a[] = {'C','O','D','E' };
char b[] = "geeksforgeeks";
string sa = a;
string sb = b;string s = "geeksforgeeks";
int n = s.length();
char char_array[n + 1];
strcpy(char_array, s.c_str());2nd approach:
string s = "Hello World!";
char cstr[s.size() + 1];
copy(s.begin(), s.end(), cstr);
cstr[s.size()] = '\0';
cout << cstr << '\n';#include <ctime>
template<class T>
T *FindMRandom(T *array, int m){
int m, n = array.size();
T *temp = new T[m];
srand((unsigned )time(0));
for (int i=0; i<m; ++i ){
m = rand() % (n-i);
temp[i] = array[m];
Swap(array[m], array[n-i-1]);
}
return temp;
}
/*
It seems to me that the second element's probability is not 1/n-1. It is the probability that it is *not* chosen the first time (n-1/n) times the probability that it *is* chosen the second time (1/n-1).
(n-1/n)*(1/n-1) = 1/n
For the third element:
(n-1/n)*(n-2/n-1)*(1/n-2) = 1/n
*/ int M = 2, N = 3, O = 4;
int* A = (int*)malloc(M * N * O * sizeof(int));
// assign values to allocated memory
for (int i = 0; i < M; i++)
for (int j = 0; j < N; j++)
for (int k = 0; k < O; k++)
*(A + i*N*O + j*O + k) = rand() % 100;
// to print, use: printf("%d ", *(A + i*N*O + j*O + k));
// deallocate memory
free(A);int *p;
p = new int[5];
for(int i=0;i<5;i++)
*(p+i)=i;
// realloc
int* temp = new int[6];
std::copy(p, p + 5, temp); // Suggested by comments from Nick and Bojan
delete [] p;
p = temp;