Set of Numbers are given to you.
convert them to Roman numbers.
Solution is in Hacker Earth style… Read More
There are N nuts and N bolts, u have to find all the pairs of nuts and bolts in minimum no. of iteration
With First look you think practical way of solving this question, and that is randomly taking a bolt and finding (by Looking at all nuts) perfect fit nut for it.
but does such logic to … Read More
Generic Object Oriented Stack with Template
Here We have implemented a Generic Stack Example with Templates in C++ where we can Push any element into stack.
#include <iostream>
#include <vector>
#include <cstdlib>
#include <string>
#include <stdexcept>
using namespace std;… Read More
C Program for TAIL command of UNIX
/*
* usage: myTail [-n] [<filename>]
*/
#include <stdio.h> #include <stdlib.h> #define MAX_LINE_LEN 1024 #define DEFAULT_N 10 int main(int argc, char *argv[]) { char **tail; int count = DEFAULT_N, n, i, headX = 0, tailX… Read More
Print Power Set of a Set
Print Power Set of a Set of character.
Power Set Power set P(S) of a set S is the set of all subsets of S. For example S = {a, b, c} then P(s) =
Stock Buy Sell to Maximize Profit
Stock Price on each day is given in an array.
Example : [ 10, 12, 7, 5, 9, 15, 13, 18 ]
Find the max profit that you can make by buying and selling in … Read More
Maximum difference between two elements s.t larger element appears after the smaller number
Find maximum profit if you can buy & sell share just once.
Given an array of integers, find out the difference between any two elements such that larger element appears after the smaller number.
Examples: … Read More
Trie Dictionary
Trie also called prefix tree (as they can be searched by prefixes).
The term trie comes from retrieval.
In the example shown, keys are listed in the nodes and values below them. Each … Read More
‘N’ Story Building, with 1,2,3 steps how many ways can a person reach top of building.
A building has n steps. A person can take 1,2 or 3 steps. In how many ways can a person reach top of building.
In order to build logic, lets think from first step
If … Read More
How strtok() Works
strtok() : Split string into tokens
Syntax :
char * strtok ( char * str, const char * delimiters );
Parameters
str C string to truncate.Notice that this string is modified by being broken into … Read More