Skip to content

teamlead/leetcode-75-solutions-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode 75 Solutions in Java

This repository contains solutions to LeetCode's 75 Essential & Trending Problems, all implemented in Java.

Must-do problem list for interview prep: The problems selected in this repository are curated based on their frequency of appearance in technical interviews and their relevance in assessing a candidate's problem-solving skills. Mastering these problems can significantly boost your chances of success in coding interviews.

Best for 1~3 month of prep time: Whether you're gearing up for a new job hunt or just looking to brush up on your algorithm skills, this collection of problems is optimally designed to be tackled over a period of one to three months. This duration allows for both in-depth understanding and regular practice, ensuring that you're well-prepared and confident in your problem-solving abilities.

Feel free to explore, practice, and ace your upcoming interviews!

Table of Contents

Problems and Solutions

Category Problem Solution Difficulty
Array / String Merge Strings Alternately MergeStringsAlternately.java Easy
Array / String Greatest Common Divisor of Strings GreatestCommonDivisorOfStrings.java Easy
Array / String Kids With the Greatest Number of Candies GreatestNumberOfCandies.java Easy
Array / String Can Place Flowers CanPlaceFlowers.java Easy
Array / String Reverse Vowels of a String ReverseVowelsOfString.java Easy
Array / String Reverse Words in a String ReverseWordsInString.java Medium
Array / String Product of Array Except Self ProductExceptSelf.java Medium
Array / String Increasing Triplet Subsequence IncreasingTriplet.java Medium
Array / String String Compression StringCompressor.java Medium
Two Pointers Move Zeroes ZeroMover.java Easy
Two Pointers Is Subsequence SubsequenceChecker.java Easy
Two Pointers Container With Most Water WaterContainer.java Medium
Two Pointers Max Number of K-Sum Pairs MaxOperationsCounter.java Medium
Sliding Window Maximum Average Subarray I MaxAverageSubarrayCalculator.java Easy
Sliding Window Maximum Number of Vowels in a Substring of Given Length MaxVowelSubstringCalculator.java Medium
Sliding Window Max Consecutive Ones III BinaryArrayMaxOnesCalculator.java Medium
Sliding Window Longest Subarray of 1's After Deleting One Element BinarySubarrayCalculator.java Medium
Prefix Sum Find the Highest Altitude AltitudeCalculator.java Easy
Prefix Sum Find Pivot Index PivotFinder.java Easy
Hash Map / Set Find the Difference of Two Arrays ArraysDifferenceFinder.java Easy
Hash Map / Set Unique Number of Occurrences UniqueOccurrenceChecker.java Easy
Hash Map / Set Determine if Two Strings Are Close StringCloseChecker.java Medium
Hash Map / Set Equal Row and Column Pairs MatrixPairs.java Medium
Stack Decode String StringDecoder.java Medium
Stack Asteroid Collision AsteroidCollisionSimulator.java Medium
Stack Removing Stars From a String StarStringProcessor.java Medium
Queue Number of Recent Calls RecentCounter.java Easy
Queue Dota2 Senate SenateDecisionSimulator.java Medium
Linked List Delete the Middle Node of a Linked List LinkedListProcessor.java Medium
Linked List Odd Even Linked List OddEvenLinkedListTransformer.java Medium
Linked List Reverse Linked List LinkedListReverser.java Easy
Linked List Maximum Twin Sum of a Linked List MaxTwinSumCalculator.java Medium
Binary Tree - DFS Maximum Depth of Binary Tree BinaryTreeDepthCalculator.java Easy
Binary Tree - DFS Leaf-Similar Trees LeafSimilarTreesChecker.java Easy
Binary Tree - DFS Count Good Nodes in Binary Tree GoodNodeCounter.java Medium
Binary Tree - DFS Path Sum III PathSumCounter.java Medium
Binary Tree - DFS Longest ZigZag Path in a Binary Tree ZigZagPathCalculator.java Medium
Binary Tree - DFS Lowest Common Ancestor of a Binary Tree LowestCommonAncestorFinder.java Medium
Binary Tree - BFS Binary Tree Right Side View RightViewTree.java Medium
Binary Tree - BFS Maximum Level Sum of a Binary Tree MaxLevelSumCalculator.java Medium
Binary Search Trie Search in a Binary Search Tree BSTSearcher.java Easy
Binary Search Trie Delete Node in a BST BSTNodeDeleter.java Medium
Graphs - DFS Keys and Rooms RoomAccessChecker.java Medium
Graphs - DFS Number of Provinces FriendshipCircleFinder.java Medium
Graphs - DFS Reorder Routes to Make All Paths Lead to the City Zero NetworkReorderer.java Medium
Graphs - DFS Evaluate Division EquationCalculator.java Medium
Graphs - BFS Nearest Exit from Entrance in Maze MazeExitFinder.java Medium
Graphs - BFS Rotting Oranges RottenOrangesCalculator.java Medium
Heap / Priority Queue Kth Largest Element in an Array KthLargestElementFinder.java Medium
Heap / Priority Queue Smallest Number in Infinite Set SmallestInfiniteSet.java Medium
Heap / Priority Queue Maximum Subsequence Score MaxScoreCalculator.java Medium
Heap / Priority Queue Total Cost to Hire K Workers HiringCostCalculator.java Medium
Binary Search Guess Number Higher or Lower NumberGuesser.java Easy
Binary Search Successful Pairs of Spells and Potions SpellPotionPairFinder.java Medium
Binary Search Find Peak Element PeakElementFinder.java Medium
Binary Search Koko Eating Bananas BananaEater.java Medium
Backtracking Letter Combinations of a Phone Number PhoneNumberCombinations.java Medium
Backtracking Combination Sum III CombinationSumFinder.java Medium
DP - 1D N-th Tribonacci Number TribonacciCalculator.java Easy
DP - 1D Min Cost Climbing Stairs StairCostCalculator.java Easy
DP - 1D House Robber HouseRobber.java Medium
DP - 1D Domino and Tromino Tiling TilingCalculator.java Medium
DP - Multidimensional Unique Paths GridPathFinder.java Medium
DP - Multidimensional Longest Common Subsequence SubsequenceFinder.java Medium
DP - Multidimensional Best Time to Buy and Sell Stock with Transaction Fee StockTradingProfitCalculator.java Medium
DP - Multidimensional Edit Distance EditDistanceCalculator.java Medium
Bit Manipulation Counting Bits BitCounter.java Easy
Bit Manipulation Single Number UniqueNumberFinder.java Easy
Bit Manipulation Minimum Flips to Make a OR b Equal to c BitFlipCalculator.java Medium
Trie Implement Trie (Prefix Tree) PrefixTrie.java Medium
Trie Search Suggestions System SearchSuggestionsSystem.java Medium
Intervals Non-overlapping Intervals IntervalOverlapRemover.java Medium
Intervals Minimum Number of Arrows to Burst Balloons ArrowBalloonBurstOptimizer.java Medium
Monotonic Stack Daily Temperatures TemperatureChangeCalculator.java Medium
Monotonic Stack Online Stock Span StockPriceSpanCalculator.java Medium

Usage

  1. Clone the repository:
git clone https://github.com/teamlead/leetcode-75-solutions-java.git
  1. Navigate to a specific problem:
cd src/category_name
  1. Compile and run the Java solution:
javac ProblemName.java
java -ea ProblemName

or if you use Java11+ run the source code file directly, without intermediate compilation:

java -ea ProblemName.java

If using IDEA, right-click the src folder, then select "Mark Directory" as "Sources Root". Now, Java files should benefit from all the Java IDE features of IntelliJ IDEA, including autocomplete, debug, syntax highlighting, and more.

Remember, when using assertions in Java, ensure that you've enabled them by using the -ea flag when running the Java program.

Contribution

Feel free to fork this repository and add your solutions or improvements. Pull requests are welcome!

Content Rights

The problems discussed in this repository are sourced from LeetCode and are Copyrighted Material owned by LeetCode. They are used here for educational purposes only. It is strongly advised not to use them in any other way that might infringe on the intellectual property rights of the original source. Always refer to the original LeetCode link for the complete and most up-to-date problem statement.

License

This project is open source and available under the MIT License.

About

Welcome to this repository, dedicated to providing solutions to list of 75 of the most common problems on LeetCode!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages