Yahoo India Web Search

Search results

  1. leetcode.com › problems › 3sum3Sum - LeetCode

    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.

  2. 3Sum Leetcode Solution - Given an array of n integers, are there elements a, b, c in array such that a + b + c = 0? Find all unique triplet..

  3. leetcode.com › problems › 3sum3Sum - LeetCode

    Can you solve this real interview question? 3Sum - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

  4. Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example 1: Input: nums = [-1,2,1,-4], target = 1 Output: 2 Explanation: The sum that is closest to the target is ...

  5. public List<List<Integer>> threeSum(int[] arr) { Arrays.sort(arr); int n = arr.length; List<List<Integer>> ans = new ArrayList<> (); for (int i = 0; i < n; i++) { if (arr[i] > 0) break; // Since arr [i] <= arr [l] <= arr [r], if a [i] > 0 then sum=arr [i]+arr [l]+arr [r] > 0.

  6. Dec 23, 2022 · In this problem, you must find all unique triplets in an array that sum up to a specific target value. Follow our clear and concise explanation to understand the approach and code for this...

  7. Mar 26, 2023 · 3 Sum (LeetCode 15) | Full solution with examples and visuals | Interview Essential - YouTube. Nikhil Lohia. 36.9K subscribers. 1K. 48K views 1 year ago Arrays. To see more videos like...

  8. class Solution: def threeSum (self, nums: List [int])-> List [List [int]]: if len (nums) < 3: return [] ans = [] nums. sort for i in range (len (nums)-2): if i > 0 and nums [i] == nums [i-1]: continue # Choose nums[i] as the first number in the triplet, then search the # remaining numbers in [i + 1, n - 1]. l = i + 1 r = len (nums)-1 while l ...

  9. Apr 15, 2024 · The 3Sum (LeetCode 15) problem is a classic algorithm challenge often encountered in software engineering interviews, particularly at companies like Google, Facebook, and Amazon. The task is straightforward yet tricky: given an array of integers, find all unique triplets in the array that add up to zero.

  10. leetcode.ca › 2015/12/15-15-3Sum15 - 3Sum | Leetcode

    Dec 15, 2015 · Description. 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.

  1. People also search for