У нас вы можете посмотреть бесплатно LeetCode 14: Longest Common Prefix - Interview Prep Ep 19 или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
⭐ Shop on Amazon to support me: https://www.amazon.com/?tag=fishercod... ⭐ NordVPN to protect your online privacy: https://go.nordvpn.net/aff_c?offer_id... ⭐ NordPass to help manage all of your passwords: https://go.nordpass.io/aff_c?offer_id... LeetCode 14. Longest Common Prefix Problem link: https://leetcode.com/problems/longest... Solution explained: Solution 1: Horizontal scan 1. we can scan every single word in this given list, we assume the first word is the longest common prefix, 2. and then start checking from the second word in the list, we check if the current prefix candidate is a valid prefix for the current word that we are iterating on, if not, we'll just keep decrementing the current prefix length by 1 (trim the last character of it) until it becomes a valid prefix of the current word. Meanwhile, we could check if at any time, prefix.length() becomes zero, we could just return an empty string, this prune will help a lot in terms of time for some corner cases. 3. after we go through all words in the list, we can just return the final prefix string as the answer. Solution 2: Vertical scan 1. we scan every single character of every single word by beginning from the first character of the first word, we'll use the first word as the possible longest common prefix candidate to start with; 2. in the inner for loop, we first check if the current character index i is equal to the current word length, if that's the case, we could simply break out of the loop and return the current prefix candidate as the result, or if the current word's character is not equal to the one that's at the same index from the first word, we should also break out and return; 3. if we could finish the two nested for loops until the end, that means, the very first word is our longest common prefix. ⭐ Support my channel and connect with me: / @fishercoder // TOOLS THAT I USE: ○ Memory Foam Set Keyboard Wrist Rest Pad - https://amzn.to/3cOGOAj ○ Electric Height Adjustable Standing Desk - https://amzn.to/2S9YexJ ○ Apple Magic Keyboard (Wireless, Rechargable) - https://amzn.to/36gy5FJ ○ Apple Magic Trackpad 2 (Wireless, Rechargable) - https://amzn.to/36ltimu ○ Apple MacBook Pro - https://amzn.to/30iSvKE ○ All-In One Printer - https://amzn.to/34etmSi ○ Apple AirPods Pro - https://amzn.to/2GpVYQf ○ My new favorite Apple Watch - https://amzn.to/2EIIUFd // MY FAVORITE BOOKS: ○ Introduction to Algorithms - https://amzn.to/36hxHXD ○ Designing Data-Intensive Applications - https://amzn.to/2S7snOg ○ Head First Java - https://amzn.to/2ScLDKa ○ Design Patterns - https://amzn.to/2SaGeU2 Coding interview made simple! See the complete solutions to Leetcode problems: https://github.com/fishercoder1534/Le... Support me on Patreon: / fishercoder Problem URL: https://leetcode.com/problems/longest... My ENTIRE Programming Equipment and Computer Science Bookshelf: https://www.amazon.com/shop/fishercoder And make sure you subscribe to my channel! Your comments/thoughts/questions/advice will be greatly appreciated! #softwareengineering #leetcode #algorithms #coding #interview #SDE #SWE #SiliconValley #programming #datastructures