BlackRock Interview Questions
Showing 15 questions
Determine if a number is a 'happy number'. A happy number eventually reaches 1 when replaced by the sum of the squares of its digits, repeating the process until it does.
#1. Happy Number
Given a tree, find the maximum possible sum of node values you can obtain by selecting nodes such that no two selected nodes are directly connected by an edge.
#2. Find the Maximum Sum of Node Values
Given a tree where each node has a color, find the largest subtree where all nodes have the same color. Return the number of nodes in that subtree.
#3. Maximum Subtree of the Same Color
Determine if a string containing parentheses is valid. A valid string has matching and properly nested opening and closing parentheses.
#4. Valid Parentheses
You are given a list of song durations. Find the number of pairs of songs whose total duration is divisible by 60.
#5. Pairs of Songs With Total Durations Divisible by 60
You're given daily stock prices. Find the maximum profit you can make by buying and selling the stock once. You must buy before you sell.
#6. Best Time to Buy and Sell Stock
Given a list of words, group together all the anagrams. Anagrams are words that contain the same letters rearranged.
#7. Group Anagrams
You are given a list of stock prices for consecutive days. Determine the maximum profit you can achieve by buying once and selling once, making sure to buy before you sell.
#8. Maximum Profit From Trading Stocks
Given a grid representing land and water, count the number of distinct islands. An island is formed by connected land cells.
#9. Number of Islands
You are given equations represented by pairs of variables and their corresponding values. Your task is to evaluate queries based on these equations, determining the value of expressions if possible, or returning -1.0 if not.
#10. Evaluate Division
Find two numbers in a given array that add up to a specific target value, and return their indices. Essentially, you need to efficiently locate the pair that satisfies the sum requirement.
#11. Two Sum
Determine if two strings are anagrams of each other, meaning they contain the same characters in a different order. You need to check if one string can be rearranged to form the other.
#12. Valid Anagram
Find the median of two sorted arrays. The arrays can be of different sizes, and you should aim for an efficient solution.
#13. Median of Two Sorted Arrays
Find the longest palindromic substring within a given string. A palindromic substring reads the same forwards and backward.
#14. Longest Palindromic Substring
Traverse a binary tree and return its boundary nodes in a specific order: left boundary, leaves, and right boundary. Ensure to exclude duplicate nodes.
#15. Boundary of Binary Tree