Skip to content

Latest commit

Β 

History

History
290 lines (282 loc) Β· 48.9 KB

File metadata and controls

290 lines (282 loc) Β· 48.9 KB

Algorithms Solutions in Swift

This repository contains Swift solutions from AlgoExpert, LeetCode, HackerRank, GeekForGeeks, and Pramp.

Suggestions and contributions are welcome.

How to Use

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

Maintenance

This README is generated from the repository directory structure.