Skip to content

georgevanuta/LeetCode-in-Scala

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode-in-Scala

My solutions for LeetCode exercises written in Scala.
If you're curious about a particular solution, just Ctrl-F the exact title of the exercise.

Note

This repo also contains some solutions written in Java (the multithreaded ones
because they can't be solved in Scala), some sqlplus queries, some c++ code and some bash scripts.

How to use the push/update script

You can find the source code for the script here.

I've made a simple scala script that updates this README.md by adding a solution and then pushing the changes to github. Also, if you want to use it, run the following command in the solution directory:

scala-cli ../../leet.scala -- "<PROBLEM_NUMBER>. <PROBLEM_TITLE>" "<DIFFICULTY>"

For example, if you wanted to add the 1. Two sum problem:

scala-cli ../../leet.scala -- "1. Two Sum" E

Easy

1. Two Sum
9. Palindrome Number
13. Roman to Integer
14. Longest Common Prefix
20. Valid Parentheses
26. Remove Duplicates from Sorted Array
27. Remove Element
28. Find the Index of the First Occurrence in a String
35. Search Insert Position
58. Length of Last Word
66. Plus One
67. Add Binary
69. Sqrt(x)
83. Remove Duplicates from Sorted List
94. Binary Tree Inorder Traversal
98. Validate Binary Search Tree
101. Symmetric Tree
102. Binary Tree Level Order Traversal
104. Maximum Depth of Binary Tree
108. Convert Sorted Array to Binary Search Tree
110. Balanced Binary Tree
111. Minimum Depth of Binary Tree
125. Valid Palindrome
136. Single Number
141. Linked List Cycle
144. Binary Tree Preorder Traversal
145. Binary Tree Postorder Traversal
160. Intersection of Two Linked Lists
169. Majority Element
175. Combine Two Tables
181. Employees Earning More Than Their Managers
182. Duplicate Emails
183. Customers Who Never Order
191. Number of 1 Bits
193. Valid Phone Numbers
195. Tenth Line
202. Happy Number
203. Remove Linked List Elements
206. Reverse Linked List
217. Contains Duplicate
226. Invert Binary Tree
231. Power of Two
232. Implement Queue using Stacks
234. Palindrome Linked List
242. Valid Anagram
268. Missing Number
292. Nim Game
326. Power of Three
342. Power of Four
344. Reverse String
345. Reverse Vowels of a String
349. Intersection of Two Arrays
350. Intersection of Two Arrays II
367. Valid Perfect Square
383. Ransom Note
387. First Unique Character in a String
389. Find the Difference
392. Is Subsequence
404. Sum of Left Leaves
412. Fizz Buzz
434. Number of Segments in a String
448. Find All Numbers Disappeared in an Array
459. Repeated Substring Pattern
461. Hamming Distance
485. Max Consecutive Ones
501. Find Mode in Binary Search Tree
504. Base 7
509. Fibonacci Number
511. Game Play Analysis I
530. Minimum Absolute Difference in BST
551. Student Attendance Record I
559. Maximum Depth of N-ary Tree
575. Distribute Candies
586. Customer Placing the Largest Number of Orders
589. N-ary Tree Preorder Traversal
595. Big Countries
596. Classes More Than 5 Students
617. Merge Two Binary Trees
620. Not Boring Movies
627. Swap Salary
645. Set Mismatch
653. Two Sum IV - Input is a BST
671. Second Minimum Node In a Binary Tree
700. Search in a Binary Search Tree
705. Design HashSet
709. To Lower Case
724. Find Pivot Index
819. Most Common Word
824. Goat Latin
832. Flipping an Image
836. Rectangle Overlap
867. Transpose Matrix
872. Leaf-Similar Trees
876. Middle of the Linked List
897. Increasing Order Search Tree
905. Sort Array By Parity
929. Unique Email Addresses
938. Range Sum of BST
941. Valid Mountain Array
953. Verifying an Alien Dictionary
977. Squares of a Sorted Array
993. Cousins in Binary Tree
1002. Find Common Characters
1022. Sum of Root To Leaf Binary Numbers
1050. Actors and Directors Who Cooperated At Least Three Times
1051. Height Checker
1108. Defanging an IP Address
1114. Print in Order
1122. Relative Sort Array
1148. Article Views I
1160. Find Words That Can Be Formed by Characters
1221. Split a String in Balanced Strings
1266. Minimum Time Visiting All Points
1290. Convert Binary Number in a Linked List to Integer
1407. Top Travellers
1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence
1523. Count Odd Numbers in an Interval Range
1527. Patients With a Condition
1528. Shuffle String
1572. Matrix Diagonal Sum
1636. Sort Array by Increasing Frequency
1667. Fix Names in a Table
1678. Goal Parser Interpretation
1729. Find Followers Count
1736. Latest Time by Replacing Hidden Digits
1748. Sum of Unique Elements
1757. Recyclable and Low Fat Products
1791. Find Center of Star Graph
1876. Substrings of Size Three with Distinct Characters
1890. The Latest Login in 2020
1929. Concatenation of Array
1965. Employees With Missing Information
2000. Reverse Prefix of Word
2129. Capitalize the Title
2133. Check if Every Row and Column Contains All Numbers
2148. Count Elements With Strictly Smaller and Greater Elements
2180. Count Integers With Even Digit Sum
2206. Divide Array Into Equal Pairs
2220. Minimum Bit Flips to Convert Number
2235. Add Two Integers
2236. Root Equals Sum of Children
2239. Find Closest Number to Zero
2248. Intersection of Multiple Arrays
2283. Check if Number Has Equal Digit Count and Digit Value
2331. Evaluate Boolean Binary Tree
2481. Minimum Cuts to Divide a Circle
2490. Circular Sentence
2496. Maximum Value of a String in an Array
2500. Delete Greatest Value in Each Row
2544. Alternating Digit Sum

Medium

2. Add Two Numbers
5. Longest Palindromic Substring
19. Remove Nth Node From End of List
22. Generate Parentheses
33. Search in Rotated Sorted Array
34. Find First and Last Position of Element in Sorted Array
36. Valid Sudoku
49. Group Anagrams
59. Spiral Matrix II
71. Simplify Path
74. Search a 2D Matrix
75. Sort Colors
79. Word Search
103. Binary Tree Zigzag Level Order Traversal
107. Binary Tree Level Order Traversal II
109. Convert Sorted List to Binary Search Tree
114. Flatten Binary Tree to Linked List
129. Sum Root to Leaf Numbers
150. Evaluate Reverse Polish Notation
162. Find Peak Element
165. Compare Version Numbers
173. Binary Search Tree Iterator
176. Second Highest Salary
199. Binary Tree Right Side View
200. Number of Islands
223. Rectangle Area
229. Majority Element II
230. Kth Smallest Element in a BST
236. Lowest Common Ancestor of a Binary Tree
237. Delete Node in a Linked List
260. Single Number III
287. Find the Duplicate Number
328. Odd Even Linked List
355. Design Twitter
371. Sum of Two Integers
382. Linked List Random Node
398. Random Pick Index
427. Construct Quad Tree
438. Find All Anagrams in a String
445. Add Two Numbers II
450. Delete Node in a BST
451. Sort Characters By Frequency
508. Most Frequent Subtree Sum
513. Find Bottom Left Tree Value
515. Find Largest Value in Each Tree Row
567. Permutation in String
590. N-ary Tree Postorder Traversal
654. Maximum Binary Tree
669. Trim a Binary Search Tree
690. Employee Importance
701. Insert into a Binary Search Tree
763. Partition Labels
788. Rotated Digits
791. Custom Sort String
796. Rotate String
814. Binary Tree Pruning
849. Maximize Distance to Closest Person
900. RLE Iterator
937. Reorder Data in Log Files
957. Prison Cells After N Days
973. K Closest Points to Origin
1019. Next Greater Node In Linked List
1021. Remove Outermost Parentheses
1026. Maximum Difference Between Node and Ancestor
1038. Binary Search Tree to Greater Sum Tree
1042. Flower Planting With No Adjacent
1115. Print FooBar Alternately
1117. Building H2O
1155. Number of Dice Rolls With Target Sum
1302. Deepest Leaves Sum
1305. All Elements in Two Binary Search Trees
1315. Sum of Nodes with Even-Valued Grandparent
1325. Delete Leaves With a Given Value
1448. Count Good Nodes in Binary Tree
1669. Merge In Between Linked Lists
2095. Delete the Middle Node of a Linked List
2130. Maximum Twin Sum of a Linked List
2221. Find Triangular Sum of an Array

Hard

23. Merge k Sorted Lists

Releases

No releases published

Packages

No packages published

Languages