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

680 Views
We are given a string containing only digits from 0 to 9, and we need to check whether it is an additive number. An additive number is a string that can form an additive sequence, where each number (starting from the third) is the sum of the previous two. For the sequence to be valid, it must have at least three numbers. Let's look at the example scenarios to understand the problem clearly: Scenario 1 Input: "112358" Output: true Explanation: The digits can form the sequence: 1, 1, 2, 3, 5, 8 Here, 1 + 1 = 2 1 ... Read More

277 Views
Suppose we have an array of citations (The citations are non-negative integers) of a researcher. These numbers are sorted in non-decreasing order. We have to define a function to compute the researcher's h-index. According to the definition of h-index: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each."So if the input is like citations = [0, 1, 4, 5, 6], then the output will be 3, as it indicates that the researcher has five papers, they have got ... Read More

752 Views
Suppose we have an array of citations (The citations are non-negative integers) of a researcher. We have to define a function to compute the researcher's h-index. According to the definition of h-index: "A scientist has index h if h of his/her N papers have at least h citations each, and the other N − h papers have no more than h citations each."So if the input is like citations = [3, 0, 6, 1, 7], then the output will be 3, as it indicates that the researcher has five papers, they have got 3, 0, 6, 1, 7 citations respectively. ... Read More

290 Views
Suppose we have to find the nth ugly number, so we have to define a method that can find it. As we know that the ugly numbers are those numbers, whose prime factors are only 2, 3 and 5. So if we want to find 10th ugly number, that will be 12, as the first few ugly numbers are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12To solve this, we will follow these steps −Make an array v, of size n + 1if n = 1, then return 1two := 2, three = 3 and five = 5, ... Read More

418 Views
Suppose we have an array, there exactly two elements appear once, but others are appearing twice. So we have to define a function, that will find these two numbers. So if the given array is like [1, 2, 3, 1, 5, 2], then the output will be [3, 5].To solve this, we will follow these steps −xor_res := 0for i in range 0 to size of numsxor_res := xor_res XOR nums[i]pos := 0while xor_res AND 2^pos = 0, do, increase pos by 1num1 := 0for i in range 0 to size of nums – 1if nums[i] and 2 ^ pos ... Read More

978 Views
Suppose we have a string of numbers and operators, we have to find all possible results from computing all the different possible ways to group the numbers and operators. Here the valid operators are +, - and *. So if the input is like “2*3-4*5”, then the output will be [-34, -14, -10, -10, 10]. This is because −(2*(3-(4*5))) = -34((2*3)-(4*5)) = -14((2*(3-4))*5) = -10(2*((3-4)*5)) = -10(((2*3)-4)*5) = 10To solve this, we will follow these steps −Define a map called a memo.Define a method called solve(). This will take the input string as input.create an array called retif the memo ... Read More

314 Views
Suppose we have one integer array; we have to find those elements that appear more than floor of n/3. Here n is the size of array.So if the input is like [1, 1, 1, 3, 3, 2, 2, 2], then the results will be [1, 2]To solve this, we will follow these steps −first := 0, second := 1, cnt1 := 0, cnt2 := 0, n := size of array numsfor i in range 0 to size of n – 1x := nums[i]if x is first, then increase cnt by 1, otherwise when x is second, then increase cnt2 by ... Read More

383 Views
Suppose we want to find the total area covered by two rectilinear rectangles in a 2D plane. Here each rectangle is defined by its bottom left corner and top right corner as shown in the figure.To solve this, we will follow these steps −if C = E or A >= G or B >= H or D = H || D

329 Views
Suppose we have an array of integers, we have to check whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t. And the absolute difference between i and j is at most k. So if input is like [1, 2, 3, 1], then if k = 3 and t = 0, then return true.To solve this, we will follow these steps −Make a set s, n := size of nums arrayfor i in range 0 to n – 1x is index of set element starting ... Read More