title-img


Minimize Maximum Stadium Size - Google Top Interview Questions

You are given an integer n and a two-dimensional list of integers views. There are n teams in a tournament and you want to build two stadiums to host the games. Each element in views contains [a, b, people] meaning that when team a and team b compete, there are people number of people that will view that game. The viewership numbers among every pair of teams will be in views. You must permanently assign each team to a stadium. Every team in a stadium plays every other team in that

View Solution →

Minimum Number of Flips to Have Alternating Values - Google Top Interview Questions

You are given a string s containing "1"s and "0"s. You can take some prefix of s and move it to the back. Afterwards, return the minimum number of characters that need to be flipped such that the string never has any two consecutive characters of the same value. Constraints n ≤ 100,000 where n is the length of s Example 1 Input s = "001010111" Output 1 Explanation After we move the first character "0" to the back we get "010101110". Then we can flip the 3rd las

View Solution →

Minimum Number of Transfers to Settle Debts - Google Top Interview Questions

You are given a two-dimensional list of integers transfers containing [source, dest, amount], which means that person source lent person dest a dollar amount equal to amount. Return the minimum number of person-to-person transfers that are required so that all debts are paid. Constraints n ≤ 13 where n is the number of participants Example 1 Input transfers = [ [0, 1, 50], [1, 2, 50] ] Output 1 Explanation Person 0 gave person 1 $50 and person 1 gave p

View Solution →

Moo - Google Top Interview Questions

You are given a string cows representing the initial conditions of some cows. Each cow can take one of three values: "L", meaning the cow is charging to the left. "R", meaning the cow is charging to the right. "@", meaning the cow is standing still. Cows charging on a direction will pick up other cows unless the cow receives a force from the opposite direction. Then, it will stand still. Return the orientation of each cow when the cow stop charging. Constraints

View Solution →

Minimum Light Radius - Google Top Interview Questions

You are given a list of integers nums representing coordinates of houses on a 1-dimensional line. You have 3 street lights that you can put anywhere on the coordinate line and a light at coordinate x lights up houses in [x - r, x + r], inclusive. Return the smallest r required such that we can place the 3 lights and all the houses are lit up. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [3, 4, 5, 6] Output 0.5 Explanation If we p

View Solution →