Skip to content

AliAzaz/InterviewAlgorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InterviewAlgorithms — Kotlin solutions to data structures, algorithms and FAANG-style interview problems

InterviewAlgorithms

Kotlin solutions to 40+ classic data structure & algorithm interview problems — curated from real FAANG, Stripe, LinkedIn and LeetCode rounds.

Kotlin License: MIT PRs Welcome Maintained GitHub stars GitHub forks

Problems · Run locally · Categories · Contributing · FAQ


About

InterviewAlgorithms is a hand-picked collection of Kotlin solutions to data structures and algorithms problems frequently asked in software engineering interviews at companies like Google, Meta, Amazon, LinkedIn, Stripe and Microsoft. Every file is a self-contained, runnable .kt source with a main function, an explanation of the problem, the approach, and the time/space complexity — perfect for Kotlin coding interview prep, LeetCode practice, or refreshing your DSA fundamentals.

If you are searching for Kotlin LeetCode solutions, Kotlin DSA examples, or a FAANG interview prep repo written in idiomatic Kotlin instead of Java or Python — you're in the right place.

Why Kotlin? Most interview-prep repos are written in Python, Java, or C++. Kotlin gives you the same JVM performance with cleaner, more expressive syntax — a huge time-saver in a 45-minute live coding round.


Highlights

  • 42 problems spanning arrays, strings, trees, graphs, dynamic programming, heaps, system design and more
  • Idiomatic Kotlin — uses data class, extension functions, let, also, sealed classes, and standard collections
  • Real interview attribution — many problems include the company that asked them and a link to the source (LeetCode, Prepfully, etc.)
  • Complexity annotations — every solution documents Big-O time and space
  • Multiple approaches — brute-force vs. optimized side-by-side where it matters (see TwoSum.kt)
  • Zero dependencies — pure Kotlin standard library, runs on any JVM

Run locally

Prerequisites

  • JDK 17 or newer
  • Kotlin compiler 2.0+ (or just open the folder in IntelliJ IDEA)

Clone

git clone https://github.com/AliAzaz/InterviewAlgorithms.git
cd InterviewAlgorithms

Run a single problem from the command line

# Compile and run any .kt file
kotlinc TwoSum.kt -include-runtime -d TwoSum.jar
java -jar TwoSum.jar

Or use the Kotlin REPL / kotlin script runner

kotlinc -script TwoSum.kts   # rename .kt to .kts to script-run

Or open in IntelliJ IDEA (recommended)

  1. File → Open → InterviewAlgorithms
  2. IntelliJ will detect Kotlin and configure the JDK
  3. Click the green ▶ next to any main function

Problem categories

Arrays & Hashing

Problem File Notes
Two Sum TwoSum.kt LeetCode 1 — brute force vs. hashmap
Contains Duplicate ContainsDuplicate.kt LeetCode 217
Group Anagrams GroupAnagrams.kt LeetCode 49
Find Duplicate & Missing FindDuplicateAndMissing.kt XOR / cyclic sort
Intersection of Two Arrays intersection/FindIntersection.kt LeetCode 349
Subarray Sum Divisible by P SubarraySumDivisibleByP.kt Prefix sums + modular arithmetic

Two Pointers & Sliding Window

Problem File Notes
Longest Substring Without Repeat LongestSubstringNoRepeat.kt LeetCode 3
Longest Increasing Subarray LongestIncreasingSubarray.kt Linear scan
Maximum Subarray Sum MaxSubarraySum.kt Kadane's algorithm
Trapping Rain Water TrappingRainWater.kt LeetCode 42
3Sum / Triplets Equal Zero Triplets_Equals_Zero.kt LeetCode 15

Strings

Problem File Notes
Valid Parentheses (Bracket Matcher) BracketMatcher.kt LeetCode 20
Decryption of Characters Decryption_Characters.kt Cipher decoding
No Number Prefix NoNumberPrefix.kt String parsing
Slowest Key SlowestKey.kt LeetCode 1629
Palindrome String palindrome/Palindrome_String.kt LeetCode 125

Math & Numbers

Problem File Notes
Factorial Factorial.kt Recursive & iterative
Fibonacci Series FibonacciSeries.kt Memoization
Natural Numbers NaturalNumber.kt Sum / generation
Reverse Integer Reverse_Integer.kt LeetCode 7 — overflow handling
Smallest Positive Integer Smallest_Positive_Integer.kt LeetCode 41
Sum Problem SumProblem.kt Pair-sum variant
Set Manipulation SetOfProblem.kt Set operations
Swap Items SwapItems.kt In-place swap idioms
Palindrome Integer palindrome/Palindrome_Integer.kt LeetCode 9
Median Finding MedianFinding.kt Two-heap approach

Linked Lists

Problem File Notes
Singly Linked List LinkedList.kt Build, insert, traverse, reverse
Merge Two Sorted Lists Merge_Two_Sorted_Lists.kt LeetCode 21

Trees & Graphs

Problem File Notes
Binary Search Tree BinaryTrees.kt Insert, search, traversal
Lowest Common Ancestor LowestCommonAncestor.kt LeetCode 236
Detect Cycle in Directed Graph DetectCycleDirectedGraph.kt DFS with coloring
Cheapest Flights Within K Stops CheapestFlightsKStops.kt LeetCode 787 — Bellman-Ford / BFS

Heaps & Priority Queues

Problem File Notes
Kth Largest Element KthLargestElement.kt LeetCode 215 — heap & quickselect
Min-Heap Implementation MinHeapImpl.kt From-scratch heap

Dynamic Programming & Greedy

Problem File Notes
Coin Change CoinChange.kt LeetCode 322
Longest Increasing Subsequence LongestIncreasingSubsequence.kt LeetCode 300 — DP & patience sort
Word Break WordBreak.kt LeetCode 139
Minimum Candies MinCandies.kt LeetCode 135 — two-pass greedy
Partition Array Min Sum Diff PartitionArrayMinSumDiff.kt Subset-sum DP
Merge Intervals MergeIntervals.kt LeetCode 56

System Design / OOP

Problem File Notes
LRU Cache LRUCache.kt LeetCode 146 — HashMap + doubly-linked list (LinkedIn favorite)
Rate Limiter RateLimiter.kt Sliding window per-key (Stripe-style)

Repository structure

InterviewAlgorithms/
├── banner.svg
├── README.md
├── *.kt                    # 39 problems at the repo root
├── intersection/
│   └── FindIntersection.kt
└── palindrome/
    ├── Palindrome_Integer.kt
    └── Palindrome_String.kt

Each .kt file is independent and self-contained — it has its own main function and can be compiled and run on its own without touching the rest of the repo.


Contributing

Pull requests are very welcome. To keep the repo readable and useful for other interview candidates, please follow these guidelines.

  1. Fork the repo and create a branch: git checkout -b add/<problem-name>
  2. One problem per file, named in PascalCase.kt (e.g., LongestPalindrome.kt)
  3. Place general problems at the repo root; group related variants in a subfolder (see palindrome/)
  4. Start the file with a comment block:
    /*
     * Problem: <one-line description, plus LeetCode # if applicable>
     * Asked at: <company / source link, optional>
     * Approach: <one or two sentences>
     * Complexity: O(...) time · O(...) space
     */
  5. Include a main() function with at least one example call so kotlinc <file>.kt -include-runtime -d <file>.jar && java -jar <file>.jar produces visible output
  6. Open the PR with a short description and the LeetCode (or other) link

Found a bug or a cleaner solution? Open an issue or send a PR — both are appreciated.


FAQ

Is this a complete LeetCode solution set?

No — it is intentionally curated. Rather than mirroring all of LeetCode, this repo focuses on the ~40 problems that have come up most often in real interview reports for FAANG, Stripe, LinkedIn and similar companies in the last two years. Quality over quantity.

Why Kotlin instead of Python or Java?

Kotlin is the official language for Android and is increasingly accepted in backend interviews at JVM-heavy companies (Google, Meta, Stripe, JetBrains). Compared to Java it is more concise — closer to Python in line count — without sacrificing JVM performance, which makes it an excellent live-coding language for a 45-minute round.

Can I use these solutions in my own interview prep / blog / course?

Yes. The repository is MIT licensed (see License). Attribution is appreciated but not required.

How do I run a single problem without setting up the whole project?

Install the Kotlin command-line compiler (brew install kotlin on macOS, sdk install kotlin via SDKMAN! on Linux) and run:

kotlinc TwoSum.kt -include-runtime -d TwoSum.jar && java -jar TwoSum.jar

That's it — no Gradle, no IDE required.

Do the solutions include unit tests?

Each main() function exercises the solution with at least one example. Adding a proper JUnit / Kotest suite is a roadmap item — PRs adding tests for individual problems are welcome.

What's the difference between this and Sean's, Neetcode's, or other DSA repos?

Most popular interview-prep repos are in Python, JavaScript, or Java. This one is Kotlin-first with idiomatic Kotlin (extension functions, scope functions, sealed classes) — useful for engineers who use Kotlin day-to-day and want their interview answers to look natural in their primary language.


Roadmap

  • Add JUnit/Kotest test suites per problem
  • Add Gradle wrapper for one-command runs (./gradlew run -PmainClass=TwoSumKt)
  • Add concurrency / coroutines section (producer-consumer, async pipelines)
  • Add Kotlin Multiplatform variants for select problems
  • GitHub Actions CI to compile every .kt on push

License

Released under the MIT License. You are free to use, modify and distribute the code for any purpose, including commercial use, with attribution.


Author

Maintained by Ali Azaz. If this repo helped you land an interview, leave a ⭐ — it helps others discover it.


Keywords: kotlin interview questions · kotlin leetcode solutions · kotlin dsa · data structures and algorithms in kotlin · faang interview prep kotlin · kotlin coding interview · kotlin algorithm practice · android engineer interview · jvm coding interview · system design kotlin · lru cache kotlin · rate limiter kotlin · sliding window kotlin · dynamic programming kotlin

About

This repo contains series of algorithms that are usually ask in interviews.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages