Problem
Ask
Submissions

Problem: Two Sum Less Than K

Medium
30 min
Explore how to solve the problem of finding the maximum sum of two numbers in an array that is less than a target value k. Understand sorting and two-pointer methods to develop an efficient solution and practice applying these techniques with example problems.

Statement

Given an array of integers, nums, and an integer k, find the maximum sum of two elements in nums less than k. Otherwise, return 1−1 if no such pair exists.

Constraints:

  • 11\leq nums.length 100\leq100

  • 11\leq nums[i] 103\leq 10^3

  • 11\leq k 103\leq 10^3

Problem
Ask
Submissions

Problem: Two Sum Less Than K

Medium
30 min
Explore how to solve the problem of finding the maximum sum of two numbers in an array that is less than a target value k. Understand sorting and two-pointer methods to develop an efficient solution and practice applying these techniques with example problems.

Statement

Given an array of integers, nums, and an integer k, find the maximum sum of two elements in nums less than k. Otherwise, return 1−1 if no such pair exists.

Constraints:

  • 11\leq nums.length 100\leq100

  • 11\leq nums[i] 103\leq 10^3

  • 11\leq k 103\leq 10^3