Interview Tips + Puzzles
Past Mistakes
- Never show ki you don't know something (Media.net)
- keep asking and clarifying + explain slowly (if needed start summarising) (GS)
- Take time to give OA (Google)
- If stuck or missing something -> khud se testcases bna and analyse
→ more you do better you improve => DO NOT stop and keep thinking - Lead technical discussion forward, try to solve question with close to minimal hints
- Try to independently find solution instead of asking interviewer for advice
- Integrate any hints/suggestions by the interviewer in your solution
Web Development
- Keep in mind, there is a difference between DSA and Dev.
- In Dev round --> do not focus more on the DSA implementations of the online judge. Focus on system design, implementation part, custom isolation & API using containerisation and Docker, authentication page
- Focus on DRY, docker best practice (keeping less changed to most changed + docker compose), code-editor all properties, boy/girl waala, privacy (custom compiler, HTTPS, CSRF Token)
- Why Django ?
- More familiar with python as I had some prior knowledge + NLA assignments.
- Django framework is simple and easy to learn. It has built-in authentication and authorization.
- Used by Youtube, Instagram, Spotify
- Built-in admin panel and user
- Easily compatible with almost all database
- I am not using any 3rd party API to compile my code --> it is a custom made compiler
- Why Docker ?
- We have our compiler and solution to those problems in same computer
- Any hacker can pass command through compiler and extract solutions
- Now, using docker we have created an isolated environment A
- We send compiled code with input to A and run in A itself and return the output to our own computer
- Compare results in our own computer
- Since, no solution is present in A => even if hacker attempts --> failed
- Options for Docker
- Sandbox -> virtual machine => but heavy file (in GBs), not easy to setup (subnets, nets, etc. involved) and expensive
- But since my aim is to only run the code => Don't need any large file
- Take too much time and space both
- Docker is the best option => provides containerisation
- **Look at the Readme.md file on Github**
Data Structures and Algorithm
- Ideally complete 1 question in 20 minutes
- 2 mins → Clarify Questions to gather all requirements from interviewer
- 8-10 mins → Propose valid solution, alternative approach and discuss trade-offs to get most optimized solution → Explain approach and reason of choosing particular data structure + analyze time and space complexity
- 5 mins → Code, Implement and Cover for Edge/Boundary Cases
- 5 mins → Dry run (sample Test Cases) and discussion with interviewers
- Space Complexity - count Stack space (in recursive code) + sort() fxn use O(log n) in worst case in cpp bcz it is hybrid of Quick Sort, Heap Sort, and Insertion Sort
- Write function name as FunctionName
- Write variable name as variable_name
- Give meaningful names to variable --> chahe bhut hi lamba kyun na ho jaaye
- Never change/alter the vi or vv given in question --> better to create copy (in industry)
int fun(vi & arr) { ....do some operations -> don't change arr[i] = x......} - Whenever given a question in coding interview
- Firstly, clarify the question => cross-check that whatever u have understood, the same is required or not
- MUST give brute force first
- Then tell your observations from the question
- Explain the solution with time & auxillary space complexity.
- Auxillary space complexity => Space of I/P not considered
- Space complexity => Space of I/P is also considered
- If creating no extra array => Space complexity = O(n) bcz I/P itself occupy but Auxillary space complexity = O(1) as only space of extra arrays are counted
- Describe the steps and data structures properly.
- Do NOT use global variables --> avoid
- DP mai use iterative (if possible) bcz Space complexity mai stack space nhi aayega
+ Can also reduce Space Complexity using current and prev => ONLY 2 vectors - Whenever see an easy problem => think twice & optimize it as much as u can
=> Don't jump on solution directly - Kbhi kbhi look at input => may miss some edge cases for simple questions
- Tricks :-
- Problem simplification → If finds tough to understand, try to find other ways to reach problem
- Inverting of problem (find complement of what problem is asking for)
- If thinking of new approach → try to counter it yourself first
HR Round Tips
- Strength and Weakness
- It dosen't matter how many moves you have. The thing matters is how many time you practiced that one move ~ Zenitsu
- One of my weaknesses is that I can be a bit of a perfectionist => aim to deliver high-quality work => spend extra time refining details.
I've been working on balancing quality with efficiency by setting more realistic deadlines for myself. - NEVER REVEAL the companies that are visiting now --> tell we are not allowed (against TPC rules) + you can ask POC
- Pre-interview => get background of company, solve archives
- Make good connections at intern.
Show you are willing to learn & complete work on time. - Never say you can't do it. You haven't done it yet.
********************************* Puzzles*****************************
- A group of people wants to find their average salary on the condition that no individual would be able to find out anyone else's salary. How?
- For n≥3 only this can be done =>A adds random number x to his salary and tells B.
Now, B knows a+x : B tells C -> a+x+b then, C tells A a+x+b+c --> Now, A subtracts x from this and tells B & C a+b+c --> everyone can find average
B knows a+x & a+b+c => can't find a or c -> can only find a+c (bcz he knows b)
then C knows a+x+b & a+b+c => can't find a or b -> can only find x (bcz he knows c)
then A knows a+b+x+c => can't find b or c -> can only find b+c (bcz he knows a, x) - Find out how many points on the globe (Earth) satisfy this - if we move one mile south, then one mile east and finally one mile north, we arrive at the starting point.
- Observation - moving east/west means rotating the globe => if rotate about a point or start from a point -> NO change
- Answer - South Pole can’t be the solution because if we go South from there, we remain at South Pole itself.
North pole is the answer, bcz since starting point is single point => if move down and rotate, then go up => since only 1point was there -> converge at same point
Cicumference at 1 radius from South Pole is also an answer, bcz if go down => reach South Pole & rotating about point -> NO change - Josephus Problem
- Given two candles. Each of them burns for one hour. Measure 45 mins and 15 mins.
- Note - you can't measure the length bcz you don't have any measuring devices
- Answer - Burn both ends of first candle and only one end of second candle
=> After 30 minutes, first candle will burn fully
Now, burn the other end of second candle 30-min(remaining) --> in 15 min => second candle will burn fully --> since, we know 15min and 30min both => we also know 45 min - Given two candles of same length but different thicknesses => thicker candle lasts for 6 hrs while thinner one lasts for 4 hrs. You lit up both candles at same time. After some time, you saw that the thicker candle was twice the length of the thinner one. How long ago did you lit up the two candles?
- Answer - let length be c and thickness of thinner one be x after some time
c burns in 6hr => 1 burns in (6/c)hr => (c-2x) burns in (6/c)*(c-2x) hr
Since, time is same => (6/c)*(c-2x) =(4/c)*(c-x) --> c = 4x
Put this c in time --> get 3 hr - 13 caves are arranged in circle. A thief is hiding in one of the caves. Each day, he may or may not move to any one of the adjacent caves in which he was staying the previous day. Each day, you can enter any two caves. What is the minimum number of days to guarantee to catch the thief ? (NOTE- if you and thief cross at some point --> can catch him => mean you going from 2->3 and he is going from 3->2)
- Answer - 7 days bcz can check in both directions => first day c1, c13 then second day c2, c12 and so on. Thief is guaranteed to be caught in max. of 7 days
- are 2 doors → life and death. Two guards stand by each door, and both knows which one is life or which one is death → one guard always tells truth and other always tells lie. You can ask only 1 question to only 1 guard → What you will ask ?
- Answer - "What would be other guard's answer for death" → no matter who you ask both point to life door bcz same as AND operator where output is negation of question
- If asked truth one → honestly tell that lie one will point to life door
- n balls out of which 1 is heavy. Find min attempt to be weighed to find heavy ball
- Answer - Split n into 3 groups → n/3 n/3 (n/3 + x) → where x can be [0, 1, 2]
If weight of 1st and 2nd are same → pick 3rd one; if weight of 1st > 2nd → pick 1st one → this way at every step, only n/3 remains → ans = ceil[ log3(n) ]
- Finding the Injection for Anesthesia ---> base system of 3
- Pay an employee using a gold rod of 7 units --> break into binary => 1, 2, 4
- 9 Students and Red Black Hats
- Red Hat vs Blue Hat
- Find the fastest 3 horses
- 100 Prisoners with Red/Black Hats
- 5 Pirates and 100 Gold Coins --> MUST Watch video
**************************************************************************

Comments
Post a Comment