Two things... (1) If you'd like to delete an entry in the dictionary (say we have key 'k' mapping to value 'val' in dictionary 'dict') you can simply call "del dict[k]". This will remove the key and the associated value from the dictionary. (2) Don't think I mentioned it in the video but this applies to Python 2.7. Python 3+ should have fairly similar syntax, this is the documentation for it if you would like to read more: docs.python.org/3/tutorial/datastructures.html
Thank You! This is exactly what I was looking for. Every video has been a tutorial on python fundamentals. Which was great when I was using django or building a game with the pygame module. Now that I'm trying to practice leetcode, I want to blow my brains out on the first "easy" question. This was exactly what I needed. I don't even know what a binary tree is and I've been learning for a year.
👌👌 Thanks for watching Allen. Good luck on working through leetcode! Also feel free to send me a message or email if you get stuck anywhere I'd be happy to help.
@@porkzilla1 It did get easier. I work for a home building supply company now. Today I built a calendar that allows our production guys to track orders in a central location for all employees to view. Excel spreadsheets weren't cutting it because they're flat databases (not connected or structured). The backend of the calendar uses mysql and the front end is just a website with a calendar using php, html and ajax responses (they update in real time, you don't have to reload. Like scrolling facebook). It might sound hard, but that's all relative. It was actually pretty easy for me now. I never once had a leet code like question on any of my interviews. But I would do it anyways. I remember this problem. It took me 2 weeks to solve it but it deepened my understanding of programming languages. Also, for what it's worth, I got my CCNA cert and put that on my resume too. Other than that, I was self taught. No bachelor's degree.
@@robn8656 I’m currently doing a little better on those questions. I’m slowly Dissecting some answers other users have to learn a little more. I don’t know if I’m on the right path, but I’m told I just need to stay consistent
No wonder the dictionary output isn't working for me as displayed in his video. Looking at his console information closely, I see he is using Python 2.7 while I am using python 3.7. But so far, good video. THX!
Worth mentioning that `d = {}` could actually become a `set` if you're not careful. Some suggest using the constructer object instead. E.g. `d = dict(my_key="my_value")`
Great video! You could improve your code slightly by using dict.get(line, 0) instead of filling the dictionary with zeros. I'd love to see a video on Big O notation if you're looking for ideas!
Nice video! Love the real life example but I have a question. Isn't accessing an element in list O(1) ? So when we do class_counts[class_names.index(line)] += 1, we actually do it in O(1), right? Because we increase the element by index, we are not searching for an element. In this case, why would using dictionary be faster? After all, dictionary operation is O(1) too.
Watching the part at 12:25 once again, I realize using index function in a list changes the scene. It'll search for each line in the list which is O(n) I believe. That's what makes dictionary faster. Thank you! 🙏
Python 2.7 is the coding language. I'm using the free version of Sublime Text 3 as the coding editor. For the command prompt I'm using the built-in Ubuntu 16 terminal which comes stock with the Python 2.7 interpreter.
I took the librety to decorate the functions to measure the time. Also if anyone wonder how to implement with python3 gist.github.com/Naruto0/55c9c53d2bc11972ccfa0ff80808ce78
Store an instance of a class in a dictionary value - just blew my mind with the possibilities. Thanks for this video!
Two things...
(1) If you'd like to delete an entry in the dictionary (say we have key 'k' mapping to value 'val' in dictionary 'dict') you can simply call "del dict[k]". This will remove the key and the associated value from the dictionary.
(2) Don't think I mentioned it in the video but this applies to Python 2.7. Python 3+ should have fairly similar syntax, this is the documentation for it if you would like to read more: docs.python.org/3/tutorial/datastructures.html
Thank You! This is exactly what I was looking for. Every video has been a tutorial on python fundamentals. Which was great when I was using django or building a game with the pygame module. Now that I'm trying to practice leetcode, I want to blow my brains out on the first "easy" question. This was exactly what I needed. I don't even know what a binary tree is and I've been learning for a year.
👌👌 Thanks for watching Allen. Good luck on working through leetcode! Also feel free to send me a message or email if you get stuck anywhere I'd be happy to help.
ah the good old find two numbers which add up to a sum
This is currently me. Please tell me it got easier.
@@porkzilla1 It did get easier. I work for a home building supply company now. Today I built a calendar that allows our production guys to track orders in a central location for all employees to view. Excel spreadsheets weren't cutting it because they're flat databases (not connected or structured). The backend of the calendar uses mysql and the front end is just a website with a calendar using php, html and ajax responses (they update in real time, you don't have to reload. Like scrolling facebook). It might sound hard, but that's all relative. It was actually pretty easy for me now. I never once had a leet code like question on any of my interviews. But I would do it anyways. I remember this problem. It took me 2 weeks to solve it but it deepened my understanding of programming languages. Also, for what it's worth, I got my CCNA cert and put that on my resume too. Other than that, I was self taught. No bachelor's degree.
@@robn8656 I’m currently doing a little better on those questions. I’m slowly Dissecting some answers other users have to learn a little more. I don’t know if I’m on the right path, but I’m told I just need to stay consistent
Thanks for clearing the difference in comlexity between list and dictionary
No wonder the dictionary output isn't working for me as displayed in his video. Looking at his console information closely, I see he is using Python 2.7 while I am using python 3.7. But so far, good video. THX!
Great videos, but why still in python 2? Support ends in 2020
Worth mentioning that `d = {}` could actually become a `set` if you're not careful. Some suggest using the constructer object instead. E.g. `d = dict(my_key="my_value")`
I don't think so. The set can be created using set() constructor only.
Great video! You could improve your code slightly by using dict.get(line, 0) instead of filling the dictionary with zeros. I'd love to see a video on Big O notation if you're looking for ideas!
Awesome Explanation , would be glad to have videos on Graphs.......
Really love your way of explaining things! Please update more videos。 found your channels so helpful!
Nice video! Love the real life example but I have a question. Isn't accessing an element in list O(1) ? So when we do class_counts[class_names.index(line)] += 1, we actually do it in O(1), right? Because we increase the element by index, we are not searching for an element. In this case, why would using dictionary be faster? After all, dictionary operation is O(1) too.
Watching the part at 12:25 once again, I realize using index function in a list changes the scene. It'll search for each line in the list which is O(n) I believe. That's what makes dictionary faster. Thank you! 🙏
Great Vidéos !!!!
This video is awesome! You are doing a good job!
I want to see more please
Nice.
Dictionary has been made an Ordered collection since Python 3.7
Can u tell me in which software you are writing
Python 2.7 is the coding language. I'm using the free version of Sublime Text 3 as the coding editor. For the command prompt I'm using the built-in Ubuntu 16 terminal which comes stock with the Python 2.7 interpreter.
Cool
In the words of my little 8yr old nephew.. "Dude You're like the greatest and sh..t... Like #1 and stuff..."
Excellent videos, thank you very much!
I took the librety to decorate the functions to measure the time. Also if anyone wonder how to implement with python3 gist.github.com/Naruto0/55c9c53d2bc11972ccfa0ff80808ce78