Check if Two Trees are Mirror Structure to each other
Solution:
https://www.prodevelopertutorial.com/check-if-two-trees-are-mirror-structure-to-each-other/
Solution:
https://www.prodevelopertutorial.com/check-if-two-trees-are-mirror-structure-to-each-other/
Subscribe us in Quora: https://www.quora.com/q/dailyonecodingproblem
Day 33 Question: Given an n x n 2D matrix rotate it by 90 degrees (clockwise) in C++ in place
You have to rotate the image in-place (https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.
Example 1:
Given input matrix =
[
[1,2,3],
[4,5,6],
[7,8,9]
],
rotate the input matrix in-place such that it becomes:
[
[7,4,1],
[8,5,2],
[9,6,3]
]
Solution:
https://www.prodevelopertutorial.com/given-an-n-x-n-2d-matrix-rotate-it-by-90-degrees-clockwise-in-c-in-place/
Buy the book:
https://www.instamojo.com/aj_guides/ajs-guide-to-algorithm-and-data-structure-in/
You have to rotate the image in-place (https://en.wikipedia.org/wiki/In-place_algorithm), which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.
Example 1:
Given input matrix =
[
[1,2,3],
[4,5,6],
[7,8,9]
],
rotate the input matrix in-place such that it becomes:
[
[7,4,1],
[8,5,2],
[9,6,3]
]
Solution:
https://www.prodevelopertutorial.com/given-an-n-x-n-2d-matrix-rotate-it-by-90-degrees-clockwise-in-c-in-place/
Buy the book:
https://www.instamojo.com/aj_guides/ajs-guide-to-algorithm-and-data-structure-in/
Wikipedia
In-place algorithm
computer algorithm that operates directly on an input data structure, without needing a full temporary copy
Group Anagrams when given an array of strings in C++
Example:
Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
Output:
[
["ate","eat","tea"],
["nat","tan"],
["bat"]
]
This problem can be solved easily using Maps.
The solution involves 2 steps:
1. Sort the element and make it as the key.
2. Take the value and place it in the key.
Solution:
https://www.prodevelopertutorial.com/group-anagrams-in-c/
Example:
Input: ["eat", "tea", "tan", "ate", "nat", "bat"],
Output:
[
["ate","eat","tea"],
["nat","tan"],
["bat"]
]
This problem can be solved easily using Maps.
The solution involves 2 steps:
1. Sort the element and make it as the key.
2. Take the value and place it in the key.
Solution:
https://www.prodevelopertutorial.com/group-anagrams-in-c/
ProDeveloperTutorial.com
Group Anagrams when given an array of strings in C++ - ProDeveloperTutorial.com
This problem can be solved easily using Maps.
Day 35 Question: Rain water trapping in C++
Given *n* non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
Input: [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6
Before solving this problem, please take a look at “Container with most water (https://www.prodevelopertutorial.com/find-the-container-with-most-water-explanation-with-diagram-and-solution-in-cpp-language/)” problem. There I have explained in detail, how two pointers work.
Solution:
https://www.prodevelopertutorial.com/rain-water-trapping-in-c/
Given *n* non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.
Input: [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6
Before solving this problem, please take a look at “Container with most water (https://www.prodevelopertutorial.com/find-the-container-with-most-water-explanation-with-diagram-and-solution-in-cpp-language/)” problem. There I have explained in detail, how two pointers work.
Solution:
https://www.prodevelopertutorial.com/rain-water-trapping-in-c/
ProDeveloperTutorial.com
Find the Container with Most Water explanation with diagram and solution in cpp language - ProDeveloperTutorial.com
You are given non negative integers "i" represents x axis, and "a" represents y axis. "n" vertical lines are drawn, find two lines together x axis that forms