You are given an integer array of prices where prices[i] is the price of a given stock on an ith day. Design an algorithm to find the maximum profit.
Some constraints are as follows:
Input: k = 2, prices = [2,4,1]
Explanation: Buy on day 1 (price = 2) and sell on day 2 (price = 4), profit = 4-2 = 2.
Input: k = 2, prices = [3,2,6,5,0,3]
Solutions to all the exercises on the Tour of Go Website.
The Tour of Go Website is an excellent start for an developer trying to learn the language Go. It gradually introduces you to the language by explaining different parts and provides exercises to the reader to implement.
Following are the solutions I wrote for the exercises as I went through the tour.
There are N children standing in a line and each child is assigned a rating value. You are giving candies to these children while making sure that each child must have at least one candy and children with a higher rating get more candies than their neighbors. What is the minimum candies you must give?
Find the minimum number of egg drops needed to know the lowest floor in a building from which an egg won’t break.
There are E eggs (= allowed egg breaks), a building with F floors [1 ≥ F] and a special floor S [0 ≤ S ≤ F] - any unbroken egg dropped at a floor higher than S will break and any egg dropped at or below this floor will not break.
Given that an unbroken egg can be dropped from any floor, what is the minimum number of egg drops D [1 ≤ D ≤ F] needed in…
LeetCode: Given a string s, find the longest palindromic substring in s.
A palindrome is a word that reads the same forwards and backwards. In my universe, there are two kinds of palindrome: “Odd Pal” and “Even Pal”.
Even Pal is a palindrome which has an even length, for example: “ZYXXYZ”. In the visualization below you can see how we can split it into 2 parts that have size 3: “ZYX” and “XYZ” . This palindrome will always have two centres called “Left Center” at index2 and “Right Center” at index3.
I have been recently asked a question: “Where can I start learning about AWS (Amazon Web Services) as a beginner ?”
There are lots of resources you can learn AWS from; following are 6 different ways that I know of: