- 博客(49)
- 资源 (9)
- 收藏
- 关注
原创 Classes more than 5 students |leetcode |mysql
select classfrom coursesgroup by classhaving count(distinct student)>=5;
2020-08-13 04:19:12
136
原创 Best Time to Buy and Sell | Leetcode | C++
class Solution{public: int maxProfit(vector<int>& prices) { int valley = INT_MAX; int profit = 0; for(int i =0; i < prices.size(); i++) { if(prices[i] < valley) valley =.
2020-08-13 03:33:21
132
原创 Merge two sorted List | leetcode | C++
class Solution {public: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) { std::vector<int> chain; ListNode* head = new ListNode(0); ListNode* result =head; ListNode* l =l1; while(l!= NUL.
2020-08-12 02:47:19
161
原创 Custmoer placing the largest orders |leetcode |mysql
select customer_number from ordersgroup by customer_numberorder by count(order_number) desclimit 1
2020-08-11 05:44:03
118
原创 Valid Parentheses |leetcode |python3
class Solution: def isValid(self, s: str) -> bool: queue = [] pare_dict = {')':'(',']':'[','}':'{'} for c in s: if c in pare_dict: if queue: top = queue.pop() e.
2020-08-11 05:34:32
102
原创 Find Customer Referee_id
select name from customer where referee_id !=2 or referee_id is NULL
2020-08-10 06:31:59
198
原创 Word Ladder | Leetcode | Python3
from collections import defaultdictclass Solution: def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int: if endWord not in wordList: return 0 all_combo_dict = defaultdict(list) for word in wo.
2020-08-10 06:27:25
132
原创 Employee Bonus | Leetcode | Mysql
SELECT Employee.name, Bonus.bonusFROM Employee LEFT JOIN Bonus ON Employee.empid = Bonus.empidWHERE bonus < 1000 OR bonus IS NULL;
2020-08-09 06:07:08
131
原创 X of a Kind in a Deck of Cards | Leetcode | Python3
def hcf(x, y): if x > y: smaller = y else: smaller = x for i in range(1,smaller + 1): if((x % i == 0) and (y % i == 0)): hcf = i return hcfclass Solution: def h.
2020-08-09 04:57:40
117
原创 Game Play Analysis | Leetcode | Mysql
1. select player_id, min(event_date) as 'first_login' from Activity group by player_id 2.select A1.player_id,A1.device_idfrom Activity A1, (select player_id, min(event_date) as 'first_login' from Activity group by player_id) A2where A1....
2020-08-07 05:35:48
116
原创 Logger Rate Limiter | Leetcode | python
class Logger: def __init__(self): """ Initialize your data structure here. """ self.msg_dict = {} def shouldPrintMessage(self, timestamp: int, message: str) -> bool: """ Returns true if the mess.
2020-08-07 04:06:31
150
1
原创 Rising Temperature | leetcode | Mysql
select w2.IdfromWeather w1, Weather w2where w2.Temperature > w1.Temperature AND DATEDIFF(w2.RecordDate, w1.RecordDate) = 1
2020-08-06 04:38:07
106
原创 MovingAverage | leetcode Python3
class MovingAverage: def __init__(self, size: int): """ Initialize your data structure here. """ self.size = size self.window = [] def next(self, val: int) -> float: size = self.size win.
2020-08-06 04:37:14
196
原创 Leetcode 299 | Bulls and cows | C++
class Solution {public: int inside(int a , std::vector<int> v) { for (int i = 0; i < v.size(); i++) { if (a == v[i]) return i; } return -1; } .
2020-08-05 09:59:20
219
原创 Python 直接拷贝 浅拷贝 深拷贝 区别
直接复制 只是把引用增多了一个 , 用任意一个引用改变对象都会导致其他引用也变.copy - 浅拷贝, 复制了一个新的父对象, 但是对象中如果有嵌套结构, 子对象的元素改变也会引起所有的引用都改变copy.deepcopy() 完全复制父对象与子对象, 完全独立.import copya = [1, 2, 3, 4, ['a', 'b']] #原始对象 b = a #赋值,传对象的引用c = copy.copy(a) ..
2020-07-22 10:55:11
106
原创 Text Justification | Leetcode 68 C++
class Solution {public: vector<string> fullJustify(vector<string>& words, int maxWidth) { std::vector<std::string> result; int line_index = 0; int letter_count = 0; int i = 0; std::ve.
2020-07-19 15:33:19
138
原创 Letter Combination | Leetcode
class Solution{private: const string digit_to_letter[10] = { " ", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" }; std::vector<std::str...
2020-06-29 06:01:11
669
原创 184. Department Highest Salary | Leetcode
select distinct Department.Name as 'Department',Employee.Name as 'Employee',D1.Salaryfrom Department, Employee,(select Max(Employee.Salary) as Salary ,DepartmentId from Employee group by DepartmentId) as D1where Department.Id = D1.DepartmentId and Empl.
2020-06-28 01:18:41
122
原创 Customers who never order | Leetcode
select C1.Name as Customersfrom Customers C1where C1.Id not in( select CustomerId from Orders);
2020-06-28 00:36:32
105
原创 3sum closest | Leetcode
class Solution{public: int threeSumClosest(vector<int>& nums, int target) { int diff = INT_MAX, size = nums.size(); sort(begin(nums),end(nums)); for(int i = 0; i < size && diff != 0; i++) {...
2020-06-28 00:18:38
91
原创 3sum closest | Leetcode
class Solution{public: int threeSumClosest(vector<int>& nums, int target) { int diff = INT_MAX, size = nums.size(); sort(begin(nums),end(nums)); for(int i = 0; i < size && diff != 0; i++) {...
2020-06-28 00:17:45
57
原创 Duplicate Emails | Leetcode
select distinct P1.Email as Emailfrom Person P1, Person P2where P1.Email = P2.Email and P1.Id != P2.Id;select Emailfrom Persongroup by Emailhaving count(Email) > 1;select Email from( select Email, count(Email) as num from Person...
2020-06-23 02:06:59
123
原创 Employees Earning more than manager | Leetcode
select E1.Name as Employeefrom Employee E1, Employee E2where E1.ManagerId = E2.Id and E1.Salary > E2.Salary;
2020-06-23 01:39:58
78
原创 14. longest common prefix | Leetcode
class Solution{public: string longestCommonPrefix(vector<string>& strs) { int str_num = strs.size(); if(str_num == 0) return ""; if(str_num == 1) return strs[0]; int min_len = INT_MAX; std::stri...
2020-06-23 01:31:43
98
原创 Consecutive Numbers | Leetcode
select distinct l1.Num 'ConsecutiveNums'from Logs l1,Logs l2,Logs l3where l1.Id = l2.Id-1 and l2.Id = l3.Id -1and l1.Num = l2.Num and l2.Num =l3.Num
2020-06-20 04:02:25
91
原创 13. Roman to Integer | Leetcode
table = { "I":1, "V":5, "X":10, "L":50, "C":100, "D":500, "M":1000, } class Solution: def romanToInt(self, s: str) -> int: total = 0 ...
2020-06-20 03:45:20
147
原创 13.Roman to integer | leetcode
class Solution{public: std::map<std::string, int> table = {{"I",1},{"IV",4},{"V",5},{"IX",9},{"X",10},{"XL",40},{"L",50}, {"XC",90},{"C",100},{"CD",400},{"D",500},{"CM",900},{"M",1000} ...
2020-06-20 03:32:36
96
原创 Rank Scores | Leetcodes
# Write your MySQL query statement belowselect s.Score, count(t.Score) 'Rank' from(select distinct Score from Scores) as t, Scores as swhere s.score <= t.scoregroup by s.Idorder by s.Score desc;
2020-06-19 12:04:52
98
原创 12. Integer to Roman | Leetcode
class Solution{ public: std::string sym_table[13] = {"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"}; int val_table[13] = {1000,900,500,400,100,90,50,40,10,9,5,4,1}; string intToRoman(int num) { std::string result;...
2020-06-19 10:56:16
147
1
原创 11. Container With Most Water
class Solution{public: int maxArea(vector<int>& height) { int len = height.size(); int maxarea = 0; int i = 0; int j = len-1; while(i < j) { int high = std::min(height[i],...
2020-06-18 04:57:13
63
原创 10. Regular Expression Matching | Leetcode pr.10
class Solution {public: bool isMatch(string s, string p) { if (p.empty()) return s.empty(); if ('*' == p[1]) // x* matches empty string or at least one character: x* -> xx* // *s is to ensure s is non-emp...
2020-06-17 09:52:29
70
原创 Leetcode 09 | Palindrome Number
class Solution{public: bool isPalindrome(int x) { if(x<0) return false; if(x==0) return true; if(x>0) { if(x<10) return true; if(x % 10 == 0) return false; else ...
2020-06-15 23:11:57
99
原创 string to integer(atoi) |leetcode 08
class Solution{ public: bool is_number(char c){ if(c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7'||c=='8'||c=='9') return true; else return false; } int...
2020-06-14 14:45:14
68
原创 Leetcode Pr.6 ZigZag string
class Solution{ public: string convert(string s, int numRows){ int r = numRows; int len = s.length(); std::string str; if(r == 1 || len <= r) { return s; ...
2020-06-09 06:03:55
70
原创 Ubuntu18.04 配置Tensorflow 环境
1 首先要先搞清楚自己的系统版本2 其次要安装nvidia的驱动ubuntu-drivers devices可以选择自己想要的驱动安装,也可以选择自动安装sudo ubuntu-drivers autoinstall3 选择合适的cuda版本并下载安装https://developer.nvidia.com/cuda-toolkit-archive我安装的是...
2020-04-10 05:38:18
447
转载 PTPv2 Protocol
转载自http://www.cnblogs.com/AdaminXie/IEEE1588 协议,又称 PTP( precise time protocol,精确时间协议),可以达到亚微秒级别时间同步精度,于 2002 年发布 version 1,2008 年发布 version 2。IEEE1588 协议的同步原理,所提出的Delay Request-Response Mechanis...
2020-04-04 06:29:17
3286
原创 GitHub 上传大文件
在本地的repo先不要add 你的大文件进入你的本地repo开始:第一步: git lfs install第二步: git lfs track (大文件)第三步: git add (大文件)第四步: git commit -m ”big file“第五步: git push...
2020-03-25 11:15:55
128
原创 5. Longest Palindromic Substring solution:
C++class Solution {public: string longestPalindrome(string s) { int n=s.length(); if(n<1) return ""; if(n==1) return s; int start=0,end=0; for(in...
2020-01-10 03:11:41
89
原创 3. Longest Substring Without Repeating Characters C++&Python3 Solutions
\\C++:class Solution {public: int lengthOfLongestSubstring(string s) { int res = 0, left = -1, n = s.size(); unordered_map<char, int> m; for (int i = 0; i &l...
2019-12-30 11:13:09
124
原创 2. Add Two Numbers C++&Python3 Solutions
\\ C++/*** Definition for singly-linked list.* struct ListNode {* int val;* ListNode *next;* ListNode(int x) : val(x), next(NULL) {}* };*/class Solution {public: List...
2019-12-29 03:21:03
69
network coding lecture notes
2019-01-28
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人