In this video I have explained one of the most common coding interview question i.e best time to buy and sell stock in Java.
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
https://openinapp.co/udemycourse
Course Description Video :
https://yt.openinapp.co/dmjvd
We target to cover most of the questions covered in leetcode.
So what is LeetCode :
It’s a website where people–mostly software engineers–practice their coding skills. There are 800+ questions (and growing), each with multiple solutions. Questions are ranked by level of difficulty: easy, medium, and hard.
LeetCode basically has more questions, better quality, plus a strong user base.
The primary reasons why our users LeetCode: to prepare for the technical portion of a job interview.
LeetCode and the like have risen in use because of the way interviews have evolved. Engineers believe that these resources help prepare them for what they will encounter in today’s technical aptitude screenings.
LeetCode questions are often asked during interviews at the elite tech companies: Facebook, Amazon, Apple, Netflix, and Google., some more than at others. Among the Big Five, Amazon is said to place the least emphasis on LeetCode.
One of the best interview question asked is Best time to buy and sell Stock using java as programming language. We have covered it's solution using iteration. In next video we will cover the solution for Best time to buy and sell Stock using recursion.
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit.
Note that you cannot sell a stock before you buy one.
Example 1:
Input: [7,1,5,3,6,4]
Output: 5
Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5.
Not 7-1 = 6, as selling price needs to be larger than buying price.
Example 2:
Input: [7,6,4,3,1]
Output: 0
Explanation: In this case, no transaction is done, i.e. max profit = 0.
LeetCode is one of the most well-known online judge platforms that you can use to practice your programming skills by solving coding questions. It has over 1,100 different problems, support for over 18 programming languages, and an active community that is always there to help you with the solutions you come up with. If your intention is to hone your coding skills, then this online judge platform is one of the best that you can use.
-------------------------------------------------------------------------------------------------------------------------------------
Code Decode Playlists
Most Asked Core Java Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXscoyL5XEZoHHZ86_6h3GWE1
Advance Java Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsexOO1VQ4vs-BM2-8CKrixd
Java 8 Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy
Hibernate Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsdC-p2186C6NO4FpadnCC_q
Spring Boot Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsexOO1VQ4vs-BM2-8CKrixd
Angular Playlist :
https://www.youtube.com/watch?v=CAl7RQSdq2Q&list=PLyHJZXNdCXsfxRtDwtGkDD_lLfTWc1g0i
GIT : https://youtube.com/playlist?list=PLyHJZXNdCXscpl6pxOnL2lRWJlzvzjyZE
-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode
Subscriber Code Decode : https://www.youtube.com/c/CodeDecode?sub_confirmation=1
Linkedin : https://www.linkedin.com/in/codedecodeyoutube/
Instagram : https://www.instagram.com/codedecode25/
--------------------------------------------------------------------------------------------------------------------------------------
#BesttimetobuyandsellStock #javacodinginterviewquestion #javaprogramminginterviewquestions #codedecode