Recursive program to print reverse of a string
Given a string, print it backwards using recursion.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a string, print it backwards using recursion.
Given a sorted integer array, find the index of a given number’s first or last occurrence. If the element is not present in the array, report that as well.
Given a circularly sorted integer array, find the total number of times the array is rotated. Assume there are no duplicates in the array, and the rotation is in the anti-clockwise direction.
Given a sorted array of n integers and a target value, determine if the target exists in the array or not in logarithmic time. If the target exists in the array, print an index of it.
Given a sorted integer array and a target, determine if the target exists in the array or not using an interpolation search. If the target exists in the array, print an index of it.
Given a sorted array of n integers and a target value, determine if the target exists in the array or not in logarithmic time using the binary search algorithm. If target exists in the array, print the index of it.
Given an M × N matrix, which is row-wise and column-wise sorted, count the total number of negative elements present in it in linear time.
Given a square matrix, rotate the matrix by 90 degrees in a clockwise direction. The transformation should be done in-place and in quadratic time.
Given an array of positive and negative integers, segregate them in linear time and constant space. The output should print all negative numbers followed by all positive numbers.
Merge sort is an efficient sorting algorithm that produces a stable sort, which means that if two elements have the same value, they hold the same relative position in the sorted sequence as they did in the input.
Bubble sort is a stable, in-place sorting algorithm named for smaller or larger elements “bubble” to the top of the list. Although the algorithm is simple, it is too slow and impractical for most problems even compared to insertion sort, and is not recommended for large input.
Selection sort is an unstable, in-place sorting algorithm known for its simplicity. It has performance advantages over more complicated algorithms in certain situations, particularly where the auxiliary memory is limited.