# 1099. Two Sum Less Than K

Reference: LeetCode
Difficulty: Easy

## Problem

Given an array A of integers and integer K, return the maximum S such that there exists i < j with A[i] + A[j] = S and S < K. If no i, j exist satisfying this equation, return -1.

Example:

Note:

• 1 <= A.length <= 100
• 1 <= A[i] <= 1000
• 1 <= K <= 2000

## Analysis

### Brute-Force

Time: $O(N^2)$
Space: $O(1)$

### Sorting & Two Pointers

Time: $O(N\log{N})$
Space: $O(1)$

## Amazon OA | Movies on Flight

Comment
Junhao Wang
a software engineering cat