In this problem, we are given an array of N elements. And need to return all the sums of the elements are divisible by an integer M.Input : array = {4, 7, 3} ; M = 3 Output : 5+4+3 ; 5+4-3To solve this problem, we need to know the concept of a power set that can be used to find all the possible sums obtained. From this sum, print all those which are divisible by M.AlgorithmStep 1: Iterate overall combinations of ‘+’ and ‘-’ using power set. Step 2: If the sum combination is divisible by M, print them ... Read More
In this problem, we are given an undirected graph and we have to print all the cycles that are formed in the graph.Undirected Graph is a graph that is connected together. All the edges of the unidirectional graph are bidirectional. It is also known as an undirected network.Cycle in a graph data structure is a graph in which all vertices form a cycle.Let’s see an example to understand the problem better −Graph-Output-Cycle 1: 2 3 4 5 Cycle 2: 6 7 8For this, we will make use of a few properties of the graph. You need to use graph coloring ... Read More
In this problem, we are given a tree. And we have to print all the levels with even number of nodes and odd number of nodes in it.Let’s take an example to understand the concept betterOutput −Levels with odd number of nodes: 1, 3, 4 Levels with even number of nodes: 2Explanation − The first level has only 1 element(odd), 2nd level contains two elements(even), 3rd level contains 3 elements(odd) and 4th level contains 1 element(even).Now, to solve this problem. We need to find the count of nodes at each level and print the even-odd levels accordingly.We will follow the ... Read More
In this problem, we are given a string and we have to find all the characters that are duplicated along with their number of occurrences in the string.Let’s take an example to understand the problem −Input: TutorialsPoint Output: t (3) o (2) i (2)Explanation− The frequencies of occurrence of each character are t → 3; u → 1; o → 2; r → 1; i → 2; a → 1; s → 1; n → 1.Now, to solve this problem we will find the character count and store it in an array from the string. And then print the characters ... Read More
This article helps you to know some key features of Linux Operating systems so that you are able to choose Linux for your environment. The year 2015 and the current 2016 will be a crucial year for Linux especially in the enterprise-level segment and consumer/home users. As a Linux user since 1996, I can see that the operating systems have come a long way since 20 years. We can definitely expect more exciting times with new flavors this year.Free/Open Source Server Based OS ‘Debian/CentOS’If you are looking at running a server, but needed a free or open source server version ... Read More
Try to keep the length of lines less than 80 characters. This would make the code easier to read. Best practice is to move to next line using break if JavaScript statements aren’t fitting in a single line.In addition, move to next line only after a comma or operator. For example, you can add statement like this, with a break after operator,function display() { var a = ""; a = a + isNaN(6234) + ": 6234"; a = a + isNaN(-52.1) + ": -52.1"; a = a + isNaN('') + ": ''"; document.getElementById("test").innerHTML = a; }
Microsoft’s Surface Studio is an elegant and mature all-in-one desktop PC with built-in touch screen specially designed for creative professionals. Microsoft first release was the Microsoft PixelSense formerly called as Microsoft Surface back in 2008. The next release was the Microsoft surface tablet followed by the Surface Book. The latest upgraded release is the Surface Studio.The Studio is a 28-inch sharp, incredibly thin display mounted on a pair of “zero gravity” hinges that allows it to act as a regular monitor or tilt down into a type of drafting table. Without doubts Microsoft studio will be a clear challenge to ... Read More
In this problem, we are given an array of unique integers. And we have to return all pairs of integers(positive and negative integers) that are present in the array.Let’s take an example to understand the problem better −Input: array = {1 , 4 , 7 , -1, 2, 5, -7} Output: -11 -33An easy way to solve the problem is by using two loops and find the positive-negative pairs. But this solution will be a complex one and will have time complexity of the order n2 where n is the size of the array.But, we have to find a more ... Read More
In this problem, we are given a string of size n. And we have to print all possible palindromic permutation that can be generated using the characters of the string in alphabetical order. If palindrome is not created using the string print ‘-1’.Let’s take an example to understand the topic better −Input: string = “abcba” Output : abcba bacbaNow, to solve this we need to find all the palindromes possible and then arrange them in alphabetical order(lexicographical order). Or another way could be finding the lexicographically first palindrome that is made from the string. Then find the sequentially next palindrome ... Read More
In this problem, we are given a Binary tree and a sum S. And we have to find the path starting from root to any node of the tree, which gives the sum equal to the given sum.InputSum = 14 Output : path : 4 10 4 3 7To find the solution to this problem, we need to find the preorder traversal of the binary tree. And then find the path that adds up to the given sum.Example Live Demo#include using namespace std; struct Node{ int key; struct Node *left, *right; }; Node* insertNode(int key){ Node* temp = ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP