Leetcode 75

Leetcode: 1679

Discover how to solve the interesting problem of LeetCode 1679: “Max Number of K-Sum Pairs.” Imagine an array of integers where each element can form a unique pair whose sum equals k. With practical examples and various approaches, including Java solutions, you will learn how to maximize the number of possible pairs. Whether you’re a beginner or an expert, our methods, ranging from brute force to using HashMap and two-pointer techniques, will help you navigate this challenge. Analyze the performance and choose the best strategy!

Leetcode: 1679 Read More »

Leetcode 443

String Compression – LeetCode Solution in Java Problem Overview Given an array of characters chars, compress it in place using the following rules: If a character appears only once consecutively, keep it as it is. If a character appears multiple times consecutively, replace the group with the character followed by its frequency. If the frequency

Leetcode 443 Read More »

LeetCode 4: Median of Two Sorted Arrays

Difficulty: Hard Language: Java Topics: Arrays, Two Pointers, Binary SearchOptimal Time Complexity: O(log(min(m, n)))Optimal Space Complexity: O(1) Introduction Median of Two Sorted Arrays is LeetCode Problem #4 and is one of the most popular binary-search problems asked in coding interviews. At first, the problem looks simple. We have two sorted arrays, so we might think:

LeetCode 4: Median of Two Sorted Arrays Read More »

Leetcode 1071: Greatest Common Divisor of Strings

Brute Force: Algorithm Find the shorter string among str1 and str2, without loss of generality, let it be str1. Start with base = str1, and check if both str1 and str2 are made of multiples of base. If so, return base. Otherwise, we shall try a shorter string by removing the last character from base. If we have checked all prefix strings without finding the GCD string,

Leetcode 1071: Greatest Common Divisor of Strings Read More »

Dare To Dream