codekofi
← All problems

Problem 125

Medium

1 · Worked examples

0 / 3

Type an input and write what you think is the output . Each problem is converted to Web Assembly, so any possible input will show the corresponding output. Only correct predictions count.

solution()
returns

2 · Which problem is it?

Locked until you have predicted 3 outputs correctly.

The accepted solution

1bool solution(const vector<vector<int>>& triplets,
2 const vector<int>& target) {
3
4 bool a = false;
5 bool b = false;
6 bool c = false;
7
8 for (const auto& t : triplets) {
9
10 if (t[0] > target[0] || t[1] > target[1] ||
11 t[2] > target[2]) {
12 continue;
13 }
14
15 if (t[0] == target[0]) {
16 a = true;
17 }
18
19 if (t[1] == target[1]) {
20 b = true;
21 }
22
23 if (t[2] == target[2]) {
24 c = true;
25 }
26 }
27
28 return a && b && c;
29}

Names have been stripped. The signature is the only clue you get for free. Compiled as C++20 with the standard headers and using namespace std; already in scope.