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 1011 of 3363
198 Views
Suppose, we are given a string 'input_str'. If we determine all the suffixes from input_str; for example if the string is 'abcd', the suffixes are 'abc', 'bcd', 'cd', 'd'. Now, we check the similarity between input_str and all the suffixes by the length of the longest common prefix in input_str and a suffix. The sum of the similarities between input_str and all the suffixes has to be returned.So, if the input is like input_str = 'tpotp', then the output will be 7All the suffixes from the string 'tpotp' are 'tpotp', 'potp', 'otp', 'tp', and 'p'.If we check the similarity of ... Read More
145 Views
Suppose, we are given a string 'input_str'. Now, we are asked to determine every possible substring from the given string then concatenate all the substrings one after another in a lexical order into another string. We are also provided an integer value k. Our task is to return the letter at index k from the concatenated string.So, if the input is like input_str = 'pqrs', k = 6, then the output will be pThe substrings from the given string in lexical order are p, pq, pqr, pqrs, q, qr, qrs, r, rs, s.If we concatenate the strings, it becomes ppqpqrpqrsqqrqrsrrss. ... Read More
231 Views
Suppose, we are given a number n and are asked to write all the possible permutations with the positive integers up to n. The permutations are then sorted lexicographically and numbered from 1 to n. Among all the permutations, one permutation is taken and is termed as the special permutation. Now, among the special permutation; the values can be forgotten. The forgotten values are then replaced with 0s. We have to find the permutations that can be equal to the original permutations and then we add their perspective number to obtain a sum. The sum value is returned as the ... Read More
1K+ Views
Suppose, we have to build a string 'str' that is of length n. To build the string, we can perform two operations.A character can be added to the end of str for cost a.A substring sub_str can be added to the end of the str for cost r.We have to calculate the minimum cost of building the string str.So, if the input is like a = 5, r = 4, str = 'tpoint', then the output will be 29.To build the string 'tpoint', the cost is described below −str = 't'; a new character added, therefore the cost is 5. ... Read More
374 Views
Suppose we have a binary string s. Now let us consider an operation, where we split the string into two non-empty substrings s1 and s2. The score of this split is the sum of "0"s count in s1 and sum of "1"s count in s2. We have to find the maximum score we can obtain.So, if the input is like s = "011001100111", then the output will be 8, because we can split the string like "01100" + "110111". Then, the score is 3 + 5 = 8.To solve this, we will follow these steps −ones := number of "1"s ... Read More
176 Views
Suppose we have a given matrix, We have to find a new matrix res, whose dimension is same as the given matrix where each element in res[i, j] = sum of the elements of matrix[r, c] for each r ≤ i, and c ≤ j.So, if the input is like8274then the output will be8101521To solve this, we will follow these steps −if matrix is empty, thenreturn matrixR := row count of matrixC := column count of matrixfor r in range 1 to R - 1, dofor c in range 0 to C - 1, domatrix[r, c] := matrix[r, c] + ... Read More
283 Views
Suppose we have a list called nums and a value k, now let us consider an operation by which we can update the value of any number in the list. We have to find the length of the longest sublist which contains repeated numbers after performing at most k operations.So, if the input is like nums = [8, 6, 6, 4, 3, 6, 6] k = 2, then the output will be 6, because we can change 4 and 3 to 6, to make this array [8, 6, 6, 6, 6, 6, 6], and the length of sublist with all ... Read More
231 Views
Suppose we have a list of lowercase alphabet strings called words. We have to find the length of the longest contiguous sublist where the first letter of each words have the same first letter.So, if the input is like words = ["she", "sells", "seashells", "on", "the", "sea", "shore"], then the output will be 3, the longest contiguous sublist is ["she", "sells", "seashells"]. The first letter for each words is 's'.To solve this, we will follow these steps −cnt := 1maxcnt := 0prev_char := blank stringfor each word in words, doif prev_char is empty, thenprev_char := first letter of wordotherwise when ... Read More
179 Views
Suppose we have three numbers n, a and b. Consider we are in a line of n people. And we are unaware about our position in the line. But we know there are at least a number of people in front of us and at most b number of people behind us. We have to find the number of possible positions possible for us.So, if the input is like n = 10 a = 3 b = 4, then the output will be 5, because there are 10 people in the line and at least 3 are in front and ... Read More
321 Views
Suppose we have three positive numbers say n, lower, and upper. We have to find a list whose length is n and that is strictly increasing and then strictly decreasing and all the numbers are in range [lower and upper] (both inclusive). And each increasing and decreasing parts should be non-empty. We have to find the lexicographically largest such list possible, if this is not possible, then return empty list.So, if the input is like n = 5 lower = 3 upper = 7, then the output will be [6, 7, 6, 5, 4], if we look closely, the [7, ... Read More