Skip to content

About

Solutions to NeetCode, Kattis, and Codeforces problems, mostly in Java and Python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

🧠 NeetCode & Kattis Solutions — Promit Das

My solutions to NeetCode.io and Kattis problems.


📊 Progress

29 solutions in this repo — 19 from NeetCode, 10 from Kattis.

NeetCode

# Problem Difficulty Language Category Source
1 Contains Duplicate 🟢 Easy Python Arrays & Hashing 📥 synced
2 Valid Anagram 🟢 Easy Python Arrays & Hashing 📥 synced
3 Two Sum 🟢 Easy Java Arrays & Hashing 📥 synced
4 Group Anagrams 🟡 Medium Java Arrays & Hashing 📥 synced
5 Top K Frequent Elements 🟡 Medium Java Arrays & Hashing 📥 synced
6 Encode and Decode Strings 🟡 Medium Java Arrays & Hashing ✍️ hand-written
7 Product of Array Except Self 🟡 Medium Java Arrays & Hashing ✍️ hand-written
8 Valid Sudoku 🟡 Medium Java Arrays & Hashing ✍️ hand-written
9 Longest Consecutive Sequence 🟡 Medium Java Arrays & Hashing ✍️ hand-written
10 Valid Palindrome 🟢 Easy Java Two Pointers ✍️ hand-written
11 Two Sum II 🟡 Medium Java Two Pointers ✍️ hand-written
12 3Sum 🟡 Medium Java Two Pointers ✍️ hand-written
13 Valid Parentheses 🟢 Easy Java Stack ✍️ hand-written
14 Min Stack 🟡 Medium Java Stack ✍️ hand-written
15 Evaluate Reverse Polish Notation 🟡 Medium Java Stack ✍️ hand-written
16 Daily Temperatures 🟡 Medium Java Stack ✍️ hand-written
17 Binary Search 🟢 Easy Java Binary Search ✍️ hand-written
18 Best Time to Buy and Sell Stock 🟢 Easy Java Sliding Window ✍️ hand-written
19 Reverse Linked List 🟢 Easy Java Linked List ✍️ hand-written

NeetCode: 19 · 🟢 Easy 8 · 🟡 Medium 11 · 🔴 Hard 0 · 📥 5 synced · ✍️ 14 hand-written

Kattis

Problem Difficulty Language
Akcija 1.4 Easy Java
Exact Change 1.6 Easy Java
What does the fox say? 1.8 Easy Java
Babelfish 2.0 Easy Java
Cooking Water 2.0 Easy Python
CD 2.1 Easy Java
Single source shortest path 2.1 Easy Java
Counting Stars 2.2 Easy Java
Grid 2.3 Easy Java
Disastrous Downtime 2.7 Easy Java

Kattis: 10 · 9 Java · 1 Python · difficulty 1.4 – 2.7

By language

Language Solutions
Java 26
Python 3

🗂️ Repository Structure

DSA Practice/                   # NeetCode roadmap, grouped by pattern
├── Arrays & Hashing/           # 9 problems
├── Two Pointers/               # 3
├── Stack/                      # 4
├── Binary Search/              # 1
├── Sliding Window/             # 1
└── Linked List/                # 1

Kattis/                         # Kattis programming problems
├── Akcija.java
├── Babelfish.java
├── CD.java
├── CookingWater.py
├── CountingStars.java
├── DisastrousDowntime.java
├── ExactChange.java
├── Grid.java
├── SingleSourceShortestPath.java
└── WhatDoesTheFoxSay.java

practice/                       # Extra competitive programming practice
├── hashmap.py                  # Custom HashMap implementation
├── A_Twins.py                  # Codeforces — Twins (Greedy)
└── helpfulMaths.py             # Codeforces — Helpful Maths (Counting sort)

🔑 Approach Highlights

Arrays & Hashing

Problem Approach Time Space
Contains Duplicate HashSet — return on first collision O(n) O(n)
Valid Anagram Character frequency maps comparison O(n) O(1)*
Two Sum One-pass HashMap storing complement lookups O(n) O(n)
Group Anagrams Character count array as HashMap key O(n·k) O(n·k)
Top K Frequent Bucket sort by frequency O(n) O(n)
Encode and Decode Strings Length-prefix each string (len#payload) so any delimiter is safe O(n) O(n)
Product of Array Except Self Prefix products, then a running suffix product O(n) O(1)†
Valid Sudoku One pass with row / column / box seen-flags O(1)‡ O(1)‡
Longest Consecutive Sequence Count only from numbers with no left neighbour O(n) O(n)

Two Pointers

Problem Approach Time Space
Valid Palindrome Converge from both ends, skipping non-alphanumerics O(n) O(1)
Two Sum II Input is sorted — move the pointer that corrects the sum O(n) O(1)
3Sum Sort, fix one value, two-pointer the rest, skip duplicates O(n²) O(1)§

Stack

Problem Approach Time Space
Valid Parentheses Push openers, match each closer against the top O(n) O(n)
Min Stack Parallel stack whose top is always the current minimum O(1) per op O(n)
Evaluate RPN Operand stack; subtraction and division respect operand order O(n) O(n)
Daily Temperatures Monotonic decreasing stack of indices awaiting a warmer day O(n) O(n)

Binary Search · Sliding Window · Linked List

Problem Approach Time Space
Binary Search l + (r - l) / 2 to avoid midpoint overflow O(log n) O(1)
Best Time to Buy and Sell Stock Track cheapest price so far, best profit against it O(n) O(1)
Reverse Linked List Iterative pointer rewiring with a trailing prev O(n) O(1)

*O(1) since the alphabet size is fixed at 26. †Excluding the output array. ‡Board size is fixed at 9x9. §Excluding the sort and the output list.


⚙️ Sync

NeetCode solutions sync automatically from NeetCode.io via GitHub integration — each accepted submission lands as its own file (submission-{n}.{ext}).

The Source column above marks which solutions are genuine synced submissions (📥) and which were written by hand to the same signature because the sync had not backfilled them (✍️).

Note: the integration writes to Data Structures & Algorithms/<neetcode-slug>/submission-{n}.{ext}. Since this repo is now organised by pattern instead, a future backfill will recreate that folder rather than updating the files here — merge anything it drops in, then delete the folder.

Kattis has no such integration; those solutions are added by hand.


📝 Languages Used

  • Python — Quick prototyping and clean syntax for easy problems
  • Java — Preferred for medium/hard problems with strong type safety

Solving the NeetCode Roadmap one problem at a time.

About

Solutions to NeetCode, Kattis, and Codeforces problems, mostly in Java and Python

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages