The collection of Scala algorithms

When you register, this becomes your homepage.

21 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. View
  21. 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

#7Binary heap (min-heap)

Free test cases & hints

#8Compute missing ranges

Free test cases & hints

#9Find kth largest element in a List

Free test cases & hints

#10Find the minimum item in a rotated sorted array

Free test cases & hints

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

Free test cases & hints

#12Compute minimum number of Fibonacci numbers to reach sum

Free test cases & hints

#13Fixed Window Rate Limiter

Free test cases & hints

#14Token Bucket Rate Limiter

Free test cases & hints

#15Leaky Bucket Rate Limiter

Free test cases & hints

#16Least-recently used cache (MRU)

Free test cases & hints

#17Game of Life

Free test cases & hints

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

Free test cases & hints

#19Reverse Polish Notation calculator

Free test cases & hints

#20Mars Rover

Free test cases & hints

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

Free test cases & hints

#22Sliding Window Rate Limiter

Free test cases & hints

#23Compute modulo of an exponent without exponentiation

Free test cases & hints

#24Count pairs of a given expected sum

Free test cases & hints

#25Establish execution order from dependencies

Free test cases & hints

#26Check a binary tree is balanced

Free test cases & hints

#27Compute keypad possibilities

Free test cases & hints

#28Reverse first n elements of a queue

Free test cases & hints

#29Least-recently used cache (LRU)

Free test cases & hints

#30Find height of binary tree

Free test cases & hints

#31Check a binary tree is a search tree

Free test cases & hints

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

Free test cases & hints

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

Free test cases & hints

#34Longest common prefix of strings

Free test cases & hints

#35Check if a directed graph has cycles

Free test cases & hints

#36Pure-functional double linked list

Free test cases & hints

#37Count passing cars

Free test cases & hints

#38Remove duplicates from an unsorted List

Free test cases & hints

#39Make a queue using Maps

Free test cases & hints

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

Free test cases & hints

#41Single-elimination tournament tree

Free test cases & hints

#42Compute the length of longest valid parentheses

Free test cases & hints

#43Binary search in a rotated sorted array

Free test cases & hints

#44Find combinations adding up to N (unique)

Free test cases & hints

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

Free test cases & hints

#46Reverse bits of an integer

Free test cases & hints

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

Free test cases & hints

#48Reshape a matrix

Free test cases & hints

#49Remove duplicates from a sorted list (Sliding)

Free test cases & hints

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

Free test cases & hints

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

Free test cases & hints

#52Compute single-digit sum of digits

Free test cases & hints

#53Add numbers without using addition (plus sign)

Free test cases & hints

#54Tic Tac Toe MinMax solve

Free test cases & hints

#55Compute nth row of Pascal's triangle

Free test cases & hints

#56Print Alphabet Diamond

Free test cases & hints

#57Reverse a String's words efficiently

Free test cases & hints

#58Monitor success rate of a process that may fail

Free test cases & hints

#59QuickSelect Selection Algorithm

Free test cases & hints

#60Rotate a matrix by 90 degrees

Free test cases & hints

#61Read a matrix as a spiral

Free test cases & hints

#62Count number of contiguous countries by colors

Free test cases & hints

#63Length of the longest common substring

Free test cases & hints

#64Find minimum missing positive number in a sequence

Free test cases & hints

#65Binary search a generic Array

Free test cases & hints

#66Run-length encoding (RLE) Decoder

Free test cases & hints

#67Run-length encoding (RLE) Encoder

Free test cases & hints

#68Find the contiguous slice with the minimum average

Free test cases & hints

#69Tic Tac Toe board check

Free test cases & hints

#70Find the minimum absolute difference of two partitions

Free test cases & hints

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

Free test cases & hints

#72Quick Sort sorting algorithm in pure immutable Scala

Free test cases & hints

#73Fibonacci in purely functional immutable Scala

Free test cases & hints

#74Count numbers divisible by another

Free test cases & hints

#75Is an array a permutation?

Free test cases & hints

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

Free test cases & hints

#77Closest pair of coordinates in a 2D plane

Free test cases & hints

#78Counting inversions of a sequence

Free test cases & hints

#79Rotate Array right in pure-functional Scala

Free test cases & hints

#80Count factors of a number

Free test cases & hints

#81Merge Sort: in pure immutable Scala

Free test cases & hints

#82Longest increasing sub-sequence length

Free test cases & hints

#83Matching parentheses algorithm with a state machine

Free test cases & hints

#84Traverse a tree Breadth-First, immutably

Free test cases & hints

#85Count number of changes for making an anagram

Free test cases & hints

#86Check if a number is a palindrome

Free test cases & hints

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

Free test cases & hints

#88Check if a String is a palindrome

Free test cases & hints

#89Find sub-array with the maximum sum

Free test cases & hints

#90Traverse a tree Depth-First

Free test cases & hints

#91Maximum wait at a fuel station

Available 5th April

#92Count dist intersections

Available 20th April

#93Print a binary tree

Available 8th May

#94Find the longest palindrome within a string

Available 20th May

#95Median of two sorted arrays

Available 8th June

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

Available 20th June

#97Check word in grid (stack-safe)

Available 8th July

#98Merge intervals

Available 20th July

#99Check Sudoku board

Available 8th August

#100Print a binary tree vertically

Available 20th August

Register for an account →