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
 
Programming Articles - Page 1024 of 3366
 
			
			194 Views
Suppose we have two strings s and t with only lowercase letters. In one operation, we can change any character in s or t to any lowercase letter. We have to satisfy one of the following three conditions −Every letter in s is strictly smaller than every letter in t in the alphabet.Every letter in t is strictly smaller than every letter in s in the alphabet.Both s and t consist of only one distinct letter.We have to find the minimum number of operations required to get the result.So, if the input is like s = "sts", t = "uss", ... Read More
 
			
			237 Views
Suppose we have an array enc. There is an array perm that is a permutation of the first n(odd) positive integers. This list will be encoded into array enc of length n-1, such that enc[i] = perm[i] XOR perm[i+1]. We have to find the original array perm.So, if the input is like enc = [2, 5, 6, 3], then the output will be [7, 5, 0, 6, 5], here [7 XOR 5 XOR 0 XOR 6 XOR 5] = [2, 5, 6, 3]To solve this, we will follow these steps −n := size of encresult := an array of size ... Read More
 
			
			205 Views
Suppose we have a number n, an array called 'languages', and an array called 'friendships', so there are n languages numbered from 1 through n, languages[i] represents a set of languages the ith user knows, and friendships[i] holds a pair [ui, vi] denotes a friendship between the users ui and vi. We can select one language and teach it to some users so that all friends can communicate with each other. We have to find the minimum number of users required to teach. (One thing we have to keep in mind that friendships are not transitive, so if x is ... Read More
 
			
			351 Views
Suppose we have an array called quality for each different worker, and have another array called wages and a value K. The i-th worker has a quality[i] and a minimum wage expectation wage[i]. We want to hire K workers to form a paid group. When we are hiring a group of K workers, we must pay them according to the following rules:Each worker in the paid group should be paid in the ratio of their quality by comparing with others in the paid group.Every worker in the paid group must be paid at least their minimum wage expectation.We have to ... Read More
 
			
			601 Views
Suppose we have a string s. We have to check whether we can split s into three palindromic substring or not.So, if the input is like s = "levelpopracecar", then the output will be True because we can split it like "level", "pop", "racecar", all are palindromes.To solve this, we will follow these steps −n := size of sdp := a matrix of order n x n and fill with falsefor i in range n-1 to 0, decrease by 1, dofor j in range 0 to n - 1, doif i >= j, thendp[i, j] := Trueotherwise when s[i] is ... Read More
 
			
			294 Views
Suppose we have N piles of stones arranged in a row. Here the i-th pile has stones[i] number of stones. A move consists of merging K consecutive piles into one pile, now the cost of this move is equal to the total number of stones in these K number of piles. We have to find the minimum cost to merge all piles of stones into one pile. If there is no such solution then, return -1.So, if the input is like nums = [3, 2, 4, 1], K = 2, then the output will be 20, because, initially have [3, ... Read More
 
			
			150 Views
Suppose we want to make a target string of lowercase letters. At first, we have the sequence as n '?' marks (n is the length of target string). We also have a stamp of lowercase letters. On each turn, we can place the stamp over the sequence, and replace every letter in the with the corresponding letter from that stamp. You can make up to 10 * n turns.As an example consider the initial sequence is "?????", and the stamp is "abc", then we may make strings like "abc??", "?abc?", "??abc" in the first turn. If the sequence is possible ... Read More
 
			
			4K+ Views
Suppose we have two matrices mat1 and mat2. We shall have to add these two matrices and form the third matrix. We shall have to do this by overloading the addition operator.So, if the input is like589679834763then the output will be131113131312To solve this, we will follow these steps −Overload the addition operator, this will take another matrix mat as second argumentdefine one blank 2d array vvDefine one 2D array vv and load current matrix elements into itfor initialize i := 0, when i < size of vv, update (increase i by 1), do:for initialize j := 0, when j < ... Read More
 
			
			477 Views
Suppose we have a Person class with two attributes first_name and the last_name. It also has two methods called get_first_name() and get_last_name() to retrieve or set first name and last name respectively. We shall have to overload the extraction operator (
 
			
			867 Views
Suppose we have an array called jobs, where jobs[i] indicates the amount of time needed to complete the ith job. We also have another value k, to them we can assign jobs. Each job should be assigned to exactly one worker. And the working time of a worker is the total time it takes to complete all jobs assigned to them. We have to find the minimum possible maximum working time of any assignment.So, if the input is like jobs = [2, 1, 3, 8, 5], k = 2, then the output will be 10 because, we can assign jobs ... Read More