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.
Top comments (0)