Packages

  • package root
    Definition Classes
    root
  • package leetcode

    This project was created with a few purposes

    Leetcode Solutions in Scala

    This project was created with a few purposes

    First it is to promote language Scala and its functional approach to solve problems, Scala is expressive, succinct meanwhile far too much underrated. Second let's just admit one cannot judge the engineering calibers of another in one hour technical interview, I personally have had and failed a few and I want to do something to alleviate this madness of the industry. Use Search above and type in some method names to get the point ...

    The listed solutions are by no means complete or optimal, if you would agree the causes, and feel like to contribute solutions, fixes or scaladocs to better illustrate everything, all PRs are welcome !

    To maintain its goal please take a few notes too,

    • Respect Scala CoC.
    • Solutions shall pass all of their tests in leetcode, using plain Scala and its std library only.
    • Solutions need to bundle their own unit tests, this project uses uTest.
    • Always prefer functional programming, which requires immutable data, pure functions etc, and keep it to the point.
    • Always prefer a generic solution, which captures the gist of a pattern or an algorithm, even if it implies some tradeoffs and becomes slightly suboptimal in terms of computational or space efficiency.
    • Try to achieve performance only after doing it right, iterate above notes for clarification, although this might defeat the original leetcode intention, one might be surprised that functional programming can be performant too.
    • Extra boilerplates are needed in package object so that Scaladoc can better serve us.
    • Last not the least, use Scalafmt
    Definition Classes
    root
  • package common
  • package p1

    Two Sum

    See also

    leetcode

    3Sum

    4Sum

    Two Sum II - Input array is sorted

    Two Sum III - Data structure design

    Subarray Sum Equals K

    Two Sum IV - Input is a BST

  • package p101

    Symmetric Tree

    See also

    leetcode

  • package p102

    Binary Tree Level Order Traversal

    See also

    leetcode

    Binary Tree Zigzag Level Order Traversal

    Binary Tree Level Order Traversal II

    Minimum Depth of Binary Tree

    Binary Tree Vertical Order Traversal

    Average of Levels in Binary Tree

    N-ary Tree Level Order Traversal

  • package p11

    Container With Most Water

    See also

    leetcode

    Trapping Rain Water

  • package p118

    Pascal's Triangle

    See also

    leetcode

    Pascal's Triange II

  • package p119

    Pascal's Triangle II

    See also

    leetcode

    Pascal's Triange

  • package p12

    Integer to Roman

    See also

    leetcode

    Roman to Integer

    Integer to English Words

  • package p121

    Best Time to Buy and Sell Stock

    See also

    leetcode

    Maximum Subarray

    Best Time to Buy and Sell Stock II

    Best Time to Buy and Sell Stock III

    Best Time to Buy and Sell Stock IV

    Best Time to Buy and Sell Stock with Ccoldown

  • package p13

    Roman to Integer

    See also

    leetcode

    Integer to Roman

  • package p14

    Longest Common Prefix

    See also

    leetcode

  • package p15

    3Sum

    See also

    leetcode

    Two Sum

    3Sum Closest

    4Sum

    3Sum Smaller

  • package p155

    Min Stack

    See also

    leetcode

    Sliding Window Maximum

    Max Stack

  • package p17

    Letter Combinations of a Phone Number

    See also

    leetcode

    Generate Parentheses

    Combination Sum

    Binary Watch

  • package p19

    Remove Nth Node From End of List

    See also

    leetcode

  • package p2

    Add Two Numbers

    See also

    leetcode

    Multiply Strings

    Add Binary

    Sum of Two Integers

    Add Strings

    Add Two Numbers II

    Add to Array-Form of Integer

  • package p20

    Valid Parentheses

    See also

    leetcode

    Generate Parentheses

    Longest Valid Parentheses

    Remove Invalid Parentheses

    Check if Word Is Valid After Substitutions

  • package p204

    Count Primes

    See also

    leetcode

    Ugly Number

    Ugly Number II

    Perfect Squares

  • package p206

    Reverse Linked List

    See also

    leetcode

    Reverse Linked List II

    Binary Tree Upside Down

    Palindrome Linked List

  • package p21

    Merge Two Sorted Lists

    See also

    leetcode

    Merge k Sorted Lists

    Merge Sorted Array

    Sort List

    Shortest Word Distance II

  • package p215

    Kth Largest Element in an Array

    See also

    leetcode

    Wiggle Sort II

    Top K Frequent Elements

    Third Maximum Number

    Kth Largest Element in a Stream

    K Closet Points to Origin

  • package p23

    Merge k Sorted Lists

    See also

    leetcode

    Merge Two Sorted Lists

    Ugly Number II

  • package p234

    Palindrome Linked List

    See also

    leetcode

    Palindrome Number

    Valid Palindrome

    Reverese Linked List

  • package p24

    Swap Nodes in Pairs

    See also

    leetcode

    Reverse Nodes in k-Group

  • package p242

    Valid Anagram

    See also

    leetcode

    Group Anagrams

    Palindrome Permutation

    Find All Anagrams in a String

  • package p26

    Remove Duplicates from Sorted Array

    See also

    leetcode

    Remove Element

    Remove Duplicates from Sorted Array II

  • package p27

    Remove Element

    See also

    leetcode

    Remove Duplicates from Sorted Array

    Remove Linked List Elements

    Move Zeroes

  • package p28

    Implement strStr

    See also

    leetcode

    Shortest Palindrome

    Repeated Substring Pattern

  • package p3

    Longest Substring Without Repeating Characters

    See also

    leetcode

    Longest Substring with At Most Two Distinct Characters

    Longest Substring with At Most K Distinct Characters

    Subarrays with K Different Integers

  • package p35

    Search Insert Position

    See also

    leetcode

    First Bad Version

  • package p36

    Valid Sudoku

    See also

    leetcode

    Sudoku Solver

  • package p38

    Count and Say

    See also

    leetcode

    Encode and Decode Strings

    String Compression

  • package p387

    First Unique Character in a String

    See also

    leetcode

    Sort Characters By Frequency

  • package p43

    Multiply Strings

    See also

    leetcode

    Add Two Numbers

    Plus One

    Add Binary

    Add Strings

  • package p48

    Rotate Image

    See also

    leetcode

  • package p49

    Group Anagrams

    See also

    leetcode

    Valid Anagram

    Group Shifted Strings

  • package p5

    Longest Palindromic Substring

    See also

    leetcode

    Shortest Palindrome

    Palindrome Permutation

    Palindrome Pairs

    Longest Palindromic Subsequence

    Palindromic Substrings

  • package p53

    Maximum Subarray

    See also

    leetcode

    Best Time to Buy and Sell Stock

    Maximum Product Subarray

    Degree of an Array

    Longest Turbulent Subarray

  • package p58

    Length of Last Word

    See also

    leetcode

  • package p6

    ZigZag Conversion

    See also

    leetcode

  • package p66

    Plus One

    See also

    leetcode

    Multiply Strings

    Add Binary

    Plus One Linked List

    Add to Array-Form of Integer

  • package p67

    Add Binary

    See also

    leetcode

    Add Two Numbers

    Multiply Strings

    Plus One

    Add to Array-Form of Integer

  • package p7

    Reverse Integer

    See also

    leetcode

    String to Integer Atoi

    Reverse Bits

  • package p73

    Set Matrix Zeroes

    See also

    leetcode

    Game of Life

  • package p78

    Subsets

    See also

    leetcode

    Subsets II

    Generalized Abbreviation

    Letter Case Permutation

  • package p8

    String to Integer Atoi

    See also

    leetcode

    Reverse Integer

    Valid Number

  • package p89

    Gray Code

    See also

    leetcode

    1-bit and 2-bits Characters]

  • package p9

    Palindrome Number

    See also

    leetcode

    Palindrome Linked List

  • Tags
p

leetcode

package leetcode

Leetcode Solutions in Scala

This project was created with a few purposes

First it is to promote language Scala and its functional approach to solve problems, Scala is expressive, succinct meanwhile far too much underrated. Second let's just admit one cannot judge the engineering calibers of another in one hour technical interview, I personally have had and failed a few and I want to do something to alleviate this madness of the industry. Use Search above and type in some method names to get the point ...

The listed solutions are by no means complete or optimal, if you would agree the causes, and feel like to contribute solutions, fixes or scaladocs to better illustrate everything, all PRs are welcome !

To maintain its goal please take a few notes too,

  • Respect Scala CoC.
  • Solutions shall pass all of their tests in leetcode, using plain Scala and its std library only.
  • Solutions need to bundle their own unit tests, this project uses uTest.
  • Always prefer functional programming, which requires immutable data, pure functions etc, and keep it to the point.
  • Always prefer a generic solution, which captures the gist of a pattern or an algorithm, even if it implies some tradeoffs and becomes slightly suboptimal in terms of computational or space efficiency.
  • Try to achieve performance only after doing it right, iterate above notes for clarification, although this might defeat the original leetcode intention, one might be surprised that functional programming can be performant too.
  • Extra boilerplates are needed in package object so that Scaladoc can better serve us.
  • Last not the least, use Scalafmt
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. leetcode
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. object Tags

Inherited from AnyRef

Inherited from Any

Ungrouped