
Blackrock


Blackrock Software Developer Interview Questions and Answers
Q1. Greatest Common Divisor Problem Statement
You are tasked with finding the greatest common divisor (GCD) of two given numbers 'X' and 'Y'. The GCD is defined as the largest integer that divides both of the given...read more
Find the greatest common divisor (GCD) of two given numbers 'X' and 'Y'.
Iterate from 1 to the minimum of X and Y, check if both X and Y are divisible by the current number, update GCD if true
Use Euclidean algorithm to find GCD: GCD(X, Y) = GCD(Y, X % Y)
If one of the numbers is 0, the other number is the GCD
Handle edge cases like when one of the numbers is 0 or negative
Q2. Ninja And The Triangle Problem Statement
Ninja is provided with 'N' stars and the task is to construct a triangle such that the 'i'th level of the triangle uses 'i' number of stars. The goal is to make the tria...read more
Given 'N' stars, construct a triangle with maximum height using 'i' stars in 'i'th level.
Calculate the maximum height of the triangle using the formula: height = floor((-1 + sqrt(1 + 8 * N)) / 2)
Iterate through each test case and calculate the maximum height for each 'N'.
Output the maximum height for each test case.
Q3. Shortest Distance in a Binary Search Tree
Your task is to determine the shortest distance between two nodes with given keys in a Binary Search Tree (BST).
It is assured that both keys exist within the BST.
Inpu...read more
Find the shortest distance between two nodes in a Binary Search Tree.
Traverse the BST to find the paths from the root to both nodes.
Compare the paths to find the common ancestor node.
Calculate the distance by adding the lengths of the paths from the common ancestor to both nodes.
Return the shortest distance as the result.
Q4. Bridge in Graph Problem Statement
Given an undirected graph with V vertices and E edges, your task is to find all the bridges in this graph. A bridge is an edge that, when removed, increases the number of conne...read more
Find all the bridges in an undirected graph.
Use Tarjan's algorithm to find bridges in the graph.
A bridge is an edge whose removal increases the number of connected components.
Check for bridges by removing each edge and running a DFS to see if the graph is still connected.
Q5. Binary to Decimal Conversion
Convert a given binary number, represented as a string 'S' of size 'N', into its decimal equivalent integer and output it.
Input:
The first line contains an integer 'T', denoting th...read more
Convert a binary string to its decimal equivalent integer.
Iterate through the binary string from right to left, multiplying each digit by 2 raised to the power of its position.
Add the results of the multiplication to get the decimal equivalent.
Ensure the binary string consists only of '0' and '1' characters.
Handle multiple test cases by repeating the conversion process for each case.
Q6. 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...read more
Validate if a given binary tree is a valid Binary Search Tree (BST) based on its properties.
Check if the left subtree of a node has only nodes with data less than the node's data.
Verify if the right subtree of a node has only nodes with data greater than the node's data.
Ensure that both the left and right subtrees are also binary search trees.
Implement a validation function for a BST.
Output 'true' if the binary tree is a BST, otherwise output 'false'.
More about working at Blackrock

Interview Process at Blackrock Software Developer

Top Software Developer Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

