Welcome To Tutorialspoint.dev
Officially launched 18th May 2019

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...

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...

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...

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 &#x2018;k&#x2019; times where k &gt; 0? And Examples: Input : a[] = {2...

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

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

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 ...

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-&gt;2-&gt;1-&gt;2-&gt;1-&gt;3-&...

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 ...

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 ...

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...