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

125 Views
In this problem, we need to achieve the same string by performing the rotations of the string and need to count rotations. There can be different ways to solve the problem, but here we will learn some best approaches in PHP. The first approach uses the rotational substring, and another approach divides the string into two parts from the particular index. Problem statement − We have a string str containing n characters. We have to find the minimum rotations of string we should perform to achieve the same string again. Sample examples Input str = "bcbc"; Output ... Read More

185 Views
Problem statement − We have given the binary string of length N. We need to find the minimum number of flipping characters required to get the balanced binary string. Flipping characters means converting 0 to 1 and 1 to 0. If any string contains an equal number of ‘01’ and ‘10’ pairs, we can say that string is a balanced binary string. Sample examples Input str = "001010" Output 0 Explanation − The string contains 2 ‘01’ and ‘10’ pairs. So, we don’t need to perform any flipping operations. Input str = ‘00001’ ... Read More

260 Views
In this problem, we need to ensure whether the string String2 contains string String1 as a substring. We will first see the naïve approach to solving the problem, finding all substrings of String1’s length in String2 with String1. Furthermore, we will use built−in methods like match(), includes(), and indexOf() methods to find the String1 substring in the String2. Problem statement − We have given a string String1 and String2 of different sizes. We need to check whether string String1 is present in string String2 as a substring. Sample examples Input string1 = "tutor"; string2 = "pointtutorial"; Output ... Read More

351 Views
In this article, we will learn to count the total number of minimum required rotations to get the original string in Java. We can solve the problem by getting the rotations substrings of the original string or concatenating the original string to itself. Problem statement We have given string str of length N. The task is to find the total number of minimum rotations we need to perform to get the original string. Input 1 str = "bcdbcd"; Output 1 3 Explanation − We need to make 3 rotations to get the original string. ... Read More

198 Views
In this article, we will learn how to solve a problem where we are given an array of strings, and we need to make all strings equal by rotating them. This can be done by performing left rotations on the strings. We need to count the minimum number of operations required to do this. If it is impossible to make the strings equal, the output should be -1. Problem statement We have given an array containing n strings. All strings are permutations of each other. We need to count the total number of minimum operations required to make all strings ... Read More

303 Views
In this problem, we need to add spaces before the given indexes in the string. We can use two different approaches to solve the problem. The first approach moves the characters of the given string to add space at a particular index, and the second approach replaces the characters of the pre−initialize string with spaces. Problem statement − We have given string str of length N containing the alphanumeric characters. Also, we have given the spaceList array containing M positive integers representing the string index. We need to app space to the string before each index that exists in the ... Read More

694 Views
We need to find all palindrome strings from the given array in this problem. The string is a palindrome if we can read it the same from the start and end. We can use two approaches to check whether the string is a palindrome. In the first approach, we reverse the string and compare it with the original string, and in the second approach, we keep comparing the string characters from start to last. Problem statement − We have given an array containing the N strings. We need to print all the strings of the array, which are palindrome. If ... Read More

361 Views
In this problem, we need to decode the given string by repeatedly adding the total count number of times. We can have three different approaches to solving the problem, and we can use two stacks or one stack to solve the problem. Also, we can solve the problem without using the two stacks. Problem statement − We have given a string str containing the opening and closing brackets, alphabetical and numeric characters. We need to decode the string recursively. Here are the patterns or rules to decode the string. [chars] − The ‘chars’ should appear count times in ... Read More

250 Views
In this problem, we need to count the total vowels and constants in the given linked list. We can traverse the linked list and check for each character, whether it is a constant or vowel. Problem statement − We have given a linked list containing the lowercase alphabetical characters. We need to count the total number of vowels and constants in the linked list. Sample examples Input 'a' -> 'b' -> 'e', 'c' -> 'd' -> 'e' -> 'f'’ -> 'o' -> 'i' -> 'a' -> 'a' Output Vowel – 7, constant - 4 Explanation − ... Read More

102 Views
In this problem, we need to perform the given operations with each string prefix. In the end, we need to count the frequency of each character. We can follow the greedy approach to solve the problem. We need to take each prefix of length K and update its characters according to the given conditions. We can use the map to count the frequency of characters in the final string. Problem statement − We have given the strings tr containing the N lowercase alphabetical characters. Also, we have given the mapping list, which contains total 26 elements. Each element is mapped ... Read More