This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//||||Hola chicos{HEllo GUYS}, many students requested me to contribute this code. Here is your solution:)|||| | |
//I have used STL and created the program using Pure Object Oriented Paradigm. | |
// This code tried to solve the problem considering TIME_COMPLEXITY. | |
// The algorithm and schema can be improved though. | |
// https://vitspot.com/code/amount-remaining-after-shopping/ | |
// Else go to bottom of file, to read the whole question. | |
#include<iostream> | |
#include<string> | |
#include<tuple> | |
#include<vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
No Change | |
Vikram’s mom gave him a certain amount of money and asked him to get change for the money in coins. | |
She also told the denominations of coin she wanted and also told the total number of coins must be minimum. | |
If that amount of money cannot be made up by any combination of the coins, print -1. | |
Example1:- | |
Let the Amount – 11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We have a collection of potatoes, each potato has a positive integer weight. | |
Each turn, we choose the two heaviest potatoes and smash them together. Suppose the potatoes have weights x and y with x <= y. The result of this smash is: | |
If x = = y, both potatoes are totally destroyed; | |
If x ! = y, the potato of weight x is totally destroyed, and the potato of weight y has new weight y-x. | |
At the end, there is at most 1 potato left. Return the weight of this potato (or 0 if there are no potatoes left.) | |
Example:- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Point to Point | |
Shyam is standing in Point A. He has to reach Point B. There are m number of divisions | |
between Point A and point B. | |
These division may or may not have a stone. One can jump only on the stone. | |
Given a list of stones positions (in division) in sorted ascending order, | |
determine whether Shyam can reach Point B. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Help the doctor | |
Sabarish, A doctor forms a grid where each cell represents the condition of a patient. | |
The cell can take any of the three values as follows: | |
1-The person is virus free | |
2-The person is infected with the virus | |
3-Empty cell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Eat chocolates | |
Ramesh wants to buy some chocolates. But there are some constraints that she needs to follow. | |
She can only buy “m” chocolates and can buy the chocolates of the same brand only up to a certain limit. | |
Given the cost and brand of the chocolates find the maximum cost at which she can buy the chocolates | |
Example1:- | |
Cost of chocolates:- [5,4,3,2,1] | |
Cost[i] represents the cost of ith chocolate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Skipping Stones | |
Yogee and his friends are playing skipping stones. | |
Each stone has a value which represents the maximum number of stones you can jump from that particular stone. | |
It was yogee’s turn. Given the value of every stones help him to find the minimum number of jumps required to | |
reach to the last stone provided that he starts from the first stone. | |
Assume you can always reach the last stone | |
Example:- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Can they Marry | |
Two strings A and B can marry each other if and only if we can swap any two letters in A so that the result equals B | |
Example:- | |
A=”ab”, B=”ba” | |
Yes, As when you swap a and b in A you will get “ba” which is B | |
A=”aa”, B=”aa” |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Squares | |
Every number can be expressed as sum of perfect squares. | |
For example | |
1= 1 | |
So number of perfect squares required 1 | |
2=1+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Train routes | |
A train stops on n stations numbered from 0 to n - 1 that form a circle. | |
We know the distance between all pairs of neighboring stations where distance[i] is the distance between the station number | |
i and (i + 1) % n. | |
The train goes along both directions i.e. clockwise and counterclockwise. | |
Return the shortest distance between the given start and destination stations. | |
Example:- |
OlderNewer