
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 1860 Articles for Data Structure

167 Views
In this problem, we will encode the string by inserting it in the matrix in a column-wise manner and printing the string in a row-wise manner. The naïve approach to solve the problem is to create a matrix, fill the matrix top-bottom manner, and print the string row-wise. The second solution is to use the vector to store the string and print each vector value individually. Here, we will learn both approaches to solve the problem. Problem statement – We have given string str of length N. Also, we have given the positive integer rows. The task is to encode ... Read More

226 Views
In this tutorial, we will learn the difference between the concatenation of string using the ‘+=’ or ‘+’ operator. Both operators are used to merge strings, but we learn some differences below with examples. What is Addition Assignment (+=) operator? The addition assignment (+=) operator concatenates the two strings. It takes two operands. The left operand is the original string, and the right operand is a string we need to concatenate with the original string. Generally, we use the ‘+=’ operator when we require to concatenate only two strings. Syntax Users can follow the syntax below to use the addition ... Read More

240 Views
In this problem, we need to decrypt the given ciphertext by traversing the matrix diagonally. We can solve the problem by traversing the matrix diagonally. Also, we require to traverse only the upper part of the matrix diagonally to get the decrypted string. Problem statement – We have given an encrypted string of length N and row counts. We need to put the string in the matrix in a row-wise manner. After that, we need to traverse the matrix diagonally, starting from the [0, 0] index to decrypt the string. Sample examples Input str = "TRSI_ _ _UIPN _ ... Read More

264 Views
A binary tree is a tree where each node has a maximum of two children. We are given a binary tree that consists of only 0 and 1 as the node values. We have to find the number of levels of the binary tree that consists of at least one 1 and all the ones of that level must be present consecutively. Example Let's understand with the help of an example − Input 0 / \ 1 0 / ... Read More

163 Views
A binary string is a string that only contains the binary numbers in it. In this problem, we are given a binary string, an array that represents the last index up to which we can flip the ones after starting from the ith index which will cost and cost for each index is given in another cost array. We have to perform some number of operations on the string to make the string completely zero. Example Let's understand the problem with the help of an example − Input string str = "101011" int arr[] = {1, 2, 2, 4, 5, ... Read More

112 Views
In this problem, we will count the number of strings we can create using the given frequencies such that the string contains same or different characters. We have four options to create a string of length 3 using the 0, 1, and 2 characters. The first string is 012, 000, 111, and 222. So, we need to count the total number of such strings to get the answer. Problem statement – We have given three integer values: X, Y, and Z. The X represents the frequency of the ‘0’, Y represents the frequency of the ‘1’, and Z represents the ... Read More

120 Views
In this problem, programmers require to make all characters of str1 equal to any character of str2 by performing the increment or decrement operation. Also, we can increment or decrement rotationally. It means ‘z’ + 1 ==‘a’ and ‘a’ – 1 == ‘z’. We can solve the problem by finding the minimum cost of making the str1 string’s character equal to any character of the string str2. For each character, we can find the minimum required operations and sum them all. Problem statement – We have given two strings named str1 and str2. The size of the str1 is ... Read More

211 Views
We are given two arrays of the same length and we have to apply some operations to get the product of the first array with all elements maximum. The operations are to multiply or add any element of the second array only once to any element of the first array only once. We can add or multiply two different elements from the second array element to a single first array element. After all operations, we have to take the product of all the elements of the first array and return that. Example Let's understand the problem with the help of ... Read More

186 Views
In this problem, we need to find the maximum consecutive zeros at the start and end of string rotation. We can follow two approaches to solve the problem. The first approach is to find all rotations of the given string and count start and end zeros. The second approach is to count the maximum consecutive zeros in the string and get the answer. Problem statement – We have given the binary string named str of size equal to ‘len’. We need to count the maximum number of consecutive zeros at the start and end of any rotation of the string. ... Read More

165 Views
In this problem, we need to perform the given queries on the string. We can solve the problem by making the rotations of the string differently and accessing the required characters using their index. Problem statement – We have given string str of length N and array ‘que’ of size M containing queries. We need to perform the queries given in the array according to the below conditions. (1, x) – Make x left rotations of the string. (2, x) – Show the xth character in the output. Sample examples Input que[][2] = {{1, 2}, {2, 1}, ... Read More