A personal repository documenting my journey of learning Data Structures and Algorithms using Java.
The goal is simple: practice consistently, understand the logic behind every solution, analyze time and space complexity, and gradually progress from Java fundamentals to advanced DSA.
- Hello World and basic syntax
- Variables and data types
- User input using
Scanner - Conditional statements
switchstatements- Loops
- Methods
- Method overloading
- Largest of three numbers
- Leap-year checker
- Simple calculator
- Counting digits
- Reversing a number
- Palindrome checker
- Factorial calculation
- Fibonacci series
- Prime number checking
- Prime numbers in a range
- Pattern problems
- Method-based problem solving
- Array creation and user input
- Array traversal
- Sum and average of elements
- Minimum and maximum elements
- Linear search
- Counting occurrences
- In-place array reversal
- Two-pointer technique
- Finding the second-largest distinct element
- Checking if an array is sorted
- Finding duplicate elements
- Copying arrays
- First and last occurrence
- Counting even and odd elements
- Moving zeros
- Left rotation
- Right rotation
- Array rotation by
Kpositions - Merging arrays
- Finding a missing number
- Input validation and edge-case handling
- Array indexing and boundary management
- String creation and user input
next()vsnextLine()- String indexing
length()charAt()- Forward traversal
- Backward traversal
- Uppercase and lowercase conversion
- String immutability
equals()andequalsIgnoreCase()- Empty String validation
- String reversal
- Palindrome checking
- Counting vowels and consonants
- Counting digits and whitespace
- Character frequency
- Removing whitespace
- Removing duplicate characters
- Anagram checking
- String compression
- Character-by-character traversal
- Frequency arrays
- Character-to-index mapping using
ch - 'a' - Boolean arrays for duplicate tracking
- Case-insensitive processing
- Adjacent-character comparison
- Building transformed Strings
- Character classification using the
Characterclass
Currently learning:
- Mutable vs immutable Strings
- Creating a
StringBuilder append()insert()setCharAt()deleteCharAt()reverse()length()toString()- Efficient String construction
The problems completed so far have introduced:
- Linear traversal
- Reverse traversal
- Two-pointer technique
- Frequency arrays
- Character-to-index mapping
- Boolean tracking arrays
- Counter variables
- Accumulator variables
- Input validation
- Edge-case handling
- Boundary management
- Character-by-character processing
- Adjacent-element comparison
- In-place operations
- Duplicate detection
- Frequency comparison
- Result construction
- Basic run-length encoding
- Mutable vs immutable data handling
For each problem, I am practicing how to identify:
- Time complexity
- Space complexity
- Auxiliary space
- Best, average, and worst cases
- Differences between multiple approaches
Examples covered so far:
- O(1) — constant-time operations
- O(n) — array traversal
- O(n) — String traversal
- O(n) — linear search
- O(n) — palindrome checking
- O(n) — character counting
- O(n) — frequency-array processing
- O(n) — anagram checking
- O(n) — duplicate detection
- O(n) — String compression traversal
- O(1) auxiliary space — fixed-size frequency and boolean arrays
- O(1) auxiliary space — in-place array reversal
I am also learning how Java's String immutability can affect the real cost of repeated String concatenation and how StringBuilder can improve String construction.
DSA-in-Java/
│
├── java_basics/
│ ├── HelloWorld.java
│ ├── VariablesAndDataTypes.java
│ ├── UserInput.java
│ ├── Conditions.java
│ ├── LargestNumber.java
│ ├── LeapYear.java
│ ├── SimpleCalculator.java
│ ├── Loops.java
│ ├── CountDigits.java
│ ├── ReverseNumber.java
│ ├── Palindrome.java
│ ├── Factorial.java
│ ├── FibonacciSeries.java
│ ├── PrimeNumber.java
│ ├── PrimeNumbersInRange.java
│ ├── MethodPractice.java
│ ├── MethodCalculator.java
│ ├── MethodOverloading.java
│ └── PrimeUsingMethod.java
│
├── arrays/
│ ├── ArrayBasics.java
│ ├── ArrayTraverse.java
│ ├── ArraySumandAverage.java
│ ├── ArrayMinandMax.java
│ ├── ArrayLinearSearch.java
│ ├── ArrayCountOccurances.java
│ ├── ArrayReverse.java
│ ├── ArraySecondLargest.java
│ ├── ArraySorted.java
│ ├── ArrayDuplicates.java
│ ├── ArrayCopy.java
│ ├── ArrayFirstLastOccurrence.java
│ ├── ArrayEvenandOddCount.java
│ ├── ArrayMoveZeros.java
│ ├── ArrayMoveLeft.java
│ ├── ArrayMoveRight.java
│ ├── ArrayMerge.java
│ ├── ArrayMissingNumber.java
│ └── ArrayRotatebyK.java
│
├── Strings/
│ ├── StringBasics.java
│ ├── StringTraversal.java
│ ├── StringReverse.java
│ ├── StringPalindrome.java
│ ├── CountCharacters.java
│ ├── CharacterFrequency.java
│ ├── RemoveSpaces.java
│ ├── RemoveDuplicates.java
│ ├── AnagramCheck.java
│ ├── StringCompression.java
│ └── StringBuilderBasics.java
│
├── .gitignore
├── LICENSE
└── README.md
Compiled
.classfiles are excluded from version control using.gitignore.
Compile a Java file:
javac FileName.javaRun the compiled program:
java FileNameExample:
javac StringReverse.java
java StringReverseDepending on the package and directory structure, programs may need to be compiled and executed from the repository root using their package name.
- Java fundamentals
- Basic time and space complexity
- Arrays
- Strings — In Progress
- Searching and sorting
- Recursion
- Backtracking
- Linked lists
- Stacks and queues
- Hashing
- Trees
- Binary search trees
- Heaps
- Graphs
- Greedy algorithms
- Dynamic programming
- String basics
- String traversal
- Reverse String
- Palindrome String
- Character counting
- Character frequency
- Removing spaces
- Removing duplicate characters
- Anagram checking
- String compression
- Frequency-array basics
-
StringBuilder - Efficient String construction
- Reverse using
StringBuilder - First non-repeating character
- First and last occurrence in a String
- Longest word
- Two-pointer String problems
- Hashing with Strings
- Sliding-window technique
- Longest substring without repeating characters
- More String-based DSA problems
For each topic, the focus is on:
- Understanding the concept
- Writing the solution independently
- Testing different inputs and edge cases
- Understanding why the solution works
- Analyzing time and space complexity
- Improving the solution when possible
- Learning reusable DSA patterns
- Committing progress consistently
This repository is not about uploading perfect solutions from day one.
It documents the actual learning process — writing code, making mistakes, debugging, understanding edge cases, improving approaches, and gradually building stronger problem-solving skills.
The objective is not to memorize solutions, but to develop the ability to recognize patterns, derive solutions independently, and understand the trade-offs behind different approaches.
Understand the logic. Write the code. Analyze it. Improve it. Repeat.
Built with consistency and curiosity by Atharva Padwal.