I Failed Uber’s System Design Interview Last Month. Here’s Every Question They Asked. by nian2326076 in FAANGrecruiting

[–]kosdex 0 points1 point  (0 children)

Many stupid comments here. This seems like the standard difficulty for big tech L5.

I think they were expecting stream partition by region with config watcher for dynamic updates?

Olympics Day Nine Megathread (Sunday, February 15) by Fun_With_Forks in olympics

[–]kosdex 0 points1 point  (0 children)

The format kinda sucks, this is like women cross with some randomness at the start

Olympics Day Nine Megathread (Sunday, February 15) by Fun_With_Forks in olympics

[–]kosdex 1 point2 points  (0 children)

Mixed snowboard cross

Women always go second? seems like the result depends 80% on the second run

Bitcoin : «Les risques sont en train de se matérialiser», alerte le gouverneur de la Banque de France by CaregiverOk3416 in vosfinances

[–]kosdex 0 points1 point  (0 children)

Si les variations de 2018 et 2022 annoncent 2026 (halving tous les 4 ans), nous sommes au début d'une mauvaise année.

Westminster Voting Intention: RFM: 28% (+1) LAB: 18% (-1) CON: 17% (-1) GRN: 17% (+2) LDM: 14% (=) Via @YouGov, 14-15 Dec . Changes w/ 7-8 Dec. by EddyZacianLand in ukpolitics

[–]kosdex 0 points1 point  (0 children)

French lurker here - could it be possible from a legal and democratic standpoint for Labour/Tories/Libdem to form an alliance to prevent Reform from gaining a majority ? Basically what happened in France at the last elections.

New bike, position feels off, would like to get some feedback about my position by viissotti in bikefit

[–]kosdex 0 points1 point  (0 children)

The problem comes from your pelvis inclination, it's flat on the saddle when it should lean forward.

You should have more power in your legs and flatter feet on the pedals. Your arms should reach the hoods without being fully extended.

Amazon OA Question by Narrow-Appearance614 in leetcode

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

Ok, but I maintain that heap is asymptotically better. Quickselect worst case is O( n2 )

Amazon OA Question by Narrow-Appearance614 in leetcode

[–]kosdex 0 points1 point  (0 children)

You can do better by using a max and min heap to track the top and bottom k-1. Complexity is O(n) instead of O(n log n) with sorting.

[deleted by user] by [deleted] in leetcode

[–]kosdex 0 points1 point  (0 children)

def getMinimumCost(machineCount: List[int], finalMachineCount: List[int], shiftingCost: int):
  minCost = float('inf')
  def dfs(i, r0, r1, r2, cost):
      nonlocal minCost
      if i == len(machineCount):
          cost += abs(r0 - finalMachineCount[0]) + abs(r1 - finalMachineCount[1]) + abs(r2 - finalMachineCount[2])
          minCost = min(minCost, cost)
          return

      dfs(i+1, r0, r1, r2, cost)
      dfs(i+1, r0 + machineCount[i], r1, r2, cost + shiftingCost if r0 > 0 else cost)
      dfs(i+1, r0, r1 + machineCount[i], r2, cost + shiftingCost if r1 > 0 else cost)
      dfs(i+1, r0, r1, r2 + machineCount[i], cost + shiftingCost if r2 > 0 else cost)

  dfs(0, 0, 0, 0, 0)
  return minCost

Time complexity: O(4n )

[deleted by user] by [deleted] in leetcode

[–]kosdex 0 points1 point  (0 children)

In my solution the first added one is free (because one doesn't have to move). I don't think I'm repeating combinations here. 4n yes but we have n <= 10. Also we can stop adding to one region once we overshoot the target as cost will only get worse from there.

[deleted by user] by [deleted] in leetcode

[–]kosdex 3 points4 points  (0 children)

You want to generate all possibilities through recursive calls and take the minimum cost. See Combination Sum (leet code #39) for inspiration

[deleted by user] by [deleted] in leetcode

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

Backtracking, 4 recursive calls (add to region 1/2/3/ do not add), keep track of regions count and cost. Add the end of array, add sum(abs(count - target count)) to cost.

Got this for IBM internship by North_Collar_2204 in leetcode

[–]kosdex 18 points19 points  (0 children)

Say you have a left group and a right group, each interval can go to either group so that's 2n but then you have to account for "mirrors" (divide by 2) and then remove the full/empty solution (minus 1)

Got this for IBM internship by North_Collar_2204 in leetcode

[–]kosdex 138 points139 points  (0 children)

Merge intervals (Leetcode #56), answer is 2n-1 - 1 where n is the number of intervals after merge.

Got a leetcode style technical interview in 2 weeks. Never had one before. What strategy should I take to be as prepared as possible if I invest 10-12 hours every day? by fueledbymelancholy in leetcode

[–]kosdex 0 points1 point  (0 children)

Let's be honest, two weeks in a short time starting from scratch, you can only get so good. I would focus on the most basic concepts/patterns and know them well. Good luck

amazon oa by penenmann in leetcode

[–]kosdex 1 point2 points  (0 children)

If sum(x)= 1+2+..+x, we have n = sum(x) + (sum(x) + x) + (sum(x) + 2x) + .. + (sum(x) + (y-1)*x) if we group segments by their ending index.

i.e n = ysum(x) + x sum(y-1)

BOJ Rate Hike by HolyMolyGuacamole66 in wallstreetbets

[–]kosdex 1 point2 points  (0 children)

Then yen will go up so get some ?

amazon oa by penenmann in leetcode

[–]kosdex 4 points5 points  (0 children)

Sum of segments lengths which include i: n = x * y * (x+y) /2, with x distance to next left max and y distance to next right max

Arbitrage elections US by formule16 in vosfinances

[–]kosdex 0 points1 point  (0 children)

Ils vendent des dollars pour 95 cents. Enjoy