id
int64
1
3.58k
problem_description
stringlengths
516
21.8k
instruction
int64
0
3
solution_c
dict
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "class Solution {\npublic:\n int f(TreeNode* root, unordered_map<TreeNode*, int> &map){\n if(!root){\n return 0;\n }\n if(!root->left and !root->right){\n return root->val;\n }\n if(map.count(root)) return map[root];\n int pick = 0;\n ...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
1
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "auto speedUP = [](){\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n return 'c';\n}();\n/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "class Solution {\npublic:\n int rob(TreeNode* root) {\n std::unordered_map<TreeNode*, int> memo;\n \n std::function<int(TreeNode*)> dfs = [&](TreeNode *curr) -> int {\n if (!curr) {\n return 0;\n }\n if (memo.count(curr)) {\n ...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "class Solution {\npublic:\n int rob(TreeNode* root) {\n std::unordered_map<TreeNode*, int> memo;\n \n std::function<int(TreeNode*)> dfs = [&](TreeNode *curr) -> int {\n if (!curr) {\n return 0;\n }\n if (memo.count(curr)) {\n ...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "class Solution {\npublic:\n int fun(TreeNode* root,int x,map<pair<TreeNode*,int>,int>& dp){\n if(root==nullptr)\n return 0;\n if(root->left==nullptr && root->right==nullptr){\n if(x==0){\n return 0;\n }\n else\n return root-...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "\nclass Solution\n{\n\tpublic:\n\t\tint rob(TreeNode* root)\n\t\t{\n\t\t\tint ans = 0;\n\t\t\tunordered_map<TreeNode*, int> dp_rob, dp_pass;\n\t\t\t\n\t\t\tdp_rob[root] = payDay(root, dp_rob, dp_pass);\n\t\t\tdp_pass[root] = payDay(root->left, dp_rob, dp_pass), payDay(root->right, dp_rob, dp_pass);\n\n\t\t...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "\nclass Solution\n{\n\tpublic:\n\t\tint rob(TreeNode* root)\n\t\t{\n\t\t\tint ans = 0;\n\t\t\tunordered_map<TreeNode*, int> dp_rob, dp_pass;\n\t\t\t\n\t\t\tdp_rob[root] = payDay(root, dp_rob, dp_pass);\n\t\t\tdp_pass[root] = payDay(root->left, dp_rob, dp_pass), payDay(root->right, dp_rob, dp_pass);\n\n\t\t...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "\nclass Solution\n{\n\tpublic:\n\t\tint rob(TreeNode* root)\n\t\t{\n\t\t\tint ans = 0;\n\t\t\tunordered_map<TreeNode*, int> dp_rob, dp_pass;\n\t\t\t\n\t\t\tdp_rob[root] = payDay(root, dp_rob, dp_pass);\n\t\t\tdp_pass[root] = payDay(root->left, dp_rob, dp_pass), payDay(root->right, dp_rob, dp_pass);\n\n\t\t...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
2
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * long long int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(long long int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(long long ...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
337
<p>The thief has found himself a new place for his thievery again. There is only one entrance to this area, called <code>root</code>.</p> <p>Besides the <code>root</code>, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will auto...
3
{ "code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\nprivate:\n static constexpr uint MAXN = 100'000u;\n static constexpr uint8_t BIAS = 17;\n static constexpr uint BMASK = (1u << BIAS) - 1u;\n static uint64_t p2i[MAXN];\n\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, const string ...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\nprivate:\n static constexpr uint MAXN = 100'000u;\n static constexpr uint8_t BIAS = 17;\n static constexpr uint BMASK = (1u << BIAS) - 1u;\n static uint64_t p2i[MAXN];\n\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, const string ...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int> &positions, vector<int> &healths, string directions) {\n int n = positions.size(), id[n];\n iota(id, id + n, 0);\n sort(id, id + n, [&](const int i, const int j) {\n return positions[i] < positions[...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "/*\n Summary\n ------------------------------------\n O(nlogn): sort and simulation\n ------------------------------------\n*/\nint idx[100000], buf[100000];\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n ...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& p, vector<int>& h, string d) {\n int n=p.size();\n pair<int,int> pi[n];\n for(int i=0;i<n;i++) pi[i]=make_pair(p[i],i);\n sort(pi,pi+n);\n vector<int> s;\n for(int i=0;i<n;i++) {\n ...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& p, vector<int>& h, string d) {\n int n=p.size();\n pair<int,int> pi[n];\n for(int i=0;i<n;i++) pi[i]=make_pair(p[i],i);\n sort(pi,pi+n);\n vector<int> s;\n for(int i=0;i<n;i++) {\n ...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<int> idxs(size(positions));\n iota(begin(idxs), end(idxs), 0);\n sort(begin(idxs), end(idxs), [&](const auto& a, const auto& b) {\n re...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions,\n vector<int>& healths, string directions) {\n std::vector<size_t> idx(positions.size());\n std::iota(idx.begin(), idx.end(), 0);\n\n std::sort(idx.begin(), idx...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\npublic:\n\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& h, string directions) {\n int n = positions.size();\n vector<int> ind(n), stack, res;\n for (int i = 0; i < n; i++)\n ind[i] = i;\n sort(ind.begin(), ind.end(), [&]...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n int n = positions.size();\n vector<int> index(n), stack, res;\n for (int i = 0; i < n; i++)\n index[i] = i;\n sort(index.begin(), inde...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "auto init = []()\n{ \n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n return 'c';\n}();\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n const int n = positions.size();\n vector<int> ind...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "auto init = []()\n{ \n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n return 'c';\n}();\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n const int n = positions.size();\n vector<int> ind...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions,\n vector<int>& healths, string directions) {\n int size = positions.size();\n vector<pair<int, int>> pv;\n deque<int> dq; // (index)\n vector<int> res;\n...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
0
{ "code": "class Solution {\n struct Robot {\n int idx;\n int pos;\n int health;\n char dir;\n\n Robot(int id, int a, int b, char c) {\n idx = id;\n pos = a;\n health = b;\n dir = c;\n }\n };\n\n static bool compPos(Robot &...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
1
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n int size = positions.size();\n vector<pair<int, int>> pos(size);\n for (int i = 0; i < size; i++) {\n pos[i] = {positions[i], i};\n }\...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
1
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n int n = positions.size();\n vector<pair<int, int>> robots(n);\n for (int i = 0; i < n; i++) {\n robots[i] = {positions[i], i};\n }\n ...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
1
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<int> idxs;\n for (int i=0;i<positions.size();++i) {\n idxs.push_back(i);\n }\n sort (idxs.begin(),\n idxs.end(),\n...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
1
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n int n = positions.size();\n vector<int> idx;\n for(int i = 0; i < n; i++) idx.push_back(i);\n sort(idx.begin(), idx.end(), [&](int a, int b) {\n ...
2,846
<p>There are <code>n</code> <strong>1-indexed</strong> robots, each having a position on a line, health, and movement direction.</p> <p>You are given <strong>0-indexed</strong> integer arrays <code>positions</code>, <code>healths</code>, and a string <code>directions</code> (<code>directions[i]</code> is either <stron...
1
{ "code": "class Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<int> indices;\n int len = positions.size();\n vector<bool> alive(len, true);\n for (int i{0}; i < len; i++) {\n indices.push_ba...