Google Interview Report
- 0of 0 votes
AnswersYou are given a binary tree in which each node contains an integer value.
- ajay.raj December 15, 2017 in United States
Find the number of paths that sum to a given value.
The path does not need to start at root, but need to end at a leaf, and it must go downwards (traveling only from parent nodes to child nodes).
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
public int pathSum(TreeNode root, int sum) {
}
}| Report Duplicate | Flag | PURGE
Google SDE1 - 1of 1 vote
AnswersGive a bunch of rectangles, randomly return a point within the rectangle, the probability to be proportional to the size of the rectangle.
- ajay.raj December 15, 2017 in United States
Follow up1: If you want to repeatedly call the function to generate random points how to do.
Follow up2: If the rectangles overlap how to do?| Report Duplicate | Flag | PURGE
Google SDE1