DEV Community

Rishitha Nallapureddy
Rishitha Nallapureddy

Posted on

Journal - 28-10-24

Hi, Folks! Today, I solved three problems on LeetCode: Max Chunks to Make Sorted, Find the Town Judge, and Maximum Subarray. Every competitive programmer has their own logic to solve problems. However, algorithms can sometimes optimize the solution. For a programmer, solving the problem is not the challenge; solving the problem in an optimized way is the real challenge. This can sometimes be achieved through algorithms and sometimes with our own logic. As programmers, we should know both algorithmic and logical approaches.

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 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: To solve this problem, we can use Kadane’s Algorithm, which is one of the most efficient ways to solve it. Using this algorithm makes the problem much easier compared to my initial logic.

I hope my experience will be helpful.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

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

Okay