I recently had my Bloomberg 2023 SDE interview round 1 for the new grad position wherein I was asked the following two questions:
Q1. There is a forest with '_' as open land and 'X' as trees:
_ _ _ X
_ X _ _
_ _ X _
we have to return the coordinates of the position with maximum visiblity. Maximum visiblity is defined as the position (X ,Y) from where I can see maximum land without the obstruction from a tree i.e the amount of open land I can see from a given position without including the current position. If the entire land consists of trees return -1. The valid directions are left, right, up and down. Also, Trees have a visiblity of 0 and they obstruct further visiblity.
The matrix here then looks like
4 2 3 0
2 0 2 2
3 1 0 1
Here maximum visiblity is 4 we return (0,0).
If max visiblity are multiple places, you can return any of the coordinates.
I have a O(MN) time solution for above
Q2. I'm given a string eample: abcabcabdefffedgijhkij
We have to return the length of maximum partitions in string such that each partition contains unique characters from string. return a list containing all the partitions in order.
Here in this case the partition would be :
abcabcab, defffed, g, ijhkij
I have to return a list like this here: [8,8,1,6]
I have a O(N logN ) and O(N) time solution for above
The interviewers accepted my solution too for both the answers. Even after solving both questions within the first 53 minutes with resume questions and we had 7 mins extra time remaining for discussion with no optimizations asked by my interviewers and yet I was not called for another rounds. Strange recruiting season 2023. Seems Medium level questions
Thanks and All the best to everyone out there