Right rotate an array `k` times
In this post, we will see how to right-rotate an array by specified positions. For example, right rotating array { 1, 2, 3, 4, 5, 6, 7 } three times will result in array { 5, 6, 7, 1, 2, 3, 4 }.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedIn this post, we will see how to right-rotate an array by specified positions. For example, right rotating array { 1, 2, 3, 4, 5, 6, 7 } three times will result in array { 5, 6, 7, 1, 2, 3, 4 }.
In this post, we will see how to left-rotate an array by specified positions. For example, left-rotating array { 1, 2, 3, 4, 5 } twice results in array { 3, 4, 5, 1, 2 }.
This post will discuss how to reverse a string using the stack data structure in C/C++, Java, and Python using explicit stack and call stack.
This post will discuss how to traverse the given directory and list out all files present in it and all its sub-directories using BFS and DFS.
Given a sorted integer array, find the floor and ceiling of a given number in it. The floor and ceiling map the given number to the largest previous or the smallest following integer.
Given a binary search tree, find a pair with a given sum present in it.
Given a binary tree, write an efficient algorithm to compute the maximum number of nodes in any level in the binary tree.
Given a binary tree, write an efficient algorithm to invert it.
Given an array representing a min-heap, convert it into a max-heap. The conversion should be done in-place and in linear time.
Given a BST and a positive number k, find the k’th smallest node in it.
Given an integer array, find a subset in it having the maximum product of its elements.
Given two integers, add their binary representation.