Uber ATG | Phone Screen | 3Sum Greater

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2019-08-17Added By Anonymous
Source: Link

Company: Uber
Role: unknown
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

Given an array of n integers nums and an int target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition nums[i] + nums[j] + nums[k] > target.

Example:
Input: nums = [2, 1, 3, 0, 3], target = 5
Output: 5
Explanation:
[0, 3, 3]
[1, 3, 3]
[1, 2, 3]
[1, 2, 3]
[2, 3, 3]

Related problems:
https://leetcode.com/problems/3sum-smaller (premium)

Comments