Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/randhir200/pair-less-than-k

You are given an array A of N integers, and an integer K. Find the maximum value of S, such S that S = a[i] + a[j], and S < K. If no such value exists, then print -1. Refer the sample test case for better understanding. Input The first line of the input contains T, the number of test cases. The first line of each test case contains N, the number of elements in the array. The next line contains N space separated integers, denoting the values in the array. The next line contains the value K. Constraints 1 <= T <= 10 1 <= N <= 10^4 1 <= A[i] <= 10^4
https://github.com/randhir200/pair-less-than-k

Last synced: 1 day ago
JSON representation

You are given an array A of N integers, and an integer K. Find the maximum value of S, such S that S = a[i] + a[j], and S < K. If no such value exists, then print -1. Refer the sample test case for better understanding. Input The first line of the input contains T, the number of test cases. The first line of each test case contains N, the number of elements in the array. The next line contains N space separated integers, denoting the values in the array. The next line contains the value K. Constraints 1 <= T <= 10 1 <= N <= 10^4 1 <= A[i] <= 10^4

Awesome Lists containing this project