Google Interview Report
- 0of 0 votes
Answerswrite the most efficient (in terms of time complexity) function getNumberOfPrimes which takes in an integer N as its parameter.
- adam2008 February 22, 2013 in United States
to return the number of prime numbers that are less than N
Sample Testcases:
Input #00:
100
Output #00:
25
Input #01:
1000000
Output #01:
78498| Report Duplicate | Flag | PURGE
Google - 0of 0 votes
AnswersThe diameter of a tree is the number of nodes on the longest path between two leaves in the tree. The diagram below shows a tree with diameter nine, the leaves that form the ends of a longest path are shaded (note that there is more than one path in each tree of length nine, but no path longer than nine nodes).
- adam2008 February 22, 2013 in United States
In particular, note that the diameter of a tree T is the largest of the following quantities:
the diameter of T's left subtree
the diameter of T's right subtree
the longest path between leaves that goes through the root of T
Given the root node of the tree, return the diameter of the tree| Report Duplicate | Flag | PURGE
Google