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 1804 of 2650
 
			
			1K+ Views
Suppose we have a DNA sequence. As we know, all DNA is composed of a series of nucleotides abbreviated such as A, C, G, and T, for example: "ACGAATTCCG". When we are studying DNA, it is sometimes useful to identify repeated sequences within the DNA.We have to write one method to find all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule.So if the input is like “AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT”, then the output will be ["AAAAACCCCC", "CCCCCAAAAA"].To solve this, we will follow these steps −Define an array ret, n := size of s, create two sets called visited ... Read More
 
			
			3K+ Views
Suppose we have to compare two version numbers version1 and version2. If the version1 > version2 then return 1; otherwise when version1 < version2 return -1; otherwise return 0. We can assume that the version strings are non-empty and contain only digits and the dot (.) characters. The dot character does not represent a decimal point and is used to separate number sequences. So for example, 2.5 is not "two and a half" or "halfway to version three", it is the fifth second-level revision of the second first-level revision.We can assume the default revision number for each level of a ... Read More
 
			
			3K+ Views
Suppose we have an integer n. We have to return 1 to n in lexicographic order. So for example when 13 is given, then the output will be [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9].To solve this, we will follow these steps −define one array ret of size ncurr := 1for i in range 0 to n – 1ret[i] := currif curr * 10 = n, then curr := curr / 10increase curr by 1while curr is divisible by 10, then curr := curr / 10return retExample(C++)Let us see the following implementation to get better understanding − Live Demo#include using namespace std; void print_vector(vector v){ cout
 
			
			415 Views
Suppose we have a 2D matrix called matrix, we have to find the sum of the elements inside the rectangle defined by its upper left corner using (row1, col1) and lower right corner using (row2, col2).So if the matrix is like −3014256321120154101710305The above rectangle with the blue color defined by (2, 1) and (4, 3), this contains sum 8.So if we perform some query like sumRegion(2, 1, 4, 3), sumRegion(1, 1, 2, 2), sumRegion(1, 2, 2, 4), these will return 8, 11, 12 respectively.To solve this, we will follow these steps −Define a matrix called dp.Initialize the task as followsn ... Read More
 
			
			285 Views
Suppose we have a list of folders, we have to remove all sub-folders in those folders and return in any order the folders after removing. Here if a folder[i] is located within another folder[j], it is denoted as subfolder of it. The paths will be like folder1/subfolder2/… etc.Suppose the input is like["/myfolder", "/myfolder/secondfolder", "/another/document", "/another/document/extrafolder", "/another/final"], then the output will be: ["/myfolder", "/another/final", "/another/document"]To solve this, we will follow these steps −sort the folder array based on the length of the pathscreate one map m, and another array ansfor i in range 0 to size of path array – 1s ... Read More
 
			
			679 Views
Suppose we have some coins. The i-th coin has a probability prob[i] of facing heads when tossed. We have to show the probability that the number of coins facing heads equals target if you toss every coin exactly once. So if the prob array is like [0.5, 0.5, 0.5, 0.5, 0.5] and target is 0, then the output will be 0.03125.To solve this, we will follow these steps −n := size of prob arraycreate one 2d array of size n x (target + 5)set dp[0, 0] = 1 – prob[0] and dp[0, 1] := prob[0]for i in range 1 to ... Read More
 
			
			1K+ Views
Suppose we have the availability time slots lists slots1 and slots2 of two people and a meeting duration d, we have to find the earliest time slot that works for both of them and is of duration d. If there is no common time slot that satisfies the requirements, then show an empty array. Here the format of a time slot is an array of two elements [start, end] representing an inclusive time range from start to end. we can assume that no two availability slots of the same person intersect with each other. That is, for any two time ... Read More
 
			
			688 Views
Suppose a die simulator generates a random number from 1 to 6 for each roll. We want to introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times. Consider we have an array of integers rollMax and an integer n, we have to return the number of distinct sequences that can be obtained with exact n rolls. The two sequences are considered different if at least one element differs from each other. So if n is 2, then rollMax = [1, 1, 2, 2, 2, 3], then the output will ... Read More
 
			
			540 Views
Suppose in a gold mine grid of size m * n, each cell in this mine has an integer representing the amount of gold in that cell, 0 means that is empty. We have to find the maximum amount of gold that you can collect under the conditions −Every time we are pointing a cell we will collect all the gold in that cell.From our position we can walk one step to the left, right, up or down.We cannot visit the same cell more than once.Never visit a cell with 0 gold.So if the input is like [[0, 6, 0], ... Read More
 
			
			375 Views
Suppose we have two integers low and high, we have to find and show a sorted list of all the Stepping Numbers in the range [low, high] inclusive. A Stepping Number is an integer means all of its adjacent digits have an absolute difference of exactly 1. For example, 321 is a Stepping Number but 421 is not. So if the input is like low := 0 and high := 21, then the result will be [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 21]To solve this, we will follow these steps −create one array tempmake ... Read More