Swift Practice Vault
Algorithm Solutions in Swift
Curated problem solutions across LeetCode, HackerRank, AlgoExpert, GeekForGeeks, and Pramp, with an auto-updating index from every commit.
Algorithms Solutions in Swift
This repository contains Swift solutions from AlgoExpert, LeetCode, HackerRank, GeekForGeeks, and Pramp.
Suggestions and contributions are welcome.
How to Use
- Use search and platform filters to quickly find a problem.
- Open Problem for the original prompt and Solution for this repository implementation.
- Update
Difficulty,Topic/Pattern, orProblem Linkoverrides inscripts/readme-metadata.tsv.
HackerRank
#1
HackerRank
#2
Almost Sorted
HackerRank
#3
Binary Search Trees
HackerRank
#4
Bitwise AND
HackerRank
#5
Convert Decimal To Binary
HackerRank
#6
Count Pairs
HackerRank
#7
Encryption
HackerRank
#8
Extra Long Factorials
HackerRank
#9
Larry's Array
HackerRank
#10
Merge Sort
HackerRank
#11
Palindrome String
HackerRank
#12
Reverse String
HackerRank
#13
Sum of Natural Number
HackerRank
#14
Tic Tac Toe Winner
HackerRank
#15
Two Strings
LeetCode
#1
3 Sum Closest
LeetCode
#2
Add Digits
LeetCode
#3
Add Strings
LeetCode
#4
Array Intersection
LeetCode
#5
Array Pair Sum
LeetCode
#6
Array Rotation
LeetCode
#7
Asteroid Collision
LeetCode
#8
Best Time to Buy and Sell Stock
LeetCode
#9
Binary Search
LeetCode
#10
Bucket Sort
LeetCode
#11
Build a Matrix With Conditions
LeetCode
#12
Can Construct
LeetCode
#13
Can Make Arithmetic Progression
LeetCode
#14
Candy Swap
LeetCode
#15
Close Strings
LeetCode
#16
Concatenation of Array
LeetCode
#17
Confusing Number
LeetCode
#18
Container With Most Water
LeetCode
#19
Contains Duplicate
LeetCode
#20
Convert Time Minimum Operations
LeetCode
#21
Count And Say
LeetCode
#22
Count Negatives
LeetCode
#23
Count Pairs
LeetCode
#24
Delete Node in a Linked List
LeetCode
#25
Design HashMap
LeetCode
#26
Divide Two Integers
LeetCode
#27
Dota2 Senate
LeetCode
#28
Encode Decode Strings
LeetCode
#29
Find All People With Secrets
LeetCode
#30
Find Differences String
LeetCode
#31
Find Peak Element
LeetCode
#32
Find Players Zero or One Loses
LeetCode
#33
Find kth Largest Element
LeetCode
#34
Find the Index of the First Occurrence in a String
LeetCode
#35
First Bad Version
LeetCode
#36
First Unique Character In String
LeetCode
#37
Fixed Point
LeetCode
#38
Flood Fill
LeetCode
#39
Four Sum
LeetCode
#40
Group Anagrams
LeetCode
#41
HashMap
LeetCode
#42
HashSet
LeetCode
#43
Increasing Triplet Subsequence
LeetCode
#44
Intersection of Two Array II
LeetCode
#45
Is Alien Sorted
LeetCode
#46
Is Majority Element
LeetCode
#47
Largest Integer Digit Swaps Parity
LeetCode
#48
Largest Triangle Area
LeetCode
#49
License Key Formatting
LeetCode
#50
Linked List Cycle
LeetCode
#51
Longest Common Prefix
LeetCode
#52
Longest Consecutive Sequence
LeetCode
#53
Longest Palindrome
LeetCode
#54
Longest Substring without Repeating Characters
LeetCode
#55
Majority Element
LeetCode
#56
Majority Element 2
LeetCode
#57
Max Area of Island
LeetCode
#58
Max Distance
LeetCode
#59
Max Number of Vowels
LeetCode
#60
Maximum Bags with Full Capacity of Rocks
LeetCode
#61
Maximum Count
LeetCode
#62
Maximum Depth of a Binary Tree
LeetCode
#63
Maximum Score From Removing Substrings
LeetCode
#64
Merge In Place
LeetCode
#65
Merge Intervals
LeetCode
#66
Merge Strings Alternatively
LeetCode
#67
Merge Two Binary Trees
LeetCode
#68
MergeIntervals
LeetCode
#69
MergeKLists
LeetCode
#70
Message Logger
LeetCode
#71
Middle of the Linked List
LeetCode
#72
Min Stack
LeetCode
#73
Minimum Window Substring
LeetCode
#74
Missing Ranges
LeetCode
#75
Move Zeros to End
LeetCode
#76
Multiply Strings
LeetCode
#77
Next Permutation
LeetCode
#78
Non-Overlapping Intervals
LeetCode
#79
Palindrome Linked List
LeetCode
#80
Partition Labels
LeetCode
#81
Pascal's Triangle II
LeetCode
#82
Permutation in String
LeetCode
#83
Plus One
LeetCode
#84
Populating Next Right Pointer in Each Node
LeetCode
#85
Product of Array Except Self
LeetCode
#86
Randomized Set
LeetCode
#87
Recursive Bubble Sort
LeetCode
#88
Recursive Insertion Sort
LeetCode
#89
Remove Duplicates Sorted Array
LeetCode
#90
Remove Element
LeetCode
#91
Remove Nth Node From End of List
LeetCode
#92
Remove Nth Node from Linked List
LeetCode
#93
Reverse Integer
LeetCode
#94
Reverse Linked Lists
LeetCode
#95
Reverse Pairs
LeetCode
#96
Reverse String
LeetCode
#97
Reverse Words in a String
LeetCode
#98
Rotate Array
LeetCode
#99
Rotate Image
LeetCode
#100
Running Sum 1D Array
LeetCode
#101
Search 2D Matrix
LeetCode
#102
Search Insert Position
LeetCode
#103
Search a 2D Matrix II
LeetCode
#104
Set Zeros Matrix
LeetCode
#105
Shortest Distance
LeetCode
#106
Single Number
LeetCode
#107
Sort An Array
LeetCode
#108
Sort Array By Parity II
LeetCode
#109
Sort Colors
LeetCode
#110
Sort by Parity
LeetCode
#111
Sorted and Rotated Array
LeetCode
#112
Spiral Matrix II
LeetCode
#113
Sprial Matrix
LeetCode
#114
Squares of a Sorted Array
LeetCode
#115
String to Integer(atoi)
LeetCode
#116
Strings Multiply
LeetCode
#117
Sub Array Sum Equals K
LeetCode
#118
Subsets
LeetCode
#119
Symmetric Tree
LeetCode
#120
Target Indicies
LeetCode
#121
Three Parts Equal Sum
LeetCode
#122
Three Sum Smaller
LeetCode
#123
Three Sum Zero
LeetCode
#124
Top K Frequent Elements
LeetCode
#125
Topological Sort
LeetCode
#126
Two Number Sum - Sorted Input Array
LeetCode
#127
Two Sum Less Than K
LeetCode
#128
Ugly Number
LeetCode
#129
Unique Binary Search Tree 2
LeetCode
#130
Unique Email Address
LeetCode
#131
Valid Anagram
LeetCode
#132
Valid Palindrome 2
LeetCode
#133
Valid Parantheses
LeetCode
#134
Valid Parentheses
LeetCode
#135
Valid Suduku
LeetCode
#136
Word Pattern
AlgoExpert
#1
Apartment Hunting
Problem N/A
Solution
AlgoExpert
#2
Array of Products
Problem N/A
Solution
AlgoExpert
#3
BST Construction
Problem N/A
Solution
AlgoExpert
#4
BST Traversal
Problem N/A
Solution
AlgoExpert
#5
Balanced Brackets
Problem N/A
Solution
AlgoExpert
#6
Binary Search
Problem N/A
Solution
AlgoExpert
#7
Binary Tree Diameter
Problem N/A
Solution
AlgoExpert
#8
Branch Sums
Problem N/A
Solution
AlgoExpert
#9
Breadth First Search
Problem N/A
Solution
AlgoExpert
#10
Bubble Sort
Problem N/A
Solution
AlgoExpert
#11
Caesar Cipher Encryptor
Problem N/A
Solution
AlgoExpert
#12
Calender Matching
Problem N/A
Solution
AlgoExpert
#13
Class Photos
Problem N/A
Solution
AlgoExpert
#14
Depth First Search
Problem N/A
Solution
AlgoExpert
#15
Find Closest Value In BST
Problem N/A
Solution
AlgoExpert
#16
Find Kth Largest Node in BST
Problem N/A
Solution
AlgoExpert
#17
Find Loop in Linked List
Problem N/A
Solution
AlgoExpert
#18
Find Nodes Distance K
Problem N/A
Solution
AlgoExpert
#19
Find Successor
Problem N/A
Solution
AlgoExpert
#20
Find Three Largest Numbers
Problem N/A
Solution
AlgoExpert
#21
First Duplicate Value
Problem N/A
Solution
AlgoExpert
#22
First Non Repeating Character
Problem N/A
Solution
AlgoExpert
#23
Four Number Sum
Problem N/A
Solution
AlgoExpert
#24
Generate Document
Problem N/A
Solution
AlgoExpert
#25
Group Anagrams
Problem N/A
Solution
AlgoExpert
#26
Height Balanced Binary Tree
Problem N/A
Solution
AlgoExpert
#27
Insertion Sort
Problem N/A
Solution
AlgoExpert
#28
Invert Binary Tree
Problem N/A
Solution
AlgoExpert
#29
Kadanes Algorithm
Problem N/A
Solution
AlgoExpert
#30
LRU Cache
Problem N/A
Solution
AlgoExpert
#31
Largest Range
Problem N/A
Solution
AlgoExpert
#32
Levenshtein Distance
Problem N/A
Solution
AlgoExpert
#33
Linked List Construction
Problem N/A
Solution
AlgoExpert
#34
Longest Common Subsequence
Problem N/A
Solution
AlgoExpert
#35
Longest Palindromic Substring
Problem N/A
Solution
AlgoExpert
#36
Longest Peak
Problem N/A
Solution
AlgoExpert
#37
Longest Substring Without Duplication
Problem N/A
Solution
AlgoExpert
#38
Lowest Common Manager
Problem N/A
Solution
AlgoExpert
#39
Max Path Sum
Problem N/A
Solution
AlgoExpert
#40
Max Subset Sum No Adjacent
Problem N/A
Solution
AlgoExpert
#41
Max Sum Increasing Subsequence
Problem N/A
Solution
AlgoExpert
#42
Merge LinkedLists
Problem N/A
Solution
AlgoExpert
#43
Merge Overlapping Intervals
Problem N/A
Solution
AlgoExpert
#44
Merge Sort
Problem N/A
Solution
AlgoExpert
#45
Min Height BST
Problem N/A
Solution
AlgoExpert
#46
Min Max Stack Construction
Problem N/A
Solution
AlgoExpert
#47
Min Number of Jumps
Problem N/A
Solution
AlgoExpert
#48
Min Rewards
Problem N/A
Solution
AlgoExpert
#49
Minimum Waiting Time
Problem N/A
Solution
AlgoExpert
#50
Monotonic Array
Problem N/A
Solution
AlgoExpert
#51
Move Element to End
Problem N/A
Solution
AlgoExpert
#52
Next Greater Element
Problem N/A
Solution
AlgoExpert
#53
Node Depths
Problem N/A
Solution
AlgoExpert
#54
Non-Constructible Change
Problem N/A
Solution
AlgoExpert
#55
Nth Fibonacci
Problem N/A
Solution
AlgoExpert
#56
Number of Ways To Traverse Graph
Problem N/A
Solution
AlgoExpert
#57
Number of Ways to Make Change
Problem N/A
Solution
AlgoExpert
#58
Palindrome Check
Problem N/A
Solution
AlgoExpert
#59
Permutations
Problem N/A
Solution
AlgoExpert
#60
Power Set
Problem N/A
Solution
AlgoExpert
#61
Product Sum
Problem N/A
Solution
AlgoExpert
#62
Quick Sort
Problem N/A
Solution
AlgoExpert
#63
Reconstruct BST
Problem N/A
Solution
AlgoExpert
#64
Remove Duplicates From Linked List
Problem N/A
Solution
AlgoExpert
#65
Remove Islands
Problem N/A
Solution
AlgoExpert
#66
Remove Kth Node From End
Problem N/A
Solution
AlgoExpert
#67
Reverse Linkedlist
Problem N/A
Solution
AlgoExpert
#68
Right Smaller Than
Problem N/A
Solution
AlgoExpert
#69
River Sizes
Problem N/A
Solution
AlgoExpert
#70
Run Length Encoding
Problem N/A
Solution
AlgoExpert
#71
Same BSTs
Problem N/A
Solution
AlgoExpert
#72
Search For Range
Problem N/A
Solution
AlgoExpert
#73
Search In Sorted Matrix
Problem N/A
Solution
AlgoExpert
#74
Selection Sort
Problem N/A
Solution
AlgoExpert
#75
Shift Linked List
Problem N/A
Solution
AlgoExpert
#76
Shifted Binary Search
Problem N/A
Solution
AlgoExpert
#77
Single Cycle Check
Problem N/A
Solution
AlgoExpert
#78
Smallest Difference
Problem N/A
Solution
AlgoExpert
#79
Sort Stacks
Problem N/A
Solution
AlgoExpert
#80
Sorted Squared Array
Problem N/A
Solution
AlgoExpert
#81
Spiral Traverse
Problem N/A
Solution
AlgoExpert
#82
Staircase Traversal
Problem N/A
Solution
AlgoExpert
#83
Subarray Sort
Problem N/A
Solution
AlgoExpert
#84
Sum of Linked List
Problem N/A
Solution
AlgoExpert
#85
Sunset Views
Problem N/A
Solution
AlgoExpert
#86
Tandem Bicycle
Problem N/A
Solution
AlgoExpert
#87
Task Assignment
Problem N/A
Solution
AlgoExpert
#88
Three Number Sort
Problem N/A
Solution
AlgoExpert
#89
Three Number Sum
Problem N/A
Solution
AlgoExpert
#90
Tournament Winner
Problem N/A
Solution
AlgoExpert
#91
Two Number Sum
Problem N/A
Solution
AlgoExpert
#92
Valid IP Addresses
Problem N/A
Solution
AlgoExpert
#93
Valid Starting City
Problem N/A
Solution
AlgoExpert
#94
Validate BST
Problem N/A
Solution
AlgoExpert
#95
Validate Subsequence
Problem N/A
Solution
AlgoExpert
#96
Validate Three Nodes
Problem N/A
Solution
AlgoExpert
#97
Water Area
Problem N/A
Solution
AlgoExpert
#98
Youngest Common Ancestor
Problem N/A
Solution
AlgoExpert
#99
ZigZag Traverse
Problem N/A
Solution
GeekForGeeks
#1
Nth Root of A Number
Pramp
#1
Nth Root of Number
Pramp
#2