GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Tuesday 14 June 2022

[Solution] 3SUM Codeforces Solution | Codeforces Problem Solution 2022

F. 3SUM
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Given an array a of positive integers with length n, determine if there exist three distinct indices ijk such that ai+aj+ak ends in the digit 3.

Input

The first line contains an integer t (1t1000) — the number of test cases.

The first line of each test case contains an integer n (3n2105) — the length of the array.

The second line of each test case contains n integers a1,a2,,an (1ai109) — the elements of the array.

Solution Click Below:-  CLICK HERE

The sum of n across all test cases does not exceed 2105.

Output

Output t lines, each of which contains the answer to the corresponding test case. Output "YES" if there exist three distinct indices ijk satisfying the constraints in the statement, and "NO" otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

No comments:

Post a Comment