Found 26504 Articles for Server Side Programming

Decode a String Recursively Encoded as Count followed by Substring

Shubham Vora
Updated on 14-Aug-2023 13:00:40

365 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

Count the Number of Vowels and Consonants in a Linked List

Shubham Vora
Updated on 14-Aug-2023 12:58:00

254 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

Count of each Lowercase Character after Performing described Operations for each Prefix of Length 1 to N

Shubham Vora
Updated on 14-Aug-2023 12:56:32

103 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

Check if a String is Present in the given Linked List as a Subsequence

Shubham Vora
Updated on 14-Aug-2023 12:46:30

232 Views

In this problem, we will check if the linked list contains the string as a subsequence. We can iterate the list and string together to check whether a string is present as a subsequence in the linked list. Problem statement − We have given a string of size N. Also, we have given a linked list of the dynamic length containing the alphabetical characters. We need to check whether the linked list contains the string as a subsequence. Sample examples Input 'e' -> 'h' -> 'e' -> 'k' -> 'h' -> 'e' -> 'l' ->'o' -> 'l' -> 'o' ... Read More

C++ Program for Generating Lyndon Words of Length n

Shubham Vora
Updated on 14-Aug-2023 12:42:40

134 Views

In this problem, we need to generate the Lyndon words of the length n using the given characters. The Lyndon words are words such that any of its rotations is strictly larger than itself in the lexicographical order. Here are examples of Lyndon words. 01 − The rotations of ‘01’ is ‘10’, which is always strictly greater than ‘01’. 012 − The rotations of ‘012’ is ‘120’ and ‘210’, which is strictly greater than ‘012’. Problem statement − We have given an array s[] containing numeric characters. Also, we have given n representing the length ... Read More

Filter key from Nested item using Python

Tapas Kumar Ghosh
Updated on 14-Aug-2023 12:36:01

961 Views

Python can extract a specific value from a complex data structure that has nested dictionaries or lists by filtering a key from a nested item. The key is a unique identifier for a certain value inside the nested item. Based on this problem statement it has various application domains such as data manipulation, data interaction, and, API interaction. Syntax The following syntax is used in the examples- append() This is a built−in method in Python that adds the element at the end of the list. isintance() Python has a built−in function called isinstance() that determines whether an object ... Read More

Python - Find Minimum Pair Sum in list

Tapas Kumar Ghosh
Updated on 14-Aug-2023 12:34:34

665 Views

The Minimum pair sum is defined by finding the smallest possible sum of two numbers taken from a given list of numbers. It can be used to solve challenges when minimizing the total of two elements is important, such as reducing the cost, distance, or time necessary for a certain operation. In Python, we have some built−in functions like float(), sort(), combination(), and, range() will be used to find the minimum pair sum in a list. Syntax The following syntax is used in the examples- float('inf') The float() is a built−in method in Python that accepts the parameter to ... Read More

Python - Find Index Containing String in List

Tapas Kumar Ghosh
Updated on 16-Aug-2023 10:41:50

2K+ Views

Sometimes working with Python string, we may come across a real-world scenario where it can be useful for text parsing, pattern matching, and extracting specific information from text data. In Python, we have some built-in functions such as type(), index(), append(), and, isinstance() will be used to find the index containing String in List. Let’s take an example of this: The given input string, my_list = [108, 'Safari', 'Skybags', 20, 60, 'Aristocrat', 78, 'Raj'] Output 1, 2, 5, 7 Explanation The variable name my_list stores the input list that contains the mixing of integer and string in ... Read More

Find the Index of Maximum Item in a List using Python

Tapas Kumar Ghosh
Updated on 14-Aug-2023 12:29:42

14K+ Views

In Python, the index of maximum item refers to a specific index in which the item will be greater than all the elements of the list. In Python, we have some built−in functions len(), max(), series(), idxmax(), and index() that can be used to find the index of maximum item in a list. Let’s take an example of this. The given string, [61, 12, 4, 5, 89, 7] So, the maximum present index becomes 4 i.e. 89. Syntax The following syntax is used in the examples- len() The len() is a built−in method in Python that returns the object ... Read More

Python - Inter Matrix Grouping

Tapas Kumar Ghosh
Updated on 14-Aug-2023 12:22:26

148 Views

The Inter Matrix Grouping is the set of two different lists where the sublist of first element will be considered to be common matches and if the matches are found it makes the first element as key in the dictionary, and the rest two elements are set for matrix grouping. In Python, we have some built−in functions such as setdefault(), defaultdict(), and, append() will be used to solve the Inter Matrix Grouping. Let’s take an example of this. The given two lists are: list_1 = [[1, 2], [3, 4], [4, 5], [5, 6]] list_2 = [[5, 60], [1, 22], [4, ... Read More

Advertisements