We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1899. Merge Triplets to Form Target Triplet
我没注意贪心,想着是排序然后一个一个比较。
但明确两点:
所以这是贪心Greedy。
class Solution { public boolean mergeTriplets(int[][] triplets, int[] target) { int[] res = new int[3]; for (int[] triplet : triplets) { if (triplet[0] <= target[0] && triplet[1] <= target[1] && triplet[2] <= target[2]) { res[0] = Math.max(res[0], triplet[0]); res[1] = Math.max(res[1], triplet[1]); res[2] = Math.max(res[2], triplet[2]); } } // res equals target? return Arrays.equals(res, target); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1899. Merge Triplets to Form Target Triplet
1899. Merge Triplets to Form Target Triplet
我没注意贪心,想着是排序然后一个一个比较。
但明确两点:
所以这是贪心Greedy。
The text was updated successfully, but these errors were encountered: