I was asked questions using hackerrank and below questions were asked:
- Maximum profit that can be achieved if we trade on non consecutive days. E.g. if we are given an array of [10,-20,30,40,5] the answer is 50 as we can trade on day0 and day3. Alongwith the profit , we have to return the days. I couldn't answer the question but found the answer later using dynamc programming. This is similar to the question: https://leetcode.com/problems/house-robber/
- Minimum number of swaps required to balance a parantheses. E.g. string value is '))(('.
The mininum number of swaps is 1 as we can swap the 1st and last position to make it balanced, that is, ()(). I couldn't answer this. I could answer in 0(n^2) by having two loops. But, I think this can be solved using single loop. Appreciate any help.
- Was asked to design ecommerce website and app. Questions were aksed about REST API and the entity relationship etc. Was able to answer this.