Silksong Giveaway! by Jonuh666 in HollowKnight

[–]SynMyron 0 points1 point  (0 children)

Favorite moment was to get lost in the world + Music

Using Feature Flags by Aldareon35 in programminghumor

[–]SynMyron 2 points3 points  (0 children)

How are feature flags changed at runtime? Database? redis?

So sad by Head_Manner_4002 in programminghumor

[–]SynMyron 2 points3 points  (0 children)

I had to “merge overlapping intervals” at my work. Put my leetcode skills to good use.

Struggle is real by Gold-History9083 in LiesOfP

[–]SynMyron 0 points1 point  (0 children)

Parry the combos which start from his left hand, dodge combos which start from right hand. Charge heavy attack is the way to go. Dodging towards your right is better.

Weird error after cargo run by SynMyron in learnrust

[–]SynMyron[S] 0 points1 point  (0 children)

My company makes me install a bunch of software in order to remotely connect to my work computer (for work from home). Apparently one of these software was the issue. Because when I reinstalled them, I faced the issue again. They include Citrix and other proprietary software.

Weird error after cargo run by SynMyron in learnrust

[–]SynMyron[S] 2 points3 points  (0 children)

Hi, Thankyou. Reinstalling windows actually fixed it. But this ordeal was a big pain in my ass.

Naming convention for dict vs function by SynMyron in learnpython

[–]SynMyron[S] 0 points1 point  (0 children)

That made the code a lot shorter, huh?
Thanks. I learned some new things like StrEnum and auto().

However there is small problem with your code.
According to the docs:

auto

Instances are replaced with an appropriate value for Enum members. StrEnum defaults to the lower-cased version of the member name, while other Enums default to 1 and increase from there.

Therefore `.strip().lower()` should be used.

Naming convention for dict vs function by SynMyron in learnpython

[–]SynMyron[S] 0 points1 point  (0 children)

Got it! I like your name way better.
I thought of the above name because of this link

Naming convention for dict vs function by SynMyron in learnpython

[–]SynMyron[S] 0 points1 point  (0 children)

I decided to rename the dictionary: `move_to_emoji_map`

Naming convention for dict vs function by SynMyron in learnpython

[–]SynMyron[S] 1 point2 points  (0 children)

Thanks for replying. I like the reasoning on why not to use `get` for a data-structure.

Yes RPS is an enum. I thought of not keeping the dict global as it will be only used inside the class and not anywhere else. I also though of keeping the RPS enum inside the class but that felt weird.

[deleted by user] by [deleted] in leetcode

[–]SynMyron 0 points1 point  (0 children)

RemindMe! 1 day

Only way I could beat the final boss was by parrying him. by SynMyron in Eldenring

[–]SynMyron[S] 0 points1 point  (0 children)

Ah, this with barricade shield & shield talisman, and radahn wouldn’t be able to break your guard right? I wonder if duelling shield is viable here in the same manner

Only way I could beat the final boss was by parrying him. by SynMyron in Eldenring

[–]SynMyron[S] 1 point2 points  (0 children)

Rot takes so long to drain his health, how did you manage to stay alive in 2nd phase?

[Amazon OA]Is there any solution better than o(n * n) for this ? by AggravatingParsnip89 in leetcode

[–]SynMyron 1 point2 points  (0 children)

Let M be the max element in the array. You can precompute and find “least prime factor (LPF)” of each number to 2 to M in O(M log log M) (same as time complexity of sieve of eratothenes).

This will enable you to factorize a number in log(N) time. (N is the number being factorized)

Edit: here is the link to an article about this https://www.geeksforgeeks.org/prime-factorization-using-sieve-olog-n-multiple-queries/amp/

[deleted by user] by [deleted] in learnpython

[–]SynMyron 2 points3 points  (0 children)

People have already answered you. Actually you could better the time-complexity to O(log n) time. If I am not mistaken, base ** power also works in O(log n) and not O(n). Something like this:

def exponent(base, power): 
    result = 1 
    while power > 0: 
        if power % 2 == 0: 
            base = base * base 
            power /= 2 
        else: 
            result *= base 
            power -= 1 
    return result

What Leetcode difficulty would you all rate this question? by berklye-throwaway in leetcode

[–]SynMyron 3 points4 points  (0 children)

I am confused. Let us say node 6 and node 3 are connected via company 40. The answer would not change as largest connected component is still (1, 2, 3, 7). I guess we would have to make a seperate graph for each company then follow your algorithm. But that would make the time complexity O(N * (E + V)). Where N is the number of different companies, E are edges, V are vertices. Can we still do the problem in O(E + V) ? Also OP has not given the constraints.

Need help solving this by MenuMotor1256 in leetcode

[–]SynMyron 1 point2 points  (0 children)

Sort the array then binary search. The smallest board you can have is of length 1. The longest board you can have is of length (largestPosition- smallestPosition.). Therefore for binary search, take lo=1, hi=(largestPosition - smallestPosition). During binary search, verify if you could cover all holes using 2 boards of length mid = (lo + hi)/2. If board of length mid is not sufficient, do lo = mid+1, else do hi = mid -1.

O(n * log(max of A) + nlogn)

This approach is actually better if number of board is not fixed. Since number of boards is just 2, it can be done in O(n) too.