Skip to content

vishnu921/Data-Structures-and-Algorithms

Repository files navigation

Data Structures and Algorithms

Hi đź‘‹ this repository contains DSA problems solved by me in C++ programming language.

Arrays

  1. reverse_array.cpp
  2. MinMax.cpp
  3. ksmall_min_heap.cpp
  4. move_negetive.cpp
  5. mini_heights.cpp
  6. min_jump.cpp
  7. merge_sorted.cpp
  8. merge_intervals.cpp
  9. rearrang_withOn.cpp
  10. max_subarray.cpp
  11. max_profit_twice_st.cpp
  12. count_inv.cpp
  13. find_duplicate_in_array_of_n+1.cpp
  14. merge_2_sorted_using_gapMethod.cpp
  15. maximum_intervals_overlap.cpp
  16. next_perm.cpp
  17. count_pairs_sum.cpp
  18. zero_sum_subarray.cpp
  19. factorial_of_large_numbers.cpp
  20. maximum_product_subarray.cpp
  21. triplet_sum_in_array.cpp
  22. three_way_partition.cpp
  23. minimum_swaps_and_k_together.cpp
  24. make_palindromic_with_minium_operations.cpp
  25. product_except_self.cpp
  26. bishu_and_soldiers_hackerearth.cpp

Searching and Sorting

  1. binary_search.cpp
  2. bubble_sort.cpp
  3. selection_sort.cpp
  4. merge_sort.cpp
  5. quick_sort.cpp
  6. count_sort.cpp
  7. insertion_sort.cpp
  8. max_occuring_element.cpp
  9. DNF_sort.cpp
  10. missing_and_repeating.cpp
  11. merge_2_sorted_array_gap_method.cpp
  12. bishu_and_soldiers_hackerearth.cpp
  13. kth_smallest_number_again.cpp
  14. kth_element_of_two_sorted_arrays.cpp
  15. aggressive_cows.cpp
  16. eko_spoj.cpp

Strings

  1. reverse_string.cpp
  2. isPalindrome.cpp
  3. print_all_subsequences.cpp
  4. split_binary_strings_with_equal_no_of_0s_and_1s.cpp
  5. next_permutation.cpp
  6. rabin_karp_algorithm.cpp
  7. recursively_print_all_sentences.cpp
  8. convert_roman_numerals_to_decimal.cpp
  9. isomorphic_strings.cpp
  10. longest_prefix_suffix.cpp
  11. kmp_algorithm.cpp
  12. count_the_reversals.cpp
  13. find_string_in_a_grid.cpp
  14. min_number_of_flips.cpp
  15. longest_common_prefix.cpp
  16. min_swaps_to_balance.cpp
  17. second_most_repeated_string.cpp
  18. generate_all_ip_address.cpp
  19. group_anagrams.cpp
  20. minimum_window_substring.cpp
  21. rearrange_such_that_adjacent_are_not_same.cpp
  22. another_string_minimum_window_substring.cpp
  23. wildcard_matching.cpp
  24. no_of_customer_with_no_computer.cpp

Recursion and Backtracking

  1. Print all subsequences
  2. Keypad Combinations
  3. Recursively remove all adjacent duplicates
  4. Print factorial of n
  5. Print Greatest Common divisor(GCD) of 2 numbers
  6. N Queens
  7. Rat in a maze
  8. Word Break Problem
  9. Remove Invalid Parantheses
  10. Sudoku Solver
  11. M colouring Problem
  12. Shortest safe route in path with landmines
  13. A Knight's tour
  14. Combination Sum
  15. Print all palindromic partitions
  16. Print all permutations
  17. nth lexographical permutation
  18. nth lexographical permutation in strings
  19. Partition into K subsets with equal sum
  20. Print all possible paths in matrix from top-left to bottom-right
  21. Length of longest possible route in matrix
  22. Find largest number by doing atmost k swaps
  23. Word Search
  24. Tug of war

Linked Lists

  1. Singly Linked List implementation
  2. Doubly Linked list implementation
  3. Reverse singly linked list
  4. Reverse k nodes in linked list
  5. Reverse k nodes in doubly linked list
  6. Check if a linked list is palindromic or not
  7. Circular linked list implementation
  8. delete operations in circular linked list
  9. delete operations in doubly linked list
  10. Add 1 to a number in the form of linked_list
  11. Delete duplicates in both (sorted and unsorted) linked list
  12. flatten a linked list
  13. Remove a given value in circular linked list
  14. Detect loop in a linked list
  15. Remove loop in circular linked list
  16. Find intersection of 2 sorted linked list
  17. Find intersection of 2 unsorted linked list
  18. Merge sort on linked list
  19. Reorder linked list
  20. Find pair with given sum in doubly linked list
  21. Rotate a doubly linked list
  22. split circular linked list in 2 halves

Stack and Queue

  1. stack_linked.cpp
  2. que_arr.cpp
  3. que_linked.cpp
  4. stack_arr.cpp
  5. balanced_paranth.cpp
  6. two_stack.cpp
  7. reverse_string.cpp
  8. next_greatest.cpp
  9. strev_recur.cpp
  10. eval_posfix.cpp
  11. celebrity.cpp
  12. sortst_rec.cpp
  13. mergeint_st.cpp
  14. area_histogram.cpp
  15. longest_valid.cpp
  16. redundant_bracket.cpp
  17. stack_usingque.cpp
  18. next_smallest.cpp
  19. que_usingStack.cpp
  20. kstacks.cpp
  21. getmin.cpp
  22. circularQueue.cpp
  23. kqueues.cpp
  24. reverse_kqu.cpp
  25. interleave.cpp
  26. circularTour.cpp
  27. first_neg.cpp
  28. sum_minmax.cpp
  29. first_nonRepeating.cpp
  30. max_of_subaarray.cpp
  31. decode_string.cpp

Tree

1. Binary Tree

  1. implement.cpp
  2. reverse_levelOrder.cpp
  3. diamter.cpp
  4. dfs.cpp
  5. left_view.cpp
  6. right_view.cpp
  7. topview.cpp
  8. bottomView.cpp
  9. zig_zagSpiral.cpp
  10. check_balanced.cpp
  11. diagonal_traversal.cpp
  12. boundary_traversal.cpp
  13. build_brackets.cpp
  14. convert_toDLL.cpp
  15. convertToSumtree.cpp
  16. isSumTree.cpp
  17. build_from_inorder_preorder.cpp
  18. min_swaps_bst.cpp
  19. check_levelleaf.cpp
  20. sumofLongRootToLeafPath.cpp
  21. largest_subtree_sum.cpp
  22. lowest_common_ancestor.cpp
  23. distanceBetweenNodes.cpp
  24. kth_ancestor.cpp
  25. duplicate_subtree.cpp
  26. max_sum_nonAdjacent.cpp
  27. isomorphous.cpp
  28. build_tree.cpp
  29. vertical_order.cpp

2. Binary Search Tree

  1. search_and_insertion.cpp
  2. deletion.cpp
  3. findMinMax.cpp
  4. inorder_pred_suc.cpp
  5. inorder_predSuc_iterative.cpp.cpp
  6. inorder_predSuc_iterative.cpp
  7. isBST.cpp
  8. populate_inorder_successor.cpp
  9. LCAinBST.cpp
  10. BST_from_preorder.cpp
  11. binaryTree_to_BST.cpp
  12. balance_BST.cpp
  13. kthLargestinBST.cpp
  14. threaded_binary_tree.cpp
  15. Morris_traversal.cpp
  16. kth_SmallestUsingMorris.cpp
  17. Brother_from_different_roots.cpp
  18. findMedian_bst.cpp
  19. countNodes_in_range.cpp
  20. replace_with_leastGreaterOnRight.cpp
  21. Dead_End.cpp
  22. valid_preorder_for_BST.cpp
  23. merge_2_bst.cpp
  24. Largest_bst.cpp
  25. flatten_bst_sorted_list.cpp

Heap

  1. max_heap.cpp
  2. heap_sort.cpp
  3. sort_characters_by_freq.cpp
  4. kthSmallest.cpp
  5. kthsmallest_using_Quickselect.cpp
  6. merge_k_sorted_arrays.cpp
  7. reorganize_string.cpp
  8. kth_largest_sum_subarray.cpp
  9. merge_k_sorted_lists.cpp
  10. smallest_range_k_lists.cpp
  11. min_cost_of_ropes.cpp
  12. minimum_sum.cpp
  13. sliding_window_max.cpp
  14. isBinaryTree_maxheap.cpp
  15. convert_bst_to_minheap.cpp
  16. nearly_sorted_algorithm.cpp
  17. median_in_stream.cpp

Graphs

  1. breadth_first_search.cpp
  2. depth_first_search.cpp
  3. detect_cycle_in_undirected_graph.cpp
  4. detect_cycle_in_directed_graph_using_dfs.cpp
  5. topological_sort_DFS.cpp
  6. kahn_algorithm_topoSort.cpp
  7. detect_cycle_in_directed_graph_using_kahn_algorithm.cpp
  8. find_number_of_islands.cpp
  9. rat_in_a_maze.cpp
  10. steps_by_knight.cpp
  11. shortest_path_in_unweighted_graph.cpp
  12. flood_fill.cpp
  13. clone_a_graph.cpp
  14. min_operations_to_connect_network.cpp
  15. is_Bipartite.cpp
  16. prerequisite_tasks.cpp
  17. prims_algorithm.cpp
  18. disjoint_sets.cpp
  19. kruskals_algorithm.cpp
  20. dijkstra_algorithm.cpp
  21. alien_dictionary.cpp
  22. word_ladder.cpp
  23. bellman_ford_algorithm.cpp
  24. detect_negetive_cycle.cpp
  25. floyd_warshall_algorithm.cpp
  26. snakes_and_ladders.cpp
  27. hamiltonian_path.cpp
  28. hamiltonian_cycle.cpp
  29. shortest_path_in_weighted_directed_acyclic_graph.cpp
  30. check__whether_an_edge_is_bridge.cpp
  31. find_all_bridges.cpp
  32. find_articulation_points.cpp
  33. kosaraju_algorithm.cpp
  34. journey_to_the_moon.cpp
  35. oliver_and_the_game.cpp
  36. path_greater_than_k_length.cpp
  37. m-coloring.cpp

Trie

  1. insert_and_search.cpp
  2. delete_in_trie.cpp
  3. shortest_unique_prefix_of_each_word.cpp
  4. word_break_using_trie.cpp
  5. Groupanagram_using_trie.cpp
  6. phone_directory.cpp
  7. unique_row_in_binary_matrix.cpp

Greedy Algorithms

  1. activity_selection.cpp
  2. job_sequencing.cpp
  3. fractional_knapsack.cpp
  4. choose_and_swap.cpp
  5. huffman_coding.cpp
  6. maximum_trains_for_stoppage.cpp
  7. minimum_platforms.cpp
  8. buy_max_stocks.cpp
  9. if_it_is_possible_to_survive.cpp
  10. maximum_product_subset.cpp
  11. maxsum_of_absDifference.cpp
  12. smallest_subset_with_largestsum.cpp
  13. chocolate_distribution.cpp
  14. defence_kingdom.cpp
  15. die_hard.cpp
  16. three_stacks.cpp
  17. wine_in_gergovia.cpp
  18. picking_up_chicks.cpp
  19. chocolate_cut.cpp
  20. arranging_amplifiers.cpp
  21. min_cost_ropes.cpp
  22. smallest_number.cpp

Dynamic Programming

  1. nth_fibonnaci.cpp
  2. 01knapsack.cpp
  3. climbing_stairs.cpp
  4. paint_stairs.cpp
  5. binomial_coefficient.cpp
  6. longest_increasing_subsequence.cpp
  7. min_jumps_to_reach_end.cpp
  8. permutation_coeff.cpp
  9. stickler_thief.cpp
  10. nth_catalan.cpp
  11. partition_equal_sum_subset.cpp
  12. subset_sum.cpp
  13. min_subset_sum_difference.cpp
  14. count_subsets_with_given_sum.cpp
  15. count_subset_with_given_difference.cpp
  16. unbounded_knapsack.cpp
  17. rod_cutting.cpp
  18. coin_change_count.cpp
  19. coin_change_Min.cpp
  20. friends_pairing.cpp
  21. gold_mine.cpp
  22. maximize_cut.cpp
  23. painting_fence.cpp
  24. longest_common_subsequence.cpp
  25. longest_common_substring.cpp
  26. edit_distance.cpp
  27. lcs_of_three.cpp
  28. print_the_lcs.cpp
  29. shortest_common_supersequence.cpp
  30. print_the_scsupersequence.cpp
  31. longest_palindromic_subsequence.cpp
  32. minimum_deletions.cpp
  33. longest_repeating_subsequence.cpp
  34. max_sum_increasing_subsequence.cpp
  35. count_subsequence_with_product_less_than_k.cpp
  36. longest_subsequence_with_given_adjacent_diff.cpp
  37. stickler_thief_with_no_3_consecutive.cpp
  38. matrix_chain_multiplication.cpp
  39. egg_dropping.cpp
  40. largest_sq_submatrix_of_1s.cpp
  41. pairs_with_specific_difference.cpp
  42. matrix_max_path_sum.cpp
  43. min_cost_path.cpp
  44. max_difference_of_01_substring.cpp
  45. optimal_strategy_for_game.cpp
  46. count_palindromic_substrings.cpp
  47. longest_palindromic_substring.cpp
  48. word_break.cpp
  49. wildcard_pattern_matching.cpp
  50. count_palindromic_subsequences.cpp
  51. count_occurences_in_a_matrix.cpp

Number Theory

  1. gcd.cpp
  2. binary_exponentiation.cpp