This repository contains a comprehensive collection of algorithm and data structure
implementations in Java.
It is designed for learning, practice, and preparing for technical interviews,
with exercises categorized by platform, problem type, and algorithmic technique.
- Java 11 or higher
- Maven 3.6+
- IDE (IntelliJ IDEA, Eclipse, VS Code)
git clone https://github.com/Daruuu/AlgoDS-Java.git
cd AlgoDS-Java
mvn clean compilemvn testmvn exec:java -Dexec.mainClass="com.daruuu.Main"| Platform | Category | Solved | Status |
|---|---|---|---|
| LeetCode | Easy Arrays | 16 | β |
| LeetCode | Easy Strings | 6 | β |
| LeetCode | Easy Math | 2 | β |
| LeetCode | Easy Two Pointers | 8 | β |
| LeetCode | Medium Arrays | 1 | π |
| LeetCode | Medium Dynamic Programming | 2 | π |
| LeetCode | Medium Greedy | 2 | π |
| LeetCode | Medium Sorting | 1 | π |
| HackerRank | Algorithms | 4 | β |
| HackerRank | Data Structures | 1 | π |
| Total | All | 41+ | π |
- Complete HackerRank Data Structures section
- Add more Dynamic Programming problems
- Implement advanced sorting algorithms (QuickSort, HeapSort)
- Add graph algorithms section
This section contains comprehensive notes and Java examples on how to analyze time and space complexity of algorithms.
View Big O Notation Guide
Java Interview Questions
Data Structures Guide
| Algorithm | Time Complexity | Space Complexity | Best Case | Worst Case |
|---|---|---|---|---|
| Linear Search | O(n) | O(1) | O(1) | O(n) |
| Binary Search | O(log n) | O(1) | O(1) | O(log n) |
| Bubble Sort | O(nΒ²) | O(1) | O(n) | O(nΒ²) |
| Selection Sort | O(nΒ²) | O(1) | O(nΒ²) | O(nΒ²) |
| Insertion Sort | O(nΒ²) | O(1) | O(n) | O(nΒ²) |
| Merge Sort | O(n log n) | O(n) | O(n log n) | O(n log n) |
| Two Sum (HashMap) | O(n) | O(n) | O(n) | O(n) |
| Two Pointers | O(n) | O(1) | O(1) | O(n) |
| Dynamic Programming | O(n) to O(nΒ²) | O(n) to O(nΒ²) | Varies | Varies |
src/main/java/com/daruuu/
βββ algorithms/ # Fundamental algorithms
β βββ sorting/ # Sorting algorithms
β βββ searching/ # Searching algorithms
βββ problems/ # Problems by platform
β βββ leetcode/ # LeetCode problems
β β βββ easy/ # Easy problems by category
β β βββ medium/ # Medium problems by category
β β βββ hard/ # Hard problems by category
β βββ hackerrank/ # HackerRank problems
β βββ algorithms/ # Algorithm challenges
β βββ dataStructures/ # Data structure challenges
βββ utils/ # Common utilities
βββ complexity/ # Complexity analysis exercises
βββ docs/ # Documentation
| Algorithm | Description | Time Complexity |
|---|---|---|
BubbleSort |
Repeatedly swaps adjacent elements in wrong order | O(nΒ²) |
SelectionSort |
Selects minimum element and places at correct position | O(nΒ²) |
InsertionSort |
Builds sorted array by inserting one element at a time | O(nΒ²) |
MergeSort |
Divides array and merges sorted halves | O(n log n) |
| Algorithm | Description | Time Complexity |
|---|---|---|
LinearSearch |
Iterates through array to find target | O(n) |
BinarySearch |
Efficiently searches sorted arrays using divide and conquer | O(log n) |
TwoSum- Find two numbers that sum to targetBuildArrayFromPermutation- Build array using permutation ruleConcatenationOfArray- Concatenate array with itselfShuffleTheArray- Shuffle array in specific patternRunningSumOfOneDArray01- Calculate running sumRichestCustomerWealth02- Find richest customerMaxConsecutiveOnes- Find maximum consecutive onesSortedSquares- Return squares in sorted orderDuplicateZeros- Duplicate each occurrence of zeroFindNumbers- Find numbers with even number of digitsFindWordsContainingCharacter- Filter words containing characterHowManyNumbersAreSmallerThanTheCurrentNumber- Count smaller numbersKeyboardRow- Words that can be typed using one keyboard rowStringMatchingInArray- Find strings that are substringsMiddleOfTheLinkedList05- Find middle of linked list
LengthOfLastWord- Find length of last wordLongestCommonPrefix- Find longest common prefixMinimumIndexSumOfTwoLists- Find common strings with least index sumRansomNote06- Check if ransom note can be constructedRomantoInteger- Convert Roman numeral to integerStringToInteger- Convert string to integer
Fizzbuzz03- Classic FizzBuzz problemNumberOfStepsToReduceANumberToZero04- Count steps to reduce number to zero
FindFirstPalindromicStringInArray- Find first palindrome in arrayFindIndexOfTheFirstOccurrenceInString- Find first occurrence of substringMergeStringsAlternately- Merge strings alternatelyRemoveDuplicatesFromSortedArray- Remove duplicates from sorted arrayReverPrefixOfWord- Reverse prefix of wordReverseString- Reverse character array in-placeReverseWordsInString3- Reverse words in sentenceValidPalindrome- Check if string is palindrome
RemoveElement_27- Remove element in-place
ClimbingStairs- Ways to climb stairs using DPFibonacciNumber- Fibonacci numbers with memoization
ArrayPartition- Maximize sum of minimums in array pairsLongestPalindrome- Find length of longest palindrome
SortColors- Sort array of 0s, 1s, and 2s
| Algorithm | Description |
|---|---|
AVeryBigSum |
Sums large integers that may exceed standard data types |
CompareTriplets |
Compares scores of two players based on multiple criteria |
DiagonalDifference |
Calculates absolute difference between diagonals of square matrix |
MiniMaxSum |
Finds minimum and maximum sum of 4 out of 5 integers |
| Algorithm | Description |
|---|---|
ReverseArray |
Reverses an array in-place using two pointers technique |
| Utility | Description |
|---|---|
ListNode |
Common ListNode class for linked list problems |
| Exercise | Description |
|---|---|
Exercise01.java to Exercise04.java |
Simple Java programs designed to analyze and reason about algorithm complexity |
| File | Description |
|---|---|
algorithms/README.md |
Sorting and searching algorithms guide |
leetcode/README.md |
LeetCode problems documentation |
leetcode/TimeAndSpaceComplexOfAlgorithms.md |
Complexity analysis notes |
theory/big-o-notation.md |
Complete Big O notation guide with examples |
theory/java-interview-questions.md |
Common Java interview questions and answers |
theory/data-structures-guide.md |
Comprehensive data structures guide |
Tests are located in the src/test/java/... directory, organized to mirror the
structure of your main code.
- Written using JUnit 5
- Each class has its corresponding test class
- Assertions for correctness and edge cases
mvn test- Fork el proyecto
- Crea una rama para tu feature (
git checkout -b feature/AmazingAlgorithm) - Commit tus cambios (
git commit -m 'Add some AmazingAlgorithm') - Push a la rama (
git push origin feature/AmazingAlgorithm) - Abre un Pull Request
- Sigue las convenciones de Java
- Incluye tests para nuevos algoritmos
- Documenta la complejidad temporal y espacial
- Actualiza el README si es necesario
- Complete HackerRank Data Structures
- Add 5 more LeetCode Medium problems
- Implement QuickSort and HeapSort
- Add Graph Algorithms section
- Implement Tree traversal algorithms
- Add Backtracking problems
- Add System Design notes
- Create video explanations
- Add competitive programming section
- "Cracking the Coding Interview" by Gayle McDowell
- "Introduction to Algorithms" by Cormen, Leiserson, Rivest, Stein
This project is licensed under the MIT License - see the LICENSE file for details.
Daruuu - GitHub
- LeetCode community for amazing problems
- HackerRank for algorithm challenges
- All contributors who help improve this repository