ASMR LeetCode: Final Array State After K Multiplication Operations I | Chill Coding

  Рет қаралды 14

LeekCodeDev

LeekCodeDev

Күн бұрын

Пікірлер: 1
@LeekCodeDev
@LeekCodeDev Ай бұрын
Source Code: class Solution: def getFinalState(self, nums: List[int], k: int, multiplier: int) -> List[int]: ''' To solve this problem, we essentially have to go through each element in the array, find the smallest number that we've seen, and we multiply it with the given multiplier. We repeat this k times. I first thought about perhaps using a priority queue to extract the smallest element easily, but I realized that this could change the initial order of our array, in which we kind of need to preserve our original order. Going through the array n times isn't too bad for our time complexity, so I figured that the brute force solution would be the best here :) ''' smallest = float('inf') chosen_one = 0 for i in range(k): for j in range(len(nums)): if nums[j] < smallest: chosen_one = j smallest = nums[j] nums[chosen_one] *= multiplier smallest = float('inf') return nums
LeetCode Day 23: Partition Labels [ No Audio ]
8:23
LeekCodeDev
Рет қаралды 13
How I Got Good at Coding Interviews
6:29
NeetCode
Рет қаралды 1,7 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
The "Just One More" Paradox
9:13
Marcin Anforowicz
Рет қаралды 3,2 МЛН
I Made Chess 2.0
14:32
From Scratch
Рет қаралды 1,6 МЛН
How to STUDY so FAST it feels like CHEATING
8:03
The Angry Explainer
Рет қаралды 2,6 МЛН
[ Codeforces ] 1475B: New Year's Number | C++
5:04
LeekCodeDev
Рет қаралды 12
I Remade Star Wars VFX in 1 Week
10:39
ErikDoesVFX
Рет қаралды 2,9 МЛН
Zig for Impatient Devs
9:48
Isaac Harris-Holt
Рет қаралды 120 М.
Fiction's Most Evil Villains Explained in 8 Minutes
8:17
Nonagon
Рет қаралды 1 МЛН
Constructors Are Broken
18:16
Logan Smith
Рет қаралды 121 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН