## Stock Single Sell Problem – O(n) Solution

Objective: Given an array represents cost of a stock on each day. You are allowed to buy and sell the stock only once. Write an algorithm to maximize the profit in single buy and sell....

Objective: Given an array represents cost of a stock on each day. You are allowed to buy and sell the stock only once. Write an algorithm to maximize the profit in single buy and sell....

The algorithm of kMeans is an unsupervised learning algorithm for clustering a set of items into groups. Given a set of multi-dimensional items and a number of clusters, k, we are tasked of categorizing...

This article is contribute by Antonis Maronikolakis Objective: We are given a data set containing items, with numeric values, categorized into classes. We are also given a new item, without a class. We want...

Objective: Given two strings, s1 and s2 and edit operations (given below). Write an algorithm to find minimum number operations required to convert string s1 into s2. Allowed Operations: Insertion – Insert a new...

Objective: In this game, which we will call the coins-in-a-line game, an even number, n, of coins, of various denominations from various countries, are placed in a line. Two players, who we will call...

Objective: You are given a set of n types of rectangular 3-D boxes, where the i^th box has height h(i), width w(i) and depth d(i) (all real numbers). You want to create a stack...

Objective: You are given a large string. You need to cut the string into chunks such that each substring that you get is a palindrome. Remember that each 1 length string is always a...

Objective: Suppose you’re managing construction of billboards on the Rocky & Bullwinkle Memorial Highway, a heavily traveled stretch of road that runs west-east for M miles. The possible sites for billboards are given by...

Objective: Given a binary tree write an algorithm to convert it into threaded binary tree. Note: Tree node has extra Boolean field to be used. In earlier article “Introduction to Threaded Binary Tree” we...

In earlier article “Introduction to Threaded Binary Tree” we have seen what is threaded binary tree, types of it and what advantages it has over normal binary tree. In this article we will see...

Objective: You have k lists of sorted integers. Find the smallest range that includes at least one number from each of the k lists. This is very nice and tricky solution, This problem was asked...

Objective: Given a string, find a longest palindromic subsequence in it. What is Longest Palindromic Subsequence: A longest palindromic subsequence is a sequence that appears in the same relative order, but not necessarily contiguous(not...

Objective: Given a number, Write an algorithm to find out minimum numbers required whose square is equal to the number. This question has been asked in the Google Interview for Software Developer position.This is...

Objective: Given Number K, Print all the strings of N length. Example: N = 2, K = 3 [1, 1] [2, 1] [3, 1] [1, 2] [2, 2] [3, 2] [1, 3] [2, 3]...

%d bloggers like this: