Insert nodes into a linked list in a sorted fashion

The solution is to iterate down the list looking for the correct place to insert the new node. That could be the end of the list, or a point just before a node which is larger than the new node. Note that we assume the memory for the new node has already been allocated and Read More →

Ibibo Web Pvt Ltd. (PayU)

Company : Ibibo (payu, tradus, goibibo) Profile : Senior Software Engineer Round 1(Telephonic) 1. Find if a string is substring of other string. 2. Write a code to multiply two matrices of dimension M*N and N*K. 3. Write a Sql to perform Matrix Multiplication.Two tables has three columns row,col and value. Round 2(F2F) 1.What is Read More →

Write a C function to find the height or depth of a tree.

Write a C function to find the height or depth of a tree. Solution : The height can be found out recursively by calculating height of left sub tree tree and right sub tree.Height of tree would be the maximum  of height of left subtree and height of right subtree + 1.  

Write a C program to return the nth node from the end of a linked list

Solution 01 – Brute Force Approach: Let’s assume length of linked list be ‘L’ , nth node from end = L – n + 1 node from start. Step 1: Iterate over the linked list and determine its length. Step 2: Now using the above mentioned formula , we can determine the position of the Read More →

Find second highest salary in employee table

Our problem is to find 2nd highest salary from the employee table using mysql . EMPLOYEE TABLE Steve    150$ James    120$ Andrew   120$ Mark    100$ First Method: We will sort the salaries in descending order and will limit the solution by one. But this will not give all the results if there are two employees Read More →

Find the angle between hour handle and minute handle

Given the time in 24 hour format.Find the angle between hour handle and minute handle in a clock at any given time. Solution : Visualize the clock as a 360 degree circle.As we know that Hour handle completes 360 degree in 12 hours.In 1 hour or 60 minutes it complete 360/12 i.e. 30 degree.Minute handle Read More →

Reverse a string word by word,(in place)

Write a Program to reverse the words in a string. Example Input : Hello! How are you Output: you are How Hello! The words are reversed, but the letters are still in order (within the word). Algorithm: i)Reverse the whole string. You will get “uoy era woH !olleH” ii)Then reverse each word. Now it will Read More →

How can four employees calculate the average of their salaries without knowing other’s salary

This solution has a limitation that information is partially passed  and there needs some trust level. Salary of A: i Salary of B: j Salary of C: k Salary of D: l A passes to B (i + a) where a is a number that A knows B takes this a passes to C (i Read More →

Write code to remove duplicates in a sorted array

In this simple C program, we change the original array and also send the new size of the array back to the caller. Method 1 And here is the output… OLD : [1] [1] [2] [3] [5] [6] [6] [7] [10] [25] [100] [123] [123] NEW : [1] [2] [3] [5] [6] [7] [10] [25] [100] [123] Method 2 If we dont want to change the input array and just want to print the array without any duplicates, the solution is very Read More →

Write a C program for calculating the factorial of a number

Here is a recursive C program Please note that there is no error handling added to this function (to check if n is negative or 0. Or if n is too large for the system to handle). 

Hello World !

This is our first blog post and we couldn’t think of a better way to say hello. Hello World is often the first program written by many when learning a new programming language. So here we go to start a portal for all the people who are really crazy for coding.