Back to questions

Two Sum (Part 3) Amazon Python Interview Question

Two Sum (Part 3)

Amazon Python Interview Question

Given an array of integers and an integer , return the largest possible such that and . If no is possible, return -1.

Example #1

Input: nums = [34, 23, 1, 24, 75, 33, 54, 8], k = 60

Output: 58

Explanation: The greatest possible sum less than 60 is 58, made by adding 34 + 24

Input

Python

Output