/LeetCode_30DayChallenge_May2020

Excited to take up the 30 Day LeetCode Challenge - May 2020! In this repo, I commit solutions to the challenge problems everyday for the Month of May 2020. You can see the TC and SC of the solutions in the Readme file. Question and Solution present in the code files.

Primary LanguageC++

Solutions to the LeetCode May 2020 Challenge

Questions are pasted in the code as comments.

S No. Problem Name Algorithm / Data Structure Time Complexity Space Complexity
1 First Bad Version Binary Search O(logn) O(1)
2 Jewels and Stones HashSet O(m+n) O(m)
3 Ransom Note MultiSet O(m+n) O(n)
4 Number Complement Bit Manipulation O(1) O(1)
5 First Unique Character in a String NA O(n) O(m)
6 Majority Element Sort O(n(logn)) O(1)
7 Cousins in Binary Tree Recursion O(n) O(1)
8 Check If It Is a Straight Line Slope Formula O(n) O(1)
9 Valid Perfect Square Binary Search O(logn) O(1)
10 Find the Town Judge HashMap O(m+n) O(n)
11 Flood Fill DFS O(n) O(n)
12 Single Element in a Sorted Array XOR O(n) O(1)
13 Remove K Digits NA O(n) O(n)
14 Implement Trie (Prefix Tree) Trie O(m*n) O(n)
15 Maximum Sum Circular Subarray Kadene's Algo O(n) O(1)
16 Odd Even Linked List Linked List O(n) O(1)
17 Find All Anagrams in a String Modified Rabin Karp O(n) O(1)
18 Permutation in String Modified Rabin Karp O(n) O(1)
19 Online Stock Span Stack O(n) O(n)
20 Kth Smallest Element in a BST Inorder Traversal O(n) O(n)
22 Sort Characters By Frequency HashMap & VectorPair O(logn) O(n)
23 Interval List Intersections NA O(m+n) O(m+n)
24 Construct Binary Search Tree from Preorder Traversal BST O(n^2) O(n)
25 Uncrossed Lines Dynamic Programming O(n) O(n)
26 Contiguous Array Dynamic Programming O(n) O(n)
27 Possible Bipartition DFS O(n) O(n)
28 Counting Bits Bit Manipulation O(logn) O(1)
29 Course Schedule Graph Coloring O(v+e) O(e)
30 K Closest Points to Origin HashMap O(n) On)
31 Edit Distance Dynamic Programming O(n) O(n)