Dsa Problems
Dsa Problems
Step 02: Traverse array to check each element if it has occurrence in future
Hashing: We can use unordered map to store array's element in pair of key and value
Optimal Approach:
Step 01: remove duplicates from sorted array
Step 02: store common value of all three arrays in new array
Step 01: store unique element in new array with the help of C++ STL Data Structure is set(dataType)
Declaration of set
Read more from this resource: https://www.geeksforgeeks.org/set-in-cpp-stl/
Step 02: store common value of all three arrays in new array
7. Wave Print A Matrix (GFG)
Approach:
- When number of column is even then print row top to bottom
- When number of column is odd then print row bottom to top
8. Spiral Print A Matrix (Leetcode-54)
Output:
1 2 3 4 5 6 12 18 24 30 29 28 27 26 25
19 13 7 8 9 10 11 17 23 22 21 14 15 16
Optimal Approach:
Step 01: find total elements
Step 02: iterate matrix till end of the total element and print
- Print startingRow
- Print endingCol
- Print endingRow
- Print startingCol