Thursday, September 23, 2021

Difference between SQL and No SQL

 SQL: 

    If Schema doesnt change

    Pros- Normalization and Joins

    Cons- Usually its hosted server in machines


No SQL:

    Scaling is easy

    Schema not defined

    High load Json schema 

    Consistency not checked

1. Your application requires super-low latency

2. Data are unstructured or you do not have any relational data.

3. You only need to serialize and deserialize data JSON, XML or YAML.

4. You  need to store a massive amount of data.


Wednesday, September 8, 2021

Self check

 In what circumstance would you use BFS (Breadth First Search) instead of Dijkstra's for finding a shortest path in a graph?

a) When you have an unweighted graph

or

b) When you have a weighted graph


What is the worst-case lookup time for a self-balancing binary search tree? Can you name a common example or type?


What is the average running time of heapsort in big-O notation? What is one benefit of using heap sort compared to merge sort?

Which of the following typically uses a Queue for an efficient implementation?

a) Breadth First Search (BFS)

b) Depth First Search (DFS)

c) Recursion


Which of the following data structures do NOT guarantee O(log n) lookup time?

a) red-black tree

b) binary tree

c) linked list

d) hash table


bcd


1. Score Negative 

2. Communication - was good 

3. Explain theory very well

4. Better solution - pick up hints

5. Data Structure & Algorithm 

6. Coding - Pretty readable and boundary cases.

7. Time Management - M 20 mins, H 35 mins 


A Supply Chain

Cap Theorem  where cosmos db stads for ?

how Distributed system works 

Gossip protocol - they maintain consistency with this

Raft protocol - 

consensus protocol

Adapter Pattern

SOLID Principles

composition over inheritance 

Strategy Pattern - DI - change dynamically 

Anti Patterns 

Flatten [[1,2],[3,[4,[5]]]] in javascript 

1. Given a set of boxes, reduce the total number of boxes by placing smaller box inside a bigger box.

you can't put more than one box of same size inside a bigger box. return the sum of final box sizes.
{10, 50, 20, 40, 30} Returns: 50
{100, 50, 100, 50, 50, 100} Returns: 300

2. Given an array of integers of size 2n, write an algorithm to arrange them such that first n elements and last n elements are set up in alternative manner.

Say n = 3 and 2n elements are {x1, x2, x3, y1, y2, y3} , then result should be {x1, y1, x2, y2, x3, y3}.
2n is always in power of 2, that is 2^i

Example:

 A [] = {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}, n= 5
Output: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

A SAP :

3. Given a stream of integers, find the first non-duplicate integer

4. Check whether the tree is complete binary tree or not.


Topics to cover:

Binary search
Graphs, BFS/DFS/Flood fill Tree traversals Hash tables Linked list, stacks, queues, two pointers/sliding window Binary heaps Dynamic programming Union find Ad hoc/string manipulations Arrays Recursion. Backtracking. Greedy algorithms. Other good to know topics: Trie, segment trees/fenwick trees, bitmasks

SF:
1. Trapping Rain water
2. Generate Paranthesis
3. Design rating system of employee
4. Maximum Subarray square

M365:

Input:

Hex Array= [0, a, f]

Roll Array = [2,3,1]


RollArray[0] = 2 => Roll the first two elements

Hex array = [1,b,f]

RollArray[1] = 3

HexArray=[2,c,0]

0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f

RollArray[2] = 1

HexArray = [3,c,0]

Design Tiny bit shorten url 

Viva:

Given a binary matrix mat[][] of dimensions of N * M and pairs of integers src and dest representing source and destination cells respectively, the task is to find the shortest sequence of moves from the given source cell to the destination cell via cells consisting only of 1s. The allowed moves are moving a cell left (L), right (R), up (U), and down (D) (if exists). If no such path exists, then print “-1”. Otherwise, print the sequence of moves.

Substrate:

Design online paint - enums for tools, bucket fill algo - utilised surrounding 1 in matrix coloring

m365  

Design coauth in editor

Rotate an array by shifting its elements 3 positions to right

Find 3rd highest element  in BST


Internal team

Given a linked list with duplicate elements, remove all duplicate elements

a bit tricky -     You are given a maze (unknown dimensions) & a robot is placed somewhere in the maze. The robot has 4 functions… canMoveLeft(), canMoveRight()….etc

       There is gold somewhere in the maze. Return the path from start to gold. Follow up - There is no gold now…. just traverse the entire maze…. How do you traverse the entire maze?

3. Given a binary tree, return the reverse level order traversal….. ie the first entry should be the list of all leaves

4. Given a string, find the biggest palindrome & return the biggest palindrome

Microsoft - PowerBI

Find the Kth largest element in an array

Microsoft - Azure

Given a list of integers, all intergers occur more than once except one. Find that element

Given a list of integers, all elements occur twice except one. Find it


2nd team -

Given 2 linked list , findout if its merged & return the first common element

Given a list of stock prices of a company , find the best time to buy & sell


Amazon

1. events[i] = [startTimei, endTimei, valuei]


Example : 

Input: events = [[1,3,2],[4,5,2],[2,4,3]]

Output: 4

Max value from 2 events or 1.

(1) Two Best Non-Overlapping Events - LeetCode

2. /*

      a
     /  \
    b    c
   / \   / \
  d   f c   b
  
  ab < aba
Lexicographically smallest from leaf to root

Fb:
1. https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/
2. https://www.geeksforgeeks.org/largest-sum-contiguous-subarray/

Rubrik:
/**

class Work:
  def do_work(self):
    // few mins to days.
    pass

class WorkCompleter:
 
  # Fill in as necessary.
  def __init__(self):
    pass
 
  # Schedules work to be done on [work], i.e. the user
  # schedules work.do_work() to be called.
  # This method should return as quickly as possible.
  def schedule(self, work):
    pass
 
  # Does not return until all previously scheduled work
  # has been completed.
  def block_until_complete(self):
    pass

*/

Friday, September 3, 2021

Rajasthan Trip for Shaadi dhok and Jarula (Baby's hair)

The long awaited trip which was being planned in the family since a year, but either due to Covid or due to timing etc, somehow it was not getting finalized! We had done our bookings for May'21 via flight, but it got cancelled due to the lockdown for 2nd Covid wave. 

We booked the tickets nearly fortnight ago via Train for 28th Aug'21 to 2nd Sep'21. We were 14 people altogether, including two toddlers below 2 years.

Train tickets from Kolkata to New Delhi costed around 2800/- per person. 

Day 1: 28th August 2021 - Kolkata to New Delhi 

We started our journey around 2 pm, boarded the train for 3:50 and reached Delhi the next day around 10 am. The train was right on time. Although it was Rajdhani, no food and no bedding was provided due to Covid. We had got packed food from a local vendor for dinner.

Food packed for train journey

Day 2: 29th August 2021 - New Delhi to Sardarshahar

We had booked a tempo traveler for all the days for our trip from Kolkata itself. (Driver ashok- 8383894022). He was waiting at the station when we arrived. We boarded the tempo and started our journey for Sardarshahar- our ancestor's village. En route, we stopped for lunch at the highway at Mannat hotel. We had plain simple food and it costed around 3500/- for 12 people. We stopped for tea at a place and reached Sardarshahar Agrasen Bhawan around 8:30 pm. We booked 5 rooms ( each room had a capacity of around 3) there for night stay. Since it was our native place, they dint charge us, but we paid 2100 as donation. Dinner was arranged by them. Plain simple food, delicious, costed us 500 for 12 people.

Inside tempo traveler
Inside Agrasen Bhavan, Sardarshashar

Day 3: 30th August'21 - Sardarshahar to Jhunjhunu 

We started our day by visiting the Bayla Bayanjee Mandir. We visited the temple, did puja, first shaadi dhok and then mundan (baby's hair). Beside the temple there were two other temples - Ujli and Maili temple and Bhairav's temple. In Bayla's temple, for jarula 5kg wheat, jaggery and prasad. Krishna Nai ji assembled all the things for us including prasad and it costed us around 900/-. He visited with us to the temple helping in the route and procedure for the puja. We had cut the baby's hair before the trip, the same hair we gave there in Bayla's temple. We did puja with dry roli and dry mehendi. We gave 5kg wheat and jaggery and Maili mandir as well. We gave baby's hair there also. In Bhairav's temple we did puja and the rule is not to turn back after stepping out of the temple. 

Inside Bayla 
Entrance of Bayla Mandir


We proceeded to Ichhapuran Balaji Mandir. Visited the temple and moved for lunch to the nearby location of Agrasen Bhawan which Krishna ji arranged for us. It costed us around 1300/-. We took some rest, started our trip to Jhunjhunu.

We reached Jhujhunu approx. 7pm. Booked our stay in the mandir premises of Rani Sati Daadi. It costed us around 1000/- per room. We booked 5 rooms (each room had a capacity of around 2 pax) there. We had dinner there, ordered thali for us, costed us around 100/- each plate.

Day 4 - 31st August'21 Jhujhunu to Salasar

We did shaadi dhok puja in the room as it was not allowed to do any puja in the temple,  and went to the rani sati daadi temple, gave baby hair there as well, had breakfast in the canteen and started for salasar. We reached Salasar. Booked our night stay in Agarwal Seva Sadan hotel, costed us 700/-. We stayed there for the night.

Jhunjhun Shaadi dhok puja in the room

Day 5 - 1st Sep'21 - Salasar to Khatu

We visited the temple early in the morning, gave baby hair in the temple, shopped for delicacies, sweets etc, had breakfast in some random place and proceeded for Khatu. It was 2 hours journey. We reached Khatu, had lunch at a hotel called Shyam Sakha Sadan. Each thali costed us 100/- . Since it was raining  incessantly, we decided to stay in the same hotel. It costed us around 1200/- per room with capacity of 4 people in each room. We booked 3 rooms there.  We visited the Khatu temple, bought sweets and did some shopping.



 Day 6 - 2nd Sept'21 - Khatu to New Delhi to Kolkata

We started our journey to New Delhi early in the morning 6 am. Stopped for breakfast at a nice place King's highway which was huge and fancy and nice, kind of a mall with lot of shops and food court. En route, we had lunch at the famous old Rao dhaba. It was also huge and good food. We reached airport at around 1 pm. We had a flight to Kolkata at 7:40. We spent our time at the lounge. Flight tickets we booked for 4 people at 2500/-, luckily we got some discount + 2 toddlers below 2 years ( 1500/-) . For test 8 people, came by train. Train tickets costed us around 2100/- for 3 tier. 


Inside train, while returning to Kolkata

Flight to Kolkata, while returning



Thursday, August 26, 2021

HTML CSS to put in center

To put the item in center of the page

 height: 100%;

 display: flex;          

 justify-content:center; // horizontal

 align-items: center; // verticial 


If the flex is column, 

justify-items: center;

align-content: center

Monday, August 16, 2021

Paisa wasool toys for 0-1 year old baby - Must have!!!

 Children toys are costlier than you expect. With lot of research, following mom bloggers/ amazon reviews I bought some toys keeping in mind not to burn a hole in my pocket. 

Sharing some toys which my 1 year old utlitised it to the max as possible. She is 20 months old and still loving it.

The very first toy I bought for her was stacking cups.

1.  Stacking cups : I bought this for 153/- when she was around 6 months old. From that day till this date, she plays it.  Around 6 months she used to love destroying the built stack. Around 1 year she stopped playing, but now again she hides stuff in the cups, and picks one by one to find where is the hidden object, stacks it.


I will recommend to buy cubic ones stacking cup as they help is forming firmer grip for the kid. 

2.  Nesting eggs : Bought this for 236/-. Around 8 months old, She used to open the nested eggs and throw aside. Now she is 20 months old and enjoys closing the eggs, choosing what would fit to close the eggs.




3. Wooden Hammer Case Toy : Oh boy, one of the best thing i bought only for 270/-. Prisha used to wake up ealry in the morning like 5 am. After she was a year old, i used to give her this, and go back to sleep. She would play with this for good 30 mins or so. Not only did she learn color sorting with this, but still plays with this in her own way. She never missed to map the correct balls in the correct case and pushes them inside the hole.


4. Shape sorter: I have couple of shape sorters for her. But the one shared below is the best one, as it has big blocks, easier for the kid to hold it and push it. She was around 9 months old when she could easily pick up and try to push it in the shape. She would randomly pick the shapes and try to put it inside and try till she succeeds and clap happily.




5. Plush Toys:  My mother got the crochet teddy bear from a local fair. She pretend plays with them, trying to make them sleep, feed them or take them to places along.






Saturday, July 3, 2021

First year monthly pictures of baby Prisha






18 months milestone

  • Likes doing color matching, pattern matching and her activities sheet.
  • Coloring doesn't interest her much except for first 30 secs may be.
  • Loves playing with pom pom and stickers. Sticks stickers on her face and her dad's too! 
  • Knows people well by name and can point rightly when asked.
  • Light goes off says bhoot. :D
  • Able to say potty susu, after she is done. Not yet potty/susu trained.
  • Can name whose clothes it is
  • Knows her hunger and asks for milk when she is hungry 
  • Repeats almost every word you say
  • Loves listening to Lakdi ki Kathi and Baby Shark
  • Loves holding phone 24*7 and watch instagram  or any videos in phone :D
  • Gets very excited for park and doesnt want to come back home.
  • Loves sweet. Add gur to each spoon and she will have a little else wont show interest in her meals.
  • Loves eating chips, cake, chocolates, basically everything she is not supposed to eat.
  • Wakes me up with 'Utho', holding near my neck, trying to pull me up. 
  • Sleeps only with bottle in mouth and keeps the bottle in mouth for hours before sleeping, even at night times.
  • Given any opportunity runs to her sister's room. Loves playing with Dhwani.
  • Enjoys watching cat and dogs videos and gets very excited.



My mumma's best matar paneer