
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

427 Views
We are given a positive integer N. The goal is to count the pairs of distinct non-negative positive integers that satisfy the inequality: x*x + y*y < NWe will start from x=0 to x2 < N and y=0 to y2 < N . If any x2 + y2 < N, increase count of pairs.Inputn=4Outputdistinct pairs= 4Explanation − pairs will be (0, 0), (1, 1), (0, 1), (1, 0). All these satisfy the inequality x2 + y2 < 4Inputn=2Outputdistinct pairs= 3Explanation − pairs will be (0, 0), (0, 1), (1, 0). All these satisfy the inequality x2 + y2 < 2Approach ... Read More

2K+ Views
We are given with the prices of toys in the form of an array and an amount K in hand. The goal is to purchase the maximum no. of toys with that amount. Each element of the array is a price of a single toy, so no. of toys is no. of elements. We will sort the array of prices in ascending order so that maximum toys of less prices can be purchased first followed by costly toys.Inputtoyprices[]= { 10, 20, 12, 15, 50, 30 } K=50OutputMaximum no. of toys that can be purchased : 3Explanation − Sorting prices of ... Read More

475 Views
We are given with the number of edges Noe and number of vertices Nov. The goal is to find the minimum and maximum number of isolated vertices that are possible in such graphs which have no edges and No vertices count.An isolated vertex is the one that has no edge connected to it.For minimum isolated verticesWe will make sure that every edge is isolated. ( No two edges have common vertices ) Each edge requires only 2 vertices. So ,count of non isolated vertices = 2 * no. of edgescount of isolated vertices = total vertices - count of non ... Read More

240 Views
We are given an array of height of the walls of the container. The goal is to find the container that can contain the maximum volume of water. As heights of walls are elements of an array, the distance between them is considered as width between two walls. For example walls of height Arr[i] and Arr[j] have j-i width between them ( 0

241 Views
We are given a binary tree. The goal is to find the maximum length cycle in the given tree. We will do this by finding the maximum height of the left subtree and right subtree from the root node and will join these maximum length paths to get the longest cycle.For the above tree the maximum length cycle is 1-2-3-4-7-6 or 1-6-7-4-3-2-1. The length is 6.Input − treeOutput − Maximum length cycle is − 5Explanation − The max height of left subtree is 3 and of right subtree is 1. Cycle length becomes 3+1+1=5. Cycle is 1-2-3-4-6 or 1-6-4-3-2Input − ... Read More

929 Views
We are given the Inorder and Preorder traversals of a binary tree. The goal is to construct a tree from given traversals.Inorder traversal − In this type of tree traversal, a left subtree is visited first, followed by the node and right subtree in the end.Inorder (tree root)Traverse left subtree of node pointed by root, call inorder ( root→left )Visit the rootTraverse right subtree of node pointed by root, call inorder ( root→right )Preorder traversal − In this type of tree traversal, the node visited first, followed by the left subtree and right subtree in the end.Preorder (tree root)Visit the ... Read More

206 Views
A Continuous Tree is defined as a tree with any path from root node to leaf node has value or weight of nodes such that the absolute difference between the parent node and all of its direct children nodes is always 1.If we pick any node on the path from root to leaf, then|weight of node-weight of left child node|=|weight of left child node-weight of node| = 1, this holds true for right child as well|weight of node-weight of right child node|=|weight lof right child node-weight of node| = 1DiagramLet us understand with examples.The tree below is continuous as absolute ... Read More

664 Views
Derangement is permutation of N numbers such that no number appears at original position. For example one possible derangement of { 1, 2, 3 } is { 2, 1, 3 }. No element in this is at its original position. The goal here is to count the possible derangements for N numbers.We will do this using a recursive solution. For following no. of elements −N=0, no derangement, return 1N=1, only one number, return 0N=2, only one swap of position possible, { 1, 2 } → { 2, 1 }, return 1N=3, 2 possible permutations eg, { 1, 2, 3 } ... Read More

3K+ Views
If we go by the term Content Management System word to word, then it basically means a system of managing the content. It is defined as a collaborative platform with different features and functionalities that allow the creating, designing, publishing and maintaining web content easily and effectivelWhat is a Content Management System (CMS)?A Content Management System is a software application used to create and design the web content online. It allows the users to manage the digital content easily by providing access to features like database handling, smart reporting, archiving, designing and animation features etc. These are generally used in ... Read More

126 Views
We are given a string containing (, ), {, }, [, ] characters only. The goal is to find the maximum length of such string so that it becomes balanced by swapping adjacent characters or removing a character. We will do this by comparing adjacent characters, if they are opposite of each other then they can be swapped. ( }{, )(, ][ can be swapped, while {{, )), [[, }}, )), ]] cannot be swapped ).Also if a character has no matching pair, then it can be removed also. ( “{{}][“, here first { can be removed and balanced string ... Read More