Day - 56
Assalamu alaykum, everyone! How are you?
I am trying with my best to complete my challenge successfully. Today is the 56th day of my coding challenge and we passed more than half part of my challenge. Sometimes it is hard to solve even one problem, but I tried. I think I am going well but it is not enough for succeed. Because, I do not think I got something I want. Right, I got something from this challenge but I want to learn more and more. So, I am planning to start another challenge to make my skills better. I think you will support my anytime! Thank you for your valuable time.
/*
?* @param {number[]} prices
?* @return {number}
?*/
var maxProfit = function (prices) {
? let max_profit = 0,
? ? k = 0,
? ? i = 0;
? while (i < prices.length) {
? ? if (prices[i] > prices[k]) {
? ? ? let profit = prices[i] - prices[k];
? ? ? max_profit = Math.max(max_profit, profit);
? ? } else {
? ? ? k = i;
? ? }
? ? i++;
? }
? return max_profit;
};
2. Problem 575. Distribute Candies
/*
?* @param {number[]} candyType
?* @return {number}
?*/
var distributeCandies = function (candyType) {
? return Math.min(
candyType.length / 2, new Set(candyType).size
);
};
That's all I am going to share with you. Thank for your attention as well. I think you like it, and I want you share this article with your friends as well. Do not forget to follow for more solutions if you are newcomer!
Software developer, Java
1 年Good luck bro, friendly advice don’t just show your solution, give details on how and why, also state which algorithms you used, time and memory complexity of solution.