Тёмный
nexTRIE
nexTRIE
nexTRIE
Подписаться
I used to provide solutions on coding interview questions by covering problems from LeetCode, HackerRank, C++ algorithms, JavaScript beginner tutorials and more. All tutorials are made by Isaac Asante.
Python HackerRank Solutions: Capitalize!
7:52
2 месяца назад
Score of a String - Leetcode 3110 (Python)
3:59
2 месяца назад
Комментарии
@Murali-lv3os
@Murali-lv3os 15 дней назад
Can we use array.filter() 😅
@Murali-lv3os
@Murali-lv3os 15 дней назад
Mm nice example
@RiversPPC
@RiversPPC Месяц назад
I didn’t understand anything!
@nextrie
@nextrie Месяц назад
Hey, let me explain to you more clearly. The pow() function in Python can take two or three arguments. With two arguments, say A and B, the statement pow(A, B) calculates A raised to the power of B. This is the same as writing A**B in Python. If you want to find A raised to the power of B, then take the result modulo C, you can use the three-argument version of the pow() function. The modulo operator (%) gives the remainder of a division. So, (A**B) % C first calculates A raised to the power of B and then finds the remainder when that result is divided by C. Instead of writing (A**B) % C, which can be slow for large numbers, you can use pow(A, B, C). This does the same calculation but more efficiently. Is it clearer now?
@jnb3451
@jnb3451 Месяц назад
So this is used to adjust html code or text via javascript?
@nextrie
@nextrie Месяц назад
Hey, actually, this is used to access specific HTML elements in your HTML code, using their ID. From there, you can choose to do anything you want with the referenced element, in your JS script. It doesn't have to be limited to adjusting text. :)
@ElectronicMusicEnjoyer
@ElectronicMusicEnjoyer Месяц назад
So did the 4 just straight up dissapear, what am I missing here?
@nextrie
@nextrie Месяц назад
It has to do with how the terms are distributed. Please check again the part where I show the breakdown in Google Search.
@nextrie
@nextrie Месяц назад
This one-line solution can be improved by sorting the list only once, outside of the list comprehension. See this below: Updated code here: isaacasante.com/816/leetcode-1365-how-many-numbers-are-smaller-than-the-current-number-solution-in-python/
@manishpandey8967
@manishpandey8967 2 месяца назад
What's the difference between for, while loops?
@nextrie
@nextrie 2 месяца назад
The convention is to use FOR LOOPS when you know how many times you want to run your loop, and you have a fixed increment/decrement. For example, repeat an action one-by-one for an entire list, or an entire range. Conversely, you use WHILE LOOPS when you need to run a loop purely based on a condition. E.g. while I haven't reached the value I'm looking for, keep repeating a certain action. Of course, in many common/simple cases, you can use these loops interchangeably, but there will be times when your increment (or decrement) will vary greatly depending on what happens in the loop. Sometimes, you'll need to increment by one, or by four, etc, depending on many variables. In such instances, using a WHILE loop might help. It's one of those things that becomes more intuitive to you as you gain more coding experience.
@manishpandey8967
@manishpandey8967 2 месяца назад
@@nextrie thnx ❤️🙌
@nextrie
@nextrie 2 месяца назад
You're welcome, hope you subscribe!@@manishpandey8967
@luke78896t
@luke78896t 2 месяца назад
thankyou
@nextrie
@nextrie 2 месяца назад
You're welcome, Luke! I've got more tutorials coming up. I hope you subscribe :)
@sreehari4833
@sreehari4833 2 месяца назад
Thank you for this solution.
@jasminbt21
@jasminbt21 3 месяца назад
thank youuuuuuuuuuuuuuuu sooo muchhhhh
@nextrie
@nextrie 3 месяца назад
You're welcome!
@MyKneeHurts
@MyKneeHurts 3 месяца назад
could you not just print a sorted list. then after its sorted, the highest is automatically at index -1, then u pop index-1, then the next -1 is the runner up. This was the idea I had but struggled to code it
@francois-xaviermenage4531
@francois-xaviermenage4531 4 месяца назад
How do you compute the fair amount of loops required?
@nextrie
@nextrie 4 месяца назад
You have to iterate through each letter of every word in the list of words. That's why it's a nested loop.
@francois-xaviermenage4531
@francois-xaviermenage4531 4 месяца назад
Ok but sometimes , we use loops easily and I have already been reproched to use too many loops..I am wondering how measuring better when I am asked to optimize..​@@nextrie
@nextrie
@nextrie 4 месяца назад
@@francois-xaviermenage4531 Well, it depends on the nature of the problem. If you can use a data structure like a Trie to process words faster and reduce time complexity, then that's great. But in this debugging problem, the instructions expect you to go through each letter (inner loop) of each word provided (outer loop). So, it's okay to go with a nested loop here. Plus, it's only a small problem, so the input size won't cause any issue.
@Garfield_Minecraft
@Garfield_Minecraft 4 месяца назад
i shifting bit by adding 00001010 111111011+ (fliping all 0 to 1 when found 1 then just copy and paste on top then add 1 the overflow will cancel out) ---------- 00000101 left shift is easier 00000101 00000101+ (add by itself) ----------- 00001010
@user-bt5mz7jl7n
@user-bt5mz7jl7n 4 месяца назад
good jop
@abobakrmostafa8723
@abobakrmostafa8723 4 месяца назад
what is the difference between invalid argument and exception? And why did you use "exception" when it stated the exceptions that might occur?
@yahyaabdulmajeed8223
@yahyaabdulmajeed8223 5 месяцев назад
This is O(n^2) solution, assuming you calculate both numbers together. There is O(n) solution available.
@nextrie
@nextrie 5 месяцев назад
Not exactly. I've provided the complexity analysis for this approach here: isaacasante.com/676/add-two-numbers-leetcode-solution-in-python/?amp=1
@sayhii6338
@sayhii6338 5 месяцев назад
If image for add classlist does the opacity become 0?
@IsaacAsante17
@IsaacAsante17 5 месяцев назад
Sorry, are you asking if you can control an image's opacity via the classList method?
@sayhii6338
@sayhii6338 5 месяцев назад
@@IsaacAsante17 I added a class to the element in the JavaScript section. and I gave the class name = fade. then in the CSS section I gave it an animation. And the animation didn't work
@sayhii6338
@sayhii6338 5 месяцев назад
@@IsaacAsante17 but if the class name is replaced with something else... the animation runs. I'm confused. What's wrong with the class name "fade"
@sayhii6338
@sayhii6338 5 месяцев назад
@@IsaacAsante17 I just found out the problem. It turns out the class name "fade" is connected to bootstrap. So when it's not connected to it. The animation runs with the class name fade
@nextrie
@nextrie 5 месяцев назад
@@sayhii6338 Good to know you found the problem. That looked like a tricky situation, indeed. All the best with your coding.
@nextrie
@nextrie 5 месяцев назад
I want to clarify that at 0:31, when I say you get 807, I mean that you'll get this result after summing up both numbers. That's because after processing the first linked list, you get the original input 342. After processing the second linked list, you get 465. Using the normal addition operator, you get 807. You can then process 807 using a combination of modulo and integer division operations to store each digit in a new linked list in reverse order.
@treslivingston
@treslivingston 5 месяцев назад
Thank you!! I have learned a lot from these videos
@nextrie
@nextrie 5 месяцев назад
I'm so glad! I hope you subscribe! I'm going to resume coding challenge videos very soon. I've got some new equipment on the way for this. :)
@user-db6iu2vm3k
@user-db6iu2vm3k 5 месяцев назад
How can I get API KEY? And where?
@nextrie
@nextrie 5 месяцев назад
I've got a video on how to get a Bard API key here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-tWk3Q9xIsVE.html
@mridulasthana8111
@mridulasthana8111 5 месяцев назад
Please explain with 8 bit machine, thanks
@MostafaMaher98
@MostafaMaher98 6 месяцев назад
thank you so much, it's the most straightforward way
@nextrie
@nextrie 6 месяцев назад
You're welcome. I hope you enjoy my other tutorials. I've got more of them coming up soon.
@World-Of-Mr-Motivater
@World-Of-Mr-Motivater 6 месяцев назад
nice solution
@nextrie
@nextrie 6 месяцев назад
Thanks!
@ssd1374
@ssd1374 6 месяцев назад
Good stuff man. I just needed an explanation of the problem, not even the code. I was able to solve right away once I actually understood the problem (VERY important in programming).
@nextrie
@nextrie 6 месяцев назад
Great to know!
@ginger_breadman
@ginger_breadman 6 месяцев назад
How were the names inputted - via keyboard entry?
@nextrie
@nextrie 6 месяцев назад
Yeah, the HackerRank system takes care of those.
@kwameotengdankwa425
@kwameotengdankwa425 6 месяцев назад
Ist the DOB an array or a string ?
@nextrie
@nextrie 6 месяцев назад
It's a string, but in programming, a string is an array of characters. That's why you can apply array methods on strings.
@kwameotengdankwa425
@kwameotengdankwa425 6 месяцев назад
so you used the split method to turned the const DOB to an array@@nextrie
@nextrie
@nextrie 6 месяцев назад
@@kwameotengdankwa425 Yeah, I'm using the split method to divide it into an array of substrings.
@AmanMishra-hy5fk
@AmanMishra-hy5fk 6 месяцев назад
I need your sir pls help
@nextrie
@nextrie 6 месяцев назад
How can I help you?
@deleteduser4033
@deleteduser4033 6 месяцев назад
god
@danielperalta2624
@danielperalta2624 7 месяцев назад
where I can get the api key?
@nextrie
@nextrie 6 месяцев назад
You can get one on Google's MakerSuite platform.
@abgamer4388
@abgamer4388 7 месяцев назад
the api key is free?
@nextrie
@nextrie 7 месяцев назад
Yeah, it's currently free. :)
@may_as.well2
@may_as.well2 7 месяцев назад
Thank you this helped a bunch!
@nextrie
@nextrie 7 месяцев назад
Great to know! Hope you subscribe for more tutorials :)
@lioncrud9096
@lioncrud9096 7 месяцев назад
does this method work if you input a negative number?
@nextrie
@nextrie 7 месяцев назад
If your input is less than zero, the function will NaN (not a number).
@lioncrud9096
@lioncrud9096 7 месяцев назад
ah ok thank you!@@nextrie
@kamalkamals
@kamalkamals 7 месяцев назад
again that s not full bard api, on the documentation you have not web search to look for current information.
@kamalkamals
@kamalkamals 7 месяцев назад
that s not bard 100% it s model palma and cannot give you current information like weather ...etc, bard use web search with scrapping pages of result
@0verrun292
@0verrun292 7 месяцев назад
Could you explain why we typed -i on [size-1-i] ?
@nextrie
@nextrie 7 месяцев назад
You can think of it this way below: First iteration: i = 0, so arr[size-1-i] is the size of the array, minus 1 (because array indices are zero-based), and minus zero again (which is the value of i). So, at the first iteration, we get the value of the array's last element. Second iteration: The value of i is 1, so we get the second-to-last element's value. Third iteration: The value of i is 2, so we get the element before that. Fourth iteration: The value of i is 3, so we get the value before the previous one again. By the time the For Loop terminates, we'd have accessed the last 4 elements at the end of the array in backward sequence, which is what we need to compute the value of "maxsum" variable. I hope this helps.
@lutfi8748
@lutfi8748 7 месяцев назад
is it free unlike in ChatGPT API???
@nextrie
@nextrie 7 месяцев назад
For public preview, yes, it's free to try it out. However, to use it on Vertex AI, here is the pricing information: cloud.google.com/vertex-ai/docs/generative-ai/pricing
@Cloudxxx23
@Cloudxxx23 8 месяцев назад
this doesn't work on pycharm. The inputs on n and arr variables are empty. What values are we supposed to put in there? Hackerrank must have explanations at every challenge why the syntaxes are like this and so on...
@nextrie
@nextrie 8 месяцев назад
Oh, interesting... I agree that clarity can be a problem on HackerRank sometimes.
@safi6173
@safi6173 8 месяцев назад
I already see the page and the button to generate an API key. but I keep getting internal error has occurred. how long do you wait until you manage to generate the API key?
@nextrie
@nextrie 8 месяцев назад
In my case, the API key worked instantly. Where are you seeing the error?
@safi6173
@safi6173 8 месяцев назад
@@nextrie right after i select existing or new google cloud project.
@nextrie
@nextrie 8 месяцев назад
@@safi6173 If you're using a VPN, try turning it off. You can also try from your phone, using a different connection. The alternative is to retry in a few hours.
@safi6173
@safi6173 8 месяцев назад
@@nextrie after waiting 3 days I managed to generate the API key.
@nextrie
@nextrie 8 месяцев назад
@@safi6173 Great! That's weird, though. At least, it's working for you now.
@goldmenberd1350
@goldmenberd1350 8 месяцев назад
This is the palm2 api, the model is text bison. It is not bard api.
@kevinfrancis7819
@kevinfrancis7819 8 месяцев назад
The explanation is very 😞
@nextrie
@nextrie 8 месяцев назад
Oh no, I'll try to improve my future short videos. I hope you're getting value from my other videos.
@Pinkijhabnp
@Pinkijhabnp 8 месяцев назад
Is there any module named google.generativeai
@nextrie
@nextrie 8 месяцев назад
Yeah, but you have to install it first via PIP command. In your coding environment's terminal, you can run this: pip install google-generativeai
@manisharya2138
@manisharya2138 8 месяцев назад
it truely helpful , and also working well
@nextrie
@nextrie 8 месяцев назад
I'm happy to hear this. I'll resume uploading videos soon.
@Web-Himansu
@Web-Himansu 8 месяцев назад
you just teach us syntax. make a push method related very small project where you can push any item in array and it show in DOM used
@user-ny6tz2rb1r
@user-ny6tz2rb1r 8 месяцев назад
There is no essence of solving this problem.If we use inbuilt function.
@nextrie
@nextrie 8 месяцев назад
Sure, but it's good to think about how we could solve this problem manually, without using inbuilt functions. It's just for practice.
@goldenwind5681
@goldenwind5681 8 месяцев назад
Thanks bro
@nextrie
@nextrie 8 месяцев назад
You're welcome, bro!
@anthonyerdenetuguldur5609
@anthonyerdenetuguldur5609 9 месяцев назад
Difficult is "Easy" on this challenge on HackerRank, it is more like Medium. I have taken a tutorial on list comprehensions, and it never showed how to have multiple loops together in a list comprehension. HackerRank should built the user up to this challenge.