Prateek Jangid has Published 190 Articles

Replace every element with the least greater element on its right using C++

Prateek Jangid

Prateek Jangid

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

145 Views

To find the least greater element on the right of an array of integers, we need to consider an array of integers. For each element, we need to find an element that is greater than the current element and is the least from all the candidate elements we have. Suppose ... 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

117 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

385 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

Replace All Consonants with Nearest Vowels In a String using C++ program

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 08:59:19

902 Views

The method is devised to replace a string of consonants with the closest vowels from the alphabet (also known as lowercase Latin letters). If two vowels are equally close, we can replace them with the first ones in these letters. Let us look at some input scenarios − Suppose we ... 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

306 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

174 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 Reorder the Position of the Words in Alphabetical Order

Prateek Jangid

Prateek Jangid

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

388 Views

In this problem, a string is taken as the input and we have to sort the words present in the string in a lexicographical order. To do that, we assign an index to each word in the string (differentiated with spaces in between) starting from 1, and the output is ... 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

654 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

92 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

C++ program to remove minimum elements from either side such that 2*min becomes more than max

Prateek Jangid

Prateek Jangid

Updated on 10-Aug-2022 08:27:13

238 Views

The problem involves removing elements from any side of a list of integers in such a way that 2*min is greater than max. vector arr = {250, 10, 11, 12, 19, 200}; res = solve(arr); We can use brute force approach. We can try all possible subarrays which satisfy ... Read More

Previous 1 ... 3 4 5 6 7 ... 19 Next
Advertisements