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
Top 10 Interviews Techniqes for Campus Interview in IIT NIT BITS for MTech
Couple of years ago when me and my friends appeared for campus interviews in IITs, NITs and BITs we faced many challenging interview questions like N petrol bunks arranged in a city, Sort Stack … Read More
Difference between a LinkedList and a Binary Search Tree BST
Pointers
In a linked list, the items are linked together through a single next pointer.
Next Nodes
In a binary tree, each node can have 0, 1 or 2 subnodes, where (in case of a … Read More
Binary Tree in Java
How to write Binary Search Tree Code in Java with proper class structure and methods.
Here is the implementation of Binary Search Tree in Java.
Class Structure, Get Set Methods, Binary Tree Operation, Pre-Post-InOrder code … Read More
K’th Largest Element in BST when modification to BST is not allowed
Given a Binary Search Tree (BST) and a positive integer k, find the k’th largest element in the Binary Search Tree.
Count number of ways to reach a given score in a game
Input: n = 20