Tip 1 : Use coding platforms for DSA
Tip 2 : System Design - An Insider Guide - Good book for system design
Tip 3 : Two scoops of Django
Tip 1 : Resume should be of one column.
Tip 2 : Your main skills should be highlighted
It was an online test.
1. All the node values are positive.
2. The size of the linked list is greater than 1.
3. The end of the linked list is represented by -1.
You can’t sell without buying first.
For the given array [ 2, 100, 150, 120],
The maximum profit can be achieved by buying the stock at minute 0 when its price is Rs. 2 and selling it at minute 2 when its price is Rs. 150.
So, the output will be 148.
I solved it using Dynamic Programming.
I employed a straightforward approach that iterates through the array of stock prices. At each step, I kept track of the minimum stock price seen so far (min_price) and calculated the potential profit that could be obtained by selling at the current price (prices[i] - min_price). I updated the maxprof (maximum profit) variable with the maximum of its current value and the calculated profit. Additionally, I updated the min_price to be the minimum of the current stock price and the previously seen minimum.
This was a 60 minute round with senior developer
If 'N' is 5 and 'K' is 3 and the array is 7, 2, 6, 1, 9
Sorting the array we get 1, 2, 6, 7, 9
Hence the 3rd smallest number is 6.
A min-heap to maintain the k-th most significant elements. The heap allows us to efficiently compare each new element with the smallest k-th most prominent elements. By the end of the iteration, the top of the heap will contain our desired kth most significant element.
Can you solve each query in O(logN) ?
Binary search is an efficient algorithm for finding a target value within a sorted list. It works by repeatedly dividing the search interval in half. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise, narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.
Difference b/w select_related and prefetch_related? (Learn)
Tip 1: Read about Django Optimisation
Tip 2: Read about Django ORM
This round was with the team lead.
Here we need to deal with the adjacent nodes, a bfs will be very easy approach towards this problem.
For each connected component we will give it a color and try bfs and check for the constraints recursively
‘N’ = 3, ‘coins’ = {1, 2, 3}, ‘freq’ = {1, 1, 3}, ‘V’ = 6
For the given example, we can make six by using the following coins:
{1, 2, 3}
{3. 3}
Hence, the answer is 2.
def change(self, amount: int, coins: List[int]) -> int:
dp = [0] * (amount + 1)
dp[0] = 1
for coin in coins:
for j in range(coin, amount + 1):
dp[j] += dp[j - coin]
return dp[amount]
We kick off by initializing our dp with zeroes, setting dp[0] to 1 (because there's just one way to make zero: by not using any coins).
As we iterate over each coin, we update our dp slice. For every potential amount from the coin's value up to our target, we incrementally update the number of ways in the dp slice.
Design Instagram (Practice)
Tip 1: Read about designs and different approaches for optimized design
Tip 2: I suggest some books - System Design, An Insider Guide, and Data Intensive Application
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is the output of print(type("Python"))?