
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

607 Views
Suppose we have a company name as string. We have to find the most common three characters from the company name and show them by following these rules −Pick most frequent three lettersSort them in descending orderIf the frequencies of some characters are same then take by their alphabetical orderSo, if the input is like s = "TUTORIALSPOINT", then the output will be [[3, 'T'], [2, 'I'], [2, 'O']]To solve this, we will follow these steps −x := a map containing letters and frequencies of letters in sres := a new listfor each i in x, doinsert pair (x[i], i) ... Read More

3K+ Views
Suppose we have a list of ordered points represents a simple polygon endpoint on a 2D plane. We have to find the area of this polygon.So, if the input is like points = [(0, 0), (0, 5), (3, 5), (3, 0)], then the output will be 15.To solve this, we will follow these steps −Define a function getInfo() . This will take x1, y1, x2, y2return x1*y2 - y1*x2From the main method, do the followingN := size of points(firstx, firsty) := points[0](prevx, prevy) := (firstx, firsty)res := 0for i in range 1 to N-1, do(nextx, nexty) := points[i]res := res ... Read More

571 Views
Suppose we have a numeric string s contains few digits. The digits may occur multiple times. We have to return some pairs (digit, count) represents which digit has occurred consecutively how many times in s. To solve this problem we can use the groupby() function that comes under itertools library. This will return one iterator object inside that each item will be at first place and another groupby objects at the second place. We have to count number of groupby objects for each pair.So, if the input is like s = "11522226551", then the output will be [(1, 2), (5, ... Read More

877 Views
Suppose we have a list of words. These words may occur multiple times. We have to show the frequencies of these words and count how many distinct words are there.So, if the input is like words = ["Book", "Sound", "Language", "Computer", "Book", "Language"], then the output will be (4, '2 1 2 1') because there are four distinct words, the first and third words have occurred twice.To solve this, we will follow these steps −d:= an OrderedDict to store items based on insert orderfor each w in words, doif w is in d, thend[w] := d[w] + 1otherwise, d[w] := ... Read More

2K+ Views
Suppose we have a list of ordered points represents a simple polygon endpoint on a 2D plane. We have to find the perimeter of this polygon.So, if the input is like points = [(0, 0), (0, 5), (3, 5), (3, 0)], then the output will be 16 becausetwo sides are of length 3 and two sides are of length 5, so 2*5 + 2*3 = 16.To solve this, we will follow these steps −Define a function getInfo() . This will take x1, y1, x2, y2return square root of ((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) which is Euclidean distancebetween (x1, y1) and (x2, y2)From the main ... Read More

497 Views
Suppose we have a list of data say x, represents a domain and a list of data y (size of y is same as size of x), represents a range. We have to check whether x -> y is a function or not. Here we are considering all elements in x and y are positive.So, if the input is like x = [1, 3, 2, 6, 5] y = [1, 9, 4, 36, 25], then the output will be True, because for each x, the corresponding y is its square value here, so this is a function.To solve this, we ... Read More

334 Views
Suppose we have an array nums with n different integers. We also have two disjoint sets A and B. We have one happiness parameter which is set to 0 initially. We go through each integer i in nums. If i is in A then add happiness by 1 and if i is in B decrease it by 1. We have to finally find the final happiness value.So, if the input is like nums = [1, 2, 5, 8, 6, 3] A = {5, 8, 9, 7, 3} B = {2, 4, 12, 15}, then the output will be 2 because ... Read More

121 Views
Suppose we have a number n. We have to find $e^{x}$ efficiently, without using library functions. The formula for $e^{x}$ is like$$e^{x} = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + ...$$So, if the input is like x = 5, then the output will be 148.4131 because e^x = 1 + 5 + (5^2/2!) + (5^3/3!) + ... = 148.4131...To solve this, we will follow these steps −fact := 1res := 1n := 20 it can be large for precise resultsnume := xfor i in range 1 to n, dores := res + nume/factnume := nume * xfact := fact ... Read More

2K+ Views
Suppose we have two sides of a right angled triangle, these sides are AB and BC. Consider the midpoint of hypotenuse AC is M. We have to find the angle between M and BC.So, if the input is like ab = 6 bc = 4, then the output will be 56.309932474020215 because arc_tan of ab/bc is 0.9828 but in degrees it is 56.31.To solve this, we will follow these steps −ans := arc-tan(ab/bc)return ans in degreesExampleLet us see the following implementation to get better understandingfrom math import atan, pi def solve(ab, bc): def deg(rad): return 180/pi ... Read More

3K+ Views
Suppose we have two times in this format "Day dd Mon yyyy hh:mm:ss +/-xxxx", where Day is three letter day whose first letter is in uppercase. Mon is the name of month in three letters and finally + or - xxxx represents the timezone for example +0530 indicates it is 5 hours 30 minutes more than GMT (other formats like dd, hh, mm, ss are self-explanatory). We have to find absolute difference between two timestamps in seconds.To solve this using python we will use the datetime library. There is a function called strptime() this will convert string formatted date to ... Read More