Skip to content

anxious-coder-lhs/cs-algorithms

Repository files navigation

Algorithms

This repository provides code snippets for several of the programming questions. The questions have been read from various sources. Wherever possible, there would be links presented along with question.

Programming Langugages

I use mostly Javascript, Typescript, Java, and Scala. You can expect solutions in one of these programming languages.

Sources

The problems for the documented solutions have been fetched from various sources including Udemy, AlgoExpert, LeetCode, Educative, etc. Wherever possible, I am attaching the source. I am not attaching the sources for premium subscriptions, just to make sure the premium subscriptions are not misused.

Contributions

Happy to accept any contributions to this in any langugage.

Easy

  1. Find Numbers with Even Numbers of Digits | Solution
  2. Roman To Integer | Solution
  3. Excel Sheet Column Title | Solution
  4. Second Highest Salary | Solution
  5. Valid Phone Numbers | Solution
  6. Count Primes | Solution 1 | Solution 2
  7. Sorted Array Merge | Solution
  8. Educative Array | Solution
  9. Find Pair Sum | Solution
  10. Third Maximum Number | Solution 1 | Solution 2 | Solution 3
  11. Median of 2 sorted arrays | Solution
  12. K-Diff Pairs in an array | Solution
  13. Shortest Sorted Continuous Subarray | Solution 1 | Solution 2 | Solution 3 | Solution 4 | Solution 5 | Solution 6 | Solution 7
  14. Non Decreasing Array | Solution 1 | Solution 2 | Solution 3
  15. Buddy Strings | Solution 1 | Solution 2
  16. Rearrange Positive Negative | Solution
  17. Rearrange Sorted Max Min | Solution
  18. String Duplicates | Solution
  19. String Reversal | Solution
  20. Valid Paranthesis | Solution 1

Medium

  1. Minimum Remove to Make Valid Paranthesis | Solution
  2. Finding if the string with curly braces are balanced | Solution
  3. Create a minimum height BST using a sorted input array | Solution
  4. Find Longest Peak in an array | Solution
  5. Monotonic Increasing | Solution 1 | Solution 2
  6. Suffix Trie Construction | Solution
  7. Traversing a 2D Array in a Spiral Order: Returning 1D Array | Solution
  8. Finding groups of anagrams in a string | Solution 1 | Solution 2
  9. Finding Longest Palindromic Substring | Solution 1 BF | Solution 2
  10. Min Max Stack | Solution
  11. Leet Code 146 - LRU Cache | Solution Java Collection | Solution Typescript Custom
  12. Leet Code 283 Move Zeros | Solution | Solution 2
  13. Leet Code 70 Climbing Stairs | Solution DP Top Down | Solution DP Bottoms Up
  14. Leet Code 200 Number of Islands | Solution 1 DFS | Solution BFS | Solution Union Find
  15. Leet Code 362 Design Hit Counter | Solution 1 | Solution 2
  16. LeetCode Web Crawler 1242 | Solution 1 | Solution 2
  17. Leet Code 554 Brick Wall | Solution 1
  18. Leet Code 1190 Reverse Substrings Between Each Pair of Paranthesis | Solution 1 | Solution Optimized
  19. Leet Code 22 Generate Paranthesis | Solution Brute Force | Solution BF Optimized

Hard

  1. Find Missing Positive | Solution
  2. Read N Characters Given Read 4 II - Call Multiple Times - LeetCode 158 | Solution 1 | Solution 2 Optimized

Sorting

  1. Bubble Sort | Solution
  2. Insertion Sort | Solution
  3. Merge Sort | Solution
  4. Quick Sort | Solution
  5. Radix Sort | Solution
  6. Selection Sort | Solution

Frequency Pattern

  1. Anagram Check | Solution
  2. Are Same with Squares? | Solution
  3. Check Substring | Solution
  4. Count Characters in String | Solution
  5. Same Frequency | Solution

Multiple Pointers Pattern

  1. Are there Duplicates? | Solution
  2. Average Pair | Solution
  3. Count Unique Values | Solution
  4. Zero Sum Pair | Solution

Recursive Pattern

  1. Capitalize Words | Solution
  2. Collect Strings | Solution
  3. Fibonnaci | Solution Bottoms Up | Solution Dynamic Programming | Solution Recursion | Solution Recursive
  4. Factorial | Solution
  5. Flatten | Solution
  6. Is Palindrome? | Solution
  7. Nested Even Sum | Solution
  8. Power | Solution
  9. Product of Arrays | Solution
  10. Range | Solution
  11. Some Recursive | Solution
  12. Stringify Numbers | Solution

Sliding Window Pattern

  1. Finding Longest Substring | Solution
  2. Max Subarray Sum | Solution
  3. Min Subarray Length | Solution

Linked List

  1. Detecting Loops in Linked List | Solution
  2. Find Middle Node in Linked List | Solution
  3. Find nth node from last | Solution
  4. Reverse Linked List | Solution

Searching

  1. Linear Search | Solution
  2. Binary Search | Solution
  3. Searching in a Sorted Array | Solution 1 | Solution 2

Dynamic Programming

  1. 0/1 Knapsack Problem
  2. Equal Subset Problem
  3. Subset Sum Problem
  4. Minimum Difference Subset Sum
  5. Count of Subset Sum
  6. Target Sum using positive negative assignments
  7. Unbounded Knapsack Problem
  8. Road Cutting
  9. Coin Change
  10. Minimum Coin Change Needed
  11. Maximum Ribbon Cut
  12. Find Longest Palindromic Subsequence

TODO Items (More topics to explore further)

About

CS Algorithms practice repo.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published