Leetcode 0015. 3Sum

Posted on Thu 12 December 2024 in Leetcode • Tagged with k-sum

Question Link : https://leetcode.com/problems/3sum/

Difficulty: Medium

Premium: False

Question

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must …


Continue reading

Leetcode 0653. Two Sum IV - Input is a BST

Posted on Sat 08 October 2022 in Leetcode • Tagged with k-sum, dfs

Question Link : https://leetcode.com/problems/two-sum-iv-input-is-a-bst/

Difficulty: Easy

Question

Given the root of a Binary Search Tree and a target number k, return true if there exist two elements in the BST such that their sum is equal to the given target.   Example 1:

Input: root = [5,3,6 …


Continue reading

Leetcode 0167. Two Sum II - Input Array Is Sorted

Posted on Wed 08 June 2022 in Leetcode • Tagged with k-sum

Question Link : https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/

Difficulty: Medium

Question

Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1] and numbers[index2] where 1 <= index1 …


Continue reading