Skip to content

Latest commit

 

History

History
240 lines (167 loc) · 9.74 KB

File metadata and controls

240 lines (167 loc) · 9.74 KB
  1. Linked List Operations Implement basic operations for a singly linked list, such as insertion, deletion, and reversing the list.

  2. Stack Implementation Implement a stack data structure with push, pop, and peek operations.

  3. Queue Implementation Implement a queue data structure with enqueue, dequeue, and peek operations.

  4. Find the Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.

  5. Longest Common Prefix Write a function to find the longest common prefix string amongst a list of strings.

  6. Word Frequency Counter Write a function to count the frequency of each word in a given text.

  7. Two Sum: Given an array of integers, find two numbers such that they add up to a specific target.

  8. Valid Parentheses: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

  9. Maximum Subarray Sum: Find the contiguous subarray with the largest sum.

  10. Linked List Cycle: Given a linked list, determine if it has a cycle.

  11. Reverse Linked List: Reverse a linked list.

  12. Rotate Array: Rotate an array to the right by k steps.

  13. Longest Increasing Subsequence: Find the length of the longest increasing subsequence in an array of integers.

  14. Palindrome Linked List: Check if a linked list is a palindrome.

  15. Count and Say: The count-and-say sequence is a series of strings where each string is the result of counting and saying the digits of the previous string.

  16. Merge Intervals: Given a collection of intervals, merge any overlapping intervals.

  17. Valid Sudoku: Determine if a 9x9 Sudoku board is valid.

  18. First Missing Positive: Given an unsorted integer array, find the smallest missing positive integer.

  19. Container With Most Water: Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.

  20. Implement a Trie (Prefix Tree): Implement a trie with insert, search, and startsWith methods.

  21. Evaluate Reverse Polish Notation: Evaluate the value of an arithmetic expression in Reverse Polish Notation.

  22. Valid Anagram: Given two strings, check if they are valid anagrams of each other.

  23. Minimum Path Sum: Given a 2D grid filled with non-negative numbers, find the minimum sum path from the top-left to the bottom-right, moving only right or down.

  24. Intersection of Two Arrays: Given two arrays, write a function to compute their intersection.

  25. ZigZag Conversion: Convert a given string to a zigzag pattern given a number of rows.

  26. Group Anagrams: Given an array of strings, group anagrams together.

  27. Word Search: Given a 2D board and a word, determine if the word exists in the grid.

  28. Unique Paths: A robot is located at the top-left corner of a m x n grid. It can only move either down or right. Count the number of unique paths to reach the bottom-right corner.

  29. Sort Colors: Given an array with n objects colored red, white, or blue, sort them in-place.

  30. Combination Sum: Given a set of candidate numbers and a target sum, find all unique combinations where the candidate numbers sum to the target.

  31. Longest Substring Without Repeating Characters: Given a string, find the length of the longest substring without repeating characters.

  32. Jump Game: Given an array of non-negative integers, you are initially positioned at the first index and each element in the array represents your maximum jump length. Determine if you can reach the last index.

  33. Symmetric Tree: Given a binary tree, check whether it is a mirror of itself.

  34. Find Peak Element: Find the peak element in an array. An element is a peak if it is greater than or equal to its neighbors

  35. Binary Tree Inorder Traversal: Implement inorder traversal of a binary tree.

  36. Valid Sudoku: Determine if a 9x9 Sudoku board is valid.

  37. Maximum Depth of Binary Tree: Find the maximum depth of a binary tree.

  38. Number of Islands: Given a 2D grid map of '1's (land) and '0's (water), count the number of islands.

  39. Top K Frequent Elements: Given an array, find the k most frequent elements.

  40. Rotate Image: Rotate an N x N 2D matrix (representing an image) 90 degrees.

  41. Minimum Window Substring: Given a string S and a string T, find the minimum window in S that contains all the characters in T.

  42. Construct Binary Tree from Preorder and Inorder Traversal: Given preorder and inorder traversal of a tree, construct the binary tree.

  43. Valid Palindrome: Given a string, determine if it is a valid palindrome, considering only alphanumeric characters and ignoring cases.

  44. Word Break: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.

  45. Longest Palindromic Substring: Given a string, find the longest palindromic substring.

  46. Meeting Rooms II: Given an array of meeting time intervals, find the minimum number of conference rooms required.

  47. Best Time to Buy and Sell Stock: Given an array representing stock prices on different days, find the maximum profit that can be obtained by making a single transaction.

  48. Spiral Matrix: Given an m x n matrix, return all elements of the matrix in spiral order.

  49. Reverse Words in a String: Given a string, reverse each word in it while maintaining the order of words.

  50. Valid Sudoku: Determine if a 9x9 Sudoku board is valid. The rules are as follows:

    • Each row must contain the digits 1-9 without repetition.
    • Each column must contain the digits 1-9 without repetition.
    • Each of the 9 3x3 sub-boxes must contain the digits 1-9 without repetition.
  51. Subarray Sum Equals K: Given an array of integers and an integer k, find the total number of continuous subarrays whose sum equals k.

  52. Letter Combinations of a Phone Number: Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent on a phone keypad.

  53. Maximum Depth of Binary Tree: Given a binary tree, find its maximum depth.

  54. Valid Palindrome: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.

  55. Merge k Sorted Lists: Merge k sorted linked lists and return it as one sorted list.

  56. Find the Duplicate Number: Given an array containing n + 1 integers where each integer is between 1 and n (inclusive), find the duplicate one.

  57. Set Matrix Zeroes: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.

  58. Longest Common Subsequence: Given two strings, find the length of the longest common subsequence.

  59. Combination Sum II: Given a collection of candidate numbers and a target, find all unique combinations in candidates where the candidate numbers sum to the target.

  60. Find All Anagrams in a String: Given a string s and a non-empty string p, find all the start indices of p's anagrams in s.

  61. Counting Bits: Given a non-negative integer num, for every number i in the range 0 ≤ i ≤ num, calculate the number of 1's in their binary representation.

  62. Implement Trie (Prefix Tree): Implement a trie with insert, search, and startsWith methods.

  63. Find the Missing Element: Given two lists, find the missing element in one of the lists.

  64. Merge Sorted Lists: Merge two sorted lists into a single sorted list.

  65. Shuffle Deck of Cards: Implement a function to shuffle a deck of cards represented as a list.

  66. Remove Nth Node From End: Given a linked list, remove the n-th node from the end.

  67. Find Common Elements: Given two lists, find the common elements between them.

  68. Move Zeros to End: Given an array, move all zeros to the end without changing the order of non-zero elements.

  69. Rotate List: Rotate a list to the right by k steps.

  70. Implement Stack Using Lists: Implement a stack data structure using Python lists.

  71. Implement Queue Using Lists: Implement a queue data structure using Python lists.

  72. Maximum Subarray Sum: Find the maximum sum of a contiguous subarray in a given list.

  73. Find Majority Element: Given a list, find the majority element (element appearing more than n/2 times).

  74. Minimum Element in Stack: Implement a stack that supports push, pop, top, and retrieving the minimum element in constant time.

  75. Flatten Nested List Iterator: Implement an iterator to flatten a nested list.

  76. Check for Anagrams in a List of Words: Write a function to check for anagrams in a given list of words.

  77. Substring with Concatenation of All Words: You are given a string s and a list of words. Write a function to find all the starting indices of substring(s) in s that is a concatenation of each word in words.

  78. Rotate Image: Given an N x N matrix representing an image, write a function to rotate the image by 90 degrees (clockwise).

  79. Reverse Linked List: Implement a function to reverse a linked list.

  80. Longest Common Prefix: Write a function to find the longest common prefix string amongst an array of strings.

  81. Validate Email Address: Write a function to validate an email address based on certain criteria (e.g., presence of '@' and '.' symbols, proper placement, etc.).

  82. String Compression: Write a function that performs basic string compression. For a string like "aabcccccaaa," return "a2b1c5a3." If the compressed string is not smaller than the original, return the original string.