Recently I gave OA of Microsoft and here are the questions,
- Given an array, you need to find a subsequence such that AND of that subsequence is not 0. My Approach:
I iterate over bits and check and with the array. O(32 * N) Time, O(1) space
Similar Question: (diffrence is we need to give max length not product)
https://stackoverflow.com/questions/65677628/size-of-subset-of-an-array-with-largest-bitwise-and-product
- You are given a string and a cost array, you need to delete some character from string such that no two same characters will appear next to each other. We need to minimize the cost. I did this question greedily.
aaaabbbaccc, [1,2,3,2,4,1,9, 5. 9, 7, 8]
ans = 20
Waiting for results :)