Tip 1: Practice 250 questions on online coding platforms.
Tip 2: Practice all the algorithms.
Tip 3: Give mocks regularly.
Tip 1: Create a one-pager resume.
Tip 2: Highlight keywords based on the job description (JD).
4 DSA Questions at a Medium-Hard Level.



Let’s say the array ‘A’ = [1, 2, 3, 4, 5] and ‘K’ = 2, then after increasing each element by ‘K’. The array ‘A’ will become [3, 4, 5, 6, 7]. So the maximum - minimum will be 7 - 3 = 4.
Step 1: I initially attempted a brute force approach by trying all possible combinations of adding or subtracting K to each stick's height.
Step 2: During the online test, I realized the inefficiency of this approach and considered optimizing it by sorting the array to focus on boundary values.
Step 3: After sorting the array, I applied the following logic:
Conclusion: By implementing the optimized, sorting-based approach, I successfully passed the test cases and minimized the maximum difference effectively. This solution was significantly faster than the brute force method.

Approach:
1. Understand the cost function:
The cost of the box is defined as the sum of the squares of the frequencies of each letter in the string. To minimize the cost, we should remove candles corresponding to the letter with the highest frequency. This is because reducing the highest frequency has the most significant impact on lowering the cost.
2. Steps to solve:

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is the purpose of the return keyword?