
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 10476 Articles for Python

732 Views
Suppose we have a number n, we have to check whether n can be expressed as a sum of two semi-primes or not.As we know the semi-prime is a number if it can be expressed as product of two primes number. First few semi-prime numbers are (1 - 100 range): 4, 6, 9, 10, 14, 15, 21, 22, 25, 26, 33, 34, 35, 38, 39, 46, 49, 51, 55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95.So, if the input is like n = 108, then the output will be True as this ... Read More

160 Views
Suppose we have an array called nums represents an encoding of a binary string of size k, we have to check whether given encoding uniquely finds a binary string or not. Here the encoding has counts of contiguous 1s which are separated by single 0s.So, if the input is like nums = [4, 2, 3] k = 11, then the output will be True as there is a binary string like 11110110111 of k = 11.To solve this, we will follow these steps −total := sum of all elements in numstotal := total + size of nums - 1return true ... Read More

581 Views
The Binary Search Tree (BST) is a widely used data structure that maintains the elements in a sorted hierarchical order. Each node in the BST follows the specific property: The values in the left subtree are always less than the values of the current node. The values in the right subtree are always greater than the node. In this article, we are going to learn about checking if an array represents the inorder of a BST or not in Python. Checking for inorder of the BST Inorder traversal is the ... Read More

179 Views
Suppose we have an array nums which only stores 1 and 2 in it. We have to check whether the array can be divided into two different parts such that sum of elements in each part is same.So, if the input is like nums = [1, 1, 2, 2, 2], then the output will be True as we can divide this array like [1, 1, 2] and [2, 2] the sum of each part is 4.To solve this, we will follow these steps −total := 0, one_count := 0total := sum of all elements of numsone_count := count of 1s ... Read More

2K+ Views
Suppose we have an array called nums. We also have two numbers x and y defining a range [x, y]. We have to check whether the array contains all elements in the given range or not.So, if the input is like nums = [5, 8, 9, 6, 3, 2, 4] x = 2 y = 6, then the output will be true as there are all elements [2, 3, 4, 5, 6].To solve this, we will follow these steps −temp_range := y - xfor i in range 0 to size of nums, doif |nums[i]| >= x and |nums[i]| 0, ... Read More

253 Views
Check if Array Can Be Divided into Pairs with Sum Divisible by K In this article, we are given an array of integers and a number k. The task is to determine whether it is possible to divide the entire array into pairs such that the sum of every pair is divisible by k. For example, if the given array of integers is [2, 4, 1, 3], and a value k = 5. The task is to form pairs (two elements at a time) from the array such that when you add each pair, the result is divisible by ... Read More

171 Views
Suppose we have a binary string str, we have to check whether all of the 1s in the string are equidistant or not. In other words, the distance between every two 1s is same. And the string contains at least two 1s.So, if the input is like s = "100001000010000", then the output will be True as the 1s are at distance 4 from each other.To solve this, we will follow these steps −index := a new listfor i in range 0 to size of s, doif s[i] is same as 1, theninsert i at the end of indext := ... Read More

246 Views
Suppose we have a number n, we have to check whether all sub-numbers of this number have unique digit product or not. As we know, n digit number has n*(n+1)/2 sub-numbers. For example, the sub-numbers of 135 are 1, 3, 5, 13, 35, 135. And the digit product of a number is product of its digits.So, if the input is like n = 235, then the output will be True as sub numbers are [2, 3, 5, 23, 35, 235], digit products are [2, 3, 5, 6, 15, 30]To solve this, we will follow these steps −Define a function dig_prod() ... Read More

136 Views
Suppose we have a number n denotes n people and there are two identical voting machines. We also have an array called time of size n such that time[i] represents total time spent by i-th person to vote on any machine. At one time instant, only one person can be there on each of the two machines. We also have another value x, representing the maximum allowable time for which machines are operational, we have to check whether all persons can place their vote or not.So, if the input is like n = 3, x = 7, time = [3, ... Read More

340 Views
Suppose we have a string s and another character c, we have to check whether all occurrences of c appear together in s or not. If the character c is not present in s then also return true.So, if the input is like s = "bbbbaaaaaaaccddd", c = 'a', then the output will be True.To solve this, we will follow these steps −flag := Falseindex := 0n := size of stringwhile index < n, doif string[index] is same as c, thenif flag is True, thenreturn Falsewhile index < n and string[index] is same as c, doindex := index + 1flag ... Read More