Skip to content

Latest commit

 

History

History
320 lines (289 loc) · 26.4 KB

README.md

File metadata and controls

320 lines (289 loc) · 26.4 KB

DSA-Problems-and-Solutions

Table of Contents

Arrays

  1. Concatenation of Array
  2. Build Array from Permutation
  3. Final Value of Variable After Performing Operations
  4. Running Sum of 1d Array
  5. Shuffle the Array
  6. Number of Good Pairs
  7. Richest Customer Wealth
  8. Maximum Number of Words Found in Sentences
  9. Kids With the Greatest Number of Candies
  10. How Many Numbers Are Smaller Than the Current Number
  11. Queries on Number of Points Inside a Circle
  12. Decode XORed Array
  13. Create Target Array in the Given Order
  14. Decompress Run-Length Encoded List
  15. Max Increase to Keep City Skyline
  16. Largest Local Values in a Matrix
  17. Number of Arithmetic Triplets
  18. Sum of All Odd Length Subarrays
  19. Count Number of Pairs With Absolute Difference K
  20. Minimum Number of Moves to Seat Everyone
  21. Maximum Product Difference Between Two Pairs
  22. Count Good Triplets
  23. Flipping an Image
  24. Count Equal and Divisible Pairs in an Array
  25. Matrix Diagonal Sum
  26. Maximum Product of Two Elements in an Array
  27. Sum of All Subset XOR Totals
  28. Minimum Time Visiting All Points
  29. Find the Highest Altitude
  30. Number Of Rectangles That Can Form The Largest
  31. Subarray Sums Divisible by K
  32. Difference Between Element Sum and Digit Sum of an Array
  33. Minimum Operations to Make the Array Increasing
  34. Maximum Count of Positive Integer and Negative Integer
  35. Find the Town Judge
  36. Median of Two Sorted Arrays
  37. Two Sum
  38. Delete Greatest Value in Each Row
  39. Minimum Amount of Time to Collect Garbage
  40. Sort the Matrix Diagonally
  41. Group the People Given the Group Size They Belong To
  42. Cells with Odd Values in a Matrix
  43. Count Number of Distinct Integers After Reverse Operations
  44. Find N Unique Integers Sum up to Zero
  45. Find Numbers with Even Number of Digits
  46. Rearrange Array Elements by Sign
  47. Finding the Users Active Minutes
  48. Arithmetic Subarrays
  49. Find Greatest Common Divisor of Array
  50. Find Target Indices After Sorting Array
  51. Maximum Number of Pairs in Array
  52. Sum of Unique Elements
  53. Number of Students Doing Homework at a Given Time
  54. N-Repeated Element in Size 2N Array
  55. Difference Between Ones and Zeros in Row and Column
  56. Watering Plants
  57. Sort Array By Parity
  58. Count Negative Numbers in a Sorted Matrix
  59. Height Checker
  60. Baseball Game
  61. Search Insert Position
  62. Sort an Array
  63. Left and Right Sum Differences
  64. Separate the Digits in an Array
  65. Squares of a Sorted Array
  66. Sum Multiples
  67. Find the Difference of Two Arrays
  68. Remove Element
  69. Merge Sorted Array
  70. Remove Duplicates from Sorted Array
  71. Remove Duplicates from Sorted Array II
  72. Best Time to Buy and Sell Stock
  73. Rotate Array
  74. Best Time to Buy and Sell Stock II
  75. Jump Game
  76. Jump Game II
  77. H-Index
  78. Plus One
  79. Reverse The Array
  80. Sum Of Max And Min
  81. Find the "Kth" max and min element of an array
  82. Maximum Number of Achievable Transfer Requests
  83. Longest Subarray of 1's After Deleting One Element
  84. Minimum Size Subarray Sum
  85. Put Marbles in Bags
  86. Combinations
  87. Can Place Flowers
  88. Find Pivot Index
  89. Move Zeroes
  90. Maximum Average Subarray I

BinarySearchTrees

Problems

  1. Search in a Binary Search Tree
  2. Convert Sorted Array to Binary Search Tree
  3. Kth Smallest Element in a BST
  4. Validate Binary Search Tree

BinaryTree

Operations

  • Binary Tree Creation
  • Binary Tree Traversal (Inorder,Preorder,Postorder)
  • Binary Tree Level Order Traversal
  • Binary Tree Left View
  • Binary Tree Right View

Problems

  1. Binary Tree Inorder Traversal
  2. Deepest Leaves Sum
  3. Find a Corresponding Node of a Binary Tree in a Clone of That Tree
  4. Range Sum of BST
  5. Root Equals Sum of Children
  6. Top View Of Binary Tree
  7. Bottom View Of Binary Tree
  8. Reverse Level Order traversal
  9. Height of a tree
  10. Minimum Depth of Binary Tree
  11. All Nodes Distance K in Binary Tree
  12. Maximum Level Sum of a Binary Tree
  13. Maximum Depth of Binary Tree
  14. Leaf-Similar Trees

Bit Manipulation

  1. Reverse Bits
  2. Single Number
  3. Single Number II

DynamicProgramming

  1. Counting Bits
  2. Count Sorted Vowel Strings
  3. Number of Longest Increasing Subsequence

Graphs

- Basic Programs

  1. Graph Creation using Adjacency Matrix.
  2. Graph Creation using Adjacency list.
  3. Graph BFS Traversal.

GreedyProblems

  1. Activity Selection Problem

Linkedlist

Operations :

  • Singly Linked List
  • Doubly Linked List
  • Circular Linked List

Linked List Problems:

  1. Convert Binary Number in a Linked List to Integer
  2. Middle of the Linked List
  3. Reverse Linked List
  4. Maximum Twin Sum of a Linked List
  5. Merge Nodes in Between Zeros
  6. Merge Two Sorted Lists
  7. Delete Node in a Linked List
  8. Linked List Cycle
  9. Write a program to Delete loop in a linked list
  10. Find the starting point of the loop
  11. Find the starting point of the loop
  12. Delete the Middle Node of a Linked List
  13. Odd Even Linked List

Matrix

  1. Rotate Image
  2. Spiral Matrix

Pointers

  1. Program to illustrate Pointers.
  2. Program to illustrate call-by-methods.
  3. Program to illustrate Array Name as Pointers.
  4. Program to illustrate Void Pointer.
  5. Program to swap 2 numbers without using 3rd variable.

Queue

  1. Number of Students Unable to Eat Lunch

Recursion

Basic Problems

  1. Printing 1-N using recursion.
  2. Printing N to 1 using recursion.
  3. Calculating sum using recursion.
  4. Factorial using recursion.
  5. Reversing array elements using recursion.
  6. Checking Palindrome using recursion.

SearchingandSortingProblems

  1. Find first and last positions of an element in a sorted array

SortingConcepts

  1. Bubble Sort
  2. Insertion Sort
  3. Selection Sort

Stack

  1. Final Prices With a Special Discount in a Shop
  2. Construct Smallest Number From DI String
  3. Valid Parentheses

Strings

  1. Shuffle String
  2. Design an Ordered Stream
  3. Count Items Matching a Rule
  4. Check If Two String Arrays are Equivalent
  5. Truncate Sentence
  6. Unique Morse Code Words
  7. Count the Number of Consistent Strings
  8. Sort the People
  9. Find First Palindromic String in the Array
  10. Counting Words With a Given Prefix
  11. DI String Match
  12. Defanging an IP Address
  13. Jewels and Stones
  14. Partitioning Into Minimum Number Of Deci-Binary Numbers
  15. Goal Parser Interpretation
  16. Encode and Decode TinyURL
  17. Minimum Number of Operations to Move All Balls to Each Box
  18. Cells in a Range on an Excel Sheet
  19. Split a String in Balanced Strings
  20. Decode the Message
  21. Palindrome Partitioning
  22. Sorting the Sentence
  23. Check if the Sentence Is Pangram
  24. Maximum Nesting Depth of the Parentheses
  25. Longest Palindromic Substring
  26. Detect Capital
  27. Roman to Integer
  28. Longest Common Prefix
  29. Count Asterisks
  30. To Lower Case
  31. Reverse Words in a String III
  32. Rings and Rods
  33. Replace All Digits with Characters
  34. Remove Outermost Parentheses
  35. Number of Strings That Appear as Substrings in Word
  36. Decrypt String from Alphabet to Integer Mapping
  37. Reverse Prefix of Word
  38. Determine if String Halves Are Alike
  39. Determine Color of a Chessboard Square
  40. Partition Labels
  41. Find and Replace Pattern
  42. Minimum Number of Steps to Make Two Strings Anagram
  43. Generate a String With Characters That Have Odd Counts
  44. Destination City
  45. Increasing Decreasing String
  46. Check if All Characters Have Equal Number of Occurrences
  47. Merge Strings Alternately
  48. Reverse String
  49. Lexicographically Smallest Equivalent String
  50. Verifying an Alien Dictionary
  51. Remove Palindromic Subsequences
  52. First Letter to Appear Twice
  53. Robot Return to Origin
  54. Subdomain Visit Count
  55. Delete Columns to Make Sorted
  56. String Compression
  57. Find the Index of the First Occurrence in a String
  58. Check if Word Equals Summation of Two Words
  59. Percentage of Letter in String
  60. Count the Number of Vowel Strings in Range
  61. Maximum Value of a String in an Array
  62. Reformat Phone Number
  63. Number of Senior Citizens
  64. Length of Last Word
  65. Valid Palindrome
  66. Reverse Words in a String
  67. Valid Anagram
  68. Is Subsequence
  69. Reverse a String
  70. Check whether a String is Palindrome or not
  71. Count and Say
  72. Substring With Largest Variance
  73. Letter Combinations of a Phone Number
  74. Greatest Common Divisor of Strings
  75. Reverse Vowels of a String

UnorderedMap

  1. Optimal Partition of String
  2. Check if Number Has Equal Digit Count and Digit Value
  3. Ransom Note
  4. Majority Element
  5. Contains Duplicate II
  6. Group Anagrams
  7. Maximize the Confusion of an Exam

MemsetFunction

  1. Program to demonstrate memset()
  2. Program to demonstrate memset() to set all values as 0 or -1 for integral data types,also demonstrated the use of vector.
  3. Program to demonstrate memset() to set all values as boolean data types also.