
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
Server Side Programming Articles - Page 876 of 2650

392 Views
Suppose we have a list of queries Q, where each query Q[i] contains a triplet [a_i, b_i and d_i]. Consider we are at position (0, 0) initially, then in one step we can move from some position (x1, y1) to (x2, y2) where Euclidean distance between these two points is at least a and at most b. Now for each queries we have to find minimum number of steps needed to reach (d_i, 0) from (0, 0).So, if the input is like Q = [(2, 3, 1), (1, 2, 0), (3, 4, 11)], then the output will be [2, 0, ... Read More

241 Views
Suppose we have an array called nums holding n-1 arithmetic sequence terms. One element except the first or last element of nums was removed before. We have to find the removed number.So, if the input is like nums = [5, 7, 11, 13], then the output will be 9 because, the items are following the formula 2i+5, so for i = 2 it will be 2*2 + 5 = 9 which is missing.To solve this, we will follow these steps −if size of nums is same as 2, thenreturn floor of (sum of all elements present in nums)/2if nums[0] is ... Read More

453 Views
Suppose we have a string s and another character c, c must be present in s, we have to find a list whose length is same as length of s where for each index i its value is set the closest distance of s[i] to c.So, if the input is like s = "ppqppq" c = "q", then the output will be [2, 1, 0, 1, 1, 0]To solve this, we will follow these steps −j := size of sd := [j - 1] * jx := index of c in sfor i in range 0 to j - 1, ... Read More

700 Views
Suppose we have a number n. We have to check whether this is power of 2 or not.So, if the input is like n = 2048, then the output will be True as 2048 is 2^11.To solve this, we will follow these steps −if n is same as 0, thenreturn Falsereturn true when (n AND (n - 1)) is same as 0 otherwise falseExampleLet us see the following implementation to get better understandingdef solve(n): if n == 0: return False return (n & (n - 1)) == 0 n = 2048 print(solve(n))Input2048 OutputTrue

3K+ Views
Suppose we have a number n, we have to check whether n is a perfect square number or not. A perfect square number k can be represented as k = a * a for some integer a. We have to solve this without using built-in square root function.So, if the input is like n = 121, then the output will be True because 121 = 11*11.To solve this, we will follow these steps −if n is same as 0 or n is same as 1, thenreturn Truestart := 2stop := floor of n / 2while start n, thenstart := ... Read More

106 Views
Suppose there are two spheres whose radius values are r1 and r2. They are at (x1, y1, z1) and (x2, y2, z2) coordinates. And their acceleration values are given like (ax1, ay1, az1) and (ax2, ay2, az2). We have to check whether these two spheres will ever meet on 3D space if they move with given acceleration or not.So, if the input is like r1 = 1 r2 = 2 pos1 = (0, 0, 0) acc1 = (100, 0, 0) pos2 = (4, 0, 0) acc2 = (0, 0, 0), then the output will be True, because second sphere has ... Read More

594 Views
Suppose we have an alphanumeric string s with digits from "0" to "9" and lowercase English letters. We have to find the sum of the numbers that are present in s. If digits are consecutive then consider them into a single number.So, if the input is like s = "hello25world63power86", then the output will be 174 because 25+63+86 = 174To solve this, we will follow these steps −ret := 0, curr := 0for each ch in s, doif ch is a digit, thencurr := 10 * curr + (ch as an integer)otherwise, ret := ret + currcurr := 0return ret ... Read More

282 Views
Program to find the maximum sum of the subarray modulo by m in PythonSuppose we have an array nums with n elements. We have another integer m. We have to find the maximum value of sum of any of its subarrays modulo m.So, if the input is like nums = [1, 5, 7, 3] m = 5, then the output will be 3 because[1] mod 5 = 1[5] mod 5 = 0[7] mod 5 = 2[3] mod 5 = 3[1, 5] mod 5 = 1[5, 7] mod 5 = 2[7, 3] mod 5 = 0[1, 5, 7] mod 5 = ... Read More

205 Views
Suppose we have a list called nums, we have to check whether we can rearrange the order of nums in such a way that the difference between every pair of consecutive two numbers is same.So, if the input is like nums = [8, 2, 6, 4], then the output will be True, because if we rearrange nums like [2, 4, 6, 8], then the difference between every two pair of consecutive numbers is 2.To solve this, we will follow these steps −N := size of numsif N

289 Views
Suppose we have list of numbers called nums and another two variables k and t. Let us consider an operation where we choose an element say e in range [-k, k] and insert it to nums at the end. We have to find the minimum number of operations needed so the sum of the nums equals to target.So, if the input is like nums = [3, 1] k = 4 t = 19, then the output will be 4 because we can add like [3, 1, 4, 4, 4, 3] to get the sum 19.To solve this, we will follow ... Read More