Suppose we have a string with dots (.) and a number, a dot indicates the cell is empty, and if there is a number x in any cell, it indicates that we can move x steps to the right or left within the string. Our task is to check whether we can visit a cell more than once or not. For example, if a string is like “. 2 . . . 2 . .”, then we can visit 4th cell in two different ways. From second cell to two step to right, or from two step left from cell ... Read More
Here we will see how to check a binary tree is level wise sorted or not. The level wise sorted binary tree will be look like below −In each level, the nodes are sorted from left to right, and each layer contains higher value than its previous level.We can solve this problem by performing level order traversal, and keep track of the minimum and maximum elements of current level. Use another variable prev_max to hold maximum value of the previous level. Then compare the minimum value of current level and maximum value of previous level prev_max. If min value is ... Read More
Consider we have a binary tree. We have to find if there are some duplicate subtrees of size 2 or more in the tree or not. Suppose we have a binary tree like below −There are two identical subtrees of size 2. We can solve this problem by using tree serialization and hashing process. The idea is serializing the subtrees as string, and store them in hash table. Once we find a serialized tree which is not leaf, already exists in hash table, then return true.Example Live Demo#include #include using namespace std; const char MARKER = '$'; struct Node ... Read More
Consider we have a binary tree, this binary tree is not a BST. We have to check whether the binary tree contains same element more than one time or not. To solve this, we will use hashing. We will traverse the given tree, for each node, we will check whether the node is present in the table or not, if that is already present, then return false, otherwise true.Example Live Demo#include #include using namespace std; class Node { public: int data; Node *left; Node *right; }; Node* getNode(int data){ Node *newNode = new Node; ... Read More
Suppose we have a binary string, another integer k. We have to check the string is containing all permutations of binary of k bits. Suppose a string is like “11001”, and if the K = 2, then it must have all permutations of k bit numbers. (00, 01, 10, 11), the given string has all permutation. So this is valid string.by taking the binary string and the value of k, we have to check whether binary sequences are matched or not. The binary sequence is made of size k. So there will be 2k number of different binary permutations. We ... Read More
Nowadays, we all know that one of the most panicking moments of our life is when we have lost our smartphone. We tend to miss it during our daily commute or misplace it in any public spots. It’s now time to thank our technology growth which gives us the ray of hope to find our missing phones back. There are a few ways to remote control and track your phone even if you haven’t installed a recovery app before it vanishes.Do not wait until you’ve lost your smartphone and then to wonder how to track it. This article will help ... Read More
Refurbished Samsung Galaxy Note 7Seems like the world hasn’t had enough of the Galaxy Note 7, they just might sell out refurbished units of the Note 7 with smaller batteries minus the chance of explosions happening anymore. To avoid garbage and environmental damage, Samsung Galaxy has decided to revamp their design and use the older scraps and units of the smartphones and make sales post minor yet necessary changes.Moto G5 and G5 PlusThe awaited Moto G5 models coming out with a few similar specifications, Android 7.0 Nougat, full-HD screen resolution, Corning Gorilla Glass 3 cover, 128GB expandable storage, fingerprint scanner, ... Read More
For many years, companies have been using computers to send business documents instead of mailing paper documents. But the problem arises when Company A won’t recognize e-format of Company B due to the absence of a standard format which led to the condition where computers could no longer “talk” to one another and again a great deal of effort by programmers need to put which led the cost.In 1979 the American National Standards Institute (ANSI) formed the Accredited Standards Committee (ASC) X12 to rectify this situation. This committee was to standardize the format of electronic documents to allow for easy ... Read More
Suppose we have one 2D array of size N x M. The task is to check if we can select a number from every row, in such a way that the XOR of those elements is non-zero or greater than 0. Suppose one matrix is like this −77710107If we perform XOR, the answer will be non-zero, as the except last elements of two rows are 7 and 10To solve this problem, the solution will be very easy. Initially check if XOR of the elements of the first column of each row is 0 or not. If it is non-zero then ... Read More
The bold move made by Apple to remove the traditional 3.5 mm headphone jack from the iPhone 7 has created quite a hustle, all over the internet and the social media. This is Apple’s take on moving ahead towards the future. Since the announcement of the decision, the company has been subjected to comic criticism, sarcastic mockery, and millions of jokes.Disappointment from UsersIn fact, this decision has disappointed a great number of Apple fans. Now iPhone users cannot connect their older headphones directly with their iPhones. Although, Apple provides a Lightning to 3.5 mm converter within the sales package of ... Read More