Q1: Cannot remember:
Q2: A large package can hold five items, while the small package can hold only one item, The available # of both large and small packages is limited. All items must be placed in packages and
used packages must be filled up completely. Write a function that calculates the minimum # of packages to hold a given number of items. Return -1, if not possible.
Answer:
cat Q3.cpp
// Search in a BST tree (Leetcode 700)
class Solution {
public:
TreeNode* searchBST(TreeNode* root, int val) {
if (!root)
return nullptr;
else if (val == root->val)
return root;
else if (val > root->val)
return searchBST(root->right, val);
else
return searchBST(root->left, val);
}
};