Grind75 Flashcards

1
A

Use a hash map to store the difference of the target and the current element as the key and the index as the value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Best Time To Buy And Sell Stock,https://leetcode.com/problems/best-time-to-buy-and-sell-stock

A

Keep track of the minimum price and maximum profit while iterating through the list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Majority Element,https://leetcode.com/problems/majority-element

A

Use Boyer-Moore Voting Algorithm to find the majority element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Contains Duplicate,https://leetcode.com/problems/contains-duplicate

A

Use a set to check for duplicates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Insert Interval,https://leetcode.com/problems/insert-interval

A

Merge intervals while iterating through the list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

3Sum,https://leetcode.com/problems/3sum

A

Sort the array and use three pointers to find the triplets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Product Of Array Except Self,https://leetcode.com/problems/product-of-array-except-self

A

Use two arrays to store the product of all elements to the left and right of each element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Combination Sum,https://leetcode.com/problems/combination-sum

A

Use backtracking to find all possible combinations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Merge Intervals,https://leetcode.com/problems/merge-intervals

A

Sort intervals by starting point and merge overlapping intervals.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Sort Colors,https://leetcode.com/problems/sort-colors

A

Use the Dutch National Flag algorithm to sort the colors in one pass.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Container With Most Water,https://leetcode.com/problems/container-with-most-water

A

Use two pointers to find the maximum area.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Invert Binary Tree,https://leetcode.com/problems/invert-binary-tree

A

Use a recursive function to swap the left and right children of each node.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Balanced Binary Tree,https://leetcode.com/problems/balanced-binary-tree

A

Check if the difference in heights of the left and right subtrees is no more than one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Diameter of Binary Tree,https://leetcode.com/problems/diameter-of-binary-tree

A

Use a recursive function to find the maximum depth of the left and right subtrees.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Maximum Depth of Binary Tree,https://leetcode.com/problems/maximum-depth-of-binary-tree

A

Use a recursive function to find the maximum depth.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Binary Tree Level Order Traversal,https://leetcode.com/problems/binary-tree-level-order-traversal

A

Use a queue to traverse the tree level by level.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Lowest Common Ancestor of a Binary Tree,https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree

A

Use a recursive function to find the lowest common ancestor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Binary Tree Right Side View,https://leetcode.com/problems/binary-tree-right-side-view

A

Use a queue to traverse the tree level by level and add the rightmost node of each level to the result.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Construct Binary Tree from Preorder and Inorder Traversal,https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal

A

Use a recursive function to build the tree.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Serialize and Deserialize Binary Tree,https://leetcode.com/problems/serialize-and-deserialize-binary-tree

A

Use a queue to traverse the tree and serialize/deserialize it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Valid Palindrome,https://leetcode.com/problems/valid-palindrome

A

Use two pointers to check if the string is a palindrome.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Valid Anagram,https://leetcode.com/problems/valid-anagram

A

Use a hash map to count the frequency of each character.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Longest Palindrome,https://leetcode.com/problems/longest-palindromic-substring

A

Use dynamic programming to find the longest palindromic substring.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Longest Substring Without Repeating Characters,https://leetcode.com/problems/longest-substring-without-repeating-characters

A

Use a sliding window to find the longest substring.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

String to Integer (atoi),https://leetcode.com/problems/string-to-integer-atoi

A

Handle whitespaces, signs, and overflow while converting the string to an integer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Longest Palindromic Substring,https://leetcode.com/problems/longest-palindromic-substring

A

Use dynamic programming to find the longest palindromic substring.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Find All Anagrams in a String,https://leetcode.com/problems/find-all-anagrams-in-a-string

A

Use a sliding window and a hash map to find all anagrams.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Minimum Window Substring,https://leetcode.com/problems/minimum-window-substring

A

Use a sliding window and a hash map to find the minimum window substring.

29
Q

Flood Fill,https://leetcode.com/problems/flood-fill

A

Use a queue or recursive function to perform the flood fill.

30
Q

01 Matrix,https://leetcode.com/problems/01-matrix

A

Use a queue to perform a breadth-first search from all zero cells.

31
Q

Clone Graph,https://leetcode.com/problems/clone-graph

A

Use a depth-first search to clone the graph.

32
Q

Course Schedule,https://leetcode.com/problems/course-schedule

A

Use a depth-first search to detect cycles in the graph.

33
Q

Number of Islands,https://leetcode.com/problems/number-of-islands

A

Use a depth-first search to count the number of islands.

34
Q

Rotting Oranges,https://leetcode.com/problems/rotting-oranges

A

Use a queue to perform a breadth-first search from all rotten oranges.

35
Q

Accounts Merge,https://leetcode.com/problems/accounts-merge

A

Use a union-find data structure to merge the accounts.

36
Q

Word Search,https://leetcode.com/problems/word-search

A

Use a depth-first search to find the word in the grid.

37
Q

Minimum Height Trees,https://leetcode.com/problems/minimum-height-trees

A

Use a breadth-first search to find the minimum height trees.

38
Q

Word Ladder,https://leetcode.com/problems/word-ladder

A

Use a breadth-first search to find the shortest transformation sequence.

39
Q

Valid Parentheses,https://leetcode.com/problems/valid-parentheses

A

Use a stack to check if the parentheses are valid.

40
Q

Implement Queue using Stacks,https://leetcode.com/problems/implement-queue-using-stacks

A

Use two stacks to implement a queue.

41
Q

Evaluate Reverse Polish Notation,https://leetcode.com/problems/evaluate-reverse-polish-notation

A

Use a stack to evaluate the reverse Polish notation.

42
Q

Min Stack,https://leetcode.com/problems/min-stack

A

Use two stacks to implement a min stack.

43
Q

Trapping Rain Water,https://leetcode.com/problems/trapping-rain-water

A

Use two pointers to find the amount of trapped rainwater.

44
Q

Basic Calculator,https://leetcode.com/problems/basic-calculator

A

Use a stack to evaluate the expression.

45
Q

Largest Rectangle in Histogram,https://leetcode.com/problems/largest-rectangle-in-histogram

A

Use a stack to find the largest rectangle.

46
Q

Merge Two Sorted Lists,https://leetcode.com/problems/merge-two-sorted-lists

A

Use two pointers to merge the lists.

47
Q

Linked List Cycle,https://leetcode.com/problems/linked-list-cycle

A

Use two pointers to detect a cycle in the linked list.

48
Q

Reverse Linked List,https://leetcode.com/problems/reverse-linked-list

A

Use a recursive or iterative function to reverse the linked list.

49
Q

Middle of the Linked List,https://leetcode.com/problems/middle-of-the-linked-list

A

Use two pointers to find the middle of the linked list.

50
Q

LRU Cache,https://leetcode.com/problems/lru-cache

A

Use a hash map and a doubly linked list to implement the LRU cache.

51
Q

Binary Search,https://leetcode.com/problems/binary-search

A

Use binary search to find the target element.

52
Q

First Bad Version,https://leetcode.com/problems/first-bad-version

A

Use binary search to find the first bad version.

53
Q

Search in Rotated Sorted Array,https://leetcode.com/problems/search-in-rotated-sorted-array

A

Use binary search to find the target element.

54
Q

Time Based Key-Value Store,https://leetcode.com/problems/time-based-key-value-store

A

Use a hash map and a list to store the key-value pairs.

55
Q

Maximum Profit in Job Scheduling,https://leetcode.com/problems/maximum-profit-in-job-scheduling

A

Use dynamic programming to find the maximum profit.

56
Q

Lowest Common Ancestor of a Binary Search Tree,https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree

A

Use a recursive function to find the lowest common ancestor.

57
Q

Validate Binary Search Tree,https://leetcode.com/problems/validate-binary-search-tree

A

Use a recursive function to validate the binary search tree.

58
Q

Kth Smallest Element in a BST,https://leetcode.com/problems/kth-smallest-element-in-a-bst

A

Use an inorder traversal to find the kth smallest element.

59
Q

Climbing Stairs,https://leetcode.com/problems/climbing-stairs

A

Use dynamic programming to find the number of ways to climb the stairs.

60
Q

Maximum Subarray,https://leetcode.com/problems/maximum-subarray

A

Use dynamic programming to find the maximum subarray.

61
Q

Coin Change,https://leetcode.com/problems/coin-change

A

Use dynamic programming to find the minimum number of coins.

62
Q

Partition Equal Subset Sum,https://leetcode.com/problems/partition-equal-subset-sum

A

Use dynamic programming to partition the array.

63
Q

Unique Paths,https://leetcode.com/problems/unique-paths

A

Use dynamic programming to find the number of unique paths.

64
Q

Ransom Note,https://leetcode.com/problems/ransom-note

A

Use a hash map to count the frequency of each character.

65
Q

Add Binary,https://leetcode.com/problems/add-binary

A

Use a loop to add the binary numbers.

66
Q

Spiral Matrix,https://leetcode.com/problems/spiral-matrix

A

Use four pointers to traverse the matrix in a spiral order.

67
Q

K Closest Points to Origin,https://leetcode.com/problems/k-closest-points-to-origin

A

Use a priority queue to find the k closest points.

68
Q

Task Scheduler,https://leetcode.com/problems/task-scheduler

A

Use a priority queue to schedule the tasks