Skip to content

Implementations of algorithms and data structures in Java for learning, practice, and interview preparation.

Notifications You must be signed in to change notification settings

Daruuu/AlgoDS-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

81 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 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 Build Tests License LeetCode HackerRank


πŸš€ Getting Started

Prerequisites

  • Java 11 or higher
  • Maven 3.6+
  • IDE (IntelliJ IDEA, Eclipse, VS Code)

Installation

git clone https://github.com/Daruuu/AlgoDS-Java.git
cd AlgoDS-Java
mvn clean compile

Running Tests

mvn test

Running Specific Examples

mvn exec:java -Dexec.mainClass="com.daruuu.Main"

πŸ“Š Progress Overview

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+ πŸ”„

🎯 Current Focus

  • Complete HackerRank Data Structures section
  • Add more Dynamic Programming problems
  • Implement advanced sorting algorithms (QuickSort, HeapSort)
  • Add graph algorithms section

πŸ“Š 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

πŸ“ Directory Overview

πŸ—οΈ 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

algorithms/sorting/

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)

algorithms/searching/

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)

πŸ“Œ LeetCode Problems

Easy Problems (32 total)

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)


πŸ“Œ HackerRank Problems

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

πŸ› οΈ Utilities

utils/

Utility Description
ListNode Common ListNode class for linked list problems

⏱️ Complexity Analysis

complexity/

Exercise Description
Exercise01.java to Exercise04.java Simple Java programs designed to analyze and reason about algorithm complexity

πŸ“˜ Documentation

docs/

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.

Features:

  • Written using JUnit 5
  • Each class has its corresponding test class
  • Assertions for correctness and edge cases

Run all tests:

    mvn test

🀝 Contributing

  1. Fork el proyecto
  2. Crea una rama para tu feature (git checkout -b feature/AmazingAlgorithm)
  3. Commit tus cambios (git commit -m 'Add some AmazingAlgorithm')
  4. Push a la rama (git push origin feature/AmazingAlgorithm)
  5. Abre un Pull Request

Guidelines

  • Sigue las convenciones de Java
  • Incluye tests para nuevos algoritmos
  • Documenta la complejidad temporal y espacial
  • Actualiza el README si es necesario

πŸ—ΊοΈ Roadmap

Short Term (Next 2 weeks)

  • Complete HackerRank Data Structures
  • Add 5 more LeetCode Medium problems
  • Implement QuickSort and HeapSort

Medium Term (Next month)

  • Add Graph Algorithms section
  • Implement Tree traversal algorithms
  • Add Backtracking problems

Long Term

  • Add System Design notes
  • Create video explanations
  • Add competitive programming section

πŸ“š Additional Resources

Learning Materials

Books

  • "Cracking the Coding Interview" by Gayle McDowell
  • "Introduction to Algorithms" by Cormen, Leiserson, Rivest, Stein

Practice Platforms


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘¨β€πŸ’» Author

Daruuu - GitHub


πŸ™ Acknowledgments

  • LeetCode community for amazing problems
  • HackerRank for algorithm challenges
  • All contributors who help improve this repository

About

Implementations of algorithms and data structures in Java for learning, practice, and interview preparation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages