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

258 Views
Given an array of positive integers, the task is to erase a subarray containing all the unique elements. What you get by erasing the subarray is equal to the sum of its elements.Return the maximum sum of the current subarray by erasing the terms before or after it, we can get the maximum sum by erasing exactly one subarray.An array arr is called to be a subarray of a if it forms a contiguous subsequence of a that is if it is equal to a[l], a[l+1], ..., a[r] for some (l, r). For example, Input-1 −arr[ ] = { 1, 2, ... Read More

7K+ Views
A linked List is a linear data structure that has multiple nodes that are connected with each other. Each node consists of two fields Data Field and address of the next node.Let us assume we have given a singly linked list the task is to insert a node at the beginning of the given linked list. For example, Input-1 − 1 → 2 → 3 → 4Insert ‘5’ at the head or beginning of the given linked list.Output − 5 → 1 → 2 → 3 → 4Explanation − After inserting the node at the beginning of the linked list ... Read More

500 Views
Pandigital Number − In Mathematics, a Pandigital number is an integer that in a given base has among its significant digits each digit used in the base at least once.Pandigital numbers are the integers in which each digit is used as the base at least one time.For example, 1245678 is a pandigital number.Approach to solve this problemTake Input a number and a base.Check the base if it is less than 2 and greater than 10 then return 1 otherwise check the number if it is pandigital or not.An Integer function is_pandigital(long long n, int base) takes a number and a ... Read More

2K+ Views
Let’s Suppose we have given two strings ‘a’ and ‘b. We have to check that the given two strings are anagram of each other or not. Two Strings are said to be anagram of each other if one string contains the same character as another.For ExampleInput-1 −a= anagram b= gnaramaOutput −TrueExplanation − String ‘gnarama’ has the same character as String ‘anagram’ has. Hence we return True.Input-2 −a= programmer b= mprogretmrqpOutput −FalseExplanation − String ‘b’ has more characters than the string ‘a’ and thus we can say that the length of the string is different. Thus we return False.The approach used ... Read More

693 Views
Given an array of sorted numbers containing only 0s and 1s, find the transition point. A transition point is the index of the first ‘1’ appearing in the array. For example, Input-1 −N = 6 arr[ ] = {0, 0, 0, 0, 1, 1}Output −4Explanation − Since in the given array containing 0’s and 1’s we can see that the element at the index ‘4’ is having the number ‘1’.Input-2 −N = 5 arr[ ] = {0, 0, 1, 1, 1}Output −2Explanation − In the given array containing 0’s and 1’s, we can see that the element at the index ... Read More

1K+ Views
Suppose we have an array of integers of size N and a key K. Our task is to print the top K most frequent element of the array. For example, Input-1 −N = 6 K = 2 arr[ ] = {1 ,1, 1, 2, 2, 3}Output −1 2Explanation − In the given array of integers, the top K=2 elements whose frequency is most in the array are {1, 2}.Input-2 −N = 2 K = 1 arr[ ] = {1, 2}Output −1Explanation − In the given array of integers, the top K=1 elements whose frequency is most in the array are ... Read More

4K+ Views
Let’s suppose we have an array of integers of size N. The task is to find the most frequent element present in the given array of integers. For example, Input-1 −N = 8 A[ ] = {1, 2, 4, 3, 3, 1, 1, 5}Output −1Explanation − In the given array of integers, the most appearing number is ‘1’. Thus the output is ‘1’.Input-2 −N = 6 A[ ] = {1, 4, 4, 4, 1, 1}Output-a −1Output-b −4Explanation: In the given array of integers, the most appearing number is ‘1’ and ‘4’. Thus we can return the output to any one ... Read More

474 Views
We are given an array of unsorted integers, and the task is to find the missing positive integer. The given array may contain negative numbers, zeros, and duplicate values, all in any random order. Let's look at some example scenarios to understand the problem clearly- Scenario 1- Input: arr = [3, -2, 5, 1, -7, 4, -1, 8] Output: 2 Explanation: The number 2 is not present in the array, so the missing positive is 2 Scenario 2- Input: arr = [0] Output: 1 Explanation: In the given array, '1' is the only positive ... Read More

4K+ Views
We are given an array of unsorted integers of size N. The task is to find the distinct maximum and second maximum elements which are present in the array. The array may contain duplicate elements also, so we have to find only distinct elements. If there is no second maximum, we will return -1 for the second maximum. Let's look at some example scenarios to understand the problem clearly - Scenario 1- Input: N = 5, A[] = {2, 2, 1, 3, 4} Output: 4 and 3 Explanation: From the given array, we can see that '4' is ... Read More

477 Views
A linked list is a linear data structure that has multiple nodes that are connected with each other. Each node consists of two fields Data Field and address of the next node. Let us assume we have given a singly linked list the task is to find the kth node from the end in a given singly linked list. For example, Input −1→2→3→4→7→8→9 K= 4Output −Node from the 4th Position is − 4Explanation − Since in the given singly linked list ‘4th’ node from the end is ‘4’, we will return the output as ‘4’.Approach to solve this problemInitially, we ... Read More