Skip to content

VijayKumarCode/DSA_java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

240 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

/*# Java-Data-Structures-and-Algorithms Optimized Java solutions for 150+ DSA patterns with documented Time/Space complexity analysis.

πŸ› οΈ Tech Stack & Standards

  • Language: Java
  • Concepts: Arrays, Strings, HashMaps, Two Pointers, Trees, Graphs, Dynamic Programming.
  • Documentation: Every solution includes a Big-O analysis header.
  • Style: Following Google Java Style Guide for clean, readable code.

πŸ—οΈ Architecture: Linked Lists

To demonstrate Separation of Concerns, the Linked List section is implemented using a modular approach:

  • Node.java: The data model and reference structure.
  • LinkListSingly.java: The core algorithm implementation (Logic).
  • LL.java: The driver class for execution and test cases.

πŸ“Š Progress Tracker

# Problem Topic Complexity Status
1 Two Sum Hash Table $O(n^2)$ Time, $O(1)$ Space βœ…
2 Valid Palindrome Two Pointers $O(n)$ Time, $O(1)$ Space βœ…
3 Merge Sorted Array Two Pointers $O(m+n)$ Time, $O(1)$ Space βœ…
4 Remove Element Two Pointers $O(n)$ Time, $O(1)$ Space βœ…
5 Remove Duplicates Two Pointers $O(n)$ Time, $O(1)$ Space βœ…
6 Majority Element Two Pointers $O(n log n)$ Time, $O(n)$ Space βœ…
7 Length Of Last Word One Pointer $O(n)$ Time , $O(n)$ Space βœ…
8 Singly Linked List Node β€’ Logic β€’ Driver $O(n)$ Search, $O(1)$ Head Ops βœ…
9 Linked List Cycle slow and fast Pointer $O(n)$ Time , $O(1)$ Space βœ…
10 Reverse Words In String Two Pointers String $O(n)$ Time , $O(n)$ Space βœ…
11 Reverse Linked List II Partial Reversal $O(n)$ Time , $O(1)$ Space βœ…
12 Merge Two Sorted Lists Linked List $O(n+m)$ Time , $O(1)$ Space βœ…
13 Linked List Cycle II slow and fast pointer $O(n)$ Time , $O(1)$ Space βœ…
14 First Occurence In String Sliding window $O(n \cdot m)$ Time , $O(n)$ Space βœ…
15 Longest Common Prefix In String Strings scanning $O(n)$ Time , $O(1)$ Space βœ…
16 Two Sum II Two Pointers $O(n)$ Time, $O(1)$ Space βœ…
17 Three Sum Two Pointers/sorting $O(n^2)$ Time, $O(1)$ Space βœ…
18 Palindrome Number Math / Reversal $O(\log n)$ Time, $O(1)$ Space βœ…
19 BinarySearch Search Divide and conquer $O(log n)$ Time, $O(1)$ Space βœ…
20 PlusOne Number Math / Arrays $O(n)$ Time, $O(n)$ Space βœ…
21 Add Two Numbers Linked List/Math $O(max(l1,l2))$ Time , $O(max(l1,l2))$ Space βœ…
22 SearchIn2DMatrix BinarySearch Search $O(log (m*n))$ Time, $O(1)$ Space βœ…
23 Roman To Int Arrays /Strings $O(n)$ Time, $O(1)$ Space βœ…
24 Int To Roman Arrays /Strings $O(1)$ Time, $O(1)$ Space βœ…
25 Square Root Math $O(\sqrt{n})$ Time, $O(1)$ Space βœ…
26 Power Function Math $O(log(n)$ Time, $O(1)$ Space βœ…
27 Min Sub Array Math $O(log(n)$ Time, $O(1)$ Space βœ…
28 Longest Sub String Math/HashSet $O((n)$ Time, $O(min(m,n)$ Space βœ…
29 Find All Sub String Math/HashSet $O((n)$ Time, $O(m)$ Space βœ…
30 Max Area Array/Two Pointer Approach $O((n)$ Time, $O(1)$ Space βœ…
31 Spiral Matrix Array/Matrix $O((MXN)$ Time, $O(1)$ Space βœ…
32 Is Valid Sudoku Array/Matrix $O((N^2)$ Time, $O(1)$ Space βœ…
33 Can construct HashMap $O((MXN)$ Time, $O(k)$ Space where k is 1 to 26 βœ…
33 Isomorphic HashMap $O((N)$ Time, $O(k)$ Space βœ…
34 Word Pattern HashMap $O((N)$ Time, $O(N)$ Space where n is same as take n time and space will also take same. βœ…
35 Happy Number Linked List/Math $O(log n)$ Time , $O(1)$ Space βœ…
36 Group Anagrams Hash Table / String $O(N \cdot K)$ Time, $O(N \cdot K)$ Space βœ…
37 Contains Duplicate II Hash Table / Sliding Window $O(n)$ Time, $O(\min(n, k))$ Space βœ…
38 SummaryRanges Two Pointer /Arrays $O(n)$ Time, $O(1)$ Space βœ…
39 Merge Intervals Two Pointer /Arrays/Greedy Approach $O(n(logn))$ Time, $O(logn)$ Space βœ…
40 Insert Interval Two Pointer /Arrays/Greedy Approach $O(n)$ Time, $(n)$ Space βœ…
41 Insert Interval Two Pointer /Arrays/Greedy Approach $O(n(logn))$ Time, $O(logn)$ Space βœ…
42 Jump One Arrays/Greedy Approach $O(n(logn))$ Time, $O(logn)$ Space βœ…
43 MaxDepth BinarySearch Tree / Math $O(n)$ Time, $O(n)$ Space βœ…
44 Same Tree BinarySearch Tree / Recursion $O(n)$ Time, $O(n)$ Space βœ…
45 Invert Tree BinarySearch Tree / Recursion $O(n)$ Time,Space : Best $O(logn)$, Worst $O(n)$ βœ…
46 Sysmmetric Tree BinarySearch Tree / Recursion $O(n)$ Time, $O(n)$ space βœ…
47 Construct A Tree From Both Preoder And Inorder BinarySearch Tree / Recursion/HashMap $O(n)$ Time, $O(n)$ space βœ…
48 Construct A Tree From Both Postorder And Inorder BinarySearch Tree / Recursion/HashMap $O(n)$ Time, $O(n)$ space βœ…
49 Populating Next Right Pointers II BinarySearch Tree / Iterative/LinkList $O(n)$ Time, $O(1)$ space βœ…
50 Flatten BinarySearch Tree To LinkedList BinarySearch Tree /Recursion Using preorder /LinkList $O(n)$ Time, $O(n)$ space βœ…
51 Path Sum Solver BinarySearch Tree /Recursion $O(n)$ Time, $O(n)$ space βœ…
52 Jump To End II Array/Greedy $O(n)$ Time, $O(1)$ space βœ…
53 Sum To Root Leaf BinarySearch Tree /Recursion /DFS $O(n)$ Time, $O(n)$ space βœ…
54 SubString Concatenation String /HashMap /ArrayList $O(n)$ Time, $O(m *w)$ space βœ…
55 Path Sum Solver II BinarySearch Tree/DFS /Recursion $O(n)$ Time, $O(n)$ space βœ…
56 BinarySearch Adder Bit Manupulation / Math $O(max(n,m))$ Time, $O(max(n,m))$ space βœ…
57 Reverse Bits Bit Manupulation /Divide and Conquer $O(1)$ Time, $O(1)$ space βœ…
58 Hamming Weight calculator Bit Manupulation /Bitwise operator $O(1)$ Time, $O(1)$ space βœ…
59 Single Number Bit Manupulation /Bitwise operator /XoR operator $O(n)$ Time, $O(1)$ space βœ…
60 Single Number II Bit Manupulation /Bitwise operator /XoR operator $O(n)$ Time, $O(1)$ space βœ…
61 Range Bitwise And Bit Manupulation /Bitwise operator $O(\logn)$ Time, $O(1)$ space βœ…
62 Count Trailing Zeroes Math $O(log_5 n)$ Time, $O(1)$ space βœ…
63 Max Points in the (X, Y) plane Math $O(n^2)$ Time, $O(n)$ space βœ…
64 Merge K Sorted Lists Math/Divide and Conquer /LinkedList $O(n log k)$ Time, $O( log k)$ space βœ…
65 Kadane's Algorithm Math/Kadene's Algorithm $O(n)$ Time, $O(1)$ space βœ…
66 Peak Finder Math/Binary Search/ Recursive $O(log n)$ Time, $O(log n)$ space βœ…
67 Search In Rotated Sorted Array Math/Binary Search/ Recursive $O(log n)$ Time, $O(log n)$ space βœ…
68 Return First And Last Target In Array Math/Binary Search/ Recursive $O(log n)$ Time, $O(log n)$ space βœ…
69 Find Minimum In Rotated Array Math/Binary Search/ Recursive $O(log n)$ Time, $O(log n)$ space βœ…
70 Find The Median From Two Sorted Array Math/Binary Search/Recursive/Iterative $O(log(min(m, n))$ Time, $O(1)$ space βœ…
71 Valid Parentheses Check Stack $O(n)$ Time, $O(1)$ space βœ…
72 Unix Style Path Simplifier Stack /String $O(n)$ Time, $O(n)$ space βœ…
73 Reverse Polish Notation Stack /String /Switch $O(n)$ Time, $O(n)$ space βœ…
74 Stack Implementation Like pop(), push(), MinStack() etc Stack/ArrayList $O(1)$ Time, $O(n)$ space βœ…
75 Basic Calculator Using Stack Stack/ArrayDeque/Deque $O(n)$ Time, $O(n)$ space βœ…
76 Find Kth Element In Unsorted Array Heap/PriorityQueue $O(n (log k))$ Time, $O(k)$ space βœ…
77 Find The Sum of SubArray Using Kadane's Algo Kadanes Algorithm/Math $O(n))$ Time, $O(1)$ space βœ…
78 Rotate Image By 90 Degree Array/Matrix $O(n^2)$ Time, $O(1)$ Space βœ…
79 Array To Binary seatch Tree Conversion Array/Binary Search Tree/ Recursion $O(n)$ Time, $O(log(n))$ Space βœ…
80 Jump II Array $O(n)$ Time,$O(1)$ Space βœ…
81 Binary Search Iterator Binary Tree, Recursion $O(1)$ Time,$O(h)$ Space βœ…
82 Reverse Nodes In K Group LinkedList, Recursion $O(n)$ Time,$O(n/k)$ Space βœ…
83 H Index Finder Array,Bucket Sort $O(n)$ Time,$O(n)$ Space βœ…

πŸš€ How to Use

Each folder is categorized by data structure. Navigate to a folder and open the .java file to see the logic and performance analysis in the comments. */

About

Optimized Java solutions for 150+ DSA patterns with documented Time/Space complexity analysis.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages