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

757 Views
Suppose there is a string. That string is called a magical string S, that consists of only '1' and '2' and obeys the following rules −The string S is magical because concatenating the number of contiguous occurrences of characters '1' and '2' generates the string S itself.The first few components of string S is the following − S = "1221121221221121122……"If we group the consecutive '1's and '2's in S, it will be − 1 22 11 2 1 22 1 22 11 2 11 22 ...... and the occurrences of '1's or '2's in each group are − 1 2 ... Read More

1K+ Views
Suppose we have the radius and x-y positions of the center of a circle, we have to write a function called randPoint() which generates a uniform random point in the circle. So there will be some important points that we have to keep in mind −Input and output values are in floating-point.Radius and x-y position of the center of the circle is passed into the class constructor.A point on the circumference of the circle is considered to be in the circle.The randPoint() returns x-position and y-position of the random point, in that order.So if the input is like [10, 5, ... Read More

502 Views
Suppose we have a dominator of m 0s and n 1s respectively. On the other hand, there is an array with binary strings. Now our task is to find the maximum number of strings that we can generate with given m 0s and n 1s. Each 0 and 1 can be used at most once. So if the input is like Array = [“10”, “0001”, “111001”, “1”, “0”, ] and m = 5 and n = 3, then the output will be 4. This is because there are totally 4 strings can be formed by the using of 5 0s ... Read More

349 Views
Suppose there is a little match girl. And we know exactly what matchsticks the little match girl has, we have to find out a way we can make one square by using up all those matchsticks. We should not break any stick, but we can link them up, and each matchstick must be used exactly one time. Our input will be several matchsticks the girl has, represented with their stick length. our output will be either true or false, to represent whether we could make one square using all the matchsticks the match girl has. So if the input is ... Read More

421 Views
Suppose we have a function rand7 which generates a uniform random integer in the range 1 to 7, we have to write another function rand10 which generates a uniform random integer in the range 1 to 10. We cannot use some library function to generate random numbers.Suppose we want two random numbers, so they may be [8, 10].To solve this, we will follow these steps −rand40 := 40while rand40 >= 40rand40 := (rand7() - 1) * 7 + (rand7() – 1)return rand40 mod 10 + 1Let us see the following implementation to get better understanding −Example Live Demo#include using namespace ... Read More

1K+ Views
Suppose there are n bulbs that are initially switched off. We first turn on all the bulbs. Then, we turn off every second bulb. On the third round, we toggle every third bulb (turning on if it's off or turning off if it's on). Similarly, for the i-th round, we toggle every i bulb. For the n-th round, we only toggle the last bulb. So we have to find how many bulbs are on after n rounds. So if the input is 3, then the result will be 1. This is because −At first, the three bulbs are [off, off, ... Read More

332 Views
Suppose we have an integer array arr and a target value target, we have to find the integer value such that when we change all the integers larger than value in the given array will be equal to value, the sum of the array gets as nearest as possible to target. If they are same, then return the minimum such integer. So if the array is like [4, 9, 3] and target is 10, then the output will be 3 as using 3, the array will be [3, 3, 3], so the sum is 9, that is nearest element to ... Read More

287 Views
Suppose we have an array of integers nums and a positive integer k, we have to find whether it's possible to divide this array into sets of k consecutive numbers. So we have to return True if its possible otherwise return False. So if the input is like [1, 2, 3, 3, 4, 4, 5, 6] and k = 4, then output will be true. This is because, we can divide the array such that [1, 2, 3, 4] and [3, 4, 5, 6]To solve this, we will follow these steps −Make one map m, set n := size of ... Read More

443 Views
Suppose we have an integer, that has sequential digits if and only if each digit in the number is one more than the previous digit. We have to find a sorted list of all the integers in the range [low, high] inclusive that have sequential digits. So if the low = 100 and high = 300, then the output will be [123,234]To solve this, we will follow these steps −create one array resfor i in range 1 to nfor j := 1, until j + i – 1

728 Views
Suppose we have an array of integers called nums and an integer k, that is threshold value, we will choose a positive integer divisor and divide all the array by it and sum the result of the division. We have to find the smallest divisor such that the result mentioned above is less than or equal to threshold value k. For example − if nums = [1, 2, 5, 9] and k = 6, then the output will be 5. We can get the sum as (1+2+5+9) = 17 when the divisor is 1. If the divisor is 4, then ... Read More