-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from shynutpirate/master
Solution for human traffic of stadium
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Definition for a binary tree node. | ||
* struct TreeNode { | ||
* int val; | ||
* TreeNode *left; | ||
* TreeNode *right; | ||
* TreeNode(int x) : val(x), left(NULL), right(NULL) {} | ||
* }; | ||
*/ | ||
class Solution { | ||
public: | ||
TreeNode* searchBST(TreeNode* root, int val) { | ||
if (root == NULL) | ||
return NULL; | ||
if (root->val > val) | ||
return searchBST(root->left,val); | ||
else if (root->val < val) | ||
return searchBST(root->right,val); | ||
return root; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
select s1.* from stadium as s1, stadium as s2, stadium as s3 | ||
where ((s2.id = s1.id + 1 and s3.id =s1.id + 2) | ||
or (s2.id = s1.id - 1 and s3.id = s1.id + 1) | ||
or (s2.id = s1.id - 2 and s3.id = s1.id - 1)) | ||
and s1.people >= 100 | ||
and s2.people >= 100 | ||
and s3.people >= 100 | ||
Group by(s1.id); |