Server Side Programming Articles

Page 277 of 2109

Program to check points are forming convex hull or not in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 853 Views

Suppose we have outer points of a polygon in clockwise order. We have to check these points are forming a convex hull or not. ...

Read More

Program to find ith element by rotating k times to right

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 190 Views

Suppose we have an array nums, and a value k and another value i. We have to find the element at index i after rotating elements of nums, k number of times to the right. So, if the input is like nums = [2, 7, 9, 8, 10] k = 3 i = 2, then the output will be 10 because after 3rd rotation array will be [9, 8, 10, 2, 7], so now the ith element will be nums[2] = 10. Method 1: Using pop() and insert() We can simulate the rotation by moving the last ...

Read More

Program to count number of common divisors of two numbers in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 687 Views

When working with two numbers, we often need to find how many positive integers divide both numbers evenly. These are called common divisors. A key insight is that all common divisors of two numbers are also divisors of their GCD (Greatest Common Divisor). So, if the input is like a = 288 and b = 240, then the output will be 10 because the common divisors are [1, 2, 3, 4, 6, 8, 12, 16, 24, 48]. Algorithm To solve this problem, we follow these steps ? Find the GCD of ...

Read More

Python program to validate postal address format

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 1K+ Views

Postal address validation is important for ensuring data integrity in applications. A valid postal code must meet specific criteria including proper length, numeric format, and digit pattern restrictions. Validation Criteria A valid postal code must satisfy the following conditions ? It must be exactly 6 digits long It must be a number in the range from 100000 to 999999 (cannot start with 0) It must not contain more than one alternating repetitive digit pair (digits at positions i and i+2 should not be the same more than once) Example Let's implement a function ...

Read More

Python program to find ways to get n rupees with given coins

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 587 Views

Suppose we have coins of denominations (1, 2, 5 and 10). We need to find in how many ways we can make n rupees using these denominations. We have an array called count with 4 elements, where count[0] indicates number of coins of denomination 1, count[1] indicates number of coins of denomination 2, and so on. So, if the input is like n = 27 and count = [8, 4, 3, 2], then the output will be 18, meaning there are 18 possible combinations. Some of them are ? 10*2 + 5*1 + 2*1 = 27 10*2 ...

Read More

Python program to find word score from list of words

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 785 Views

Suppose we have a list of words in lowercase letters. We need to find the total score of these words based on specific vowel counting rules. Scoring Rules Consider vowels as [a, e, i, o, u, y] If a word contains an even number of vowels, its score is 2 If a word contains an odd number of vowels, its score is 1 The total score is the sum of all individual word scores Example Analysis For words = ["programming", "science", "python", "website", "sky"]: "programming" has 3 vowels (o, a, i) → ...

Read More

Program to remove duplicate characters from a given string in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 8K+ Views

When working with strings in Python, we often need to remove duplicate characters while preserving the order of first occurrence. This is useful in data cleaning, text processing, and algorithm problems. We can solve this using an ordered dictionary to maintain the insertion order of characters. The dictionary tracks which characters we've seen, and we can join the keys to get our result string. So, if the input is like s = "bbabcaaccdbaabababc", then the output will be "bacd". Algorithm Create an ordered dictionary to store characters in insertion order For each character c in ...

Read More

Program to rotate a string of size n, n times to left in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 762 Views

Suppose we have a string s of size n. We need to find all rotated strings by rotating them 1 place, 2 places, up to n places to the left. So, if the input is like s = "hello", then the output will be ['elloh', 'llohe', 'lohel', 'ohell', 'hello'] Approach To solve this, we will follow these steps − Create an empty result list Get the length of the string For each rotation from 1 to n places: Move the first character to the end Add the rotated string to the result ...

Read More

Python program to check credit card number is valid or not

Arnab Chakraborty
Arnab Chakraborty
Updated on 26-Mar-2026 4K+ Views

Credit card numbers must follow specific formatting rules to be considered valid. We need to check if a credit card number meets all the required criteria including format, length, and digit patterns. Credit Card Validation Rules A valid credit card number must satisfy these conditions ? Start with 4, 5, or 6 Be exactly 16 digits long Contain only numeric digits May have digits grouped in four sets separated by hyphens Must not use spaces, underscores, or other separators Must not have 4 or more consecutive identical digits Implementation Here's a complete solution ...

Read More

Python program to find factorial of a large number

Akshitha Mote
Akshitha Mote
Updated on 26-Mar-2026 924 Views

Before going to the solution let's understand about factorial. The factorial is a product of all the integers smaller than or equal to n. The mathematical representation is n! = n × (n-1) × (n-2) × ... × 1. For example, 4! = 4 × 3 × 2 × 1 = 24. In this article, let's explore different ways to find the factorial of a large number in Python. Various Methods Following are multiple ways to find the factorial of a large number in Python − Using 'math' Module ...

Read More
Showing 2761–2770 of 21,090 articles
« Prev 1 275 276 277 278 279 2109 Next »
Advertisements