Largest Positive Integer That Exists With Its Negative

Problem Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array. Return the positive integer k. If there is no such integer, return -1. Examples Example 1: Input: nums = [-1,2,-3,3] Output: 3 Explanation: 3 is the only valid k we can find in the array. ...

kSum Problem

kSum Problem Problem Given an array S of n integers, are there elements a1, a2, a3…ak in S such that sum(a1, a2, a3, ... ak) = target? Find all unique lists in the array which gives the sum of target. Examples Refer problems like 4Sum, 3Sum - Classic Problem, 3Sum0 - Find three elements in an array that sum to a zero for examples. ...

Subarray Sum Equals K Problem

`` Problem Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. Examples Example 1: Input: nums = [1,1,1], k = 2 Output: 2 Example 2: Input: nums = [1,2,3], k = 3 Output: 2 ...

Two Sum 4 - Input is Binary Search Tree

Problem Given a binary search tree T, where each node contains a positive integer, and an integer K, you have to find whether or not there exist two different nodes A and B such that A.value + B.value = K. Return 1 to denote that two such nodes exist. Return 0, otherwise. OR 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. ...

Number of Subsequences That Satisfy the Given Sum Condition

Problem You are given an array of integers nums and an integer target. Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 10^9 + 7. Examples Example 1: Input: nums = [3,5,6,7], target = 9 Output: 4 Explanation: There are 4 subsequences that satisfy the condition. [3] -> Min value + max value <= target (3 + 3 <= 9) [3,5] -> (3 + 5 <= 9) [3,5,6] -> (3 + 6 <= 9) [3,6] -> (3 + 6 <= 9) ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy