A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired. For example, in array A such that: A[0] = 9 A[1] =… Continue reading
Author: Avidlearner
Program to Rotate an Array in C++|LeetCode |techtrendings
An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7]… Continue reading
Custom Deleters in C++
In this tutorial, we will learn how to create a custom deleted to delete a smart pointer in C++. Introduction to Custom Deleter in C++ When a smart pointer of any user-defined type is destroyed, the destructor of the class is invoked giving us the ability to explicitly inspect and modify the delete process. But… Continue reading
Copy Constructor vs Assignment Operator in C++
The Assignment Operator is when you replace the data with an already existing(previously initialized) object withsome other object’s data. Lets see an example: You can see here I call the assignment operator when I already initialized the Assign object. Then later I assign foo2 tofoo . All the changes to appear when you call that… Continue reading
marsexploration in C++ Hackerank
A space explorer’s ship crashed on Mars! They send a series of SOS messages to Earth for help. Letters in some of the SOS messages are altered by cosmic radiation during transmission. Given the signal received by Earth as a string, , determine how many letters of the SOS message have been changed by radiation.… Continue reading
Caesar Cipher Problem C++ HackerRank
Julius Caesar protected his confidential information by encrypting it using a cipher. Caesar’s cipher shifts each letter by a number of letters. If the shift takes you past the end of the alphabet, just rotate back to the front of the alphabet. In the case of a rotation by 3, w, x, y and z… Continue reading
Super Reduced String in C++
Reduce a string of lowercase characters in range ascii[‘a’..’z’]by doing a series of operations. In each operation, select a pair of adjacent letters that match, and delete them. Delete as many characters as possible using this method and return the resulting string. If the final string is empty, return Empty String Example. aab shortens to b in one operation: remove… Continue reading
Print Odd and Even in Separate thread – C++ Multithreading
In this article we will discuss about the how to print odd and even number in separate threads. Let’s see We can also use condition and notify with threads to print odd and even in separate threads.
getline Concept in C++
getline() in C++ is a special convenience function provided by string class for reading line by line. This function reads all characters, including leading whitespaces, until the line delimiter orend-of-file is reached. The line delimiter is extracted but not appended. By default, the line delimiter is the newline character, but you can pass your own… Continue reading
decltype Keyword C++
The decltype keyword takes an expression as argument, and computes the type of that expression,as shown here:int x = 123;decltype(x) y = 456; In this example, the compiler deduces the type of y to be int because that is the type of x.The difference between auto and decltype is that decltype does not strip reference… Continue reading