Prateek Jangid has Published 165 Articles

C++ program to find Second most repeated word in a sequence

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:52:54

501 Views

We are given an array of words, and we need to find the word whose frequency is the second largest in the array. Let’s assume some simple input and output scenarios Let’s assume we are having an array which consists of elements like [“point, ” “world, ” “articles, ” “articles, ... Read More

Smallest integer > 1 which divides every element of the given array: Using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:51:06

300 Views

In this article, we are given integers in an array, and we must find the smallest number which is greater than 1 that divides all the elements in the array. For example, let us consider a sample array [30, 90, 15, 45, 165]. vector arr = {30, 90, 15, ... Read More

C++ program to Replace Nodes with Duplicates in Linked List

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:49:07

455 Views

In this article, we are given a linked list that contains elements from 1 to n and duplicates. Elements 1 to n will always be there with duplicates from [1..n]. We need to replace every duplicate element with n+1, n+2, and so on. Lets consider an example 1→2→2→4→5→3→6→6 Next n ... Read More

C++ program to Replace Every Matrix Element with Maximum of GCD of Row or Column

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:47:24

503 Views

In this method, we need to replace every element in the given matrix with the maximum Greatest Common Divisor (GCD) of that row and column. Let us look at some input scenarios − Suppose we are given a 2D matrix of dimensions m*n is; Input: [[3, 2, 1, 4] [7, ... Read More

Replace each node with its Surpasser Count in Linked List Using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:16:23

254 Views

We are given a linked list, and we need to find elements in the given linked list which are greater and present in the right of the current element. The count of these elements needs to be substituted into the current node's value. Let's take a linked list with ... Read More

C++ program to replace all occurrences of string AB with C without using extra space

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 09:01:33

560 Views

In this article, we will replace "AB" with "C" in the given string having upper case latin characters. The occurrences of "AB" becomes "C, " but single "A" and "B" are unaffected. Let us look at some input scenarios − Let's have a string "ABOUTME" Input: "ABOUTME" Result: COUTME ... Read More

Repeatedly Search for an Element by Doubling it After Every Successful Search Using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 08:56:48

424 Views

In this article, we are given an array of integers and a key. We must find the key repeatedly in the array and double it on each find in the array. We need to return the value not present in the array doing this operation. Some input scenarios to look ... Read More

C++ Program to find if the given string has Repeated Subsequence of Length 2 or More

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 08:52:17

316 Views

Given a string, find a subsequence with the length, at least two, repeated in the string. The index of the subsequence element numbers must not be in the same order. string s = "PNDPNSP"; print("Repeated subsequence of length 2 or more: ", (check(s) ? "Yes" : "No")); Let us ... Read More

C++ program to remove spaces from a string using String stream

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 08:41:07

1K+ Views

As the given problem says, we need to remove spaces from the string using a string stream. As the name suggests, a string stream converts a string into a stream. It works similar to cin in C++. It associates a string object that can access the string buffer in which ... Read More

Removing a Number from Array to make It Geometric Progression using C++

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 08:29:25

195 Views

We are given an array of elements. We need to find whether the elements in the array are in Geometric Progression (GP) or not after removing any 1 element from the array. We can run out the possibilities and with observations to figure out that the first element is fake, ... Read More

Advertisements