The collection of Scala algorithms

When you register, this becomes your homepage.

22 Scala concepts

  1. Class Inside Class
  2. Class Inside Def
  3. Collect
  4. Def Inside Def
  5. Drop, Take, dropRight, takeRight
  6. foldLeft and foldRight
  7. For-comprehension
  8. Lazy List
  9. Option Type
  10. Ordering
  11. Partial Function
  12. Pattern Matching
  13. Range
  14. scanLeft and scanRight
  15. Sliding / Sliding Window
  16. Stack Safety
  17. State machine
  18. Tail Recursion
  19. Type Class
  20. Variance
  21. View
  22. Zip

100 Scala Algorithms

#1Balanced parentheses algorithm with tail-call recursion

Free

#2Check if an array is a palindrome

Free

#3Find an unpaired number in an array

Free

#4Count binary gap size of a number using tail recursion

Free

#5Find maximum potential profit from an array of stock price

Free

#6Fizz Buzz in purely functional immutable Scala

Free

#7Print a binary tree vertically

Free test cases & hints

#8Check Sudoku board

Free test cases & hints

#9Merge intervals

Free test cases & hints

#10Check word in grid (stack-safe)

Free test cases & hints

#11Check word in grid (depth-first search)

Free test cases & hints

#12Median of two sorted arrays

Free test cases & hints

#13Find the longest palindrome within a string

Free test cases & hints

#14Print a binary tree

Free test cases & hints

#15Count dist intersections

Free test cases & hints

#16Maximum wait at a fuel station

Free test cases & hints

#17Binary heap (min-heap)

Free test cases & hints

#18Compute missing ranges

Free test cases & hints

#19Find kth largest element in a List

Free test cases & hints

#20Find the minimum item in a rotated sorted array

Free test cases & hints

#21Compute the steps to transform an anagram only using swaps

Free test cases & hints

#22Compute minimum number of Fibonacci numbers to reach sum

Free test cases & hints

#23Fixed Window Rate Limiter

Free test cases & hints

#24Token Bucket Rate Limiter

Free test cases & hints

#25Leaky Bucket Rate Limiter

Free test cases & hints

#26Least-recently used cache (MRU)

Free test cases & hints

#27Game of Life

Free test cases & hints

#28Find triplets that sum to a target ('3Sum')

Free test cases & hints

#29Reverse Polish Notation calculator

Free test cases & hints

#30Mars Rover

Free test cases & hints

#31Find indices of tuples that sum to a target (Two Sum)

Free test cases & hints

#32Sliding Window Rate Limiter

Free test cases & hints

#33Compute modulo of an exponent without exponentiation

Free test cases & hints

#34Count pairs of a given expected sum

Free test cases & hints

#35Establish execution order from dependencies

Free test cases & hints

#36Check a binary tree is balanced

Free test cases & hints

#37Compute keypad possibilities

Free test cases & hints

#38Reverse first n elements of a queue

Free test cases & hints

#39Least-recently used cache (LRU)

Free test cases & hints

#40Find height of binary tree

Free test cases & hints

#41Check a binary tree is a search tree

Free test cases & hints

#42Make a binary search tree (Red-Black tree)

Free test cases & hints

#43Check a directed graph has a routing between two nodes

Free test cases & hints

#44Longest common prefix of strings

Free test cases & hints

#45Check if a directed graph has cycles

Free test cases & hints

#46Pure-functional double linked list

Free test cases & hints

#47Count passing cars

Free test cases & hints

#48Remove duplicates from an unsorted List

Free test cases & hints

#49Make a queue using Maps

Free test cases & hints

#50Make a queue using stacks (Lists in Scala)

Free test cases & hints

#51Single-elimination tournament tree

Free test cases & hints

#52Compute the length of longest valid parentheses

Free test cases & hints

#53Binary search in a rotated sorted array

Free test cases & hints

#54Find combinations adding up to N (unique)

Free test cases & hints

#55Find the index of a substring ('indexOf')

Free test cases & hints

#56Reverse bits of an integer

Free test cases & hints

#57Find k closest elements to a value in a sorted Array

Free test cases & hints

#58Reshape a matrix

Free test cases & hints

#59Remove duplicates from a sorted list (Sliding)

Free test cases & hints

#60Remove duplicates from a sorted list (state machine)

Free test cases & hints

#61Find combinations adding up to N (non-unique)

Free test cases & hints

#62Compute single-digit sum of digits

Free test cases & hints

#63Add numbers without using addition (plus sign)

Free test cases & hints

#64Tic Tac Toe MinMax solve

Free test cases & hints

#65Compute nth row of Pascal's triangle

Free test cases & hints

#66Print Alphabet Diamond

Free test cases & hints

#67Reverse a String's words efficiently

Free test cases & hints

#68Monitor success rate of a process that may fail

Free test cases & hints

#69QuickSelect Selection Algorithm

Free test cases & hints

#70Rotate a matrix by 90 degrees

Free test cases & hints

#71Read a matrix as a spiral

Free test cases & hints

#72Count number of contiguous countries by colors

Free test cases & hints

#73Length of the longest common substring

Free test cases & hints

#74Find minimum missing positive number in a sequence

Free test cases & hints

#75Binary search a generic Array

Free test cases & hints

#76Run-length encoding (RLE) Decoder

Free test cases & hints

#77Run-length encoding (RLE) Encoder

Free test cases & hints

#78Find the contiguous slice with the minimum average

Free test cases & hints

#79Tic Tac Toe board check

Free test cases & hints

#80Find the minimum absolute difference of two partitions

Free test cases & hints

#81Compute a Roman numeral for an Integer, and vice-versa

Free test cases & hints

#82Quick Sort sorting algorithm in pure immutable Scala

Free test cases & hints

#83Fibonacci in purely functional immutable Scala

Free test cases & hints

#84Count numbers divisible by another

Free test cases & hints

#85Is an array a permutation?

Free test cases & hints

#86Merge Sort: stack-safe, tail-recursive

Free test cases & hints

#87Closest pair of coordinates in a 2D plane

Free test cases & hints

#88Counting inversions of a sequence

Free test cases & hints

#89Rotate Array right in pure-functional Scala

Free test cases & hints

#90Count factors of a number

Free test cases & hints

#91Merge Sort: in pure immutable Scala

Free test cases & hints

#92Longest increasing sub-sequence length

Free test cases & hints

#93Matching parentheses algorithm with a state machine

Free test cases & hints

#94Traverse a tree Breadth-First, immutably

Free test cases & hints

#95Count number of changes for making an anagram

Free test cases & hints

#96Check if a number is a palindrome

Free test cases & hints

#97Compute maximum sum of subarray (Kadane's algorithm)

Free test cases & hints

#98Check if a String is a palindrome

Free test cases & hints

#99Find sub-array with the maximum sum

Free test cases & hints

#100Traverse a tree Depth-First

Free test cases & hints

Register for an account →