- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 10783 Articles for Python
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
148 Views
Suppose we have three arrays A, B, C and another value called "sum", We have to check whether there are three elements a, b, c such that a + b + c = sum and a, b and c should be under three different arrays.So, if the input is like A = [2, 3, 4, 5, 6], B = [3, 4, 7, 2, 3], C = [4, 3, 5, 6, 7], sum = 12, then the output will be True as 4+2+6 = 12, and 4, 2, 6 are taken from A, B, C respectively.To solve this, we will follow ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
76 Views
Suppose we have an undirected graph of b number of nodes and a number of edges; we have to find minimum edges needed to build Euler Circuit in this graph.So, if the input is likethen the output will be 1.To solve this, we will follow these steps −Define a function dfs() . This will take g, visit, odd_vert, degree, comp, vvisit[v] := 1if degree[v] mod 2 is same as 1, thenodd_vert[comp] := odd_vert[comp] + 1for u in range 0 to size of g[v], doif visit[u] is same as 0, thendfs(g, visit, odd_vert, degree, comp, u)From the main method do the ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
173 Views
Suppose we have one binary string representing the scores of a volleyball match, we have to find the winner of the match based on following conditions −There are two teams play with each other and the team which scores 15 points first will be the winner except when both teams have reached to 14 points.When both teams have reached 14 points at that time the team maintaining a lead of two points will be the winner.From the given binary string, the 0 is representing team lose a point and 1 indicates team win a point. We have to check whether ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
56 Views
Suppose we have one A x B chessboard (matrix), we have to calculate the maximum numbers of cuts that we can make in this board so that the board is not divided into 2 parts.So, if the input is like A = 2 and B = 4, then the output will be 3To solve this, we will follow these steps −res := 0res :=(M - 1) *(N - 1)return resExampleLet us see the following implementation to get better understanding − Live Demodef max_cuts_count(M, N): res = 0 res = (M - 1) * (N - 1) return res ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
106 Views
Suppose we have an array A of positive integers, the elements are unique, now, two players P and Q are playing a game. At each move, any one player picks two numbers a and b from the array and if |a – b| is not in the array after that the player adds this number to the array. When a player cannot make the move loses the game. We have to find the winner of the game if player P always starts the game.So, if the input is like A = [8, 9, 10], then the output will be P.To ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
132 Views
Suppose we have a board of length p and width q; we have to break this board into p*q number of squares such that cost of breaking is as minimum as possible. Cutting cost for each edge will be given.So, if the input is like X_slice = [3, 2, 4, 2, 5], Y_slice = [5, 2, 3]then the output will be 65To solve this, we will follow these steps −res := 0horizontal := 1, vertical := 1i := 0, j := 0while i < m and j < n, doif X_slice[i] > Y_slice[j], thenres := res + X_slice[i] * verticalhorizontal ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
270 Views
Suppose we have a string s that represents a time in the 24 hours format as HH:MM so that HH will be in range 0 to 23 and MM will be in range 0 to 59, We have to find the next closest time which is a palindrome when read as a string. If there is no such string, then return -1.So, if the input is like "22:22", then the output will be "23:32".To solve this, we will follow these steps −n := size of shour_string := substring of s[from index 0 to 2]minute := substring of s[from index 3 ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
784 Views
Suppose we have a N*M matrix A, this is the representation of 3D figure. The height of the building at point (i, j) is A[i][j]. We have to find the surface area of the figure.So, if the input is like N = 3, M = 3, A = [[1, 4, 5], [3, 3, 4], [1, 3, 5]], then the output will be 72.To solve this, we will follow these steps −res := 0for i in range 0 to N, dofor j in range 0 to M, doup_side := 0left_side := 0if i > 0, thenup_side := array[i - 1, j]if ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
86 Views
Suppose we have an array of integers A; we have to find all the values for sum so that for a value sum[i] the array can be divided into sub-arrays of sum sum[i]. If we cannot divide the array into sub-arrays of equal sum then return -1.So, if the input is like A = [2, 4, 2, 2, 2, 4, 2, 6], then the output will be [6, 8, 12] as the array can be divided into sub-arrays of sum 6, 8 and 12. These are as follows: [{2, 4}, {2, 2, 2}, {4, 2}, {6}] [{2, 4, 2}, {2, ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
149 Views
Suppose we have three sorted arrays A, B, and C (these can be of different sizes), we have to find compute the minimum absolute difference between the maximum and minimum number of any triplet (A[i], B[j], C[k]) such that they are under arrays A, B and C respectively, So, if the input is like A : [ 2, 5, 6, 9, 11 ], B : [ 7, 10, 16 ], C : [ 3, 4, 7, 7 ] , then the output will be 1 as by selecting A[i] = 6 B[j] = 7 and C[k] = 7, we will ... Read More