
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 1631 of 2650

398 Views
Suppose we have an array A. In this array there are different numbers that occurs twice. But there is only one number that occurs once. We have to find that element from that array.Suppose A = [1, 1, 5, 3, 2, 5, 2], then the output will be 3. As there are each number twice, we can perform XOR to cancel out that element. because we know y XOR y = 0To solve this, we will follow these steps.Take one variable res = 0for each element e in array A, preform res := res XOR ereturn resExample Let us see the ... Read More

188 Views
Suppose we have an array of N numbers, where each element in the array appears same number of times (m times, this is also given) except one element, We have to find this element.So, if the input is like A = [6, 2, 7, 2, 2, 6, 6], m = 3, then the output will be 7.To solve this, we will follow these steps −INT_SIZE := 8 * size of an integer type variableDefine an array count of size − INT_SIZE. and fill with 0for initialize i := 0, when i < INT_SIZE, update (increase i by 1), do:for initialize ... Read More

8K+ Views
The Web API action method can have following return types.VoidPrimitive Type/Complex TypeHttpResponseMessageIHttpActionResultVoid −It's not necessary that all action methods must return something. It can have void return type.Exampleusing DemoWebApplication.Models using System.Web.Http; namespace DemoWebApplication.Controllers{ public class DemoController : ApiController{ public void Get([FromBody] Student student){ //Some Operation } } }The action method with void return type will return 204 No Content response.Primitive Type/Complex Type −The action method can return primitive type like int, string or complex type like List etc.Exampleusing DemoWebApplication.Models; using System.Collections.Generic; using System.Web.Http; namespace DemoWebApplication.Controllers{ public class ... Read More

500 Views
Suppose we have an array, we have to find an element before which all elements are less than it, and after which all are greater than it. Finally, return the index of the element, if there is no such element, then return -1.So, if the input is like A - [6, 2, 5, 4, 7, 9, 11, 8, 10], then the output will be 4.To solve this, we will follow these steps −n := size of arrmaximum_left := an array of size nmaximum_left[0] := -infinityfor i in range 1 to n, domaximum_left[i] := maximum of maximum_left[i-1], arr[i-1]minimum_right := infinityfor i ... Read More

117 Views
Suppose one race is going to be organized. Where different stones are placed on a road. One bucket is present at the starting point of the race, this is 6 units away from the first stone. The other stones are 4 units apart from each other and lie straight in a line one after another. Now, the participants start from the bucket, then collects the nearest stone, comes back and puts that stone into the bucket, after that runs again to collect the next nearest stone, runs back, and puts it in the bucket. This process will be continued until ... Read More

713 Views
Suppose we have a string which contains only L and R, this denotes left rotation and right rotation respectively, we have to find the final direction of pivot. Here directions are north(N), east(E), south(S) and west(W). We are assuming that the pivot is pointed towards north(N) in a compass.So, if the input is like "RRLRLLR", then the output will be E, as initial direction is N, RR will point to S, then LR will point to the same N again, then LL will point to previous position N, then R will point to E. So E is the final.To solve ... Read More

276 Views
Suppose we have a string S (all letters are in lowercase), we have to find the count of all of the sub-strings of length four whose characters can be rearranged to form this word "bird".So, if the input is like "birdb", then the output will be 2.To solve this, we will follow these steps −cnt := 0for i in range 0 to size of s - 3, dobird := an array with [0, 0, 0, 0]for j in range i to i + 4, doif s[j] is same as 'b', thenbird[0] := bird[0] + 1otherwise when s[j] is same as ... Read More

6K+ Views
When the ASP.NET Web API calls a method on a controller, it must set values for the parameters, a process called parameter binding.In order to bind a model (an action parameter), that would normally default to a formatter, from the URI we need to decorate it with [FromUri] attribute. FromUriAttribute simply inherits from ModelBinderAttribute, providing us a shortcut directive to instruct Web API to grab specific parameters from the URI using the ValueProviders defined in the IUriValueProviderFactory. The attribute itself is sealed and cannot be extended any further, but you add as many custom IUriValueProviderFactories as you wish.The [FromBody] attribute ... Read More

212 Views
Suppose we have a string of lowercase characters (all are ASCII characters), we have to find all distinct continuous palindromic sub-strings of the given string.So, if the input is like "level", then the output will be 7 as there are seven substrings ['level', 'eve', 'l', 'e', 'v', 'e', 'l'].To solve this, we will follow these steps −N := 26n := length of strsum := 0my_map := a list of size N and fill with 0for i in range 0 to n, domy_map[ASCII of (str[i]) - ASCII of ('a') ] := my_map[ASCII of (str[i]) - ASCII of ('a') ] + 1for ... Read More

8K+ Views
The Task.WaitAll blocks the current thread until all other tasks have completed execution. The Task.WhenAll method is used to create a task that will complete if and only if all the other tasks have completed.If we are using Task.WhenAll we will get a task object that isn’t complete. However, it will not block but will allow the program to execute. On the contrary, the Task.WaitAll method call actually blocks and waits for all other tasks to complete.To understand with an example, let us say we have a task that performs some activity with the UI thread say some animation needs ... Read More