Hot Topics
Deutsche Bank Solution
Technical Round
- Question 1
I have 10 weights. 9 of them are equal, 1 is of a different weight. You only have a way to compare weights of items with other items. How many moves would it take you to determine the rogue weight?
- Answer
To determine the rogue weight, you need log2(n) moves, where n is the number of weights. In this case, it would take log2(10) = 3.32 moves.
- Question 2
If there are 3 lightbulbs in a room, and 3 light switches in another room how do you know which bulb belongs to which switch?
- Answer
You can determine which bulb belongs to which switch by performing the following steps:
Turn on the first switch and keep it on for a few minutes.
Turn off the first switch and turn on the second switch.
Observe which bulb is now on. This bulb belongs to the first switch.
Repeat the process for the rest of the switches and bulbs.
- Question 3
SQL joins
- Answer
SQL join is used to combine rows from two or more tables based on a related column between them. The related column is used to match rows from both tables and return a result set containing the combined data.
- Question 4
Code for sum of all the digits from 1 to 50
- Answer
Here is a code snippet to find the sum of all digits from 1 to 50 in Python:
def sum_of_digits(n):
return sum([int(i) for i in str(n)])
def main():
sum = 0
for i in range(1, 51):
sum += sum_of_digits(i)
print(sum)
if __name__ == '__main__':
main()