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

659 Views
In this problem, we are given an array arr[] and Q queries, each can be one of the two types, {1, L, R}− For the count of array elements in the range [L, R].{2, index, val}− For updating the element at index with val.Our task is to create a program to solve the Queries for counts of array elements with values in given range in C++.Let’s take an example to understand the problem, Input:arr[] = {1, 5, 2, 4, 2, 2, 3, 1, 3}Q = 3Query = { {1, 4, 8}, {2, 6, 5}, {1, 1, 4}}Ouput:3 7ExplanationQuery 1: count ... Read More

375 Views
In this problem, we are given an arr[] and Q queries each consisting of a value m. Our task is to create a program to solve the Queries for counts of multiples in an array in C++.Problem DescriptionFor solving the queries, we need to count all the numbers that are multiples of m. For this we will check for elements divisible by m.Let’s take an example to understand the problem, Input:arr[] = {4, 7, 3, 8, 12, 15}Q = 3 query[] = {2, 3, 5}Ouput:3 3 1ExplanationQuery 1: m = 2, multiples in the array = 4, 8, 12. Count ... Read More

168 Views
In this problem, we are given a number N. Our task is to find the sum of first N natural numbers which are divisible by 2 and 7.So, here we will be given a number N, the program will find the sum of numbers between 1 to N that is divisible by 2 and 7.Let’s take an example to understand the problem, Input −N = 10Output −37Explanation −sum = 2 + 4 + 6 + 7 + 8 + 10 = 37So, the basic idea to solve the problem is to find all the numbers that are divisible by 2 ... Read More

272 Views
In this problem, we are given a set S of n number. Our task is to create a program to find the sum of subset difference which is the difference of last and first elements of subset.The formula is, sumSubsetDifference = Σ [last(s) - first(s)] s are subsets of the set S.Let’s take an example to understand the problem, Input −S = {1, 2, 9} n = 3Output −Explanation − All subset are −{1}, last(s) - first(s) = 0 {2}, last(s) - first(s) = 0 {9}, last(s) - first(s) = 0 {1, 2}, last(s) - first(s) = 1 {1, 9}, last(s) ... Read More

241 Views
In this problem, we are given string str. Our task is to create a program to find the sum of similarities of the string with all of its suffixes.Suffixes of string str are all the strings that are created by eliminating starting characters of the string.Similarities of string str1 and str2 is the length of the longest prefix common to both the string. For example, str1 = ‘abbac’ and str2 = ‘abb’ is 3.While str1 = ‘abca’ and str2 = ‘ca’ is 0. As we count from start.Let’s take an example to understand the problem, Input − str = ‘xyxyx’Output ... Read More

465 Views
In this problem, we are given a number n of the series. Our task is to find the sum of series 1^2 + 3^2 + 5^2 +... + (2*n - 1)^2 for the given value of n.Let’s take an example to understand the problem,Input −n = 5Output −84Explanation −sum = 1^2 + 3^2 + 5^2 + 7^2 + 9^2 = 1 + 9 + 25 + 49 = 84A basic approach to solve this problem is by directly applying the formula for the sum of series.Example Live Demo#include using namespace std; int calcSumOfSeries(int n) { int sum = 0; for (int i = 1; i

197 Views
In this problem, we are given 3 array X, Y, Z. Our task is to create a program to find the Sum of special triplets having elements from 3 arrays.Special Triplet is a special type of triplet that hold the following property −For (a, b, c): a ≤ b and b ≥ c, i.e the middle element of the triplet should be greeter that the other two.And, the value of the triplet is given by the formula −f(a, b, c) = (a+b) * (b+c)To create this triplet we need to use one element from each other the three arrays given.Let’s ... Read More

137 Views
In this problem, we are given a linked list with a node consisting of two values and a pointer. Our task is to create a program to find the sum of smaller elements of a node in a linked list.Here, in the linked list we have two elements say X and Y. The program will find a minimum of x and y. The minimum elements from all nodes are added which is the required result.Input −(5, 2)->(7, 9)->(6, 3)->(36, 24)->(19, 26)->nullOutput −55Explanation −Let’s take the minimum of X and Y from each node −node1 - mini = 5 node2 - ... Read More

1K+ Views
The block swap algorithm for array rotation is an efficient algorithm that is used for array rotation. It can do your work in O(n) time complexity.So, in array rotation, we are given an array arr[] of size n and a number k that define the no. of the element to be rotated.Let’s see an example on array rotations −Input −arr[] = {4, 6, 1, 8, 9, 2}, k = 2 (number of rotations.)Output −{1, 8, 9, 2, 4, 6}Explanation − On rotation, we will shift the one element to the last position and shift the next elements to one position.Element ... Read More

345 Views
BK tree or Burkhard tree is a form of a data structure usually used to perform spell checks based on Levenshtein distance. It is also used for string matching Autocorrect feature can be used making this data structure. Let's say we have some words in a dictionary and we need to check some other words for spelling errors. We need to have a collection of words that is close to the given word whose spelling is to be checked. For example, if we have the word “uck” The correct word can be (truck, duck, duck, suck). Therefore spelling mistakes can ... Read More