Archives

How to free up a port on windows ?

Run the below command on windows to find the PID of the process that’s running on the port you want to free using the below command:-   netstat -ano | Findstr <portNo> where portNo is the port which you want to free.   The above command will give an output like:-   The last column […]

Given a string s, convert it into a palindrome

There are different edge cases we want to tackle in this sort of a problem   Check if the string contains all non-repeating characters, if that’s the case, prefix last N-1 characters from the string of length N in front of the string       2. If first criteria isn’t met, check the indices […]

Why does time dilation slow down the biological clock ?

Mass and speed both slow down time due to a phenomenon called Time dilation. Time dilation can be explained by Einstein’s equation as below:-   If we travel for 14 years at 99% of the speed of light (nearly 14 light years distance), it will be equal to 99 earth years as explained below:-   […]

Can you explain the output of below C++ program ?

Let’s try to dissect this C++ program step by step   The above initializes a teacher object T with values Tid = 5, TeachCode = 0 and TeacherCount = 0     This will initialize M with values Tid = 1 (default value assigned in the constructor) TeachCode = 0 and TeacherCount = 0 —————————- […]

Algorithm to determine if a sudoku puzzle is valid

Below long but self explanatory algorithm in javascript !!   A sudoku is said to be valid if If all boxes (3×3 grids) contain no duplicates and thus unique numbers between 1-9 All rows contain no duplicates and thus unique numbers between 1-9 All columns contain no duplicates and thus unique numbers between 1-9 Checking […]