0% found this document useful (0 votes)
4 views10 pages

Leetcode 75

The document lists various algorithmic problems categorized by data structures such as Array, Binary, DP, Graph, Heap, Linked List, Matrix, String, Tree, and Two Pointer, along with their difficulty levels and completion status. Each problem is accompanied by a brief solution note outlining the approach to solve it. Additionally, the document includes runtime complexities for the proposed solutions.

Uploaded by

temp.knah1d
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views10 pages

Leetcode 75

The document lists various algorithmic problems categorized by data structures such as Array, Binary, DP, Graph, Heap, Linked List, Matrix, String, Tree, and Two Pointer, along with their difficulty levels and completion status. Each problem is accompanied by a brief solution note outlining the approach to solve it. Additionally, the document includes runtime complexities for the proposed solutions.

Uploaded by

temp.knah1d
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Question Number Question Name Array

1 Two Sum Array


4 Container With Most Water Array
5 3Sum Array
14 Maximum Subarray Array
38 Maximum Product Subarray Array
39 Find Minimum in Rotated Sorted Array Array
55 Product of Array Except Self Array
10 Search in Rotated Sorted Array Array, DP
30 Best Time to Buy and Sell Stock Array, Hashta
50 Contains Duplicate Binary
40 Reverse Bits Binary
41 Number of 1 Bits Binary
60 Missing Number Binary
67 Counting Bits Binary
69 Sum of Two Integers Binary
3 Longest Palindromic Substring DP
11 Combination Sum DP
16 Jump Game DP
19 Unique Paths DP
20 Climbing Stairs DP
24 Decode Ways DP
35 Word Break DP
42 House Robber DP
49 House Robber II DP
64 Longest Increasing Subsequence DP
65 Coin Change DP
76 Longest Common Subsequence DP
33 Longest Consecutive Sequence DP
34 Clone Graph Graph
43 Number of Islands Graph
45 Course Schedule Graph
70 Pacific Atlantic Water Flow Graph
63 Find Median from Data Stream Heap
68 Top K Frequent Elements Heap
17 Merge Intervals Intervals
18 Insert Interval Intervals
72 Non-overlapping Intervals Intervals
6 Remove Nth Node From End of List Linked List
8 Merge Two Sorted Lists Linked List
9 Merge k Sorted Lists Linked List
36 Linked List Cycle Linked List
37 Reorder List Linked List
44 Reverse Linked List Linked List
12 Rotate Image Matrix
15 Spiral Matrix Matrix
21 Set Matrix Zeroes Matrix
23 Word Search String
7 Valid Parentheses String
13 Group Anagrams String
22 Minimum Window Substring String
56 Valid Anagram String
71 Longest Repeating Character Replacement String
75 Palindromic Substrings String, Slidi
2 Longest Substring Without Repeating Characters Topic
25 Validate Binary Search Tree Tree
26 Same Tree Tree
27 Binary Tree Level Order Traversal Tree
28 Maximum Depth of Binary Tree Tree
29 Construct Binary Tree from Preorder and Inorder Traversal Tree
31 Binary Tree Maximum Path Sum Tree
46 Implement Trie (Prefix Tree) Tree
47 Design Add and Search Words Data Structure Tree
48 Word Search II Tree
51 Invert Binary Tree Tree
52 Kth Smallest Element in a BST Tree
53 Lowest Common Ancestor of a Binary Search Tree Tree
54 Lowest Common Ancestor of a Binary Tree Tree
73 Serialize and Deserialize BST Tree
74 Subtree of Another Tree Tree
32 Valid Palindrome Two Pointer
Difficulty Completed
Easy X
Medium X
Medium X
Medium X
Medium X
Medium X
Medium X
Medium X
Easy X
Easy X
Easy
Easy
Easy X
Easy
Medium
Medium X
Medium
Medium X
Medium X
Medium X
Medium X
Medium X
Medium X
Medium X
Medium X
Medium X
Medium X
Medium X
Medium
Medium X
Medium
Medium
Medium
Medium X
Medium X
Medium X
Medium X
Easy X
Medium X
Hard X
Medium X
Medium
Easy X
Medium
Medium
Medium
Hard
Easy X
Medium X
Medium
Medium X
Medium X
Medium X
Easy X
Easy X
Easy X
Medium X
Easy X
Hard
Hard
Medium X
Medium X
Medium
Medium X
Medium
Easy X
Medium X
Medium
Easy X
Easy X
Solution Notes
Create hashmap for compliment solution, run through list of nums checking if compliment is in map if yes return ind
2 Pointer, while l<r. Move pointer with lower height.
Sort list, for every unique num. move left and right point if sum is too small or great, add ans if achieved.
Current = first element, max = max element. For every num if the curr total is < 0 reset to 0 else add the num to curr
For every element in array keep track of min and max product and update with each number, keep a global max to r
if mid-1 >mid or mid+1<mid return mid/mid+1. Else check if l<mid and move l to mid+1, else move r to mid-1.
Count product of array without 0s and num of 0s. If num 0s >1, return all 0s. If a 0 and this num isnt 0 append 0. if n
While l<=r: if mid = target return. If l<mid then check if target is in range of l and mid and change r. Else change l. Els
loop over prices if price is lowest so far set buy to price otherwise check if maxProfit is less than price-buy
Use hashtable, loop if in hash return True. OR compare len of set(nums) to len of nums

n(n+1)/2 - sum(nums)

Expand around center of 1 or 2 chars while outer 2 char in bound and equal for each char in s. Return longest.

for every num if it can be reached up longest with max of longest and num+jump distance. If num cant be reached r
If out of bounds return 0, if end of path return 1, else return dp of down a square + dp of right a square. Use lru_cac
If n ==1, return 1 elif n==2, return 2 else return helper(n-1)+helper(n-2). Store results in a hashtable. OR use fibonci
create array of ans, for every num add the answer to the problem of num before. If 9<num and num before<27 add
Bottomup: create array size of word, for every word in dict check if it matches current string, if so update ith elemen
Max on current house plus DP on position+2 and DP on position+1. If second to end return max of 2. if end return en
Do House Robber but take max between houses - first house and houses - last house
DP map keep track of longest starting at end and if num is less than curr, update DP. Create array add first num, for
Bottomup: Create array size target+1 and set each index to target+1. For each coin check if target can be made in fe

Create set from nums. For each num check if previous num is in set. If not then check for consecutive numbers. This

Use dfs on every point, if 1 and not in visited add an island and run dfs.

count occurance of each num in dictionary. Use priority qeue to pop top k elements by value.
Sort intervals by start time, for each interval check if starts after previous ends, ends after previous, or is encompass
Add newInterval, sort by start value, remove overlapping intervals. Use extra space for answer. Can do in O(N) with
Sort intervals by start time, for each check if previous end is after curr start, If so add 1 to ans then update curr end
Fast pointer advance to N nodes ahead. Advance slow pointer and fast pointer until fast pointer hits null. Then skip
Create new empty list, while both lists add smaller element then add rest of nonempty list.
Divide and conquer using merge 2 sorted lists
Use fast and slow pointer, if equal return cycle, if one pointer null return no cycle
Prev=None, cur=head. While cur: next = cur.next, cur.next=prev, prev=cur, cur=next. Return prev

Use stack to keep track of opening, if closing not top of stack return false. If stack not empty at end return false. Use
Use unique prime for each char in each string. Find product and use as key of hashmap for each group

Create hashmap with all chars from first string and their count, remove them for each occurance in second string if
Dict of freq of chars, keep l, r pointer. Move r constantly, add r char to freq, if freq-l+r+1>k move l otherwise don’t, t
Def function to count palandroms starting from center. Call function on each char in string and take sum of all result
Map for last time each char was used, loop through string and if char used more recently than start of current subst
If not node return True. Else set min and max vals to None and if val is out of min, max, return false otherwise recur
Use dfs to check if each node is the same in both tree. Dfs should take 2 nodes, one from each tree.
Use bfs but don’t update q with children until q is empty. Use separate array to store curr next and nextLevel
If root is none return 0 otherwise return 1+max of recursive call of left and right node.

Create TrieNode class with map children and boolean endWord. Insert each char and add TrieNode if not in children
Create TrieNode class. Add word like Implement Trie. Search if '.' for all children of node call

Set root.right to self.invertTree(right,left) and vica versa

If q/p of different sides of root return root else move down. If root = p or q return p or q.
Use dfs, if node then check left and right trees if 2 of curr, left or right are targets then curr node is ans, else if one o

Function checks if each tree = subtree recursively. Call sameTree function recursively on all nodes of tree.
while left < right the check if char is alnum in while loop and if chars don’t match return false else change r/l.
Runtime
O(N)
O(N)
O(N^2)
O(N)
O(N)
Log(N)
O(N)
O(log(n))
O(N)
O(N)

O(N)

O(N^2)

O(N)
O(N*M)
O(N)
O(N)
O(len(s)*DictWord)
O(N)
O(N)
O(N^2) / O(nLog(N))
O(Coins*Target)

O(N)

O(N*M)

O(Nlog(k))
O(nLog(n))
O(nLog(n))
O(nLog(n))
O(N)
O(N+M)
O(Nlog(k))
O(N)
O(N)

O(N)
O(N*M)

O(N+M)
O(N)
O(N^2)
O(N)
O(N)
O(N)
O(N)
O(N)

X
Add O(all letters of all words) SearchO(height) for no .

O(N)

O(H)
O(N)

O(T*ST)
O(N)
Question Number Question Name Array Difficulty Completed
Solution Notes Runtime

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy