Find first and last index of target element from sorted array The best way we can do this with binary search. Big O will be O(2log(n)).
This algorithm to count number of valid substring in given binary string. Valid substrings will be 01, 10, 0011, 1100, 000111, 111000, 00001111, 11110000 …. etc
Merge two sorted arrays in a such a way that a newly generated array will be sorted. Here we are going to take two pointers one for each.
This is the simple algorithm to replace all the keys from sentence with some values. Here I am going to use StringBuilder to rebuild new string and It will going to take O(n), Here n is a number of characters in sentence.
How many different ways can you make change for an amount, given a list of coins?
Given a string, write a function to check if it is a permutation of palindrome.
Algorithm to find middle node in LinkedList, To find middle node we will use two pointers P1 and P2, We will increment P2 after every two steps of P1.
LinkedList is most popular subject in interview room. This post is about creating your own LinkedList. It will be helpful for solving LinkedList related algorithms.
Right circular rotation on an array of integers [1,2,…,n-1,n]. After performing one right circular rotation operation, the array is transformed from [1,2,…,n-1,n] to [n,1,2,…,n-1]. Perform rotation k number of times and find out element in particular position. Inputs : Line One : Size of array, Number of rotation, Number of positions going to print. Line… Read more
Fibonacci sequence : It is the sum of the two preceding ones