DEV Community

Mukilan Palanichamy
Mukilan Palanichamy

Posted on

My journey in competitive programming

Hello, friends! Today, I have solved four problems on LeetCode, which are Generate Parentheses, 3Sum Closest, Remove K-Digits, and Number of Subarrays with Bounded Maximum. All of these can be solved using different concepts. So by solving at least one problem from each concept, we can recap various concepts in a single day.

The Generate Parentheses problem is solved with a recursive approach. 3Sum Closest is solvable with the two-pointer approach. Remove K-Digits, as a logical problem can be approached by using a stack. Finally, the Number of Subarrays with Bounded Maximum problem can also be solved with a logical approach.

This involves finding all the possible parenthesized arrangements of a given number within the Generate Parentheses problem. Applying recursion here, we go over the process until we hit all possible arrangements. If we hit the input number, we stop.

In the 3Sum Closest problem, we use the two-pointer technique. We initialize the left pointer to zero and the right pointer to the last index. We then traverse with both pointers until we find the sum closest to the target.

We can solve Remove K-Digits using a stack with a logical approach. In this problem, we also have to handle edge cases like leading zeros. In each iteration, we push the smaller digits to the stack and then pop the stack at the end to form the new number.

For the Count of Subarrays with Bounded Maximum, we use a loop from the array to traverse each, compare it with the defined bounds, and then move on to increment the counter. At the end of it all, we are returning the count.

Well, hope my experience helps!!!

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay