- 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 1862 Articles for Data Structure
![Eva Sharma](https://www.tutorialspoint.com/assets/profiles/614747/profile/60_1298397-1678427862.jpeg)
310 Views
5, 55, 555, ... is a series that can be derived from geometric progression and, thus, computed with the help of GP formulae. Geometric progression is a type of series in which each succeeding term is the product of some specific term (ratio) with the preceding term. We will utilize the knowledge of GP, to find the sum of the given series. Problem Statement Given a number n, find the sum of the series 5+5+555+... up to n terms. Examples Input − N = 3 Output − 595 Explanation 5 + 5 + 555 = 595. ... Read More
![Eva Sharma](https://www.tutorialspoint.com/assets/profiles/614747/profile/60_1298397-1678427862.jpeg)
109 Views
There can be multiple combinations of numbers if taken 1 to n at a time. For example, if we take one number at a time, the number of combinations will be nC1. If we take two numbers at a time, the number of combinations will be nC2. Hence, the total number of combinations will be nC1 + nC2 +… + nCn. To find the sum of all combinations, we will have to use an efficient approach. Otherwise, the time and space complexities will go very high. Problem Statement Find the sum of products of all the combinations of numbers taken ... Read More
![Eva Sharma](https://www.tutorialspoint.com/assets/profiles/614747/profile/60_1298397-1678427862.jpeg)
96 Views
Sorting a vector using STL is a piece of cake. We can use the famous sort() function to perform the task. The real challenge is to count the number of factors for each number. A factor is a number which divides another number completely, i.e. with zero remainder. Traversing through all the numbers to count the factors might be an approach but we will try to optimize and reach efficient solutions in this article. Problem Statement Sort a given array based on the number of factors of each number in increasing order. Thus, the number having the lowest number of ... Read More
![Eva Sharma](https://www.tutorialspoint.com/assets/profiles/614747/profile/60_1298397-1678427862.jpeg)
87 Views
A number is p-friable for p-smooth if all of its prime factors are less than or equal to p. For example, 1620 is a 5-smooth number. Because, the prime factors of 1620 are: 2, 3, and 5. As it can be seen, 1620 is also a 7-smooth and 11-smooth number. Problem Statement Given two numbers N and P, we have to check if N is a P-friable number or not. Examples Input − N = 50, P = 7 Output − Yes, 50 is a 7-friable number. Explanation 50 can be prime factorized as: 5*5*5*5. Hence, ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
362 Views
In this problem, we need to convert one binary string to another binary string by flipping the characters of the string. We can hold any set bit and flip other bits, and we need to count the total operation to achieve another string by doing it. We can solve the problem based on the total number of ‘01’ and ‘10’ pairs in the given strings. Problem statement − We have given two strings named str1 and str2 of the same length containing ‘0’ and ‘1’ characters, representing the binary string. We need to convert the string str1 to str2 by ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
64 Views
In this problem, we need to find the reversible equal substring of maximum length from the start and end of the string. The problem is very similar to finding the palindromic string. We can start traversing the string and traverse the string until characters from the start and end match. Problem statement − We have given string str containing N characters. We need to check whether the string contains the reversible equal substring at the start and end of the string. If we find the substring according to the given condition, print the longest substring. Otherwise, print ‘false’ in the ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
109 Views
In this problem, we need to transform the string of a length greater than 2 into its abbreviation form. We can use the ‘length’ property of the string to count the total number of middle characters in the string, and we can first and last characters using the respected index value. Problem statement − We have given a string str of length greater than or equal to 2 and need to convert the string into its abbreviation form. The abbreviation form of the string is as shown here: first character + the total number of middle characters + last ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
152 Views
In this problem, we need to sort the given array of characters using a linked list. We can use bubble sort, selection sort, merger sort, etc. techniques to sort the array. Here, we will convert the array into the linked list first and then use the selection sort and bubble sort techniques to sort the array. Problem statement − We have given an array arr[] of length N. The array contains lowercase alphabetical characters. We need to sort the array using the linked list. Sample examples Input arr[] = {'e', 's', 'a', 'x', 'c', 'e', 'f', 'p', 'b', 'n', ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
52 Views
In this problem, we need to find the total number of rotations to get the same string. The naïve approach to solving the problem is that we can keep rotating the string. We can print the total number of required rotations if we find the same string. Also, other approaches take the substring from the string and make it equal to the original string. After that, we can get rotations using the substring length. Problem statement − We have given string str. We need to find the total number of rotations required to get the same string again. Sample examples ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
58 Views
In this problem, we will find all Lyndon words using the array's alphanumeric characters. Before we start, let’s understand the definition of the Lyndon word. All words are Lyndon words which are strictly lexicographically smaller than all of their rotations. Here are examples of Lyndon words. ab − The ‘ab’ is strictly lexicographically smaller than all of its permutations which is ‘ba’. 89 − The rotations of ‘89’ is ‘98’, which is strictly lexicographically larger than ‘89’. abc − The rotations of ‘abc’ are ‘bca’ and ‘cab’, which are strictly greater than ‘abc’. Here ... Read More