
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
Found 33676 Articles for Programming

7K+ Views
Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, access to selected resources from a different origin. A web application executes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, or port) from its own.For example, let us consider an application which is having its front end (UI) and back end (Service). Say the front-end is served from https://demodomain-ui.com and the backend is served from from https://demodomain-service.com/api. If an end user tries to access the application, for security ... Read More

1K+ Views
We can create our own custom class as a result type by implementing IHttpActionResult interface. IHttpActionResult contains a single method, ExecuteAsync, which asynchronously creates an HttpResponseMessage instance.public interface IHttpActionResult { Task ExecuteAsync(CancellationToken cancellationToken); }If a controller action returns an IHttpActionResult, Web API calls the ExecuteAsync method to create an HttpResponseMessage. Then it converts the HttpResponseMessage into an HTTP response message.ExampleTo have our own custom result we must create a class that implements IHttpActionResult interface.using System.Net.Http; using System.Threading; using System.Threading.Tasks; using System.Web.Http; namespace DemoWebApplication.Controllers{ public class CustomResult : IHttpActionResult{ string _value; HttpRequestMessage _request; ... Read More

160 Views
Suppose we have an array A with n numbers and another input K, we have to find the index which will be the last to be reduced to zero after performing a given operation. The operation is explained as follows −Starting from A[0] to A[N – 1], update each element as A[i] = A[i] – K. Now, if A[i] < K then put A[i] = 0 and no further operation will be done on A[i] once it is 0.We have to repeat the operation until all of the elements are reduced to 0. And return the index which will be ... Read More

390 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

183 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

494 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

113 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

702 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

270 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