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 1748 of 2646
6K+ Views
Both HashTable and Dictionary are the type of data structure which are used to store data. Both of these data structures hold the stored data in key value pair.On the basis of difference between key features of these we can distinguish between HashTable and Dictionary as follows −Sr. No.KeyHashTableDictionary1DefinitionHashTable is the non-generic type of collection which is used to store data in key/value pair and is defined in System.Collections name space.On other hand Dictionary is a generic type collection defined under System.Collection.Generics name space which also store data in the form of key/value pairs.2DataTypeIn HashTable same or different data type ... Read More
2K+ Views
Suppose we have a number. The number can be anything in between 0 to 231 – 1. We have to convert the number into words. So if the number is like 512, then the result will be Five hundred twelve.To solve this, we will follow these steps −Define some lists like less_than_20, this will hold all words from one to nineteenAnother array like tens to hold tens, twenty, thirty and so on up to ninetyAnother array for thousands, to hold thousand, million and billionDefine one function called helper(), this will take nif n is 0, then return blank stringotherwise when ... Read More
259 Views
Suppose we have a binary tree. We have to find the post order traversal of this tree using iterative approach. So if the tree is like −Then the output will be: [9, 15, 7, 10, -10]To solve this, we will follow these steps −if root is null, then return empty arraycreate an array retstack := define a stack with pair [root, 0]while stack is not empty −node := top of stack, then delete element from stack.if second value of node pair is 0, thencurrent := first value of node pairinsert a pair (current, 1) into stackif right of current is ... Read More
342 Views
Suppose we have strings S and T. We have to count number of distinct sequences of S which is equal to T.We know that a subsequence of a string is a new string which is formed from the original string by removing some (can be none) of the characters without disturbing the relative positions of the remaining characters. (Like, "ACE" is a subsequence of "ABCDE" while "AEC" is not).If the input strings are “baalllloonnn” and “balloon”, then there will be 36 different ways to select.To solve this, we will follow these steps −n := size of s, m := size ... Read More
345 Views
Suppose we have one m * n matrix called mat, and an integer k, mat has its rows sorted in nondecreasing order. We can choose exactly one element from each row to form an array. We have to find the Kth smallest array sum among all possible arrays.So, if the input is like mat = [[1, 3, 11], [2, 4, 6]]1311246and k = 5, then the output will be 7, as when we choose one element from each row the first k smallest sums are [1, 2], [1, 4], [3, 2], [3, 4], [1, 6]. here the 5th sum is ... Read More
216 Views
Suppose there are n people and 40 different types of hats those are labeled from 1 to 40. Now a 2D list is given called hats, where hats[i] is a list of all hats preferred by the i-th person. We have to find the number of ways that the n people wear different hats to each other. The answer may come very large, so return the answer modulo 10^9 + 7.So, if the input is like [[4, 6, 2], [4, 6]], then the output will be 4, as there are 4 different ways to choose, these are [4, 6], [6, ... Read More
196 Views
Suppose we have an array called nums and an integer k, we have to find the maximum sum of a non-empty subsequence of that array such that for every two consecutive numbers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i k and first element of dq is same as dp[i - k - 1], thendelete front element from dqdp[i] := maximum of dp[i] and (if dq is empty, then dp[i] + 0, otherwise first element of dp + dq[i])while (not dq is empty and last element of dq < dp[i]), do −delete ... Read More
408 Views
Suppose there is a program that is used to print the array elements of an array A, but there was a little mistake in the program. In that program there was no white space after each element, so if we have one printed string, can we regenerate the array again? We know the array elements are in range 1 to k.Given the string s and the integer k. We have to find how many number of ways we can restore the array. The answer may be very large so return it modulo 10^9 + 7.So, if the input is like ... Read More
327 Views
Suppose we have grid of size n x 3 and we want to paint each cell of the grid with exactly one of the three colors. The colors are Red, Yellow or Green. Now there is a constraint that is no two adjacent cells have the same color. We have n the number of rows of the grid. We have to find the number of ways we can paint this grid. The answer may be very large so return it modulo 10^9 + 7.So, if the input is like 1, then the output will be 12To solve this, we will ... Read More
264 Views
Suppose Amal and Bimal are playing with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is a number given in the array called stoneValue.Amal and Bimal take turns, with Amal starting first. On each player's turn, he/she can take 1, 2 or 3 stones from the first remaining stones in the row.The score of each player is the sum of values of the stones taken. Initially the score is 0. The goal of the game is to end with the highest score, and the winner is the player with ... Read More