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 […]
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 […]
Below is a JavaScript algorithm. We handle edge cases first:- Delete first element if there is a match Delete all the matching elements in between Delete last element if there is a match
Traverse the tree using tree traversal algorithm for e.g. inorder Push all the traversed nodes in an array. Sort the array Find the minimum difference between array elements by looping through Javascript code below:-
Below is a simple self explanatory recursive algorithm using javascript
From the problem statement it’s clear that the octal string is first converted into binary string and then the binary string is converted into decimal value bytes (8 bits each). If the binary string is not in multiples of 8, zeroes are padded in the beginning of it to make it evenly divisible by 8. […]
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:- […]
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 —————————- […]
Here is another cryptic but short solution in javascript
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 […]