- 博客(43)
- 资源 (8)
- 收藏
- 关注
原创 Leetcode 133. Clone Graph
Leetcode 133. Clone GraphGiven a reference of a node in a connected undirected graph.Return a deep copy (clone) of the graph.Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors.class Node { public int val; pub
2021-07-30 00:03:36
314
原创 Leetcode1482. Minimum Number of Days to Make m Bouquets [Medium] Python Binary Search
Given an integer arraybloomDay, an integermand an integerk.We need to makembouquets. To make a bouquet,you need to usekadjacent flowersfrom the garden.The garden consists ofnflowers, theithflower will bloom in thebloomDay[i]and then can...
2020-08-13 01:13:45
279
原创 Leetcode 410 Split Array Largest Sum [Hard] Python Binary Search
Given an array which consists of non-negative integers and an integerm, you can split the array intomnon-empty continuous subarrays. Write an algorithm to minimize the largest sum among thesemsubarrays.Note:Ifnis the length of array, assume the f...
2020-08-12 23:52:08
526
原创 Leetcode 1148.1149 Article Views
drop table ViewsCreate table Views (article_id int, author_id int, viewer_id int, view_date date)insert into Views (article_id, author_id, viewer_id, view_date) values ('1', '3', '5', '2019-08-01'...
2020-03-10 06:14:35
704
原创 Leetcode 1113. 1132 Reported Posts
drop table ActionsCreate table Actions (user_id int, post_id int, action_date date, action varchar(20), extra varchar(20))insert into Actions (user_id, post_id, action_date, action, extra) values ...
2020-03-09 06:30:16
764
原创 Leetcode 1141. 1142 User Activity for the Past 30 Days
drop table ActivityCreate table Activity (user_id int, session_id int, activity_date date, activity_type varchar(20))insert into Activity (user_id, session_id, activity_date, activity_type) values...
2020-03-09 04:11:11
2438
原创 LeetCode 1158,1159 Market Analysis
drop table Usersdrop table Ordersdrop table Itemscreate table Users (user_id int, join_date date, favorite_brand varchar(20))create table Orders (order_id int, order_date date, item_id int, buyer...
2020-03-08 09:16:18
783
原创 LeetCode 1075, 1076,1077 Project Employees
drop table Projectdrop table EmployeeCreate table Project (project_id int, employee_id int)Create table Employee (employee_id int, name varchar(20), experience_years int)insert into Project (pro...
2020-03-08 05:27:34
392
原创 LeetCode 1082,1083,1084 Sales Analysis
Create table If Not Exists Product (product_id int, product_name varchar(10), unit_price int)Create table If Not Exists Sales (seller_id int, product_id int, buyer_id int, sale_date date, quantity i...
2020-03-07 00:53:46
324
原创 Email Open Rate
Create table emails (email_id int, sent_date DATE NULL, status varchar(20))Truncate table emailsinsert into emails (email_id, sent_date, status) values ('1', '2017-01-01', 'sent')insert into email...
2019-09-18 05:19:42
460
原创 Leetcode 601. Human Traffic of Stadium
X city built a new stadium, each day many people visit it and the stats are saved as these columns:id,visit_date,peoplePlease write a query to display the records which have 3 or more consecutive...
2019-09-18 04:36:39
542
原创 LeetCode 615 Average Salary: Departments VS Company
Given two tables as below, write a query to display the comparison result (higher/lower/same) of the average salary of employees in a department to the company's average salary.So for the sample ...
2019-09-17 04:38:17
313
原创 LeetCode 1068 1069 Product Sales Analysis
drop table Productdrop table SalesCreate table Sales(sale_id int,product_id int,year int,quantity int,price int);Create table Product(product_id int,product_name varchar(20));insert into Sales v...
2019-09-10 11:59:39
339
原创 LeetCode 511, 512, 534, 550 Game Play Analysis
(player_id, event_date) is the primary key of this table.This table shows the activity of players of some game.Each row is a record of a player who logged in and played a number of games (possibly 0...
2019-09-09 11:08:35
1315
原创 LeetCode 1075. 1076 Project Employees
drop table Projectdrop table EmployeesCreate table Project(project_id int,employee_id int);insert into Project values(1,1);insert into Project values(1,2);insert into Project values(1,3);inse...
2019-09-08 12:23:15
480
原创 Leetcode 594. Longest Harmonious Subsequence Python
594.Longest Harmonious SubsequenceWe define a harmounious array as an array where the difference between its maximum value and its minimum value isexactly1.Now, given an integer array, you need...
2019-08-01 11:54:10
231
原创 Leetcode Backtracking Python
Backtracking 的基本套路是for循环加一个dfs.77.CombinationsGiven two integersnandk, return all possible combinations ofknumbers out of 1 ...n.Input:n = 4, k = 2Output:[ [2,4], [3,4], [2...
2019-07-28 11:01:51
148
原创 Leetcode 126. Word Ladder II Python BFS 实现
题目:126.Word Ladder IIhttps://leetcode.com/problems/word-ladder-ii/Given two words (beginWordandendWord), and a dictionary's word list, find all shortest transformation sequence(s) frombeginWor...
2019-06-29 03:34:18
1590
原创 659. Split Array into Consecutive Subsequences Python 贪心算法
题目:659.Split Array into Consecutive Subsequenceshttps://leetcode.com/problems/split-array-into-consecutive-subsequences/You are given an integer array sorted in ascending order (may contain dupli...
2019-06-27 04:23:45
231
原创 Leetcode 15. 3Sum 18. 4Sum 通用解法for N Sum Python
15.3SumGiven an arraynumsofnintegers, are there elementsa,b,cinnumssuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set mus...
2019-05-13 10:01:19
217
原创 Leetcode 262. Trips and Users SQL Server
TheTripstable 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 theUserstable. Status is an ENUM type of (‘completed’, ‘cancel...
2019-05-10 10:53:18
182
原创 Leetcode 717. 1-bit and 2-bit Characters Python
We have two special characters. The first character can be represented by one bit0. The second character can be represented by two bits (10or11).Now given a string represented by several bits. Re...
2019-04-14 11:18:46
101
原创 Leetcode 697. Degree of an Array 最大频率数字的最短子数组 Python实现
题目:Given a non-empty array of non-negative integersnums, thedegreeof this array is defined as the maximum frequency of any one of its elements.Your task is to find the smallest possible length ...
2019-04-14 11:01:15
730
原创 Leetcode 665 Non-decreasing Array 非递减数列 Python 实现
题目:Given an array withnintegers, your task is to check if it could become non-decreasing by modifyingat most1element.We define an array is non-decreasing ifarray[i] <= array[i + 1]holds ...
2019-04-13 11:47:04
281
转载 Leetcode 603. Consecutive Available Seats
Several friends at a cinema ticket office would like to reserve consecutive available seats.Can you help to query all the consecutive available seats order by the seat_id using the following cinemata...
2018-08-25 00:04:53
1311
1
转载 Leetcode 577. Employee Bonus
Select all employee's name and bonus whose bonus is < 1000.Table:Employee+-------+--------+-----------+--------+| empId | name | supervisor| salary |+-------+--------+-----------+--------+...
2018-08-24 23:55:03
664
转载 Leetcode 607. Sales Person
DescriptionGiven three tables: salesperson, company, orders.Output all the names in the table salesperson, who didn’t have sales to company 'RED'.ExampleInputTable: salesperson+----------+--...
2018-08-24 23:46:46
1382
转载 LeetCode 597. Friend Requests I: Overall Acceptance Rate
In social network like Facebook or Twitter, people send friend requests and accept others’ requests as well. Now given two tables as below: Table: friend_request| sender_id | send_to_id |reques...
2018-08-23 11:01:51
999
转载 LeetCode 619. Biggest Single Number
Table number contains many numbers in column num including duplicated ones.Can you write a SQL query to find the biggest number, which only appears once.+---+|num|+---+| 8 || 8 || 3 || 3 ||...
2018-08-22 10:26:58
540
转载 LeetCode 570. Managers with at Least 5 Direct Reports
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+------+----------+-----------+----------+|Id |Name |...
2018-08-22 10:22:41
815
转载 LeetCode 608. Tree Node
Given a table tree, id is identifier of the tree node and p_id is its parent node's id.+----+------+| id | p_id |+----+------+| 1 | null || 2 | 1 || 3 | 1 || 4 | 2 || 5 | 2 ...
2018-08-22 09:54:02
1343
转载 Leetcode 612. Shortest Distance in a Plane
Table point_2d holds the coordinates (x,y) of some unique points (more than two) in a plane. Write a query to find the shortest distance between these points rounded to 2 decimals. | x | y ...
2018-08-21 10:56:24
895
转载 Leetcode 585. Investments in 2016
Write a query to print the sum of all total investment values in 2016 (TIV_2016), to a scale of 2 decimal places, for all policy holders who meet the following criteria:Have the same TIV_2015 value ...
2018-08-21 10:41:20
1122
转载 Leetcode 602. Friend Requests II: Who Has Most Friend?
In social network like Facebook or Twitter, people send friend requests and accept others' requests as well. Table request_accepted holds the data of friend acceptance, while requester_id and acce...
2018-08-19 00:25:11
907
转载 Leetcode 580. Count Student Number in Departments
A university uses 2 data tables, student and department, to store data about its students and the departments associated with each major.Write a query to print the respective department name and num...
2018-08-19 00:17:44
822
转载 LeetCode 574. Winning Candidate SQL Server
create table candidate(id int,Name varchar(2))insert into candidate values (1,'A')insert into candidate values (2,'B')insert into candidate values (3,'C')insert into candidate values (4,'D')ins...
2018-08-17 10:31:59
831
原创 LeetCode 578. Get Highest Answer Rate Question
Get the highest answer rate question from a tablesurvey_logwith these columns:uid,action,question_id,answer_id,q_num,timestamp.uid means user id; action has these kind of values: "show", "an...
2018-08-16 11:13:55
832
转载 571 Find Median Given Frequency of Numbers SQL Server with CTE
drop table numberscreate Table numbers (number int,frequency int)insert into numbers values (0,7)insert into numbers values (1,1)insert into numbers values (2,3)insert into numbers values (3,1...
2018-08-15 11:04:44
1210
翻译 LeetCode 618. Students Report By Geography
drop table studentcreate Table student (name varchar(25),continent varchar(25));insert into student values('Jack','America')insert into student values('Pascal','Europe')insert into student value...
2018-08-14 09:30:45
1736
翻译 LeetCode 615. Average Salary: Departments VS Company
drop table salaryCreate table salary(Id int,employee_id int,amount int,pay_date date);insert into salary values(1,1,9000,'2017-03-31');insert into salary values(2,2,6000,'2017-03-31');insert int...
2018-08-13 11:47:17
1090
[C.大学教程(第5版)].Cpp-How.to.Program,5th.Edition
2011-01-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人