
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 26504 Articles for Server Side Programming

786 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.From this diagram it is clear that for each three consecutive points the interior angle is not more than 180°. So if all angles are not more than 180° then the polygon is convex hull.So, if the input is like points = [(3, 4), (4, 7), (7, 8), (11, 6), (12, 3), (10, 1), (5, 2)], then the output will be True.To solve this, we will follow these steps −n := size of pointsfor i in range ... Read More

360 Views
Suppose we have an array nums of some large numbers. The large numbers are in range (-2^31 to 2^31 - 1). We have to find the sum of these numbers.So, if the input is like nums = [5000000003, 3000000005, 8000000007, 2000000009, 7000000011], then the output will be 25000000035.To solve this, we will follow these steps −x := 0for initialize i := 0, when i < size of nums, update (increase i by 1), do −x := x + nums[i]return xExampleLet us see the following implementation to get better understanding#include #include using namespace std; long long int solve(vector nums){ long long int x = 0; for(int i=0; i

141 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.To solve this, we will follow these steps −for r in range 0 to k, dodelete last element from nums ... Read More

615 Views
Suppose we have two numbers a and b. We have to find how many positive integers are there, that are divisors to both a and b.So, if the input is like a = 288 b = 240, then the output will be 10 because the common divisors are [1, 2, 3, 4, 6, 8, 12, 16, 24, 48].To solve this, we will follow these steps −res := 0for i in range 1 to gcd(a, b) + 1, doif (a mod i) is 0 and (b mod i) is 0, thenres := res + 1return resExampleLet us see the following implementation ... Read More

1K+ Views
Suppose we have a postal code we have to check whether it is valid or not. A valid postal code has following criteriaIt must be a number in the range from 100000 to 999999 (both inclusive).It must not contain more than one alternating repetitive digit pair.So, if the input is like s = "700035", then the output will be True as this is in range 100000 to 999999 and there are no consecutive digits either.To solve this, we will follow these steps −n := size of snb := 0ok := Truefor i in range 0 to n - 1, dook ... Read More

487 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

497 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

705 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

685 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