DEV Community

Rishitha Nallapureddy
Rishitha Nallapureddy

Posted on

Journal - 28-11-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 Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

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