Count the Number of matching characters in a pair of string in Python

Pradeep Elance
Published on 04-Jun-2020 15:03:47
We are given two strings. We need to find the count it of the characters in the first string which are also present in a second string.With setThe set function gives us unique values all the elements in a string. We also use the the & operator which finds the ... Read More

Count Vowels Permutation in C++

Arnab Chakraborty
Published on 04-Jun-2020 15:03:36
Suppose we have one number n, we have to count how many strings of length n can be formed using these rules − Each character is a lower case vowel Each vowel 'a' may only be followed by an 'e'. Each vowel 'e' may only be followed by an 'a' ... Read More

Count of elements matching particular condition in Python

Pradeep Elance
Published on 04-Jun-2020 15:01:05
In this article we will see how to get some selected elements out of a Python list. So we need to design some condition and only the elements satisfying that condition should be picked and their count to be printed.Wit in and sumIn this approach we use in condition to ... Read More

Critical Connections in a Network in C++

Arnab Chakraborty
Published on 04-Jun-2020 14:59:57
Suppose there are n servers. And these are numbered from 0 to n-1 connected by an undirected server-to-server connections forming a network where connections[i] = [a, b] represents a connection between servers a and b. All servers are connected directly or through some other servers. Now, a critical connection is ... Read More

Count occurrences of an element in a list in Python

Pradeep Elance
Published on 04-Jun-2020 14:58:53
In this article we are given a list and a string. We are required to find how many times the given string is present as an element in the list.With CounterThe counter function from collections module will give us the count of each element present in the list. From the ... Read More

Count occurrences of a character in string in Python

Pradeep Elance
Published on 04-Jun-2020 14:57:03
We are given a string and a character. We want to find out how many times the given character is repeated in a given string.With range and lenWe design a for loop to match the character with every character present in the string which are accessed using index. The range ... Read More

Make Array Strictly Increasing in C++

Arnab Chakraborty
Published on 04-Jun-2020 14:56:02
Suppose we have two arrays arr1 and arr2, these can store integer numbers. We have to find the minimum number of operations needed to make arr1 strictly increasing. Here, we can choose two indices 0 <= i < n and 0 <= j < m and do the assignment arr1[i] ... Read More

Count occurrence of all elements of list in a tuple in Python

Pradeep Elance
Published on 04-Jun-2020 14:54:17
We have a list and tuple. We match the elements of the list with the elements of the tuple and account the number of elements in the table matching with the elements of the list.With CounterWe use the counter function from collections to get the count of every element in ... Read More

Last Substring in Lexicographical Order in C++

Arnab Chakraborty
Published on 04-Jun-2020 14:54:02
Suppose we have s as string, we have to find the last substring of s in lexicographic order.So, if the input is like "abbbcabbc", then the output will be "cabbc"To solve this, we will follow these steps −i := 0, j := 1, k := 0while j + k < ... Read More

Longest Chunked Palindrome Decomposition in python

Arnab Chakraborty
Published on 04-Jun-2020 14:51:56
Suppose we have a text. We have to find the largest possible k such that there exists a[1], a[2], ..., a[k] such that: Each a[i] is a non-empty string; Their concatenation a[1] + a[2] + ... + a[k] is equal to the given text; For all i in range 1 ... Read More
Advertisements