AfterAcademy Tech
Write a program to find the factorial of a given number n. n is a non-negative integer. Factorial of a non-negative integer n is the multiplication of all integers smaller than or equal to n.
Sort a linked list using Merge Sort. This is a very famous interview problem that demonstrates the concept of recursion. This problem is quite similar to Merge Sort in Arrays.
You are given an integer n, write a program to find the smallest multiple of n which consists of 0 and 1. The resultant number could be quite large so return it in the form of a string. This problem is a good example of graph-based problems.
You are given the head of a linked list which probably contains a loop. If the list contains a loop, you need to find the last node of the list which points to one of its previous nodes to create a loop and make it point to NULL, thereby removing the loop.
Given a square chessboard of A x B size, the position of Knight (C, D) and the position of a target (E, F) is given. Write a program to find out the minimum steps a Knight will take to reach the target position. This problem is a good example of BFS algorithm.
Given an array arr[] of size n , write a program to find the largest element in it. To find the largest element we can just traverse the array in one pass and find the largest element by maintaining a max variable.
Given two binary search trees with root nodes as tree1 and tree2 of size n and m, write a program to return an array of integers that contains all the elements of tree1 and tree2 in non-decreasing order. The expected time complexity is O(m+n).
Given a singly linked list, write a program to group all odd nodes together followed by the even nodes. You should try to do it in place and the program should run in O(n) time complexity.
You are given an unsorted array of integers(arr) of length n, write a program to sort it in wave form. The array elements in the resultant array must be such that arr[0] >= arr[1] <= arr[2] >= arr[3] <= arr[4] ... and so on. If there are multiple sorted orders in wave-form, return the one which is lexicographically smallest.
You are given two sorted arrays arr1[ ] and arr2[ ] of sizes m and n respectively. Write a program to merge them in such a way that the resultant array is sorted too.