Dev Prakash Sharma has Published 556 Articles

Write a program in Java to rotate a matrix by 90 degrees in anticlockwise direction

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:49:35

1K+ Views

Let’s suppose we have given a square matrix of N×N. The task is to rotate the matrix counterclockwise. For example, Input-1 −N = 3 matrix[ ][ ] = [    [1 2 3],    [4 5 6],    [7 8 9] ]Output −3 6 9 2 5 8 1 4 ... Read More

Reverse Vowels of a string in C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:49:03

1K+ Views

Given a string, the task is to reverse all the vowels present in the given string. For example, Input-1 −a = “tutor”Output −toturExplanation − Reversing the string “tutor” will generate the output as “totur.Input-2 −a = “mathematics”Output −mithametacsExplanation − Reversing the string “mathematics” will generate the output as “mithametacs”.Approach to ... Read More

Write a program in C++ to replace all the 0’s with 5 in a given number

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:48:02

998 Views

Given an integer N, the task is to replace all the 0’s that appear in the number with ‘5’. However, the number with leading ‘0’ cannot be replaced with ‘5’ as it remains unchanged. For example, Input-1 −N= 1007Output −1557Explanation − The given number has 2 zeros which when replaced ... Read More

Write a program in C++ to remove duplicates from a given array of prime numbers

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:46:48

264 Views

Let us suppose we have given an array N size which consists of all the prime numbers. The task is to find the duplicates in the given array and remove them. For example, Input-1 −N = 8 arr[ ] = { 2 ,2 ,2 ,3 ,3 ,3 ,5 ,7 }Output ... Read More

Remove comments in a string using C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:46:09

699 Views

Given a C++ program as input, remove the comments from it. ‘source’ is a vector where the i-th line of the source code is the source[i]. This represents the result of splitting the source code string by the newline character . In C++, we can create two types of comments, ... Read More

Nth Catalan Number in Go Lang

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:45:36

131 Views

Catalan Numbers are sequences of natural numbers that gives the number of BST (Binary Search Tree) possible with n Values. So, the Catalan number is a full binary tree with n+1 leaves.Some applications of Catalan Numbers are counting the pairs of nested parentheses, valid mountain ranges etc.For n = 5, ... Read More

Majority Element in Java

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:43:28

829 Views

Let’s suppose we have given an array of integers. The task is to find the index of a particular element in the given array. For example, Input-1 −N = 8 A[ ] = { 1, 2, 4, 3, 3, 1, 1, 5}Output −1Explanation − In the given array of integers, ... Read More

Write a program in C++ to insert a Node at the beginning of the given Singly linked list

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:43:04

6K+ Views

A linked List is a linear data structure that has multiple nodes that are connected with each other. Each node consists of two fields Data Field and address of the next node.Let us assume we have given a singly linked list the task is to insert a node at the ... Read More

Insertion in the Red Black Tree in Data Structure

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:42:32

7K+ Views

Red Black Tree is a Self-Balanced Binary Search Tree in which each node of the tree is colored with either Red or Black. There are three types of operations we can perform on a Red Black Tree – Searching, Insertion and Deletion.Let us suppose we have to insert an element ... Read More

What are pandigital numbers. Approach to find the pandigital Numbers using C++

Dev Prakash Sharma

Dev Prakash Sharma

Updated on 05-Feb-2021 12:36:00

339 Views

Pandigital Number − In Mathematics, a Pandigital number is an integer that in a given base has among its significant digits each digit used in the base at least once.Pandigital numbers are the integers in which each digit is used as the base at least one time.For example, 1245678 is ... Read More

Advertisements