<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KVGHS6G" height="0" width="0" style="display:none;visibility:hidden"></iframe>

BlackRock计算机科学面试真题

职位分类
全部
数据相关
计算机科学
人工智能
产品经理
BQ
面试题
全部(5)
OOD(0)
Algorithm(5)
System Design(0)
高频题(0)
Math(0)
全部(5)
OOD(0)
Algorithm(5)
System Design(0)
高频题(0)
Math(0)
1.Happy Number
2.Simple Tree Problem
3.Employee Hierarchy Levels
4.Happy Number
5.Determine if a Number is a Happy Number
1. Happy Number
The problem is to determine if a number is a 'happy number'. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers. Please provide your solution and discuss the logic behind it.
2. Simple Tree Problem
You are given a simple tree problem to solve. Please explain your approach and solution to this problem.
3. Employee Hierarchy Levels
Write a program that will count how many levels exist between any two names in a hierarchy of employees. The program must read a list of name pairs that represent an employee and their manager. The two names to compare may be in different parts of the organizational tree and not have a direct managerial line. Input: The first line of input will be a pair of names to compare. All subsequent lines will be employee/manager pairs. The company's complete hierarchy will be included so no incomplete trees will exist. For example: Susan/Amy Susan/John John/Amy Output: The number of levels between the pair requested, including the top manager's level. In the example above, the Output should be: 2
4. Happy Number
Write a program to determine if a number is a 'happy number'. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers. Example: Input: 19 Output: True Explanation: 1^2 + 9^2 = 82 8^2 + 2^2 = 68 6^2 + 8^2 = 100 1^2 + 0^2 + 0^2 = 1
5. Determine if a Number is a Happy Number
Define a happy number as a number which eventually reaches 1 when replaced by the sum of the squares of each digit. If it enters a loop that does not include 1, then it is not a happy number. The task is to determine whether a given number is a happy number.