π§ Algorithms and Data Structures in Java
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 compile
Running Specific Examples
mvn 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+
π
π Big O Notation, Time & Space Complexity
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 Complexity Reference
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
ποΈ New Organized Structure
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
π Fundamental Algorithms
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)
problems/leetcode/easy/arrays/ (16 problems)
problems/leetcode/easy/strings/ (6 problems)
problems/leetcode/easy/math/ (2 problems)
problems/leetcode/easy/twoPointers/ (8 problems)
Medium Problems (6 total)
problems/leetcode/medium/arrays/ (1 problem)
problems/leetcode/medium/dynamicProgramming/ (2 problems)
problems/leetcode/medium/greedy/ (2 problems)
problems/leetcode/medium/sorting/ (1 problem)
problems/hackerrank/algorithms/ (4 problems)
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
problems/hackerrank/dataStructures/ (1 problem)
Algorithm
Description
ReverseArray
Reverses an array in-place using two pointers technique
Utility
Description
ListNode
Common ListNode class for linked list problems
β±οΈ Complexity Analysis
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
β
Unit Testing with JUnit 5
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
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
Short Term (Next 2 weeks)
π Additional Resources
"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