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

165 Views
Problem Statement We have given a string str and character c in the input. We need to insert the given character c in the string at the index so that we can convert the string to non-palindromic. If we can’t convert the string to non-palindrome, print ‘-1’. Sample Examples Input str = ‘nayan’, c = ‘n’ Output ‘nnayan’ Explanation There can be multiple output strings as we can insert ‘n’ at any index in the given string. So, the output string can be ‘nnayan’, ‘nanyan’, ‘naynan’, ‘nayann’, etc. Input str = ‘sss’, c = ‘s’ Output ‘-1’ ... Read More

547 Views
Problem Statement We have given a positive integer num. We need to find the lexicographically largest string of lowercase alphabetical characters such that the sum of all characters of the string is equal to num. Here, ‘a’ = 1, ‘b’ = 2, ‘c’ = 3, ‘d’ = 4, …., ‘z’ = 26. We need to use the ‘z’ characters at the string's start to create the largest lexicographical string. At last, we need to use the last character according to the num % 26 value. Sample Examples Input num = 30 Output ‘zd’ Explanation The ‘zd’ is the ... Read More

446 Views
Problem Statement We have given binary string str of length N. We need to find all permutations of the string, convert them to the decimal value, and return all unique decimal values. Sample Examples Input str = ‘1’ Output [1] Explanation All permutations of the ‘1’ is only ‘1’. So, the decimal value related to ‘1’ equals 1. Input str = ‘10’ Output [1, 2] Explanation The permutations of ‘10’ are only ‘01’ and ‘10’, equivalent to 1 and 2, respectively. Input ‘101’ Output [3, 5, 6] Explanation All possible permutations of ‘101’ are ... Read More

122 Views
Problem Statement We have given a two-dimensional array containing the pairs of starting and ending times for time intervals in the 12-hour format. Also, we have given string str in the 12-hour time format. We need to find a total number of intervals which included the time represented by str. Sample Examples Input arr[][2] = {{“12:02:AM”, “10:55:PM”}, {“12:51:AM”, “11:40:AM”}, {“01:30:AM”, “12:00:PM”}, {“11:57:PM”, “11:59:PM”}}, str = “2:30:AM” Output 3 Explanation The time “2:30:AM” intersects the first three intervals. Input arr[][2] = {{“01:02:PM”, “10:55:PM”}, {“01:30:AM”, “11:00:AM”}}, str = “11:30:PM” Output 0 Explanation The ... Read More

339 Views
Problem Statement We have given string str and a binary string B. The length of both strings is equal to the N. We need to check if we can make string str palindromic by swapping the characters of it multiple times at any pair of indices that contains unequal characters in string B. Sample Examples Input str = ‘AAS’ B = ‘101’ Output ‘YES’ Explanation We can swape the str[1] and str[2] as B[1] and B[2] are not equal. The final string can be ‘ASA’. Input str = ‘AASS’ B = ‘1111’ Output ‘No’ Explanation ... Read More

8K+ Views
In C++, the string is a collection of various alphanumeric and special characters. We can create a string using the ‘string’ data type in C++. Problem Statement We have given a length of the string and one single character, and we require to generate a string of a given length containing the single character. In C++, we can define the string of a particular length by hard coding the values, but when we require to generate a string of different lengths and use the given character, we require to use the below approaches. Sample Examples Here are the sample ... Read More

276 Views
Problem Statement We have given a string ‘str’, containing the alphabetical characters in uppercase or lowercase. We require to check if uppercase characters are used correctly in the string. Followings are the correct way to use uppercase characters in the string. If only the first character is in uppercase, the other characters are in lowercase. If all characters of a string are in lowercase. If all characters of the string are in uppercase. Sample examples Input "Hello" Output "valid" Explanation In "Hello", only the first character is in uppercase, and others are in lowercase, so it ... Read More

1K+ Views
In this problem, we will sort the array of strings in the lexicographical order. There are various sorting algorithms to sort the array of strings. In this tutorial, we will use the built−in sort() method to sort the strings. Also, we will use the merge sort algorithm, one of the efficient approaches to sort the array of strings. Problem statement − We have given an str[] array containing N strings. We need to sort all strings in the lexicographical order. Sample examples Input str[] = {"tutorials", "point", "save", "java", "c++"} Output c++, java, point, save, tutorials ... Read More

334 Views
In this problem, we will perform M reverse queries on the given string according to the array values. The naïve approach to solving the problem is to reverse each string segment according to the given array value. The optimized approach uses the logic that when we reverse the same substring two times, we get the original string. Problem statement − We have given an alpha string containing the alphabetical characters. Also, we have given an arr[] array of size M containing the positive integers. We need to perform the M operations on the given string and return the final ... Read More

211 Views
In this problem, we will count the number of characters whose frequency and position have the same parity and print the count of the number as odd or even. To solve the problem, we can find the frequency of each character in the string, and count total characters whose freqeuncy and position have the same parity. After that, we can print the odd or even answer based on the counts. Problem statement − We have given a string alpha containing only lowercase english alphabetical characters. We need to check whether the number of characters having equal parity of their alphabetical ... Read More