BlackRock logo

BlackRock

Interview Questions for BlackRock

1. What are your strengths?

2. Write a program to determine if a number is prime.

3. What tools have you used?

4. Validate Binary Search Tree Problem Statement Your task is to determine if a given binary tree with 'N' nodes is a valid Binary Search Tree (BST). A BST is defined by the following properties: The left subtree of a node has only nodes with data less than the node's data. The right subtree of a node has only nodes with data greater than the node's data. Both the left and right subtrees must also be binary search trees. Input: The input consists of multiple test cases. Each test case provides the level order traversal of the binary tree as follows: The first line contains an integer 'T', the number of test cases.Each test case contains a line with space-separated integers representing the values of nodes in level order. A value of -1 indicates a null node in the tree. Output: For each test case, output 'true' if the binary tree is a BST, otherwise output 'false'. Each result is displayed on a new line. Example: Input: 11 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1 Output: false Constraints: 1 ≤ T ≤ 100 1 ≤ N ≤ 5000 -106 <= data ≤ 106, and data ≠ -1 Note: You are only required to implement the validation function for a BST. The input and output are managed elsewhere.

5. Given a string, find the frequency of each character in the string.