
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++

845 Views
We are given an array of any size and the task is to find the subsequence in the given array with the elements having difference between adjacent elements as 0 or 1.Input − int arr[] = { 2, 1, 5, 6, 3, 4, 7, 6}Output − Maximum length subsequence with difference between adjacent elements as either 0 or 1 is − 3Explanation − The subsequence of adjacent elements in an array with difference as 0 or 1 are {2, 1}. Therefore, the maximum length of subsequence is 2.Input − int arr[] = { 2, 1, 7, 6, 5}Output − Maximum ... Read More

684 Views
We are given an array of any size and the task is to find the subarray of the given array with the elements having difference between adjacent elements as 0 or 1.Input − int arr[] = { 2, 1, 5, 6, 3, 4, 7, 6}Output − Maximum length subarray with difference between adjacent elements as either 0 or 1 are − 2Explanation − The adjacent elements in an array with difference as 0 or 1 are {2, 1}, {5, 6}, { 3, 4} and {7.6}. Therefore, the maximum length of subarray is 2.Input − int arr[] = { 2, 1, ... Read More

159 Views
We are given with an unsorted array of integer elements and the task is to calculate the two major things i.e.Elements with same number of set bitsAlso, Elements with the same set bits should be contiguous in nature.Inputint arr[] = { 5, 8, 1, 2, 9, 12}Output − Maximum number of contiguous array elements with same number of set bits are − 3Explanation − we will calculate the binary digits for the elements of an array and calculate their set bits.arr[0] = 5 => 0101 => total set bits are -: 2 arr[1] = 8 => 1000 => total set ... Read More

200 Views
We are given a big object let’s say, ‘a’ and a small object let’s say, ‘b’. The choices for the object ‘a’ and ‘b’ depend upon the user. In the example below, we are taking objects to be toys which are big as well as small as per the size characteristics. The task is to calculate the maximum number of big toys that can be achieved by giving the small toys in return.Input − big_toys = 8, small_toys = 20, a = 6, b = 4Output − Maximize big when both big and small can be exchanged are − 11Explanation ... Read More

356 Views
Suppose we have a digital clock of type HH:MM. Which shows the time in hours and minutes only. We are given a number of hours and minutes as input. The goal is to count the number of times all digits are the same. H=M.This happens 3 times a day, first at 00:00 midnight, then at 11:11 and last at 22:22. As time is represented in 24 hour format.InputInput: 12 hours 22 minutes.Output2Explanation − For times 00:00 and 11:11. Twice in 12 hours.InputInput: 48 hours 22 minutes.Output5Explanation − For times 00:00 and 11:11, 22:22 .Approach used in the below program is ... Read More

428 Views
We are given with integers N and K. We have binary strings of length N, containing 0’s and 1’s only. The goal is to find the number of such strings of length N that have K consecutive 1’s. I.e, if N=3, and K=2, then count all 3-digit binary strings possible that have 2 consecutive 1’s.Example − 111, here adjacent 1’s appear twice ( K times ).In 011 and 110 adjacent 1’s appeared once only.We will solve this by storing the results of previous values.Taking 3D array count[x][y][z]. Where x is N, y is K and z is last digit of ... Read More

783 Views
As the computing world is constantly improvising. Everyday a new device comes into picture which makes previous versions unfit for current technological changes and development. Gone are the days when computers were room sized and calculations take hours.From vacuum tubes, transistors and integrated circuits to touch screen devices, the technological advancement has changed the computing methods as well. The programming styles for new devices have also changed. Traditional ways of writing programs don’t work for them. The software embedded needs to be efficient, more responsive and interactive.The basic difference is revolutionized hardware devices that are faster, less heat emissions and ... Read More

750 Views
What is an Open Source?Open Source is the term generally referred to as Open Source Software (OSS) in the software world. An OSS is generally the one which is freely available on the internet, to use, modify, test, and develop further accordingly. OSS is more convenient to use by various users across the world as it is modifiable in nature. Users have the choice of adding or removing software patches to it according to their requirements.It has drastically changed the software world for the benefit of programmers, developers, testers who try their hands on by contributing to open source.Why contribute ... Read More

272 Views
We are given a Binary search tree as an input. The goal is to find the count of subtrees in BST which have node values in between the range of start and end. If start is 5 and end is 50. Then count subtrees in BST whose all nodes have weights >=5 and right = insert(70); ) and to the left of root ( root->left = insert(30); ).Variables l and h are used to store minimum and maximum value of a range.Variable count stores the count of BST’s inside the tree that are in range between l and h. Initially ... Read More

179 Views
We are given a binary sequence of 0’s and 1’s. Also assume a person is sitting at a position or point stored in current_pos. Now starting from current_pos, if the binary sequence has 0 then he moves one step left ( current_pos - 1). If it’s 1 he moves one step right ( current_pos + 1). The goal is to find distinct positions or points he visited after the whole binary sequence is completed.We will solve this using the number of times a point is visited. If frequency is non-zero, increase count of distinct points.InputPath[]= “001100” current_pos=3OutputDistinct points visited on ... Read More