Leetcode 178: Rank Score

https://leetcode.com/problems/rank-scores/ 178. Rank Scores  Total Accepted: 13824 Total Submissions: 58154 Difficulty: Medium Contributors: Admin Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the next ranking number should be the next consecutive integer value. In other words, there …

Leetcode 3466: Moving Average from Data Stream

346. Moving Average from Data Stream Total Accepted: 11701 Total Submissions: 20717 Difficulty: Easy Contributors: Admin Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window. For example, MovingAverage m = new MovingAverage(3); m.next(1) = 1 m.next(10) = (1 + 10) / 2 m.next(3) = …

Leetcode 163: Missing Ranges

163. Missing Ranges Total Accepted: 19465 Total Submissions: 66232 Difficulty: Medium Contributors: Admin Given a sorted integer array where the range of elements are in the inclusive range [lower, upper], return its missing ranges. For example, given [0, 1, 3, 50, 75], lower = 0 and upper = 99, return ["2", "4->49", "51->74", "76->99"].   …

Leetcode 388: Longest Absolute File Path

388. Longest Absolute File Path Total Accepted: 11837 Total Submissions: 35565 Difficulty: Medium Contributors: Admin Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: dir subdir1 subdir2 file.ext The directory dir contains an empty sub-directory subdir1 and a sub-directory subdir2 containing a file file.ext. The string "dir\n\tsubdir1\n\t\tfile1.ext\n\t\tsubsubdir1\n\tsubdir2\n\t\tsubsubdir2\n\t\t\tfile2.ext" …

Why do we use Poisson distribution or Negative Binomial distribution for regression?

Let’s say we have predictor variables (features) denoted as $latex X \in \mathbb{R}^n$ and response variable (label) $latex y$ whose underlying random variable is $latex Y$. If we want to fit an Ordinary Least Square (OLS) regression such that $latex y=WX+\epsilon$ where $latex \epsilon$ is an error term, then we have the following assumptions:  strict exogenous: $latex E(\epsilon|X)=0$ …

Leetcode 198: House Robber

https://leetcode.com/problems/house-robber/ 198. House Robber  Total Accepted: 101581 Total Submissions: 275668 Difficulty: Easy Contributors: Admin You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it …

Leetcode 298: Binary Tree Longest Consecutive Sequence

https://leetcode.com/problems/binary-tree-longest-consecutive-sequence/ Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The longest consecutive path need to be from parent to child (cannot be the reverse). For example, 1 \ …