Giter Site home page Giter Site logo

stepantita / interview-prep Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 140 KB

This repository contains C++ solutions for various LeetCode problems, categorized into multiple sections by topics

C++ 98.99% Python 1.01%
algorithm-challenges algorithms c-plus-plus cpp data-structures leetcode leetcode-solutions problem-solving programming programming-exercises

interview-prep's Introduction

LeetCode Problem Solutions in C++

Welcome to my LeetCode problem solutions repository! ๐Ÿ‘‹ Here, you'll find C++ solutions to a variety of interesting problems across different categories. Feel free to explore and learn from these solutions as you tackle your own LeetCode challenges. If you find this repository helpful, please consider giving it a โญ๏ธ!

Problems

Binary Search ๐Ÿ”:

  1. Search Insert Position
  2. Search a 2D Matrix
  3. Search a 2D Matrix II
  4. Find Peak Element
  5. Search in Rotated Sorted Array
  6. Find First and Last Position of Element in Sorted Array
  7. Find Minimum in Rotated Sorted Array
  8. Median of Two Sorted Arrays
  9. Ways to Split Array Into Three Subarrays

Dynamic Programming ๐Ÿงฎ:

  1. Climbing Stairs
  2. House Robber
  3. Word Break
  4. All Possible Full Binary Trees
  5. Get Maximum in Generated Array
  6. N-th Tribonacci Number
  7. Longest Increasing Subsequence
  8. Coin Change
  9. Partition Array for Maximum Sum
  10. Egg Drop With 2 Eggs and N Floors
  11. Count Substrings That Differ by One Character
  12. Fair Distribution of Cookies
  13. Stone Game II
  14. Palindromic Substrings
  15. Longest ZigZag Path in a Binary Tree
  16. Longest Subarray of 1's After Deleting One Element
  17. Palindrome Partitioning
  18. Minimum Path Cost in a Grid
  19. Minimum Falling Path Sum
  20. Minimum Cost For Tickets
  21. Arithmetic Slices
  22. Minimum ASCII Delete Sum for Two Strings
  23. Minimum ASCII Delete Sum for Two Strings
  24. Beautiful Arrangement Solution
  25. Ways to Make a Fair Array
  26. Uncrossed Lines
  27. Longest Palindromic Subsequence
  28. Maximum Compatibility Score Sum
  29. Flip String to Monotone Increasing Solution
  30. Different Ways to Add Parentheses Solution
  31. Delete Operation for Two Strings
  32. Longest String Chain
  33. Unique Binary Search Trees
  34. Integer Break
  35. Maximum Sum of Two Non-Overlapping Subarrays
  36. Filling Bookcase Shelves
  37. Best Sightseeing Pair
  38. Maximum Alternating Subsequence Sum
  39. Maximum Absolute Sum of Any Subarray
  40. Minimum Deletions to Make String Balanced
  41. Number of Smooth Descent Periods of a Stock
  42. Make Costs of Paths Equal in a Binary Tree
  43. Find the City With the Smallest Number of Neighbors at a Threshold Distance
  44. Stone Game VII
  45. Longest Common Subsequence
  46. Shortest Common Supersequence
  47. Best Time to Buy and Sell Stock
  48. Best Time to Buy and Sell Stock II
  49. Best Time to Buy and Sell Stock with Cooldown
  50. Best Time to Buy and Sell Stock III
  51. Best Time to Buy and Sell Stock IV
  52. Edit Distance
  53. Find the Substring With Maximum Cost
  54. Unique Binary Search Trees II
  55. Delete and Earn
  56. Predict the Winner
  57. Count Ways To Build Good Strings
  58. Solving Questions With Brainpower
  59. Last Stone Weight II
  60. Vowels of All Substrings
  61. House Robber III
  62. House Robber II
  63. Combination Sum IV
  64. Largest Sum of Averages
  65. Jump Game
  66. Interleaving String
  67. Jump Game VI
  68. Binary Trees With Factors
  69. Extra Characters in a String
  70. Partition String Into Minimum Beautiful Substrings
  71. Domino and Tromino Tiling
  72. Video Stitching
  73. Maximum Length of Repeated Subarray
  74. Greatest Sum Divisible by Three
  75. Best Team With No Conflicts
  76. Number of Ways to Select Buildings
  77. Partition Equal Subset Sum
  78. Number of Ways to Paint N ร— 3 Grid
  79. Cherry Pickup II
  80. Word Break II
  81. Largest Divisible Subset
  82. Number of Strings Which Can Be Rearranged to Contain Substring
  83. Minimum Sideway Jumps
  84. Time Needed to Rearrange a Binary String
  85. Find Good Days to Rob the Bank
  86. Wiggle Subsequence Solution
  87. Length of Longest Fibonacci Subsequence
  88. Largest Plus Sign
  89. Out of Boundary Paths
  90. Maximum Score After Applying Operations on a Tree
  91. Number of Longest Increasing Subsequence
  92. Count Number of Texts
  93. Closest Dessert Cost
  94. Longest Turbulent Subarray
  95. Maximum Points in an Archery Competition
  96. Number of People Aware of a Secret
  97. Ugly Number II
  98. Partition String Into Substrings With Values at Most K
  99. Super Ugly Number
  100. New 21 Game
  101. Maximum Length of Subarray With Positive Product
  102. Minimum Number of Coins for Fruits

Heap ๐Ÿ“Š:

  1. Kth Largest Element in an Array
  2. IPO
  3. Find K Pairs with Smallest Sums
  4. Find Median from Data Stream
  5. Minimum Cost to Hire K Workers
  6. Find the Kth Smallest Sum of a Matrix With Sorted Rows
  7. Sliding Window Maximum
  8. Top K Frequent Words
  9. Course Schedule III
  10. Closest Dessert Cost

Stack ๐Ÿ“ฅ:

  1. Largest Rectangle in Histogram
  2. Count Submatrices With All Ones
  3. Minimum Remove to Make Valid Parentheses
  4. Remove Duplicate Letters
  5. Next Greater Node In Linked List

Greedy ๐Ÿ’ฐ:

  1. Longest Unequal Adjacent Groups Subsequence I
  2. Largest Values From Labels
  3. Reducing Dishes
  4. Next Permutation
  5. Previous Permutation With One Swap
  6. Text Justification
  7. Minimum Additions to Make Valid String
  8. Partition String Into Substrings With Values at Most K
  9. Minimum Number of Food Buckets to Feed the Hamsters

BFS & DFS ๐Ÿ”:

  1. Push Dominoes
  2. K-Similar Strings
  3. Recover a Tree From Preorder Traversal
  4. As Far from Land as Possible
  5. Binary Tree Zigzag Level Order Traversal
  6. Island Perimeter
  7. All Elements in Two Binary Search Trees
  8. Univalued Binary Tree

Math โ™พ๏ธ:

  1. Maximum of Absolute Value Expression

Data Structures ๐Ÿ—„๏ธ:

  1. Insert Delete GetRandom O(1)
  2. Exam Room
  3. Design Underground System
  4. Random Pick with Weight
  5. LRU Cache
  6. Implement Trie (Prefix Tree)
  7. Online Election

LinkedLists ๐Ÿšˆ:

  1. Remove Nth Node From End of List
  2. Reorder List

Graphs:

  1. Evaluate Division
  2. All Elements in Two Binary Search Trees
  3. Course Schedule
  4. Course Schedule II
  5. Binary Tree Maximum Path Sum
  6. Cheapest Flights Within K Stops
  7. Binary Tree Coloring Game
  8. Lowest Common Ancestor of Deepest Leaves
  9. Maximum Difference Between Node and Ancestor
  10. Network Delay Time (Dijkstra)
  11. Path With Minimum Effort (Dijkstra)
  12. Clone Graph
  13. Populating Next Right Pointers in Each Node II
  14. Lowest Common Ancestor of a Binary Tree
  15. All Paths From Source to Target
  16. Min Cost to Connect All Points
  17. Count the Number of Complete Components
  18. Minimum Height Trees
  19. Sum of Root To Leaf Binary Numbers

Arrays ๐ŸŽž:

  1. Number of Ways to Split Array
  2. Sort Array By Parity II
  3. Distance Between Bus Stops
  4. Find the Highest Altitude
  5. How Many Numbers Are Smaller Than the Current Number
  6. Count Nice Pairs in an Array
  7. Partition Array Into Three Parts With Equal Sum
  8. Binary Prefix Divisible By 5

Union Find ๐Ÿ‡บ๐Ÿ‡ณ:

  1. Most Stones Removed with Same Row or Column
  2. Number of Islands

Other:

  1. Toeplitz Matrix
  2. Bulls and Cows
  3. Brace Expansion II Solution
  4. Unique Paths III
  5. Max Increase to Keep City Skyline
  6. Set Matrix Zeroes ๐Ÿคข (genuinely hate this problem)
  7. Battleships in a Board
  8. Binary String With Substrings Representing 1 To N
  9. Candy
  10. Restore IP Addresses
  11. Minimum Time to Make Rope Colorful
  12. Pow(x, n)
  13. Partition Array into Disjoint Intervals
  14. Brick Wall
  15. Array Nesting
  16. Minimum Number of Steps to Make Two Strings Anagram II
  17. Remove Letter To Equalize Frequency
  18. Find the Town Judge
  19. Shopping Offers
  20. Check if There is a Valid Partition For The Array
  21. Number of Matching Subsequences
  22. Find Valid Matrix Given Row and Column Sums
  23. Minimum Distance to Type a Word Using Two Fingers
  24. Find All Anagrams in a String
  25. Expressive Words
  26. The Skyline Problem
  27. Remove Adjacent Almost-Equal Characters
  28. Max Points on a Line
  29. Spiral Matrix
  30. Remove Comments
  31. N-Repeated Element in Size 2N Array
  32. 4Sum II
  33. Increasing Triplet Subsequence
  34. Increasing Triplet Subsequence
  35. Rotate Image
  36. Permutations
  37. Car Pooling
  38. Swap For Longest Repeated Character Substring
  39. Optimal Partition of String
  40. Target Sum
  41. Get Biggest Three Rhombus Sums in a Grid
  42. Minimum Consecutive Cards to Pick Up
  43. Minimize Maximum of Array
  44. Maximum Repeating Substring
  45. Shortest Completing Word
  46. Shortest Distance to a Character
  47. Number of Lines To Write String
  48. Largest Triangle Area
  49. Transpose Matrix
  50. Largest Perimeter Triangle

Happy coding! If you have any questions or suggestions, feel free to open an issue or create a pull request.

๐Ÿš€ Happy Learning! ๐Ÿš€

TODO:

  • Knuth-Morris-Pratt (KMP)
  • Dijkstra
  • Floyd-Warshall
  • DSU
  • NextPermutation

interview-prep's People

Contributors

stepantita avatar

Stargazers

Alex Avdieiev avatar Jarrian Gojar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.