Race Car | Leetcode 818 | C++
Your car starts at position 0 and speed +1 on an infinite number line. Your car can go into negative positions. Your car drives automatically according to a sequence of instructions 'A' (accelerate) and 'R' (reverse):
When you get an instruction 'A', your car does the following:
position += speed
speed *= 2
When you get an instruction 'R', your car does the following:
If your speed is positive then speed = -1
otherwise speed = 1
Your position stays the same.
For example, after commands "AAR", your car goes to positions 0 -- 1 -- 3 -- 3, and your speed goes to 1 -- 2 -- 4 -- -1.
Given a target position target, return the length of the shortest sequence of instructions to get there.
Input: target = 6
Output: 5
Explanation:
The shortest instruction sequence is "AAARA".
Your position goes from 0 -- 1 -- 3 -- 7 -- 7 -- 6.
LeetCode Solutions: https://www.youtube.com/playlist?list=PL1w8k37X_6L86f3PUUVFoGYXvZiZHde1S
**** Best Books For Data Structures & Algorithms for Interviews:**********
1. Cracking the Coding Interview: https://amzn.to/2WeO3eO
2. Cracking the Coding Interview Paperback: https://amzn.to/3aSSe3Q
3. Coding Interview Questions - Narasimha Karumanchi: https://amzn.to/3cYqjkV
4. Data Structures and Algorithms Made Easy - N. Karumanchi: https://amzn.to/2U8FrDt
5. Data Structures & Algorithms made Easy in Java - N. Karumanchi: https://amzn.to/2U0qZgY
6. Introduction to Algorithms - CLR - Cormen, Leiserson, Rivest: https://amzn.to/2Wdp8rZ
*****************************************************************************
Top 10 Google Coding Interview Questions: https://youtu.be/L2QR_w5NlWU
Top 10 Microsoft Coding Interview questions: https://youtu.be/gcW8XbJJMHo
Top 10 Amazon Coding Interview Questions: https://youtu.be/0X0tVO3oOqI
Top 10 Apple Coding Interview Questions: https://youtu.be/ca5aRYgc6AI
Top 10 Meta Coding Interview Questions: https://youtu.be/lv-C-8FrMA8
Data Structures course on Skillshare: https://skl.sh/3tvDxyP
data Structures course on Udemy: https://www.udemy.com/course/data-structures-and-algorithms-course-1/?referralCode=ED7E1E1457F4FD27FA77
Race Car | LeetCode 818
Facebook Coding Interview question,
google coding interview question,
leetcode,
Race Car,
Race Car C++,
Race Car Java,
Race Car python,
Race Car solution,
818. Race Car,
#Programming #datastructures #CodingInterview #LeetCode #Google #Amazon #median #dynamicprogramming
Видео Race Car | Leetcode 818 | C++ канала Knowledge Center
When you get an instruction 'A', your car does the following:
position += speed
speed *= 2
When you get an instruction 'R', your car does the following:
If your speed is positive then speed = -1
otherwise speed = 1
Your position stays the same.
For example, after commands "AAR", your car goes to positions 0 -- 1 -- 3 -- 3, and your speed goes to 1 -- 2 -- 4 -- -1.
Given a target position target, return the length of the shortest sequence of instructions to get there.
Input: target = 6
Output: 5
Explanation:
The shortest instruction sequence is "AAARA".
Your position goes from 0 -- 1 -- 3 -- 7 -- 7 -- 6.
LeetCode Solutions: https://www.youtube.com/playlist?list=PL1w8k37X_6L86f3PUUVFoGYXvZiZHde1S
**** Best Books For Data Structures & Algorithms for Interviews:**********
1. Cracking the Coding Interview: https://amzn.to/2WeO3eO
2. Cracking the Coding Interview Paperback: https://amzn.to/3aSSe3Q
3. Coding Interview Questions - Narasimha Karumanchi: https://amzn.to/3cYqjkV
4. Data Structures and Algorithms Made Easy - N. Karumanchi: https://amzn.to/2U8FrDt
5. Data Structures & Algorithms made Easy in Java - N. Karumanchi: https://amzn.to/2U0qZgY
6. Introduction to Algorithms - CLR - Cormen, Leiserson, Rivest: https://amzn.to/2Wdp8rZ
*****************************************************************************
Top 10 Google Coding Interview Questions: https://youtu.be/L2QR_w5NlWU
Top 10 Microsoft Coding Interview questions: https://youtu.be/gcW8XbJJMHo
Top 10 Amazon Coding Interview Questions: https://youtu.be/0X0tVO3oOqI
Top 10 Apple Coding Interview Questions: https://youtu.be/ca5aRYgc6AI
Top 10 Meta Coding Interview Questions: https://youtu.be/lv-C-8FrMA8
Data Structures course on Skillshare: https://skl.sh/3tvDxyP
data Structures course on Udemy: https://www.udemy.com/course/data-structures-and-algorithms-course-1/?referralCode=ED7E1E1457F4FD27FA77
Race Car | LeetCode 818
Facebook Coding Interview question,
google coding interview question,
leetcode,
Race Car,
Race Car C++,
Race Car Java,
Race Car python,
Race Car solution,
818. Race Car,
#Programming #datastructures #CodingInterview #LeetCode #Google #Amazon #median #dynamicprogramming
Видео Race Car | Leetcode 818 | C++ канала Knowledge Center
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![Orderly Queue | Leetcode 899](https://i.ytimg.com/vi/pzClQP577Bo/default.jpg)
![Validate Binary Search Tree | Leetcode 98](https://i.ytimg.com/vi/IjQhjyihnQ4/default.jpg)
![Guess the Word | Leetcode 843](https://i.ytimg.com/vi/COnrhAabeos/default.jpg)
![Two Sum IV - Input is a BST | Leetcode 653](https://i.ytimg.com/vi/RL708FLB76k/default.jpg)
![3Sum Closest | Leetcode 16](https://i.ytimg.com/vi/TjB9eCUh9KA/default.jpg)
![Time Based Key-Value Store | Leetcode 981](https://i.ytimg.com/vi/Y6ZtxsrnJEs/default.jpg)
![Generate Parentheses | Leetcode 22 | Recursion](https://i.ytimg.com/vi/yBXTAfNuOQg/default.jpg)
![Path Sum | Leetcode 112 | C++](https://i.ytimg.com/vi/7gsJjnnV_8E/default.jpg)
![Number of Unlock patterns | Android Unlock Patterns](https://i.ytimg.com/vi/r5AQFRXWQhE/default.jpg)
![Building Blocks of System Design | Knowledge center](https://i.ytimg.com/vi/8LIECUyZ6_8/default.jpg)
![Consistency Models | System Design | Distributed Systems](https://i.ytimg.com/vi/uAqIa-mtjJ4/default.jpg)
![Design Youtube | Youtube System Design](https://i.ytimg.com/vi/RhOg5ccupK0/default.jpg)
![Median of two Sorted Arrays | Leetcode 4 | C++](https://i.ytimg.com/vi/QhShXjq5TWE/default.jpg)
![Longest Substring Without Repeating Characters | Leetcode 3 | C++](https://i.ytimg.com/vi/F5diwvtLirU/default.jpg)
![Add Two Numbers | Leetcode 2 | C++](https://i.ytimg.com/vi/dxFe7JEH77E/default.jpg)
![Disjoint Set | Union Find Algorithm | Knowledge Center](https://i.ytimg.com/vi/xsrvp2JV8bw/default.jpg)
![Time and Space Complexity Analysis of Hash Table | Knowledge Center](https://i.ytimg.com/vi/ARiek7pchig/default.jpg)
![Hash Set in C++, Java and Python | Knowledge Center](https://i.ytimg.com/vi/e-O7jiAUvos/default.jpg)
![Designing a Hash Table | Hash Function | Collision Resolution | Knowledge Center](https://i.ytimg.com/vi/L7zlfDaulTc/default.jpg)
![How Hash Table works | Principle of Hash table | Insertion and Search | Knowledge Center](https://i.ytimg.com/vi/UiLpx2gu0Oc/default.jpg)