Categories
Uncategorized

Detecting Angular Router State Changes

Detecting Route state changes can be done by subscribing to the router and listening to the events being emitted. In the example below you will see all the router events that you can listen to in Angular.

Categories
Uncategorized

Angular Material with Angular 5

Install the latest version of Angular Material + Animations using npm to get started.

npm i --save @angular/material @angular/cdk
npm i --save @angular/animations
Categories
interview

Javascript call() vs apply() vs bind()

call

The call() is a predefined Javascript function which can used to call a method of an object while passing it another object. For example, if you look at the following code, you will observe that the object being passed into the call() method replaces the this variable of the object whose method is being invoked.

Categories
Uncategorized

Testing Component with Service (Promise) in Angular

To perform unit testing on a component that makes use of a service, that returns a promise, we can use fakeAsync() and spy() methods from Angular’s unit testing package.

Categories
interview

Passing an object vs primitive data type in Js

In Javascript, when you pass a primitive data type like String or Int in Java to a function or a method, and a function modifies it, then this does not effect the actual data being passed. For example,

Categories
interview

Floyd Warshall Algorithm

The Floyd Warshall Algorithm is used to find the shortest distance between all pairs in a weighted graph with positive or negative edges. It makes use of Dynamic Programming.

  • If A, B, C are vertices, then this algorithm checks for the following
    if (AC > AB + BC)
    AC  = AB + BC;
Categories
interview

Kth largest element in an Array

Kth largest element in an array can be determined using the “Quickselect Algorithm”.

Average performance O(n)
Worst-case performance O(n^2)

Categories
Uncategorized

Interview Structure for Top Tech Companies

Amazon

Usually for SDE I, the interview involves

  • 1 Phone screen with coding.

    Onsite
  • 3 Onsite whiteboard coding interviews (includes bar raiser)
  • 1 System Design round
  • 1 Behavioral round

Google

For entry level software engineers, usually it comprises of

  • 1 Hangouts coding session

    Onsite
  • 5 whiteboard onsite coding interviews

Microsoft

For different levels of Software Engineering positions, usually the interview comprises of

  • 1 Skype coding session

    Onsite
  • 5 whiteboard onsite coding interviews

Most tech companies try to test your ability to apply core Computer Science fundamentals to solve problems.

Categories
Uncategorized

What is Dynamic Programming?

Dynamic Programming is a way of solving a problem by breaking it down into smaller sub problems and storing them without having to recalculate them. Usually this involves 3 main methods.

Categories
Uncategorized

Flashing your Samsung Galaxy S7 Edge (T-Mobile)

You will need a Windows PC for this. Make sure you have backed up your data before proceeding.

  • Download the Samsung Android drivers for Windows from here and install it.
  • Download ODIN from here and extract it.
  • T mobile S7 for flashing your T-Mobile S7 Edge device from here and extract it.
  • Hold the Volume Down + Power + Home button of your device simultaneously until you see options to Flash your device.
  • Now choose to move forward with flashing your device by pressing the  Volume up key on your device.
  • Now connect your device using a USB cable to your Windows PC.
  • Run ODIN as an admin and choose the files starting with BL, AP, CP  & CSC correspondingly into their respective fields and click on Start.
  • Wait for the flash operation to terminate successfully. This usually takes around 5-10 minutes depending on your hardware.