Arnab Chakraborty has Published 4293 Articles

Program to check whether given password meets criteria or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:24:05

629 Views

Suppose we have a string s, representing a password, we have to check the password criteria. There are few rules, that we have to follow −Password length will be At least 8 characters and at most 20 characters long.Password contains at least one digitPassword contains at least one lowercase character ... Read More

Program to find the nth row of Pascal's Triangle in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:21:42

970 Views

Suppose we have a number n, we have to find the nth (0-indexed) row of Pascal's triangle. As we know the Pascal's triangle can be created as follows −In the top row, there is an array of 1.Subsequent row is made by adding the number above and to the left ... Read More

Program to find maximum number of balanced groups of parentheses in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:16:27

450 Views

Suppose we have a string s that contains balanced parentheses "(" and ")", we have to split them into the maximum number of balanced groups.So, if the input is like "(()())()(())", then the output will be ['(()())', '()', '(())']To solve this, we will follow these steps −temp := blank stringgroups ... Read More

Program to count number of palindromes of size k can be formed from the given string characters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:05:34

411 Views

Suppose we have a string s that is representing alphabet characters and a number k. We have to find the number of palindromes where we can construct of length k using only letters in s. And we can use these letters more than once if we want.So, if the input ... Read More

Program to count number of valid pairs from a list of numbers, where pair sum is odd in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:04:00

375 Views

Suppose we have a list of positive numbers nums, we have to find the number of valid pairs of indices (i, j), where i < j, and nums[i] + nums[j] is an odd number.So, if the input is like [5, 4, 6], then the output will be 2, as two ... Read More

Program to check old and new version numbering are correct or not in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:02:42

176 Views

Suppose we have a strings older and another string newer. These two are representing software package versions in the format "major.minor.patch", we have to check whether the newer version is actually newer than the older one.So, if the input is like older = "7.2.2", newer = "7.3.1", then the output ... Read More

Program to find k-length paths on a binary tree in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 07:01:27

292 Views

Suppose we have a binary tree which contains unique values and we also have another value k, we have to find the number of k-length unique paths in the tree. The paths can go either from parent to child or from child to parent. We will consider two paths are ... Read More

Program to count number of elements in a list that contains odd number of digits in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:57:12

545 Views

Suppose we have a list of positive numbers called nums, we have to find the number of elements that have odd number of digits.So, if the input is like [1, 300, 12, 10, 3, 51236, 1245], then the output will be 4To solve this, we will follow these steps −c:= ... Read More

Program to find the sum of first n odd numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:55:44

10K+ Views

Suppose we have one number n, we have to find the sum of the first n positive odd numbers.So, if the input is like 7, then the output will be 49 as [1+3+5+7+9+11+13] = 49To solve this, we will follow these steps −if n is same as 0, thenreturn 0sum ... Read More

Program to find total number of strings, that contains one unique characters in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 06-Oct-2020 06:54:13

214 Views

Suppose we have a string s of lowercase letters, we have to find the total number of substrings that contain one unique character.So, if the input is like "xxyy", then the output will be 6 as substrings are [x, x, xx, y, y, yy]To solve this, we will follow these ... Read More

Advertisements