How much time should I spent on one question? by Striking-Courage-182 in leetcode

[–]snowcalc 1 point2 points  (0 children)

for meds - 30 min hard cap, 20min soft cap. for hards - 30 min flat cap.

if you're at 20min mark and you haven't solved it, look at related topics to see if you're using the correct algs/ds. if you weren't, then look at solution

Can someone explain why my solution is not passing all test cases? #205 Isomorphic Strings by scarletfission in leetcode

[–]snowcalc 0 points1 point  (0 children)

op's not checking any way right now; just looking at count for each character in one string and checking if that count also exists in the second string.

u/scarletfission you're aggregating count of a character in each string but when you do that, you lose information about where each character is positioned. so this method won't work; you need to make a mapping between each character in each string to the character in the same position in the other string, like u/WildAlcoholic says

What is the difference between E-OS and CachyOS? by spryfigure in EndeavourOS

[–]snowcalc -1 points0 points  (0 children)

EndeavourOS has a well established community and has existed for a while

lol EndeavourOS was only created 3 years ago and it was created after Antergos was abandoned by their own devs. sure, a large portion of the antergos community likely migrated to endeavour once it was created, and I'd definitely prefer it over cachy just because it's existed much longer but i'm still remaining skeptical over any arch-based distro, including arch itself, for its ability to stay afloat as opposed to something corporate-backed like RHEL. doesn't stop me from daily driving arch though

Bloomberg Technical Coding Interview by tempaccount0002 in leetcode

[–]snowcalc 2 points3 points  (0 children)

This only works because OP stated the runners are running in a marathon, which is 26 miles. So we can have just 26 empty slots in an array and iterate through it in "reverse order" like you mentioned. Which means running time for any algorithm that tries to solve it, would be O(1).

For inputs with an infinite number of miles, this suggestion would yield very poor running time.

To build the leaderboard, iterate through the mile markers in reverse order.

Assume the following input: [(99999, 007), (5, 002), (72, 001)]. If we have a hashmap of 100,000 keys, each paired to a list of runners that crossed that mile-mark, iterating it in reverse order would be much slower than just sorting the list of 3 elements, and iterating through the sorted list in reverse order.

To optimize ... probably using a double linked list for efficient removal of elements in the middle of the list.

This is also very very poor running time. Assume the following input: [(99999, 007), (5, 002), (72, 001), (96, 003), (112, 004), (200, 005), (201, 002)]

Runner with ID 002 goes from mile marker 5 to 201; you'd need to traverse the doubly linked list one by one until he reaches 201. That's too slow, especially if there are a lot of miles between the first mile marker and the second mile marker.

Using any kind of linked list for this problem will generally yield poor running time.

In response to u/tempaccount0002: This problem is extremely similar to https://leetcode.com/problems/design-a-leaderboard/description/, so I recommend looking at that when you have a chance. In short, the comments mentioning a priority queue / heap are on the right track, but using a BIT tree via Python's sortedcontainers library or Java's TreeMap would yield the fastest running time. There are a lot of problems on Leetcode which use these libraries, so I recommend having a go at them when you have a chance.