- We are given an array A with n elements, where each element of A is an integer in the range . We are also given an integer . The algorithm must answer the following yes-or-no question:
Do there exist indices , not necessarily distinct, such that ?
Design an time algorithm for this problem.
- Modify your algorithm to count the total number of ordered triples for which the sum of entries is at most .