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 1032 of 3366
 
			
			544 Views
Suppose we have an array nums and that is sorted in non-decreasing order. We have to make an array called result with the same length as nums such that result[i] is the summation of absolute differences between nums[i] and all the other elements in the array.So, if the input is like nums = [5, 7, 12], then the output will be [9, 7, 12] because|5-5| + |5-7| + |5-12| = 0+2+7 = 9|7-5| + |7-7| + |7-12| = 2+0+5 = 7|5-12| + |7-12| + |12-12| = 7+5+0 = 12To solve this, we will follow these steps −res := a new ... Read More
 
			
			641 Views
Suppose we have two arrays of called nums1 and nums2. The values in the arrays are between 1 and 6(inclusive). In one operation, we can update any value in any of the arrays to any value between 1 and 6. We have to find the minimum number of operations needed to make the sum of values in nums1 equal to the sum of values in nums2. We have to return -1 if it is not possible.So, if the input is like nums1 = [1, 5, 6], nums2 = [4, 1, 1], then the output will be 2 because we can ... Read More
 
			
			545 Views
Suppose we have a number n, we have to find the decimal value of the binary string by concatenating the binary representations of 1 to n one by one in order, if the answer is too large then return answer modulo 10^9 + 7.So, if the input is like n = 4, then the output will be 220 because, by concatenating binary representation from 1 to 4 will be "1" + "10" + "11" + "100" = 110111000, this is binary representation of 220.To solve this, we will follow these steps −ans := 1m := 10^9+7for i in range 2 ... Read More
 
			
			220 Views
Suppose we have two arrays called baseCosts with n items from them we can select base and toppingCosts with m items from them we can select toppings and also have a target value. We have to follow these rules to make dessert.There must be exactly one base.We can add one or more topping or have no toppings at all.There are at most two of each type of topping.Here baseCosts[i] represents the price of the ith ice cream base. The toppingCosts[i] represents price of one of the ith topping. The target value is representing the target price for dessert. We have ... Read More
 
			
			597 Views
Suppose we have an array called nums and another value k. In one operation, we can select two elements from nums whose sum is equals to k and remove them from the array. We have to find the maximum number of operations we can perform on the array.So, if the input is like nums = [8, 3, 6, 1, 5] k = 9, then the output will be 2 as we can delete [3, 6] whose sum is 9, then remove [8, 1] whose sum is also 9.To solve this, we will follow these steps −counter := a map holding ... Read More
 
			
			346 Views
Suppose there are several stones placed in a row, and each of these stones has an associated number which is given in an array stoneValue. In each round Amal divides the row into two parts then Bimal calculates the value of each part which is the sum of the values of all the stones in this part. Bimal throws away the part which has the maximum value, and Amal's score increases by the value of the remaining part. When the values of two parts are same, Bimal lets Amal decide which part will be thrown away. The next round starts ... Read More
 
			
			159 Views
Suppose we have two numeric strings s and t, we want to transform from string s to t using the following operation any number of times: 1. Select a non-empty substring in s and sort it inplace so the characters are in ascending order. We have to check whether it is possible to transform string s into string t or not.So, if the input is like s = "95643" t = "45963", then the output will be True because we can transform s into t using like "95643" -> "95463" -> "45963".To solve this, we will follow these steps −places ... Read More
 
			
			194 Views
Suppose, we are given a graph that contains n vertices numbered 0 to n - 1. The graph is undirected and each edge has a weight. The graph can have three types of weights and each weight signifies a particular task. There are two people that can traverse the graph, namely Jack and Casey. Jack can traverse the graph if an edge has weight 1, Casey can traverse the graph if it has weight 2, and both can traverse the graph if it has edge weight 3. We have to remove any edges necessary to make the graph traversable for ... Read More
 
			
			281 Views
Suppose we have one 2D array of characters called grid of size m x n. We have to check whether we can detect a cycle inside it or not. Here a cycle is a path of length 4 or more in the grid that starts and ends at the same position. We can move in four directions (up, down, left, or right), if it has the same value of the current cell, and we cannot revisit some cell.So, if the input is likemmmpmkmmmmsmftmmthen the output will be True, because the green cells are forming cycle.To solve this, we will follow ... Read More