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 1633 of 2650
381 Views
Suppose we have two arrays P and Q whose size are N, they are holding numbers 1 to N. We have to find sub-arrays from the given arrays so that they have equal sum. Finally return the indices of such sub-arrays. If there is no solution, then return -1.So, if the input is like P = [2, 3, 4, 5, 6], Q = [9, 3, 2, 6, 5], then the output will be Indices in first array : 0, 1, 2 and indices in second array: 0, so P[0..2] = 2 + 3 + 4 = 9 and Q[0] = ... Read More
97 Views
Suppose we have k different lists. The elements are sorted. We have to search the smallest range that includes at least one number from each of the k different lists. Here the range [a, b] is smaller than range [c, d] when b-a < d-c or a < c if b-a == d-c.So if the input is like [[4, 10, 15, 25, 26], [0, 9, 14, 20], [5, 18, 24, 30]], then the output will be [14, 18]To solve this, we will follow these steps −minRange := inf, maxRange := -inf, rangeSize := inf, tempMinRange := inf, tempMaxRange := -infn ... Read More
201 Views
Suppose we have a matrix that is filled with three letters 'O', 'G', and 'W' where 'O' is representing open space, 'G' is representing guards and 'W' is representing walls in a bank, we have to replace all of the O's in the matrix with respect of their shortest distance from one guard, we cannot go through any walls. In the output matrix guards are replaced with 0 and walls are replaced by -1.So, if the input is likeOOOOGOOOWOOWOOOGWWWOOOOOGthen the output will be33210233-111-14320-1-1-1112210To solve this, we will follow these steps −M := 5N := 5dir_row := [-1, 0, 1, 0]dir_col ... Read More
7K+ Views
The best datatype to use for currency in C# is decimal. The decimal type is a 128-bit data type suitable for financial and monetary calculations. The decimal type can represent values ranging from 1.0 * 10^-28 to approximately 7.9 * 10^28 with 28-29 significant digits. To initialize a decimal variable, use the suffix m or M.decimal b = 2.1m;The below example shows the min and max value of decimal.Example Live Demousing System; namespace DemoApplication{ public class Program{ public static void Main(){ Console.WriteLine($"Deciaml Min Value: {decimal.MinValue}"); Console.WriteLine($"Deciaml Max Value: {decimal.MaxValue}"); ... Read More
281 Views
Suppose we have a list of contacts holding username, email and phone number in any order, we have to find the same contacts (When same person have many different contacts) and return the same contacts together. We have to keep in mind that −A contact can store username, email and phone fields according to any order.Two contacts are same if they have either same username or same email or same phone number.So, if the input is like Contacts = [{"Amal", "amal@gmail.com", "+915264"}, { "Bimal", "bimal321@yahoo.com", "+1234567"}, { "Amal123", "+1234567", "amal_new@gmail.com"}, { "AmalAnother", "+962547", "amal_new@gmail.com"}], then the output will be [0, ... Read More
65K+ Views
There are several ways to get only date portion from a DateTime object.ToShortDateString() − Converts the value of the current DateTime object to its equivalent short date string representation.Returns a string that contains the short date string representation of the current DateTime object.ToLongDateString() − Converts the value of the current DateTime object to its equivalent long date string representation.Returns a string that contains the long date string representation of the current DateTime object.ToString() − One more way to get the date from DateTime is using ToString() extension method.The advantage of using ToString() extension method is that we can specify the ... Read More
142 Views
Suppose we have a Binary Tree. We have to perform following operations −For each level, find sum of all leaves if there are leaves at this level. Otherwise ignore it.Find multiplication of all sums and return it.So, if the input is likethen the output will be 270. First two levels have no leaves. Third level has single leaf 9. Last level has four leaves 2, 12, 5 and 11. So result is 9 * (2 + 12 + 5 + 11) = 270To solve this, we will follow these steps −if root is null, thenreturn 0res := 1que := a ... Read More
12K+ Views
Converting Integer to HexadecimalAn integer can be converted to a hexadecimal by using the string.ToString() extension method.Integer Value: 500 Hexadecimal Value: 1F4Converting Hexadecimal to Integer −A hexadecimal value can be converted to an integer using int.Parse or convert.ToInt32int.Parse − Converts the string representation of a number to its 32-bit signed integer equivalent. A return value indicates whether the operation succeeded.Hexadecimal Value: 1F4 Integer Value: 500Convert.ToInt32 −Converts a specified value to a 32-bit signed integer.Hexadecimal Value: 1F4 Integer Value: 500Converting Integer to Hexadecimal −string hexValue = integerValue.ToString("X");Example Live Demousing System; namespace DemoApplication{ public class Program{ public static void ... Read More
6K+ Views
There are several ways to validate an email address in C#.System.Net.Mail −The System.Net.Mail namespace contains classes used to send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery.System.Text.RegularExpressions − Represents an immutable regular expression.Use the below expression@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1, 3}\.[0-9]{1, 3}\.[0-9]{1, 3}\.)|(([a-zA-Z0-9\-]+\.)+))([azA-Z]{2, 4}|[0-9]{1, 3})(\]?)$"We can use the MailAddress class of the System.Net.Mail namespace to validate an email addressExample Live Demousing System; using System.Net.Mail; namespace DemoApplication{ class Program{ public static void Main(){ try{ string email = "hello@xyzcom"; Console.WriteLine($"The email is {email}"); ... Read More
382 Views
Suppose we have a square maze filled with numbers; we have to find all paths from a corner cell to the middle cell. Here, we will proceed exactly n steps from a cell in 4 directions Up, Down, Right and Left where n is the value of the cell. Thus, we can move to cell [i+n, j] to [i-n, j], [i, j+n], and [i, j-n] from a cell [i, j] where n is value of cell [i, j].So, if the input is like344473463675662662334325472655123656334301434334321335354326443351375363624345451then the output will be(0, 0)→(0, 3)→(0, 7)→(6, 7)→(6, 3)→(3, 3)→(3, 4)→(5, 4)→(5, 2)→(1, 2)→(1, 7)→(7, 7)→(7, 1)→(2, ... Read More