Ritik Jain (SDE 2- R2)
https://drive.google.com/file/d/1t6rgKgxjA_wO_7o6wZ4Wbo4z8R4Mh8r5/view
* one of the best candidates till now
* super in DSA...style of logic building and ease with which he handles different lang syntax is commentable
* good knowledge in prev projects
* able to quickly understand new requirements
* way of explanation is also pretty good
* asking relevant questions, getting clarity on the problem before starting to think of soln, thinking about cases before starting coding..all points hit :heavy_check_mark:
Qns:
1) Flatten deeply nested array
https://leetcode.com/problems/flatten-deeply-nested-array/description/
```
type MultiDimensionalArray = (number | MultiDimensionalArray)[];
var flat = function (arr: MultiDimensionalArray, n: number): MultiDimensionalArray {
if(n<= 0) {
return arr;
}
const answerArray: MultiDimensionalArray = [];
for(const i of arr) {
if(Array.isArray(i)) {
answerArray.push(...flat(i,n-1 ));
} else {
answerArray.push(i);
}
}
return answerArray;
};
// n/
//[[[[[[[[[1]]]]]]]], 2, 3, 4]
// k+k+k+k...N
// k*n
// n*k ~ O(n)
// n = length of an Array
// k = maximum depth that I needed;
```
2) Trim a Binary search tree https://leetcode.com/problems/trim-a-binary-search-tree/
```
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution {
public:
TreeNode* trimBST(TreeNode* root, int low, int high) {
while(root && (root->val < low || root->val > high)) {
root = root->val < low ? root->right : root->left;
}
if(!root) {
return root;
}
TreeNode* node = root;
// going into left dir
while(node->left) {
if(node->left->val < low) {
node->left = node->left->right;
} else {
node = node->left;
}
}
node = root;
// going into right dir
while(node->right) {
if(node->right->val > high) {
node->right = node->right->left;
} else {
node = node->right;
}
}
return root;
}
};
```
3) explain a use case of event driven system in ur prev role
- explained well how kafka is used for sending email/sms/whatsapp notifications after an order is placed
- very clear on when n why to use
4) coupons module db design
```/**
coupons module db design
admin creat coupon
this coupon will apply on product and customer will use to get discount
order above 500 get discount 10 --> code100
want to show all coupons to cust --->> user
tb_coupons
coupon_id (PK)
coupon_name
max_discount --> 100
percentage --> NULL
description --->
min_order_value. -->
valid_till
start_by --> start date
max_no_of_coupon_uses ---> 50, null
current_use_count --> 2
created_by
create_date
update_date
delete_date
-------------------
tb_user_coupon uc
id
user_id
coupon_id
created_by
create_date
update_date
delete_date
------------------
tb_product_coupon pc
id
product_id
coupon_id
created_by
create_date
update_date
delete_date
-----------------
tb_orders
order_id
coupon_id
discount_amount ---> 10
currency --> sin, inr
original_price
final_price
*/
```