Aizon the DreadedHippy πŸ¦€ (@HippyDreaded) header
Aizon the DreadedHippy πŸ¦€ (@HippyDreaded) profile picture

SWE, #rust, Competitive Programmer. I am simply the best. ✨Github: https://teapaw.org/t.co/5KKcJ34VEv ✨Codeforces: https://teapaw.org/t.co/uYYkeQXauq

Online
Joined September 2019
Photo by Aizon the DreadedHippy πŸ¦€ (@HippyDreaded)Photo by Aizon the DreadedHippy πŸ¦€ (@HippyDreaded)Photo by Aizon the DreadedHippy πŸ¦€ (@HippyDreaded)Photo by Aizon the DreadedHippy πŸ¦€ (@HippyDreaded)Photo by Aizon the DreadedHippy πŸ¦€ (@HippyDreaded)Photo by Aizon the DreadedHippy πŸ¦€ (@HippyDreaded)Photo by Aizon the DreadedHippy πŸ¦€ (@HippyDreaded)Photo by Aizon the DreadedHippy πŸ¦€ (@HippyDreaded)Photo by Aizon the DreadedHippy πŸ¦€ (@HippyDreaded)Photo by Aizon the DreadedHippy πŸ¦€ (@HippyDreaded)
Day #100 of #100DaysOfRust, all good things come to an end 🧡 The final boss, the multithreaded web server ⭐Git: github.com/DreadedHippy/mult… Some time this year, I felt serverely lacking and decided to sharpen my DSA skills. I stumbled across @fireship_dev 's Rust in 100 seconds
1
19
1,573
Today's Leetcode Keys: 1. Sort the array 2. dp[i][0]: max j >= i when nums[i] is unmodified 3. dp[i][1]: modified case 4. Pull DP: dp[i] depends on dp[i+1]. 6. It is sometimes optimal to skip an element 7. Simulate skipping by ...
1
10
233
... by setting dp[i] = dp[i+1] and subtracting 1 from both cases i.e, dp[i] = [dp[i+1][0] - 1, dp[i+1][1] -1) 8. answer is (max(dp[i][0], dp[i][1]) - i) + 1 Note: Since i depends only on i+1, you can use variables instead of an array.
1
18
Woah, my solution to today's leetcode has a runtime of 15ms, and the leaderboard starts at 50ms. I looked into it and it seems my solution is faster than the editorial's πŸ‘€ (See image 2, my solution is second)
2
6
453
I'll drop an explanation tonight
20
Today's Leetcode: Keys: 1. Consider "changing" an element as "deleting" it. The idea behind that can be seen in image 3. 2. It is optimal to delete the 2 lowest numbers, 2 highest numbers, or the highest and the lowest numbers. 3. You can sort or track max and min and calculate
1
13
280
Today's Leetcode: Keys: 1. Iterate only odd indices 2. Count how many indices i such that s[i] != s[i-1]
7
290
Today's Leetcode: Precomputation + Factorization + DP Resorted to editorial.πŸ˜” Keys: 1. Precompute factors of numbers <= n 2. Get minimum cost for all substrings with len >= 2 3. Dynamic programming with memoization for all possible k-splits of the given string.
2
19
Today's Leetcode: Keys: 1. The problem statement itself is basically the algorithm in plain english
9
366
Today's Leetcode: Keys: 1. Prefix sums 2. Even and odd prefix sums 3. Even - odd == odd, odd - even == odd 4. Consider the empty prefix, 0. 5. Modulo on your result
1
6
197
Today's Leetcode: Keys: 1. Prefix sum 2. initialize ans with i32::MAX; 3. check every possible window starting at a given index and greedily minimize ans. 4. Return ans
8
408
Today's Leetcode: Prefix Sum + Monotonic Stack + Binary Search Keys (to my approach): 1. Keep a prefix sum of the array (for querying) 2. Initialize a monotonic stack (for variable prefix max) 3. Iterate from right to left 4. For current i, get pms(i) defined as ...
1
5
316
... the prefix max sum of the array starting at i e.g. pms([3,2,1,4,4,]) = sum([3,3,3,4,4]) 5. Binary search using your monotonic stack for the j >= i such that pms([i, j]) <= k ans pms([i, j+1]) > k 6. Add the value of (j - i) + 1 to your result. Return the final result
1
29
My solution seems to be sub-optimal. I will be sure to check out the optimal solution
21
Today's Leetcode: Keys: 1. Keep a count for strictly increasing 2. Keep count of strictly decreasing 3. Keep maximum of either 4. Iterate 5. Greedily update all 3 variables 6. Return the maximum
2
7
279
Today's Leetcode: Minimum cost Keys: 1. Get min cost for both type 1 and type 2. 2. Use that min cost until need1 or need 2 becomes 0 3. Get min cost for type 1 alone, or type 2 alone 4. You can use cost_both for the "alone" costs 5. Add all these costs. 6. Beware of overflow.
6
299
Today's Leetcode: Stairs cost Keys: 1. Iterate through the indices 2. For each i, get the minimum cost to jump to (i+1, i+2, or i+3) 3. Memoization.
4
136
Today's Leetcode: Busy Servers Keys: 1. Keep all free servers in ordered set. 2. Create min-heap for busy servers 3. Initialize busy array 4. Iterate though tasks 5. At start of iteration, free up completed servers i.e. completion <= arrival[i] 6. If no server available, skip...
1
9
310
... 7. Query for first server >= (i%k). If none.... 8. Use the smallest available server. - Note: ordered set is important here because query is O(log n) 9. Keep in min-heap (arrival[i] + load[i], server). 10. Update busy value. 11. Return indices of busiest servers
13
Today's Leetcode: Grid counting Keys: 1. Iterate through the grid 1. Keep track of server cnt for: - Entire grid - Each row - Each column 3. Iterate a second time 4. for each cell with a server where row cnt is 1 and col cnt is 1, subtract from total server count...
3
9
357