Skip to content

Oluwxtope/Grind-75

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grind 75

Table of Contents

  1. Array
    1. Two Sum
    2. Best Time to Buy and Sell Stock
    3. Majority Element
    4. Contains Duplicate
    5. Meeting Rooms
    6. Move Zeroes
    7. Squares of a Sorted Array
    8. Insert Interval
    9. 3Sum
    10. Product of Array Except Self
    11. Combination Sum
    12. Merge Intervals
    13. Sort Colors
    14. Container With Most Water
    15. Gas Station
    16. Longest Consecutive Sequence
    17. Rotate Array
    18. Contiguous Array
    19. Subarray Sum Equals K
    20. Meeting Rooms II
    21. 3Sum Closest
    22. Non-overlapping Intervals
    23. Employee Free Time
    24. Sliding Window Maximum
  2. Stack
    1. Valid Parentheses
    2. Implement Queue using Stacks
    3. Min Stack
    4. Backspace String Compare
    5. Evaluate Reverse Polish Notation
    6. Daily Temperatures
    7. Decode String
    8. Asteroid Collision
    9. Basic Calculator II
    10. Trapping Rain Water
    11. Basic Calculator
    12. Largest Rectangle in Histogram
    13. Maximum Frequency Stack
    14. Longest Valid Parentheses
  3. Linked List
    1. Merge Two Sorted Lists
    2. Linked List Cycle
    3. Reverse Linked List
    4. Middle of the Linked List
    5. Palindrome Linked List
    6. LRU Cache
    7. Remove Nth Node From End of List
    8. Swap Nodes in Pairs
    9. Odd Even Linked List
    10. Add Two Numbers
    11. Sort List
    12. Reorder List
    13. Rotate List
    14. Reverse Nodes in k-Group
  4. String
    1. Valid Palindrome
    2. Valid Anagram
    3. Longest Palindrome
    4. Longest Common Prefix
    5. Longest Substring Without Repeating Characters
    6. String to Integer (atoi)
    7. Longest Palindromic Substring
    8. Find All Anagrams in a String
    9. Group Anagrams
    10. Longest Repeating Character Replacement
    11. Largest Number
    12. Encode and Decode Strings
    13. Minimum Window Substring
    14. Palindrome Pairs
  5. Binary Tree
    1. Invert Binary Tree
    2. Balanced Binary Tree
    3. Diameter of Binary Tree
    4. Maximum Depth of Binary Tree
    5. Same Tree
    6. Symmetric Tree
    7. Subtree of Another Tree
    8. Binary Tree Level Order Traversal
    9. Lowest Common Ancestor of a Binary Tree
    10. Binary Tree Right Side View
    11. Construct Binary Tree from Preorder and Inorder Traversal
    12. Path Sum II
    13. Maximum Width of Binary Tree
    14. Binary Tree Zigzag Level Order Traversal
    15. Path Sum III
    16. All Nodes Distance K in Binary Tree
    17. Serialize and Deserialize Binary Tree
    18. Binary Tree Maximum Path Sum
  6. Binary Search
    1. Binary Search
    2. First Bad Version
    3. Search in Rotated Sorted Array
    4. Time Based Key-Value Store
    5. Search a 2D Matrix
    6. Find Minimum in Rotated Sorted Array
    7. Maximum Profit in Job Scheduling
    8. Median of Two Sorted Arrays
  7. Graph
    1. Flood Fill
    2. 01 Matrix
    3. Clone Graph
    4. Course Schedule
    5. Number of Islands
    6. Rotting Oranges
    7. Accounts Merge
    8. Word Search
    9. Minimum Height Trees
    10. Pacific Atlantic Water Flow
    11. Shortest Path to Get Food
    12. Graph Valid Tree
    13. Course Schedule II
    14. Number of Connected Components in an Undirected Graph
    15. Minimum Knight Moves
    16. Cheapest Flights Within K Stops
    17. Word Ladder
    18. Longest Increasing Path in a Matrix
    19. Word Search II
    20. Alien Dictionary
    21. Bus Routes
  8. Dynamic Programming
    1. Maximum Subarray
    2. Climbing Stairs
    3. Coin Change
    4. Partition Equal Subset Sum
    5. Unique Paths
    6. House Robber
    7. Maximum Product Subarray
    8. Longest Increasing Subsequence
    9. Jump Game
    10. Maximal Square
    11. Decode Ways
    12. Combination Sum IV
  9. Binary Search Tree
    1. Lowest Common Ancestor of a Binary Search Tree
    2. Convert Sorted Array to Binary Search Tree
    3. Validate Binary Search Tree
    4. Kth Smallest Element in a BST
    5. Inorder Successor in BST
  10. Hash Table
    1. Ransom Note
    2. Insert Delete GetRandom O(1)
    3. First Missing Positive
  11. Binary
    1. Add Binary
    2. Counting Bits
    3. Number of 1 Bits
    4. Single Number
    5. Missing Number
    6. Reverse Bits
    7. Find the Duplicate Number
  12. Math
    1. Roman to Integer
    2. Palindrome Number
    3. Random Pick with Weight
    4. Pow(x, n)
    5. Reverse Integer
  13. Heap
    1. K Closest Points to Origin
    2. Task Scheduler
    3. Top K Frequent Words
    4. Find K Closest Elements
    5. Kth Largest Element in an Array
    6. Find Median from Data Stream
    7. Merge k Sorted Lists
    8. Smallest Range Covering Elements from K Lists
  14. Trie
    1. Implement Trie (Prefix Tree)
    2. Word Break
    3. Design Add and Search Words Data Structure
    4. Design In-Memory File System
  15. Recursion
    1. Permutations
    2. Subsets
    3. Letter Combinations of a Phone Number
    4. Next Permutation
    5. Generate Parentheses
    6. N-Queens
  16. Matrix
    1. Spiral Matrix
    2. Valid Sudoku
    3. Rotate Image
    4. Set Matrix Zeroes
    5. Sudoku Solver
  17. Queue
    1. Design Hit Counter

Array

  1. Two Sum

    Leetcode
    Initialize hashmap with element as key and index as value. Iterate through array checking if target number minus current element in hashmap. If yes, return indexes of both elements from hashmap

  2. Best Time to Buy and Sell Stock

    Leetcode
    Use sliding window to keep track of start index and end = start + 1 index. Keep track of max and current profit starting at 0. If end - start less than 0, update start to end and end to start + 1. Else, if end - start > max profit, update max profit and move end to next element.

  3. Majority Element

    Leetcode
    Use hashmap to keep count of how many times an element appears in array, then iterate over hashmap and return element with a count > ceiling(n/2)
    More optimal solution would be using the Boyer-Moore algorithm. Initialize count to 0 and potential candidate to first element in array. Then increment or decrement count by iterating through the array and seeing if potential candidate is present or not. Once count reaches 0, change potential candidate to be present element. Return potential candidate left.

  4. Contains Duplicate

    Leetcode
    Use hashmap to keep count of how many times an element appears while iterating through the array. If current element already in hashmap, return true. If loop concludes, return false as no duplicate elements.

  5. Meeting Rooms

    Leetcode
    Premium leetcode required, didn't solve

  6. Move Zeroes

    Leetcode
    Use 2 pointers starting from indices 0 and 1. 3 scenarios possible: both pointers = 0, move right one until find nonzero then swap; left pointer at 0 and right at nonzero, swap. left pointer at nonzero and right at zero, move both pointers 1 down array.

  7. Squares of a Sorted Array

    Leetcode
    Yet to solve

  8. Insert Interval

    Leetcode
    Create an array to store result. Iterate through intervals and check for 3 scenarios: if last num in new interval less than first num in curr element, append new interval and return result + rest of intervals; if first num in new interval greater than last num in curr element, append curr element; if none of the above, there is overlap thus update new interval numbers and continue iterating. at the end, append new interval and return res (if new interval was inserted, result would have been returned in first scenario).

  9. 3Sum

    Leetcode
    Yet to solve

  10. Product of Array Except Self

    Leetcode
    Initialize array to store results. Initialize prefix variable = 1. Start iterating through nums array and store the prefix in results array, then multiply prefix by current element before moving to next element. That way each index in the result array contains all numbers that came before that index in nums array multiplied. Repeat the same backwards with postfix that stores the suffix of numbers that came after the element. Return results array.

  11. Combination Sum

    Leetcode
    Yet to solve

  12. Merge Intervals

    Leetcode
    Yet to solve

  13. Sort Colors

    Leetcode
    Yet to solve

  14. Container With Most Water

    Leetcode
    Yet to solve

  15. Gas Station

    Leetcode
    Yet to solve

  16. Longest Consecutive Sequence

    Leetcode
    Yet to solve

  17. Rotate Array

    Leetcode
    Yet to solve

  18. Contiguous Array

    Leetcode
    Yet to solve

  19. Subarray Sum Equals K

    Leetcode
    Yet to solve

  20. Meeting Rooms II

    Leetcode
    Yet to solve

  21. 3Sum Closest

    Leetcode
    Yet to solve

  22. Non-overlapping Intervals

    Leetcode
    Yet to solve

  23. Employee Free Time

    Leetcode
    Yet to solve

  24. Sliding Window Maximum

    Leetcode
    Yet to solve

Stack

  1. Valid Parentheses

    Leetcode
    Intialize hashmap matching all types of open brackets as keys to closing brackets as values. Then intialize stack adt using array, pushing opening brackets and only popping last one when you encounter a matching closing bracket. If array is empty, then all matching brackets are positioned in valid locations.

  2. Implement Queue using Stacks

    Leetcode
    Yet to solve

  3. Min Stack

    Leetcode
    Yet to solve

  4. Backspace String Compare

    Leetcode
    Yet to solve

  5. Evaluate Reverse Polish Notation

    Leetcode
    Yet to solve

  6. Daily Temperatures

    Leetcode
    Yet to solve

  7. Decode String

    Leetcode
    Yet to solve

  8. Asteroid Collision

    Leetcode
    Yet to solve

  9. Basic Calculator II

    Leetcode
    Yet to solve

  10. Trapping Rain Water

    Leetcode
    Yet to solve

  11. Basic Calculator

    Leetcode
    Yet to solve

  12. Largest Rectangle in Histogram

    Leetcode
    Yet to solve

  13. Maximum Frequency Stack

    Leetcode
    Yet to solve

  14. Longest Valid Parentheses

    Leetcode
    Yet to solve

Linked List

  1. Merge Two Sorted Lists

    Leetcode
    Initialize linkedlist called new and let a variable called prev point to it. Start while loop that checks if both lists 1 and 2 are not empty. 2 scenarios: val of curr node in list 1 less than that of 2 so let the next node of new be curr node of l1, and move to next node of l1; else, do the same for l2. Then set prev to next node of new and repeat. At end of loop, let prev.next equal to the non-empty list and return new.next as new.val is 0 and we started by changing new.next.

  2. Linked List Cycle

    Leetcode
    Yet to solve

  3. Reverse Linked List

    Leetcode
    Yet to solve

  4. Middle of the Linked List

    Leetcode
    Yet to solve

  5. Palindrome Linked List

    Leetcode
    Yet to solve

  6. LRU Cache

    Leetcode
    Yet to solve

  7. Remove Nth Node From End of List

    Leetcode
    Yet to solve

  8. Swap Nodes in Pairs

    Leetcode
    Yet to solve

  9. Odd Even Linked List

    Leetcode
    Yet to solve

  10. Add Two Numbers

    Leetcode
    Yet to solve

  11. Sort List

    Leetcode
    Yet to solve

  12. Reorder List

    Leetcode
    Yet to solve

  13. Rotate List

    Leetcode
    Yet to solve

  14. Reverse Nodes in k-Group

    Leetcode
    Yet to solve

String

  1. Valid Palindrome

    Leetcode
    Initalize start and end pointers on the array moving in opposite directions. If start and end pointing to alnum characters, check if they're equal (apply lowercase method) and return false if not else move pointers. If a pointer not pointing to alnum char, move the pointer. If loop finishes running, return true.

  2. Valid Anagram

    Leetcode
    Initialize hash map to keep track of count of letters in first string, repeat for second string. Then iterate through both hash maps checking if a char is present in one and not the other or if count of characters in one not equal to count in other and return false. if all loops finish running, return true.

  3. Longest Palindrome

    Leetcode
    Yet to solve

  4. Longest Common Prefix

    Leetcode
    Yet to solve

  5. Longest Substring Without Repeating Characters

    Leetcode
    Yet to solve

  6. String to Integer (atoi)

    Leetcode
    Yet to solve

  7. Longest Palindromic Substring

    Leetcode
    Yet to solve

  8. Find All Anagrams in a String

    Leetcode
    Yet to solve

  9. Group Anagrams

    Leetcode
    Yet to solve

  10. Longest Repeating Character Replacement

    Leetcode
    Yet to solve

  11. Largest Number

    Leetcode
    Yet to solve

  12. Encode and Decode Strings

    Leetcode
    Yet to solve

  13. Minimum Window Substring

    Leetcode
    Yet to solve

  14. Palindrome Pairs

    Leetcode
    Yet to solve

Binary Tree

  1. Invert Binary Tree

    Leetcode
    Yet to solve

  2. Balanced Binary Tree

    Leetcode
    Yet to solve

  3. Diameter of Binary Tree

    Leetcode
    Yet to solve

  4. Maximum Depth of Binary Tree

    Leetcode
    Yet to solve

  5. Same Tree

    Leetcode
    Yet to solve

  6. Symmetric Tree

    Leetcode
    Yet to solve

  7. Subtree of Another Tree

    Leetcode
    Yet to solve

  8. Binary Tree Level Order Traversal

    Leetcode
    Yet to solve

  9. Lowest Common Ancestor of a Binary Tree

    Leetcode
    Yet to solve

  10. Binary Tree Right Side View

    Leetcode
    Yet to solve

  11. Construct Binary Tree from Preorder and Inorder Traversal

    Leetcode
    Yet to solve

  12. Path Sum II

    Leetcode
    Yet to solve

  13. Maximum Width of Binary Tree

    Leetcode
    Yet to solve

  14. Binary Tree Zigzag Level Order Traversal

    Leetcode
    Yet to solve

  15. Path Sum III

    Leetcode
    Yet to solve

  16. All Nodes Distance K in Binary Tree

    Leetcode
    Yet to solve

  17. Serialize and Deserialize Binary Tree

    Leetcode
    Yet to solve

  18. Binary Tree Maximum Path Sum

    Leetcode
    Yet to solve

Binary Search

  1. Binary Search

    Leetcode
    Yet to solve

  2. First Bad Version

    Leetcode
    Yet to solve

  3. Search in Rotated Sorted Array

    Leetcode
    Yet to solve

  4. Time Based Key-Value Store

    Leetcode
    Yet to solve

  5. Search a 2D Matrix

    Leetcode
    Yet to solve

  6. Find Minimum in Rotated Sorted Array

    Leetcode
    Yet to solve

  7. Maximum Profit in Job Scheduling

    Leetcode
    Yet to solve

  8. Median of Two Sorted Arrays

    Leetcode
    Yet to solve

Graph

  1. Flood Fill

    Leetcode
    Yet to solve

  2. 01 Matrix

    Leetcode
    Yet to solve

  3. Clone Graph

    Leetcode
    Yet to solve

  4. Course Schedule

    Leetcode
    Yet to solve

  5. Number of Islands

    Leetcode
    Yet to solve

  6. Rotting Oranges

    Leetcode
    Yet to solve

  7. Accounts Merge

    Leetcode
    Yet to solve

  8. Word Search

    Leetcode
    Yet to solve

  9. Minimum Height Trees

    Leetcode
    Yet to solve

  10. Pacific Atlantic Water Flow

    Leetcode
    Yet to solve

  11. Shortest Path to Get Food

    Leetcode
    Yet to solve

  12. Graph Valid Tree

    Leetcode
    Yet to solve

  13. Course Schedule II

    Leetcode
    Yet to solve

  14. Number of Connected Components in an Undirected Graph

    Leetcode
    Yet to solve

  15. Minimum Knight Moves

    Leetcode
    Yet to solve

  16. Cheapest Flights Within K Stops

    Leetcode
    Yet to solve

  17. Word Ladder

    Leetcode
    Yet to solve

  18. Longest Increasing Path in a Matrix

    Leetcode
    Yet to solve

  19. Word Search II

    Leetcode
    Yet to solve

  20. Alien Dictionary

    Leetcode
    Yet to solve

  21. Bus Routes

    Leetcode
    Yet to solve

Dynamic Programming

  1. Maximum Subarray

    Leetcode
    Yet to solve

  2. Climbing Stairs

    Leetcode
    Yet to solve

  3. Coin Change

    Leetcode
    Yet to solve

  4. Partition Equal Subset Sum

    Leetcode
    Yet to solve

  5. Unique Paths

    Leetcode
    Yet to solve

  6. House Robber

    Leetcode
    Yet to solve

  7. Maximum Product Subarray

    Leetcode
    Yet to solve

  8. Longest Increasing Subsequence

    Leetcode
    Yet to solve

  9. Jump Game

    Leetcode
    Yet to solve

  10. Maximal Square

    Leetcode
    Yet to solve

  11. Decode Ways

    Leetcode
    Yet to solve

  12. Combination Sum IV

    Leetcode
    Yet to solve

Binary Search Tree

  1. Lowest Common Ancestor of a Binary Search Tree

    Leetcode
    Yet to solve

  2. Convert Sorted Array to Binary Search Tree

    Leetcode
    Yet to solve

  3. Validate Binary Search Tree

    Leetcode
    Yet to solve

  4. Kth Smallest Element in a BST

    Leetcode
    Yet to solve

  5. Inorder Successor in BST

    Leetcode
    Yet to solve

Hash Table

  1. Ransom Note

    Leetcode
    Yet to solve

  2. Insert Delete GetRandom O(1)

    Leetcode
    Yet to solve

  3. First Missing Positive

    Leetcode
    Yet to solve

Binary

  1. Add Binary

    Leetcode
    Yet to solve

  2. Counting Bits

    Leetcode
    Yet to solve

  3. Number of 1 Bits

    Leetcode
    Yet to solve

  4. Single Number

    Leetcode
    Yet to solve

  5. Missing Number

    Leetcode
    Yet to solve

  6. Reverse Bits

    Leetcode
    Yet to solve

  7. Find the Duplicate Number

    Leetcode
    Yet to solve

Math

  1. Roman to Integer

    Leetcode
    Yet to solve

  2. Palindrome Number

    Leetcode
    Yet to solve

  3. Random Pick with Weight

    Leetcode
    Yet to solve

  4. Pow(x, n)

    Leetcode
    Yet to solve

  5. Reverse Integer

    Leetcode
    Yet to solve

Heap

  1. K Closest Points to Origin

    Leetcode
    Yet to solve

  2. Task Scheduler

    Leetcode
    Yet to solve

  3. Top K Frequent Words

    Leetcode
    Yet to solve

  4. Find K Closest Elements

    Leetcode
    Yet to solve

  5. Kth Largest Element in an Array

    Leetcode
    Yet to solve

  6. Find Median from Data Stream

    Leetcode
    Yet to solve

  7. Merge k Sorted Lists

    Leetcode
    Yet to solve

  8. Smallest Range Covering Elements from K Lists

    Leetcode
    Yet to solve

Trie

  1. Implement Trie (Prefix Tree)

    Leetcode
    Yet to solve

  2. Word Break

    Leetcode
    Yet to solve

  3. Design Add and Search Words Data Structure

    Leetcode
    Yet to solve

  4. Design In-Memory File System

    Leetcode
    Yet to solve

Recursion

  1. Permutations

    Leetcode
    Yet to solve

  2. Subsets

    Leetcode
    Yet to solve

  3. Letter Combinations of a Phone Number

    Leetcode
    Yet to solve

  4. Next Permutation

    Leetcode
    Yet to solve

  5. Generate Parentheses

    Leetcode
    Yet to solve

  6. N-Queens

    Leetcode
    Yet to solve

Matrix

  1. Spiral Matrix

    Leetcode
    Yet to solve

  2. Valid Sudoku

    Leetcode
    Yet to solve

  3. Rotate Image

    Leetcode
    Yet to solve

  4. Set Matrix Zeroes

    Leetcode
    Yet to solve

  5. Sudoku Solver

    Leetcode
    Yet to solve

Queue

  1. Design Hit Counter

    Leetcode
    Yet to solve