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 1923 of 2650
786 Views
Suppose we have a string s that is formed by digits ('0' - '9') and '#'. We have to map s to one English lowercase characters as follows −Characters ('a' to 'i') are represented by ('1' to '9') respectively.Characters ('j' to 'z') are represented by ('10#' to '26#') respectively.We have to find the string formed after mapping. We are taking one assumption that a unique mapping will always exist. So if the input is like “10#11#12”, then it will be “jkab”. As 10# is j, 11# is k, 1 is a and 2 is b.To solve this, we will follow ... Read More
829 Views
Suppose we have one ‘head’ which is a reference node to a singly-linked list. The value of each node present in the linked list is either 0 or 1. This linked list stores the binary representation of a number. We have to return the decimal value of the number present in the linked list. So if the list is like [1, 0, 1, 1, 0, 1]To solve this, we will follow these steps −x := convert the list elements into an arraythen reverse the list xans := 0, and temp := 1for i in range i := 0, to size ... Read More
627 Views
Suppose we have one 2D grid of size m x n. We have another variable k. We have to shift the grid k times. The shift operation will be as followsElement at grid G[i, j] moves to G[i, j + 1]Element at grid G[i, n – 1] moves to G[i + 1, 0]Element at grid G[m - 1, n – 1] moves to G[0, 0]So if the grid is like −123456789The output will be −912345678To solve this, we will follow these steps −The shift operation will take the matrix as inputn = number of rows, m := number of columns, ... Read More
411 Views
Suppose there are some chips, the i-th chip is at present at position chips[i]. We can perform any of the two following types of operations any many numbers of times as we want (possibly zero) on any chip −Move the i-th chip by 2 units to the left side or to the right side with a cost of 0.Move the i-th chip by 1 unit to the left side or to the right side with a cost of 1.Initially, there can be two or more chips. We have to return the minimum cost needed to move all the chips to ... Read More
367 Views
Suppose we have an array A of integers, we have to modify the array in the following way −We can choose an i and replace the A[i] with -A[i], and we will repeat this process K times. We have to return the largest possible sum of the array after changing it in this way.So, if the array A = [4, 2, 3], and K = 1, then the output will be 5. So choose indices 1, the array will become [4, -2, 3]To solve this, we will follow these steps −Sort the array Afor i in range 0 to length ... Read More
1K+ Views
Suppose we have an array with n integers, our task is to check whether it could become nondecreasing by modifying at most one element. We can define an array is non-decreasing if it satisfies this rule: array[i] 0if arr[i - 1] > arr[i + 1], then arr[i + 1] := arr[i]return trueExample (Python)Let us see the following implementation to get a better understanding − Live Democlass Solution(object): def checkPossibility(self, nums): if len(nums) nums[i+1]: if ans: return False ... Read More
751 Views
Suppose we have two binary trees and consider that when we put one of them to cover the other, some nodes of the two trees are overlapped while the others are overlapping. We have to merge them into a new binary tree. The merge rule is like that if two nodes are overlapping, then sum node values up as the new value of the merged node. Otherwise, the non-empty node will be used as the node of the new tree.So if the trees are −Then the output will be −To solve this, we will follow these steps −The method is ... Read More
339 Views
Suppose we have an integer array, we need to find one continuous subarray such that, if we only sort that subarray in ascending order, then the whole array will be sorted too. We need to find the shortest such subarray and output its length. So if the array is [2, 6, 4, 8, 10, 9, 15], then the output will be 5. The array will be [6, 4, 8, 10, 9]To solve this, we will follow these steps −res := sort the nums as an arrayans := 0set r as a linked listfor i in range 0 to the length ... Read More
278 Views
Suppose we have given a binary tree in which each node holds an integer key. We have to find the paths that sum to a given value. The path should start from root to leaf. We have to find the path where the sum is same.If the tree is like [5, 4, 8, 11, null, 13, 4, 7, 2, null, null, 5, 1], and sum is 22, then it will be −The paths are [[5, 4, 11, 2], [5, 8, 4, 5]].To solve this, we will follow these steps −Use the dfs function to solve this problem, the dfs is ... Read More
2K+ Views
Suppose we have a linked list. We have to check whether the list elements are forming a palindrome or not. So if the list element is like [1, 2, 3, 2, 1], then this is a palindrome.To solve this, we will follow these steps −fast := head, slow := head, rev := None and flag := 1if the head is empty, then return truewhile fast and next of fast is availableif next of the next of fast is available, then set flag := 0 and break the loopfast := next of the next of fasttemp := slow, slow := next ... Read More