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 …
Monthly Archives: November 2016
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 …
Leetcode 341: Flatten Nested List Iterator
341. Flatten Nested List Iterator Total Accepted: 20339 Total Submissions: 55207 Difficulty: Medium Contributors: Admin Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or a list — whose elements may also be integers or other lists. Example 1:Given the list [[1,1],2,[1,1]], By calling next repeatedly …
Continue reading “Leetcode 341: Flatten Nested List Iterator”
Leetcode 27: Remove Element
27. Remove Element Total Accepted: 154492 Total Submissions: 426032 Difficulty: Easy Contributors: Admin Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. The order of elements can be …
Leetcode 29: Divide Two Integers
29. Divide Two Integers Total Accepted: 82624 Total Submissions: 519755 Difficulty: Medium Contributors: Admin Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. Code (Naive) import sys class Solution(object): def divide(self, dividend, divisor): “”” :type dividend: int :type divisor: int :rtype: int “”” if not divisor: …