
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
Found 26504 Articles for Server Side Programming

407 Views
Suppose we have a non-empty array containing only positive numbers, we have to find if the array can be partitioned into two subsets such that the sum of elements in both subsets is the same. So if the input is like [1, 5, 11, 5], the output will be true. As this array can be partitioned as [1, 5, 5] and [11]To solve this, we will follow these steps −n := size of the arraysum := 0for i := 0 to n – 1sum := sum + nums[i]if sum is odd, return falsesum := sum / 2create one array called ... Read More

357 Views
Consider we have a random list of people standing in a queue. If each person is described by a pair of integers (h, k), where h is the height and k is the number of people in front of him, who have a height greater than or equal to h. We have to define one method to reconstruct the queue. So if the given array is like [[7, 0], [4, 4], [7, 1], [5, 0], [6, 1], [5, 2]], then the output will be [[5, 0], [7, 0], [5, 2], [6, 1], [4, 4], [7, 1]]To solve this, we will ... Read More

300 Views
Suppose we have a string s, and we have to find the length of the longest substring T of that given string (consists of lowercase letters only) such that every character in T appears no less than k times. So if the string is “ababbc” and k = 2, then the output will be 3 and longest substring will be “ababb”, as there are two a’s and three b’s.To solve this, we will follow these steps −create one recursive function called longestSubstring(), this takes string s and size kif k = 1, then return the size of the stringif size ... Read More

3K+ Views
Suppose we have an encoded string; we have to return its decoded string. The rule for encoding is: k[encoded_string], this indicates where the encoded_string inside the square brackets is being repeated exactly k times. We can assume that the original data does not contain any numeric characters and that digits are only for those repeat numbers, k. So if the input is like “1[ba]2[na]”, then the output will be “banana”.To solve this, we will follow these steps −create one empty stack, set i := 0while i < size of a stringif s[i] is ‘]’res := delete element from the stack ... Read More

934 Views
Suppose a decimal number can be converted to its Hexspeak representation by converting it to an uppercase hexadecimal string at first, after that replacing all occurrences of the digit 0 with the letter O, and the digit 1 with the letter I.This kind of representation is valid if and only if it consists only of the letters in the set {"A", "B", "C", "D", "E", "F", "I", "O"}.So we have a string num representing a decimal integer N, we have to find the Hexspeak representation of N if it is correct, otherwise return "ERROR". So if num = “257”, then ... Read More

650 Views
Array transformation is a popular coding question asked in technical assessments and interviews. In this article, we will discuss the problem of array transformation with example testcases, the algorithm to solve it, and provide a C/C++ implementation. Array Transformation Based on Local Maxima and Minima In this problem, you are given an array of integers arr[] of size N. Every day the array undergoes a transformation which can be defined as follows: The first and last elements of the array are not transformed. For every other element arr[i] in the array, where 0 < i < N-1, ... Read More

509 Views
Suppose there are three integer arrays arr1, arr2 and arr3 and they are sorted in strictly increasing order, we have to return a sorted array of only the integers that appeared in all of these three arrays. So if arrays are [1, 2, 3, 4, 5], [1, 2, 5, 7, 9], and [1, 3, 4, 5, 8], so the output will be [1, 5]To solve this, we will follow these steps −define an array called rescreate three maps f1, f2 and f3for i in range 0 to length of arr1f1[arr1[i]] increase by 1for i in range 0 to length of ... Read More

1K+ Views
Suppose a dieter consumes calories[i], this indicates the calories on the i-th day. If we have an integer k, for every consecutive sequence of k days that is (calories[i], calories[i+1], ..., calories[i+k-1] for all 0 upper, so increase one point, lower = length of C, then come out from the looptemp := temp + C[right]return pointsExampleLet us see the following implementation to get better understanding − Live Democlass Solution(object): def dietPlanPerformance(self, c, k, l, u): temp = 0 for i in range(k): temp += c[i] right ... Read More

413 Views
Suppose, there is a special keyboard with all keys in a single row. So if we have a string of length 26 indicating the layout of the keyboard (indexed from 0 to 25), initially our finger is at index 0. To type a character, we have to move your finger to the index of the next character. The time taken to move your finger from index i to index j is denoted as |i - j|. So if we want to type a string. we have to define a function to calculate how much time it takes to type it ... Read More

321 Views
Suppose we have an array called, nums and that is sorted in non-decreasing order, and a number target. We have to find if the target is a majority element. In an array a majority element is an element that appears more than N/2 times in an array of length N. So if the array is like − [2, 4, 5, 5, 5, 5, 5, 6, 6] and target is 5, then output is true.To solve this, we will follow these steps −There will be two helping modules, lower() and upper(). These are as follows.The lower() takes two arguments array arr ... Read More