All Posts

Leetcode 1: Two Sum

Given an array of integers nums and a target integer target, find and return the indices of two distinct numbers in the array that sum up to the given target. The solution is guaranteed to exist for the given input. You can return the indices in any order.

Leetcode 11: Container With Most Water

You are given an array of integers where each integer represents the height of a vertical line drawn on a 2D plane. The x-axis is represented by the index of the array, and each line’s height corresponds to the value at that index. Your task is to find two lines that, along with the x-axis, form a container that can hold the most water. The container’s area is determined by the distance between the lines and the height of the shorter line.

Leetcode 15: 3Sum

Given an integer array nums, find all unique triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. The solution set must not contain duplicate triplets.

Leetcode 16: 3Sum Closest

You are given an integer array nums and an integer target. Find three integers in nums such that the sum is closest to the target. Return the sum of those three integers.

Leetcode 18: 4Sum

You are given an array of integers nums and a target value. Your task is to find all unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that the sum of the four numbers equals the target value. The indices a, b, c, and d should be distinct.

Leetcode 27: Remove Element

Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val. Modify the array nums such that the first k elements contain the elements which are not equal to val, and the remaining elements of nums are not important. Return k.