Welcome To Tutorialspoint.dev
Officially launched 18th May 2019
Graph Amazon BFS

Shortest path to reach one prime to other by changing single digit at a time

Given two four digit prime numbers, suppose 1033 and 8179, we need to find the shortest path from 1033 to 8179 by altering only single digit at a time such that every...
Graph Topological Sorting Graph

Topological Sort of a graph using departure time of vertex

Given a Directed Acyclic Graph (DAG), find Topological Sort of the graph. Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such t...
Arrays Hash Arrays

First element occurring k times in an array

Given an array of n integers. The task is to find the first element that occurs k number of times. If no element occurs k times the print -1. The distribution of inte...
Arrays Hash cpp-unordered_map

Smallest element repeated exactly ‘k’ times (not limited to small range)

Given an array of size n, the goal is to find out the smallest number that is repeated exactly ‘k’ times where k > 0? And Examples: Input : a[] = {2...
Advanced Data Structure Hash Amazon

Design a data structure that supports insert, delete, search and getRandom in constant time

Design a data structure that supports following operations in Θ(1) time. insert(x): Inserts an item x to the data structure if not already present. remove(x): R...
Analysis Heap Heap

Time Complexity of building a heap

Consider the following algorithm for building a Heap of an input array A. BUILD-HEAP(A) heapsize := size(A); for i := floor(heapsize/2) downto 1 ...
Linked List Linked Lists Linked List

Write a function that counts the number of times a given int occurs in a Linked List

Given a singly linked list and a key, count number of occurrences of given key in linked list. For example, if given linked list is 1->2->1->2->1->3-&...
Matrix rotation Matrix

Rotate the matrix right by K times

Given a matrix of size N*M, and a number K. We have to rotate the matrix K times to the right side. Examples: Input : N = 3, M = 3, K = 2 12 23 34 ...
Graph Matrix Queue

Minimum time required to rot all oranges

Given a matrix of dimension m*n where each cell in the matrix can have values 0, 1 or 2 which has the following meaning: 0: Empty cell 1: Cells have fresh oranges ...
Stack Adobe Amazon

Design a stack that supports getMin() in O(1) time and O(1) extra space

Question: Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() whi...

Subscribe to Our Newsletter