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
Programming Articles - Page 1000 of 3363
538 Views
Suppose we have given a coins of denominations (1, 2, 5 and 10). We have to find in how many ways can we can arrange n using these dominations. We have an array called count with 4 elements, where count[0] indicates number of coins of 1, count[1] indicates number of coins for 2 and so on.So, if the input is like n = 27 count = [8, 4, 3, 2], then the output will be 18 so there are 18 possible combinations some of them are10*2 + 5*1 + 2*1 = 2710*2 + 2*3 + 1*1 = 2710*1 + 5*3 ... Read More
524 Views
Suppose we have two list of numbers say nums1 and nums2. There are some elements not necessarily unique. But these two lists are actually representing different permutations of same set of numbers. However, some of them are missing. We have to find missing numbers of these two lists and print them all.So, if the input is like nums1 = [4, 5, 8, 8, 6, 9] nums2 = [3, 4, 4, 8, 8, 8, 6, 9, 5, 8], then the output will be [3, 4, 8, 8] because we can see 3 is not present in nums1, but it is in ... Read More
735 Views
Suppose we have few words in an array. These words are in lowercase letters. We have to find the total score of these set of words based on following rules −Consider vowels are [a, e, i, o, u and y]The score of an individual word is 2 when the word contains an even number of vowels.Otherwise, the score of that word is 1.The score for the whole set of words is the sum of scores of all words in the set.So, if the input is like words = ["programming", "science", "python", "website", "sky"], then the output will be 6 because ... Read More
8K+ Views
Suppose we have a string s. We have to remove all duplicate characters that have already appeared before. The final string will have same ordering of characters like the actual one.We can solve this by using ordered dictionary to maintain the insertion order of the characters. The value will be the frequency of those characters, however the frequency values are not important here. After forming the dictionary, we can simply take the keys and join them to get the string.So, if the input is like s = "bbabcaaccdbaabababc", then the output will be "bacd".d := a dictionary where keys are ... Read More
718 Views
Suppose we have a string s of size n. We have to find all rotated strings by rotating them 1 place, 2 places ... n places.So, if the input is like s = "hello", then the output will be ['elloh', 'llohe', 'lohel', 'ohell', 'hello']To solve this, we will follow these steps −res := a new listn := size of sfor i in range 0 to n, dos := (substring of s from index 1 to n-1) concatenate s[0]insert s at the end of resreturn resExampleLet us see the following implementation to get better understanding −def solve(s): res = [] ... Read More
3K+ Views
Suppose we have a credit card number. We have to check whether the card number is valid or not. The card numbers have certain properties −It will start with 4, 5 and 6It will be 16 digits’ longNumbers must contain only digitsIt may have digits in four groups separated by '-'It must not use any other separator like space or underscoreIt must not have 4 or more consecutive same digitsSo, if the input is like s = "5423-2578-8632-6589", then the output will be TrueTo solve this, we will follow these steps −if number of '-' in s is greater than ... Read More
500 Views
Suppose we have a number n. We have to find the sum of first n Fibonacci terms (Fibonacci sequence up to n terms). If the answer is too large then return result modulo 10^8 + 7.So, if the input is like n = 8, then the output will be 33 as first few Fibonacci terms are 0 + 1 + 1 + 2 + 3 + 5 + 8 + 13 = 33To solve this, we will follow these steps −m := 10^8+7memo := a new mapDefine a function solve() . This will take n, mif n is in memo, ... Read More
854 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)*(n-1)*....1 .For an example, 4! = 4*3*2*1 is 24. In this article let's try to find the different ways to find the factorial of a large number. Various Methods Following are multiple ways to find the factorial of a large number in Python − Using 'math' Module Using 'for' loop Using 'array' Using the ... Read More
512 Views
Suppose we have a list of rational numbers. We have to find their product using reduce function. The reduce() function applies a function with two arguments cumulatively on a list of objects from left to right.So, if the input is like fractions = [(5, 3), (2, 8), (6, 9), (5, 12), (7, 2)], then the output will be (175, 432) because 5/3 * 2/8 * 6/9 * 5/12 * 7/2 = (5*2*6*5*7)/(3*8*9*12*2) = 2100/5184 = 175/432.To solve this, we will follow these steps −fracs := a new listfor each f in frac, doinsert a new fraction object from (numerator, denominator) ... Read More
347 Views
Suppose we have a list of elements called nums, and a value k. We have to find those elements which have occurred at least k number of times.So, if the input is like nums = [2, 5, 6, 2, 6, 1, 3, 6, 3, 8, 2, 5, 9, 3, 5, 1] k = 3, then the output will be [2, 5, 6, 3]To solve this, we will follow these steps −c := a list containing frequencies of each elements present in numsres := a new listfor each key n in c, doif c[n] >= k, theninsert n at the end ... Read More