It’s a misnomer used to describe servers in the cloud that requires zero configuration or maintenance from the developer. Imagine you need water for your house. You could spend a bunch of time and money digging a well, testing the water quality, and plumbing it to your house or you could just tap into the city water supply and pay a monthly fee based on the amount of water that you use.
Serverless computing is the same idea but instead of water, we’re talking about the amount of CPU and memory it takes to run your code. Services like AWS…
Advantages of Greedy Approach:
NOTE: We have mentioned “in most of the scenarios” in the earlier point because in some cases, this approach doesn’t always produce correct results due to the nature of not reversing the decision made. …
There are 2 popular approaches of doing graph traversals :
* Depth first search ( DFS )
* Breadth first search ( BFS )
Step 1: Push the root node in the Stack.
Step 2: Loop until stack is empty.
Step 3: Peek the node of the stack.
Step 4: If the node has unvisited child nodes, get the unvisited child node, mark it as traversed and push it on stack.
Step 5: If the node does not have any unvisited child nodes, pop the node from the stack.
Based upon the above steps, the following Java code shows the…
The term backtracking implies - if the current solution is not suitable, then eliminate that and backtrack (go back) and check for other solutions.
In any backtracking problems, the algorithm tries to find a…
These algorithms take an input list, processes it (i.e, perform some operations on it) and produce the sorted list.
The most common example we experience every day is sorting clothes or other items on an e-commerce website either by lowest-price to highest, or list by popularity, or some other order.
C++ Sorting vector V,
sort(V.begin(), V.end());
Bubble sort, also referred to as comparison sort, is a simple sorting algorithm that repeatedly goes through the list, compares adjacent elements and swaps them if they are in the wrong order. This is the most simplest algorithm and inefficient at the same time…
Maths ( especially discrete mathematics ) and computer science go very much hand in hand.
The factor of a number, N is a number d such that d divides N.
That is, N % d == 0.
Example:
For number 6, the factors are 1, 2, 3 and 6
.
Given a number N, find all factors of N.
N = 6
factors = {1, 2, 3, 6}
Time Complexity: O(sqrt(n))
Given a number N, verify if N is prime or not.
So, two-pointer ( or N pointer for that matter ) is usually a really clever optimization on some brute force approaches in certain conditions.
Let us start looking at this with the help of a question. Then we will generalize our approach.
Given a sorted array A ( sorted in ascending order ),
find if there exists 2 integers A[i] and A[j] such that A[i] + A[j] = 0, i != j
Now the naive solution would be,
This solution is O(n²).
However, let us now analyze how ‘i’ and ‘j’ move with iterations. Clearly, ‘i’ moves forward with every…
A *writes down "1+1+1+1+1+1+1+1 =" on a sheet of paper*
A : "What's that equal to?"
B : *counting* "Eight!"
A *writes down another "1+" on the left*
A : "What about that?"
B : *quickly* "Nine!"
A : "How'd you know it was nine so fast?"
A : "You just added one more"
A : "So you didn't need to recount because you remembered there were eight! Dynamic Programming is just a fancy way to say 'remembering stuff to save time later'"
This conversation has the essence of dynamic programming.
The idea is very simple, If you have solved…
React, a javascript library for building user interfaces. Developed at Facebook and released in 2013 it’s safe to say React has been the most influential ui library of recent memory.
We use it to build components that represent logical reusable parts of the UI.
The beauty of React is that the simplicity of building a component has been brought down to its theoretical minimum. It’s just a javascript function. The return value from this function is your HTML or ui which is written in a special syntax called JSX allowing you to easily combine javascript with HTML markup.
Technical Details behind all your favorite products.