Welcome to Scala Algorithms!

The table of Scala Algorithms
#1Check if an array is a palindromeCheck if an array is a palindrome

Free

#2Balanced parentheses algorithm with tail-call recursion optimisationBalanced parentheses algorithm with tail-call recursion optimisation

Free

#3Find an unpaired number in an arrayFind an unpaired number in an array

Free

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

Free

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

Free

#6Fizz Buzz in purely functional immutable ScalaFizz Buzz in purely functional immutable Scala

Free

#7QuickSelect Selection Algorithm (kth smallest item/kth order statistic)QuickSelect Selection Algorithm (kth smallest item/kth order statistic)

Free test cases & hints

#8Rotate a matrix by 90 degrees clockwiseRotate a matrix by 90 degrees

Free test cases & hints

#9Read a matrix as a spiralRead a matrix as a spiral

Free test cases & hints

#10Count number of contiguous countries by colorsCount number of contiguous countries by colors

Free test cases & hints

#11Length of the longest common substringLength of the longest common substring

Free test cases & hints

#12Find minimum missing positive number in a sequenceFind minimum missing positive number in a sequence

Free test cases & hints

#13Binary search a generic ArrayBinary search a generic Array

Free test cases & hints

#14Run-length encoding (RLE) DecoderRun-length encoding (RLE) Decoder

Free test cases & hints

#15Run-length encoding (RLE) EncoderRun-length encoding (RLE) Encoder

Free test cases & hints

#16Find the contiguous slice with the minimum averageFind the contiguous slice with the minimum average

Free test cases & hints

#17Tic Tac Toe board checkTic Tac Toe board check

Free test cases & hints

#18Find the minimum absolute difference of two partitionsFind the minimum absolute difference of two partitions

Free test cases & hints

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

Free test cases & hints

#20Quick Sort sorting algorithm in pure immutable ScalaQuick Sort sorting algorithm in pure immutable Scala

Free test cases & hints

#21Fibonacci in purely functional immutable ScalaFibonacci in purely functional immutable Scala

Free test cases & hints

#22In a range of numbers, count the numbers divisible by a specific integerCount numbers divisible by another

Free test cases & hints

#23Is an Array a permutation?Is an array a permutation?

Free test cases & hints

#24Merge Sort: stack-safe, tail-recursive, in pure immutable Scala, N-wayMerge Sort: stack-safe, tail-recursive

Free test cases & hints

#25Closest pair of coordinates in a 2D planeClosest pair of coordinates in a 2D plane

Free test cases & hints

#26Counting inversions of a sequence (array) using a Merge SortCounting inversions of a sequence

Free test cases & hints

#27Rotate Array right in pure-functional Scala - using an unusual immutable efficient approachRotate Array right in pure-functional Scala

Free test cases & hints

#28Count factors/divisors of an integerCount factors of a number

Free test cases & hints

#29Merge Sort: in pure immutable ScalaMerge Sort: in pure immutable Scala

Free test cases & hints

#30Longest increasing sub-sequence lengthLongest increasing sub-sequence length

Free test cases & hints

#31Reverse bits of an integerReverse bits of an integer

Free test cases & hints

#32Matching parentheses algorithm with foldLeft and a state machineMatching parentheses algorithm with foldLeft and a state machine

Free test cases & hints

#33Traverse a tree Breadth-First, immutablyTraverse a tree Breadth-First, immutably

Free test cases & hints

#34Count number of changes (manipulations) needed to make an anagram with foldLeft and a MultiSetCount number of changes for making an anagram

Free test cases & hints

#35Check if a number is a palindromeCheck if a number is a palindrome

Free test cases & hints

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

Free test cases & hints

#37Check if a String is a palindromeCheck if a String is a palindrome

Free test cases & hints

#38Find sub-array with the maximum sumFind sub-array with the maximum sum

Free test cases & hints

#39Traverse a tree Depth-FirstTraverse a tree Depth-First

Free test cases & hints

#40Monitor success rate of a process that may failMonitor success rate of a process that may fail

Available 28th January

#41Reverse a String's words efficientlyReverse a String's words efficiently

Available 4th February

#42Print Alphabet DiamondPrint Alphabet Diamond

Available 11th February

#43Compute nth row of Pascal's triangleCompute nth row of Pascal's triangle

Available 14th February

#44Tic Tac Toe MinMax solveTic Tac Toe MinMax solve

Available 21st February

#45Add numbers without using addition (plus sign)Add numbers without using addition (plus sign)

Available 28th February

#46Compute single-digit sum of digitsCompute single-digit sum of digits

Available 1st March

#47Find combinations adding up to NFind combinations adding up to N

Available 8th March

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

Available 15th March

#49Remove duplicates from a sorted list (Sliding)Remove duplicates from a sorted list (Sliding)

Available 22nd March

#50Reshape a matrixReshape a matrix

Available 29th March

#51Find k closest elements to a value in a sorted ArrayFind k closest elements to a value in a sorted Array

Available 4th April

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

Available 21st April

#53Sort a partially sorted ArraySort a partially sorted Array

Available 21st April

#54Binary search in a rotated sorted arrayBinary search in a rotated sorted array

Available 30th April

#55Compute the length of longest valid parenthesesCompute the length of longest valid parentheses

Available 1st May

39 available Scala algorithms

16 already scheduled and more coming up (making 55 in total). We aim to become the most comprehensive collection of Scala algorithms on the internet.

A variety of memberships is available!

  1. Check if an array is a palindrome

    Free

  2. Balanced parentheses algorithm with tail-call recursion optimisation

    Free

  3. Find an unpaired number in an array

    Free

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

    Free

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

    Free

  6. Fizz Buzz in purely functional immutable Scala

    Free

  7. QuickSelect Selection Algorithm (kth smallest item/kth order statistic)

    Free test cases & hints

  8. Rotate a matrix by 90 degrees clockwise

    Free test cases & hints

  9. Read a matrix as a spiral

    Free test cases & hints

  10. Count number of contiguous countries by colors

    Free test cases & hints

  11. Length of the longest common substring

    Free test cases & hints

  12. Find minimum missing positive number in a sequence

    Free test cases & hints

  13. Binary search a generic Array

    Free test cases & hints

  14. Run-length encoding (RLE) Decoder

    Free test cases & hints

  15. Run-length encoding (RLE) Encoder

    Free test cases & hints

  16. Find the contiguous slice with the minimum average

    Free test cases & hints

  17. Tic Tac Toe board check

    Free test cases & hints

  18. Find the minimum absolute difference of two partitions

    Free test cases & hints

  19. Compute a Roman numeral for an Integer, and vice-versa

    Free test cases & hints

  20. Quick Sort sorting algorithm in pure immutable Scala

    Free test cases & hints

  21. Fibonacci in purely functional immutable Scala

    Free test cases & hints

  22. In a range of numbers, count the numbers divisible by a specific integer

    Free test cases & hints

  23. Is an Array a permutation?

    Free test cases & hints

  24. Merge Sort: stack-safe, tail-recursive, in pure immutable Scala, N-way

    Free test cases & hints

  25. Closest pair of coordinates in a 2D plane

    Free test cases & hints

  26. Counting inversions of a sequence (array) using a Merge Sort

    Free test cases & hints

  27. Rotate Array right in pure-functional Scala - using an unusual immutable efficient approach

    Free test cases & hints

  28. Count factors/divisors of an integer

    Free test cases & hints

  29. Merge Sort: in pure immutable Scala

    Free test cases & hints

  30. Longest increasing sub-sequence length

    Free test cases & hints

  31. Reverse bits of an integer

    Free test cases & hints

  32. Matching parentheses algorithm with foldLeft and a state machine

    Free test cases & hints

  33. Traverse a tree Breadth-First, immutably

    Free test cases & hints

  34. Count number of changes (manipulations) needed to make an anagram with foldLeft and a MultiSet

    Free test cases & hints

  35. Check if a number is a palindrome

    Free test cases & hints

  36. Compute maximum sum of subarray (Kadane's algorithm)

    Free test cases & hints

  37. Check if a String is a palindrome

    Free test cases & hints

  38. Find sub-array with the maximum sum

    Free test cases & hints

  39. Traverse a tree Depth-First

    Free test cases & hints

16 upcoming Scala algorithms

Once published, these algorithms will automatically be available to our members. So make sure to Sign up.

  1. Monitor success rate of a process that may fail

    Available 28th January

  2. Reverse a String's words efficiently

    Available 4th February

  3. Print Alphabet Diamond

    Available 11th February

  4. Compute nth row of Pascal's triangle

    Available 14th February

  5. Tic Tac Toe MinMax solve

    Available 21st February

  6. Add numbers without using addition (plus sign)

    Available 28th February

  7. Compute single-digit sum of digits

    Available 1st March

  8. Find combinations adding up to N

    Available 8th March

  9. Remove duplicates from a sorted list (state machine)

    Available 15th March

  10. Remove duplicates from a sorted list (Sliding)

    Available 22nd March

  11. Reshape a matrix

    Available 29th March

  12. Find k closest elements to a value in a sorted Array

    Available 4th April

  13. Find the index of a substring ('indexOf')

    Available 21st April

  14. Sort a partially sorted Array

    Available 21st April

  15. Binary search in a rotated sorted array

    Available 30th April

  16. Compute the length of longest valid parentheses

    Available 1st May

& 20 Scala concepts

Get as familiar with Scala as possible. These are freely accessible: