@@ -0,0 +1,631 @@
+/***%0A * Say you have an array for which the ith element is the price of a given stock on day i.%0A *%0A * If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.%0A */%0Apublic class Solution %7B%0A    public int maxProfit(int%5B%5D prices) %7B%0A        int pmin = Integer.MAX_VALUE;%0A        int mprofit = 0;%0A        for (int i = 0; i %3C prices.length; i++) %7B%0A            if (pmin %3E prices%5Bi%5D)%0A                pmin = prices%5Bi%5D;%0A            mprofit = prices%5Bi%5D - pmin %3E mprofit ? prices%5Bi%5D - pmin : mprofit;%0A        %7D%0A        return mprofit;%0A    %7D%0A%7D%0A

add BestTimetoBuyandSellStock.java