Skip to content

Commit 480bf48

Browse files
Mohammad IqbalMohammad Iqbal
Mohammad Iqbal
authored and
Mohammad Iqbal
committed
updated
1 parent efe0bbf commit 480bf48

File tree

4 files changed

+261
-0
lines changed

4 files changed

+261
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.idea
22
.idea/
3+
out
4+
out/

onlineFoodOrdering/problem.txt

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
Foodkart:
2+
Description:
3+
Flipkart is starting a new online food ordering service. In this Service, users can order food from a restaurant which is serviceable in their area and the restaurant will deliver it.
4+
Features:
5+
1. Restaurants can only serve one specialized dish.
6+
2. Restaurants can serve in multiple areas.
7+
3. At a time, users can order from one restaurant, and the quantity of food can be more than one.
8+
4. Users should be able to rate any restaurant with or without comment.
9+
5. Rating of a restaurant is the average rating given by all customers.
10+
Requirements:
11+
1. Register a User:
12+
1. register_user(user_details)
13+
2. user_details: name, gender, phoneNumber(unique) and pincode.
14+
2. Users should be able to login, and all the operations will happen in the context of that user. If another user logged in, the previous user will automatically be logged out.
15+
1. login_user(user_id): this should set the context for all the next operation to be done by this user.
16+
3. Register a restaurant in context of login user:
17+
1. Register_restaurant(resturant_name, list of serviceable pin-codes, food item name, food item price, initial quantity).
18+
4. Restaurant owners should be able to increase the quantity of the food item.
19+
1. update_quantity(restaurant name, quantity to Add)
20+
5. Users should be able to rate(1(Lowest)-5(Highest)) any restaurant with or without comment.
21+
1. rate_restaurant(restaurant name, rating, comment)
22+
6. User should be able to get list of all serviceable restaurant, food item name and price in descending order: show_restaurant(rating/price)
23+
1. Based on rating
24+
2. Based on Price
25+
NOTE: A restaurant is serviceable when it delivers to the user's pincode and has non-zero quantity of food item.
26+
7. Place an order from any restaurant with any allowed quantity.
27+
1. place_order(restaurant name, quantity)
28+
Bonus:
29+
1. Order History of User: For a given user you should be able to fetch order history.
30+
Other Details:
31+
1. Do not use any database or NoSQL store, use in-memory store for now.
32+
2. Do not create any UI for the application.
33+
3. Write a driver class for demo purposes. Which will execute all the commands at one place in the code and test cases.
34+
4. Please prioritize code compilation, execution and completion.
35+
5. Please do not access the internet for anything EXCEPT syntax.
36+
6. You are free to use the language of your choice.
37+
7. All work should be your own. If found otherwise, you may be disqualified.
38+
Expectations:
39+
1. Code should be demoable (very important)
40+
2. Complete coding within the duration of 90 minutes.
41+
3. Code should be modular, with Object Oriented design. Maintain good separation of concerns.
42+
4. Code should be extensible. It should be easy to add/remove functionality without rewriting the entire codebase.
43+
5. Code should handle edge cases properly and fail gracefully.
44+
6. Code should be readable. Follow good coding practices:
45+
7. Use intuitive variable names, function names, class names etc.
46+
8. Indent code properly.
47+
9. Once the code is complete please zip the source code and upload it to: https://docs.google.com/forms/d/e/1FAIpQLSfzz8HH6fLso7NLgqJ0kC0TYP-tZhC2XhTN4EdI2c6OC1v2XA/viewform
48+
Sample Test Case:
49+
All the inputs here are just indicating the high level inputs that function should accept. You are free to model entities as per your choice.
50+
51+
52+
register_user(“Pralove”, “M”, “phoneNumber-1”, “HSR”)
53+
register_user(“Nitesh”, “M”, “phoneNumber-2”, “BTM”)
54+
register_user(“Vatsal”, “M”, “phoneNumber-3”, “BTM”)
55+
56+
57+
login_user(“phoneNumber-1”)
58+
59+
60+
register_restaurant(“Food Court-1”, “BTM/HSR”, “NI Thali”, 100, 5)
61+
NOTE: we will have 2 delimiters in input : ',' to specify separate fields & '/' to identify different pincodes.
62+
register_restaurant(“Food Court-2”, “BTM”, “Burger”, 120, 3)
63+
64+
65+
login_user(“phoneNumber-2”)
66+
register_restaurant(“Food Court-3”, “HSR”, “SI Thali”, 150, 1)
67+
login_user(“phoneNumber-3”)
68+
show_restaurant(“price”)
69+
70+
71+
Output : Food Court-2, Burger
72+
Food Court-1, NI Thali
73+
74+
75+
place_order(“Food Court-1”, 2)
76+
Output: Order Placed Successfully.
77+
78+
79+
place_order(““Food Court-2”, 7)
80+
Output : Cannot place order
81+
82+
83+
create_review(“Food Court-2”, 3, “Good Food”)
84+
create_review(“Food Court-1”, 5, “Nice Food”)
85+
86+
87+
show_restaurant(“rating”)
88+
Output : Food Court-1, NI Thali
89+
Food Court-2, Burger
90+
91+
92+
login_user(“phoneNumber-1”)
93+
update_quantity(“Food Court-2”, 5)
94+
Output: Food Court-2, BTM, Burger - 8
95+
96+
97+
update_location(“Food Court-2”, “BTM/HSR”)
98+
Output: Food Court-2, “BTM/HSR”, Burger - 8

tinder/problem.txt

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
Problem Definition:
2+
You have to create an online dating application. Every active user account will have location, age and gender information. The application should show users their potential matches in order of relevance. The ordering of relevance will be following:
3+
1. Gender : Opposite gender to be given higher priority.
4+
2. Proximity: Nearer matches should be given more priority. Use euclidean distance for computing distance between two locations (*see appendix for euclidean distance).
5+
3. Age: Less the age difference should be given more priority.
6+
7+
8+
9+
10+
Operations:
11+
A user can perform these operations in this application:
12+
1. Create Account: A person can create an account with interest and profile details.
13+
2. Potential Match: Provides all the potential match of a user in relevance order.
14+
3. Like: User can like a potential match user.
15+
4. Show Matches: Showing the users which match against a user. A match happens when both the users have liked each other.
16+
5. Show All Matches: Showing system view by displaying all the matches in the system.
17+
6. Ignore: User can ignore a potential match user.
18+
7. Delete Account: If a user deletes account, then all matches and likes will be removed.
19+
20+
21+
22+
23+
Use case:
24+
1. If a user A likes user B, the data should be stored for further processing.
25+
2. All the matches(case where 2 users have liked each other) in the system should be shown.
26+
27+
28+
29+
30+
Expectations:
31+
1. Code should be demo-able. Either use a main driver program on command line or test cases.
32+
2. Code should be functionally correct and complete.
33+
3. Code should be readable, modular, testable and use proper naming conventions. It should be easy to add/remove functionality without rewriting entire codebase.
34+
4. Code should cover all the edge cases possible and work for them or fail gracefully for errors.
35+
36+
37+
38+
39+
Guidelines:
40+
1. Use language of your choice.
41+
2. Output can be written to a file or STDOUT.
42+
3. Feel free to store all interim/output data in-memory.
43+
4. Restrict internet usage to looking up syntax.
44+
5. Please discuss any doubts you have with an interviewer.
45+
46+
47+
48+
49+
Appendix:
50+
The distance between two points in the plane with coordinates (x, y) and (a, b) is given by:
51+
dist((x, y), (a, b)) = sqrt((x - a)2 + (y - b)2)
52+
Sample User Data:
53+
54+
55+
56+
57+
1. Input format:
58+
1. create_account(user_name, x_coordinate, y_coordinate, age, gender)
59+
2. delete_account(user_name)
60+
3. potential_match(user_name)
61+
4. like(user_name, user_name)
62+
5. ignore(user_name, user_name)
63+
6. show_matches(user_name)
64+
7. show_all_matches()
65+
66+
67+
68+
69+
2. Sample test data:
70+
71+
72+
input
73+
output
74+
create_account(user_A, 2, 3, 23, Male)
75+
true
76+
create_account(user_B, 3, 4, 45, Female)
77+
true
78+
create_account(user_C, 4, 6, 32, Female)
79+
true
80+
create_account(user_D, 7, 8, 23, Male)
81+
true
82+
create_account(user_E, 8, 12, 23, Female)
83+
true
84+
potential_match(user_A)
85+
user_B,user_C,user_E,user_D
86+
like(user_A, user_B)
87+
true
88+
like(user_A, user_C)
89+
true
90+
potential_match(user_B)
91+
user_A,user_D,user_C,user_E
92+
like(user_B, user_A)
93+
true
94+
show_matches(user_A)
95+
user_B
96+
potential_match(user_E)
97+
user_D,user_A,user_C,user_B
98+
like(user_E, user_D)
99+
true
100+
potential_match(user_D)
101+
user_E,user_A,user_C,user_B
102+
like(user_D, user_E)
103+
true
104+
show_all_matches()
105+
user_A: user_B
106+
user_B: user_A
107+
user_D: user_E
108+
user_E: user_D
109+
potential_match(user_C)
110+
user_A,user_D,user_B,user_E
111+
like(user_C, user_A)
112+
true
113+
show_all_matches()
114+
115+
user_A: user_B,user_C
116+
user_B: user_A
117+
user_C: user_A
118+
user_D: user_E
119+
user_E: user_D
120+
delete_account(user_A)
121+
true
122+
show_all_matches()
123+
124+
user_D: user_E
125+
user_E: user_D

urlShortner/problem.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Problem Definition:
2+
Design and implement a URL shortener application that allows users to shorten long URLs into shorter, more manageable links. Each shortened URL should redirect to the original long URL when accessed. Users should also have the ability to manage their shortened URLs, including creating, editing, and deleting them.
3+
4+
5+
Operations:
6+
7+
8+
Onboard clients: Allow new users to onboard
9+
DeActivate/Activate Clients:
10+
Shorten URL: Allow users to shorten a long URL to create a unique, shorter link.
11+
Redirect: Redirect users from the shortened URL to the original long URL.
12+
Custom URLs: Provide custom shorten URL
13+
14+
15+
16+
17+
Use Cases:
18+
19+
20+
Onboard API:
21+
Activate / Deactivate API;
22+
Shorten URL: Users can shorten long URLs to create compact links suitable for sharing.
23+
Redirect: Users can access the original long URL by visiting the shortened link.
24+
25+
26+
27+
28+
Expectations:
29+
30+
31+
Demonstrate functionality through a main driver program or test cases.
32+
Ensure the code is functionally correct, complete, readable, modular, and testable.
33+
Properly handle edge cases such as invalid URLs or duplicate shortened links.
34+
The output can be written to a file or STDOUT, with interim/output data stored in-memory.
35+
Internet usage should be restricted to syntax lookup.
36+
Discuss any doubts with the interviewer.

0 commit comments

Comments
 (0)