Articles on Trending Technologies

Technical articles with clear explanations and examples

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

Prateek Jangid
Prateek Jangid
Updated on 10-Aug-2022 457 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 at to understand how the method works in different cases Let's have an array [1, 2, 6, 3, 7, 4, 9], and its key is 1. Input: {1, 2, 3, 4, 5, 6}, k = 1 Result: 8 If we find 1 we double it to 2. If we ...

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 344 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 look at few examples below to see how the method works in different cases − Example 1 − str = "PNDPNSP" Explanation − Here, the answer is true because there is a subsequence "PN, " repeated in the string. Example 2 − str = "PPND" Explanation − Here, the answer ...

Read More

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

Prateek Jangid
Prateek Jangid
Updated on 10-Aug-2022 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 it is stored. string s =" a for apple, b for ball"; res = solve(s); With a string buffer, we will read each word one by one and then concatenate it into a new string which will be our answer. Note − The class string stream is available ...

Read More

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

Prateek Jangid
Prateek Jangid
Updated on 10-Aug-2022 220 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, or the second element is fake, or these 2 elements will give the common ratio of the array. After the common ratio is found, we can iterate on the array to see if all elements follow that rule. 2 base conditions would be to check if the first and second ...

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 523 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 and find the longest one in which 2*min > max condition holds. We can also use dynamic programming approach to try all possible subarray combinations that are overkill and not required. Example  (Using Vector ADT) Suppose we have an array such as “[250, 10, 11, 12, 19, 200]”. To get ...

Read More

Difference between CDMA and LTE

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 10-Aug-2022 6K+ Views

Code Division Multiple Access (CDMA) is a protocol used for 2G and 3G communication. In CDMA, a channel carries all types of transmission simultaneously without division of bandwidth or time. Data from different stations is transmitted simultaneously using different code modulation.Long-Term Evolution (LTE) is a high-performance interface for cellular mobile communications. It supports high-speed networks and at present, it is the fastest network protocol for smartphones and mobile phones.Read through this article to find out more about CDMA and LTE and how they are different from each other.What is CDMA?CDMA uses a single channel to carry all signals at the ...

Read More

Remove Duplicates from a Sorted Linked List Using Recursion

Prateek Jangid
Prateek Jangid
Updated on 10-Aug-2022 634 Views

A linked list is a sequence of elements that are connected together. Each list have a head and series of nodes and each node has data of the current node and link to next node. The basic operations of a linked list are insertion, deletion, search and delete. Removing duplicates from a sorted linked list One way to remove nodes from is using recursion. The idea is to compare each node with its adjacent node and delete the duplicate one they are equal. Our recursive call will return us to the next node. So for the next element, we will ...

Read More

Removing Brackets from an Algebraic String Containing + and – Operators using C++

Prateek Jangid
Prateek Jangid
Updated on 10-Aug-2022 709 Views

Given an algebraic string like p-(q-r)-s, we need to remove the brackets and convert this string to a string with the same mathematical result. So the string p-(q-r)-s is converted to p-q+r-s, giving us the same mathematical result. To achieve this, we can use a stack and keep track of whether or not we should flip the upcoming signs in the bracket expression. 0 mean + or no flip 1 mean - or flip So on every bracket opening, we will push either 0 or 1 depending on whether the signs in this bracket will flip or not. ...

Read More

C++ program to remove Nodes that Don't Lie in Any Path With Sum>=k

Prateek Jangid
Prateek Jangid
Updated on 10-Aug-2022 250 Views

In this problem, we have a binary tree with a path from the root node to the leaf node that is completely defined. The sum of all nodes from the root node to the leaf node must be greater than or equal to, a constant value, k. So we need to remove all nodes in those paths whose sum is less than k, such that the only paths left in the tree will be greater than k. An important thing to remember here is that a node may be a part of many paths, so only remove such nodes if ...

Read More

Difference between Sync and Backup

Pradeep Kumar
Pradeep Kumar
Updated on 10-Aug-2022 536 Views

The act of copying data from one area to another, typically from one hard drive to another, is what we normally call as "backing up." This can be done manually or automatically. Synchronization is the process of ensuring that two different sites have the same collection of files by manually or automatically copying or deleting them as required. Syncing is a faster option, but it comes with a risk. Read through this article to find out more about Sync and Backup and how they are different from each other. What is Sync? Synchronization (sync) is the process of ensuring that ...

Read More
Showing 43421–43430 of 61,297 articles
Advertisements