- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 7346 Articles for C++
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
139 Views
We will be given an array that will contain the pairs which represent the range and their value will range from 0(inclusive) to N(exclusive). Here, N is the size of the binary string which we have to return as the answer. For all the given ranges we have to maximize the sum of the product of the frequencies of zero and one. We will implement two approaches one is the naive approach by finding all the strings and another is the efficient solution. Sample Examples Input 1 Given array: {{1, 3}, {2, 4}, {2, 5}} Length of string: 6 Output ... Read More
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
291 Views
Sorting an array means ordering all the elements of the array in increasing order. Sorting an array by swapping adjacent elements means we can only swap elements that are adjacent to each other but we can swap adjacent elements any number of times. We will be given a binary string that will contain only two types of characters ‘0’ and ‘1’. If any character is ‘0’ in the given string then we cannot swap the element present at that index of the array with adjacent elements. Sample Examples Input 1 Given array: {1, 4, 3, 2, 5, 7, 6} Given ... Read More
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
304 Views
A binary string is a string that contains only two different types of characters 0 and 1. We will be given two binary strings of the same length and our task is to make both of them equal by toggling two adjacent characters of the first string. Also, we have to do this in a minimum number of operations as possible. If it is not possible to convert the first string to the second string then return -1. Sample Example Input 1 string1: 101001 string 2: 100110 Output: 2 Explanation − We can toggle the second index character and the ... Read More
Max count of N using digits of M such that 2 and 5, and, 6 and 9 can be treated as same respectively
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
102 Views
Max count is a count which is the maximum possible. Here we have given an integer N and a string of integer M. Our task is to return the maximum count of making the number N using the digits of the string of integer M. Also given that, we can be treated 2 and 5, and, 6 and 9 can be same respectively. Sample Examples Input 1 N = 29 M = "2569783" Output 1: 2 Explanation − As 5 is the same as 2 and 6 is the same as 9 so we have a total of two ... Read More
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
200 Views
Inserting a number in the given number means adding a new given digit in the given number either at the front, end, or in between the numbers. We have given a number and a digit and have to add the digit in the number in a way such that the resultant new number will be minimum as possible. We will convert the number into a string to make the work of insertion easy. Also, the given number can be negative also so we have to consider this case. Sample Examples Input1 Given number: 124 Given digit: 3 Output: 1234 ... Read More
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
82 Views
A string will be given to us of length five which represents the time in the HH:MM format. There may be some ‘?’ present in the string and we have to replace them with any number such that the result is the valid time which could be the maximum possible. Also, the given string numbers will be valid, and ‘:’ will be present at the exact position of the string. We will use the two approaches first the brute force, and another the efficient approach. Sample Examples Input 1 Given string: 12:5? Output: 12:59 Explanation We have only one ... Read More
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
189 Views
Generating all possible strings is to replace a character of a string with a respective symbol and produce all possible strings. We will be given a string ‘s’ of size ‘N’ and an unordered map ‘mp’ of a pair of characters of size ‘M’. Here we can replace the mp[i][0] with mp[i][1] in the string ‘s’ and by doing this our task is to generate all possible strings. Sample Examples Input: s = “xyZ”, mp = {‘x’ : ‘$’, ‘y’ : ‘#’, ‘Z’ : ‘^’} Output: xyZ xy^ x#Z z#^ $yZ $y^ $#Z $#^ Explanation − In the ... Read More
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
131 Views
A binary string is a string that consists of only two different types of characters and that is ‘0’ and ‘1’. We will be given a binary string and the number m. We have to apply the operation to convert all the consecutive occurrences of the 0 and 1 that are ‘01’ and ‘10’ to ‘11’. One more condition is there that there must be only one neighbor of ‘0’ can be ‘1’. We can traverse over the string only m times where m will be given. Let’s understand with the following example Input 1: Given binary string: ‘01000101’ Given ... Read More
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
220 Views
Fibbinary Numbers are numbers that have no consecutive 1s in their binary representation. However, they can have consecutive zeros in their binary representation. Binary representation is the representation in which the numbers are shown with base 2 and only two digits that are 1 and 0 only. Here, we will be given a number and have to find whether the given number is the fibbinary number or not. Input 1: Given number: 10 Output: Yes Explanation − The binary representation of the given number 10 is 1010 which shows that, there is no consecutive one in the binary form. ... Read More
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
76 Views
In the normal number system, 0 is the smallest digit while 9 is the largest digit. In this problem, we will be given a list of the length 10, and starting from index 0 to index 9 it represents a digit, which indicates the priority of that digit and the list will be in increasing order means the digit present at the last index is the with highest priority. We will be given a number also and we have to find the next number which is the just greater than the current number. Input 1: Given number = “123” ... Read More