Tip 1 : Practice questions on DS Algorithm ( array/string/DP/trees)
Tip 2 : Prepare OS and Networking.
Tip 1 : Practice questions on DS Algorithm ( array/string/DP/trees)
Tip 2 : Practice OS and DBMS concepts
If ‘N’ = 4 and ‘ARR’ = [3, 5, 4, 2].
3 has 2 factors, which are 1 and 3.
5 has 2 factors, which are 1 and 5.
4 has 3 factors, which are 1, 2 and 4.
2 has 2 factors, which are 1 and 2.
Hence, the answer is [0, 0, 1, 0].
Input: 'prices' = [4, 9, 0, 4, 10]
Output: 11
Explanation:
You are given prices = [4, 9, 0, 4, 10]. To get maximum profits you will have to buy on day 0 and sell on day 1 to make a profit of 5, and then you have to buy on day 3 and sell on day 4 to make the total profit of 11. Hence the maximum profit is 11.
We see that S[i] on the day i can be easily computed if we know the closest day preceding i, such that the price is greater than on that day than the price on the day i. If such a day exists, let’s call it h(i), otherwise, we define h(i) = -1.
The span is now computed as S[i] = i – h(i).
To implement this logic, we use a stack as an abstract data type to store the days i, h(i), h(h(i)), and so on. When we go from day i-1 to i, we pop the days when the price of the stock was less than or equal to price[i] and then push the value of day i back into the stack.
Prepared leadership and communication skills
1. Introduction
2. Your strengths and weaknesses
3. Where do you see yourself after 5 years?
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How do you write a single-line comment in C++?