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.
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?
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. :)
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/
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.
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
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
@@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.
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
@@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
@@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
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.
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).
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.
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
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...
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?
@@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.
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.