To find the area of gray portion, we use the below equation Area of gray portion = Area of the semicircle on the Left hand side – Area of semicircle with diameter 2.6 cm + Area of semicircle with diameter 1.8 cm => 0.5 * π[0.5*(2.6+1.8)]^2 – 0.5*π(1.3)^2 + 0.5*π(0.9)^2 => 6.22035345411 sq cms Hope that […]
Simple Java code:- Javascript option
Same algorithm implemented in C++ Python JAVA
Below is the Javascript code for the above problem. Please follow this blog (https://www.golibrary.co/count-all-triplets-with-sum-less-than-target-in-a-given-array/) for detailed explanation on how the below code works
Even though the array is rotated, we can still use binary search here by finding the point of rotation using the function findPivotIndex() as shown below. Once we find the pivot (point of rotation), divide the array in 2 halves, each of which will still be in sorted order and apply binary search on each […]
Below is a Javascript Solution to this problem using Depth first search traversal !!
Diameter of binary tree You might also be interested in reading this as the above problem is a subset of this:- https://www.golibrary.co/finding-diameter-of-a-binary-tree/
Here is a simple Javascript algorithm to achieve the same. Steps Traverse and find height of left subtree. Traverse and find height of right subtree. Find max between heights of left and right subtrees. return the max height + 1 (for root node). Javascript code:-
Please visit this blog for a detailed explanation of this algorithm:- Diameter of Binary Tree
use the command mysqldump as below: