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 1430 of 2650
 
			
			308 Views
Suppose we have a list of strings where each string contains two letters "A"s and "B"s. We have two values a and b. We have to find the maximum number of strings that can be formed. We can use at most a number of "A"s and at most b number of "B"s, without reuse.So, if the input is like strings = ["AAABB", "AABB", "AA", "BB"] a = 4 b = 2, then the output will be 2, as we can take the strings using 4 "A"s and 2 "B"s ["AABB", "AA"].To solve this, we will follow these steps −pairs := ... Read More
 
			
			528 Views
Suppose we have a number n we have to find the number of stepping numbers of n digit. As we know a number is called stepping number when all adjacent digits have an absolute difference of 1. So if a number is 123, this is stepping number but 124 is not. If the answer is very large then return result mod 10^9 + 7.So, if the input is like n = 2, then the output will be 17, as the stepping numbers are [12, 23, 34, 45, 56, 67, 78, 89, 98, 87, 76, 65, 54, 43, 32, 21, 10]To ... Read More
 
			
			162 Views
Suppose we have a list of numbers representing the position of a car at equally spaced intervals of time. We have to find the size of the longest sublist where the car was traveling at a constant speed.So, if the input is like positions = [0, 4, 8, 12, 6, 4, 0], then the output will be 4, as the sublist is [0, 4, 8, 12].To solve this, we will follow these steps −j := 1max_cnt := 0, current := 0distance := |positions[0] - positions[1]|while j < size of positions, doprev := positions[j - 1]if distance is same as |positions[j] ... Read More
 
			
			248 Views
Suppose we have a list of numbers called pushes, and another list of numbers called pops, we have to check whether this is a valid sequence of stack push and pop actions or not.So, if the input is like pushes = [1, 2, 5, 7, 9] pops = [2, 1, 9, 7, 5], then the output will be True, as we can push [1, 2] first then pop them both. Then push [5, 7, 9] and pop them all.To solve this, we will follow these steps −s := a new stacki := 0for each ele in pushes, dopush ele into ... Read More
 
			
			148 Views
Suppose we have a 2D binary matrix, we have to find the total number of square submatrices with all 1 s are there.So, if the input is like11101110111000001011then the output will be 17 as there are 12 (1 x 1) squares, 4 (2 x 2) squares and 1 (3 x 3) square.To solve this, we will follow these steps −res := 0for i in range 0 to row count of matrix, dofor j in range 0 to column count of matrix, doif i is same as 0 or j is same as 0, thenres := res + matrix[i, j]otherwise when ... Read More
 
			
			194 Views
Suppose we have a list of numbers called nums and that is representing rocket's size and direction. Positive integer indicates right, and negative number represents left. And the absolute value of the number represents the rocket's size. Now when two rockets collide, the smaller one will be destroyed and the larger one will continue on its journey unchanged. When they are the same size rockets and they collide, they'll both destroy. When two rockets are moving in the same direction, they will never collide (assuming rockets speed are same). We have to find the state of the rockets after all ... Read More
 
			
			166 Views
Suppose we have a list of numbers called nums where each value represents a group of people looking to skydive together. And we have another value k representing how many days they can apply for skydiving. We have to find the minimum capacity of the plane we need to be able to fulfill all requests within k days. The requests should be fulfilled in the order they were given and a plane can only fly once a day.So, if the input is like nums = [16, 12, 18, 11, 13], k = 3, then the output will be 28, as ... Read More
 
			
			411 Views
Suppose we have adjacency list of a directed graph, where each list at index i is represented connected nodes from node i. We also have a target value. We have to find the length of a shortest cycle that contains the target. If there is no solution return -1.So, if the input is liketarget = 3., then the output will be 3, as the cycle is nodes 1 -> 2 -> 3 -> 1. Note there is another cycle 0 -> 1 -> 2 -> 3 -> 0, but this is not shortest.To solve this, we will follow these steps ... Read More
 
			
			311 Views
Suppose we have a list of lists called ports, where ports[i] represents the list of ports that port i is connected to. We also have another list of lists called shipments where each list of the sequence [i, j] which denotes there is a shipment request from port i to port j. And the cost to ship from port i to port j is the length of the shortest path from the two ports, we have to find the total cost necessary to complete all the shipments.So, if the input is like ports = [[1, 4], [2], [3], [0, 1], ... Read More
 
			
			146 Views
We are given a number d which represents the number of digits. The goal is to find the count of positive integers with 0 as a digit and have maximum d digits. Count all 1 digit, 2 digit, 3 digit….d digit positive numbers containing at least one 0.We will first find numbers the count of numbers that have d digits with at least one 0. Let’s say d=3. To make a 3-digit number with at least one 0, possible ways are −Here d1 can have 1 to 9 : 9 ways d2 can have 0-9 : 10 ways d3 can ... Read More