Тёмный

Solving LeetCode 136 in JavaScript (Single Number) 

KA Education
Подписаться 4,2 тыс.
Просмотров 6 тыс.
50% 1

In this video I solve LeetCode problem 136 (Single Number) with the JavaScript programming language. This question has previously appeared during Amazon coding interviews.
▶ Get my FREE Data Structures Crash Course: bit.ly/2YWCn1C
I start by helping you understand what the problem is asking for, then I will go over the pseudo-code/logic for a solution, and finally I will write the solution code explaining each line, step-by-step.
Using my simple and easy-to-understand methodology, I make difficult and complex interview questions incredibly easy to understand. So easy in fact, that even your grandma could do it! 👵🏻
I will be solving a new problem EVERY WEEK, so be sure to smash that subscribe button and hit the notification bell so you don't miss a single one! 😀
▶ Single Number: leetcode.com/p...
-----
I also offer full-length interview preparation courses, programming tutorials, and even 1-1 tutoring!
▶ Get access to MY COMPLETE SYSTEM: kaeducation.com
Who knew acing your next software engineering interview could be so incredibly easy!
-----
#programming #codinginterview #leetcode

Опубликовано:

 

20 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 10   
@suvajitchakrabarty
@suvajitchakrabarty 7 месяцев назад
If in case anyone is interested, the O(1) space complexity requires some bit manipulation. Essentially if you XOR a number with itself, it returns zero, and if you XOR a number with zero, it returns the number itself. So if you had the following numbers in the list - 3, 3, 2, the XOR between 3 and 3 would return 0, and then XORing 0 with 2 would return 2. Hence if you did a XOR for all numbers in a list which contains 2 of each numbers except for the one number, then you'd get back the number which occurs once. The code is pretty straightforward since you only need to do a XOR for every number, and return the result. Code in Javascript - var singleNumber = function(nums) { let res = nums[0]; for (let i = 1; i
@somebody-17546
@somebody-17546 Год назад
You must implement a solution with a linear runtime complexity and use only constant extra space.
@BabeCrs
@BabeCrs Год назад
it asks it to be in O(1) space complexity. How would you adapt this for that
@feng282
@feng282 3 года назад
isn't const ht an Object? When should we use map or object?
@Moe1993x
@Moe1993x 3 года назад
a hash map is simply an object in JS
@feng282
@feng282 3 года назад
@@Moe1993x so when you are asked to build a custom hashmap, should we do const hash = new Map; or const hash = {}?
@jinbo369
@jinbo369 2 года назад
ht[num] = ht[num] +1 || 1 can you please explain more on this part?
@m_blaze4508
@m_blaze4508 2 года назад
the first time, ht[num] will be undefined. At that time, undefined + 1 will be NaN which is false. Hence ht[num] will be initialized 1 because of || 1. It is explained properly at 2:05
@pineappleapplepens
@pineappleapplepens 2 года назад
developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR
@Maybehassanawad
@Maybehassanawad 3 года назад
very useful ❤️
Далее
Solving LeetCode 169 in JavaScript (Majority Element)
4:10
Solving LeetCode 101 in JavaScript (Symmetric Tree)
5:56
Miyagi & Andy panda - minor (пародия Beatrise)
0:30
Counter-Strike 2 - Новый кс. Cтарый я
13:10
Single Number - Leetcode 136 - Python
7:09
Просмотров 100 тыс.
LEETCODE 268 (JAVASCRIPT) | MISSING NUMBER
7:43
Просмотров 4,9 тыс.
Solving LeetCode 66 in JavaScript (Plus One)
4:07
Просмотров 20 тыс.
Sleep - Leetcode 2621 - JavaScript 30-Day Challenge
19:13
Solving LeetCode 112 in JavaScript (Path Sum)
5:01
Просмотров 1,6 тыс.
Leetcode Solution - 1.0 Two Sum | Javascript
14:25
Просмотров 85 тыс.
Miyagi & Andy panda - minor (пародия Beatrise)
0:30