DEV Community

Mukilan Palanichamy
Mukilan Palanichamy

Posted on • Edited on

My journey in Competitive Programming

Hi, People! Today, I have solved three problems on LeetCode: Max Chunks to Make Sorted, Find the Town Judge, and Maximum Subarray. Each competitive programmer has his or her own logic to solve problems. But algorithms sometimes can optimize the solution. For a programmer, it is not challenging to solve the problem, but to solve the problem in an optimized way is the real challenge. Sometimes we can achieve this through algorithms and sometimes with our logic. Both algorithmic and logical approaches should be known to the programmers.

Max Chunks to Make Sorted: To solve this problem, we can traverse through the input array and for each traversal find the maximum number in the array. Every time you find a new maximum number, keep track of the count. This count will be the result. This approach will solve the problem very effectively.

Find the Town Judge: To solve this problem, we first need to fully understand the problem statement. We need to identify the town judge, who trusts no one but is trusted by everyone else. Once we grasp the problem statement, solving it becomes straightforward.

Maximum Subarray: For solving this problem, we can make use of Kadane's Algorithm, which is one of the most efficient ways of doing it. This makes the problem much easier compared to my initial logic.

Hope that this experience will be useful.

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)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

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

Okay