-
Notifications
You must be signed in to change notification settings - Fork 382
Closed
Description
LeetCode Username
zi-bu-yu-mf
Problem number, title, and link
- Find Elements in a Contaminated Binary Tree https://leetcode.cn/problems/find-elements-in-a-contaminated-binary-tree/
Category of the bug
- Problem description
- Solved examples
- Problem constraints
- Problem hints
- Incorrect or missing "Related Topics"
- Incorrect test Case (Output of test case is incorrect as per the problem statement)
- Missing test Case (Incorrect/Inefficient Code getting accepted because of missing test cases)
- Editorial
- Programming language support
Description of the bug
The target should be larger (up to 1e6)
Language used for code
C++
Code used for Submit/Run operation
bool flg[100003];
class FindElements {
public:
FindElements(TreeNode* root) {
memset(flg, 0, sizeof(flg));
auto dfs = [](auto&& self, TreeNode* node, int val) {
if (val > 100000)[[unlikely]] return;
flg[val] = true;
if (node->left) self(self, node->left, 2 * val + 1);
if (node->right) self(self, node->right, 2 * val + 2);
};
dfs(dfs, root, 0);
}
bool find(int target) {
return flg[target];
}
};Expected behavior
The target is up to 1e6, but 1e5 is also passed.
