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$ …
Author Archives: czxttkl
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 \ …
Continue reading “Leetcode 298: Binary Tree Longest Consecutive Sequence”
Leetcode 70: Climbing Stairs
70. Climbing Stairs Total Accepted: 139063 Total Submissions: 363734 Difficulty: Easy Contributors: Admin You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Code from math import sqrt …
Leetcode 258: Add Digits
258. Add Digits Total Accepted: 134747 Total Submissions: 269960 Difficulty: Easy Contributors: Admin Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one …
Leetcode 262: Trips and Users
262. Trips and Users Total Accepted: 6774 Total Submissions: 43127 Difficulty: Hard Contributors: Admin The Trips table holds all taxi trips. Each trip has a unique Id, while Client_Id and Driver_Id are both foreign keys to the Users_Id at the Users table. Status is an ENUM type of (‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’). +—-+———–+———–+———+——————–+———-+ | Id | …
Sql Cheat Sheet
http://www.w3schools.com/sql/sql_quickref.asp http://files.zeroturnaround.com/pdf/zt_sql_cheat_sheet.pdf
Leetsql 185: Department Top Three Salaries
185. Department Top Three Salaries Total Accepted: 8926 Total Submissions: 57724 Difficulty: Hard Contributors: Admin The Employee table holds all employees. Every employee has an Id, and there is also a column for the department Id. +—-+——-+——–+————–+ | Id | Name | Salary | DepartmentId | +—-+——-+——–+————–+ | 1 | Joe | 70000 | 1 …
Continue reading “Leetsql 185: Department Top Three Salaries”
LeetSql 177: Nth Highest Salary
177. Nth Highest Salary Total Accepted: 12870 Total Submissions: 80808 Difficulty: Medium Contributors: Admin Write a SQL query to get the nth highest salary from the Employee table. +—-+——–+ | Id | Salary | +—-+——–+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +—-+——–+ For example, given the …
Leetcode 40: Combination Sum II
40. Combination Sum II Total Accepted: 89506 Total Submissions: 294097 Difficulty: Medium Contributors: Admin Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the combination. Note: All numbers (including …