Hi, folks! Today, I solved three problems on LeetCode: Fruits into Baskets, Max Number of K-Sum Pairs, and Maximum Length of a Concatenated String with Unique Characters. These problems helped me revise an important concept: recursion. There are thousands of problems on LeetCode, but the concepts are always limited. We should focus on learning the concepts rather than just doing a large number of problems.
To solve Max Number of K-Sum Pairs, we use the two-pointer technique. When we need to find two numbers that are maximum or minimum, or when trying to reach a specific target, we often use two pointers. One pointer starts at the zero index, and the other pointer starts at the last index. In this way, we can cover the list in both directions and solve the problem.
To solve Maximum Length of a Concatenated String with Unique Characters, we use the concept of recursion because we need to repeat the same process until we concatenate all the unique strings in the array. We must check that all the strings are unique. This approach helps us solve the problem.
To solve Fruits into Baskets, we can traverse through the fruits array and find any two types of fruits that are repeated the most. Then, we return the total number of these fruits as the output. This is how we can solve this problem.
I hope my experience will be helpful.
Top comments (0)