代码改变世界

[LeetCode] 849. Maximize Distance to Closest Person_Easy tag: BFS

2018-08-19 05:35 by Johnson_强生仔仔, 223 阅读, 0 推荐, 收藏, 编辑
摘要:In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. There is at least one empty seat, and at least 阅读全文

[LeetCode] 455. Assign Cookies_Easy tag: Sort

2018-08-19 05:10 by Johnson_强生仔仔, 247 阅读, 0 推荐, 收藏, 编辑
摘要:Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a g 阅读全文

[LeetCode] 884. Uncommon Words from Two Sentences_Easy tag: Hash Table

2018-08-19 04:54 by Johnson_强生仔仔, 348 阅读, 0 推荐, 收藏, 编辑
摘要:We are given two sentences A and B. (A sentence is a string of space separated words. Each word consists only of lowercase letters.) A word is uncommo 阅读全文

[LeetCode] 566. Reshape the Matrix_Easy

2018-08-19 04:50 by Johnson_强生仔仔, 229 阅读, 0 推荐, 收藏, 编辑
摘要:In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. 阅读全文

[LeetCode] 643. Maximum Average Subarray I_Easy tag: Dynamic Programming(Sliding windows)

2018-08-18 12:38 by Johnson_强生仔仔, 230 阅读, 0 推荐, 收藏, 编辑
摘要:Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the 阅读全文

[LeetCode] 441. Arranging Coins_Easy tag: Math

2018-08-18 12:13 by Johnson_强生仔仔, 192 阅读, 0 推荐, 收藏, 编辑
摘要:You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number 阅读全文

[LeetCode] 867. Transpose Matrix_Easy

2018-08-18 11:55 by Johnson_强生仔仔, 163 阅读, 0 推荐, 收藏, 编辑
摘要:Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column ind 阅读全文

[LeetCode] 58. Length of Last Word_Easy tag: String

2018-08-18 11:38 by Johnson_强生仔仔, 147 阅读, 0 推荐, 收藏, 编辑
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word 阅读全文

[LeetCode] 182. Duplicate Emails_Easy tag: SQL

2018-08-18 11:19 by Johnson_强生仔仔, 123 阅读, 0 推荐, 收藏, 编辑
摘要:Write a SQL query to find all duplicate emails in a table named Person. + + + | Id | Email | + + + | 1 | a@b.com | | 2 | c@d.com | | 3 | a@b.com | + + 阅读全文

[LeetCode] 476. Number Complement_Easy tag: Bit Manipulation

2018-08-18 11:14 by Johnson_强生仔仔, 169 阅读, 0 推荐, 收藏, 编辑
摘要:这个题目思路就是比如101 的结果是010, 可以从111^101 来得到, 那么我们就需要知道刚好比101多一位的1000, 所以利用 while i <= num : i <<= 1, 去得到1000, 然后-1, 便得到111, 再跟num ^, 也就是异或即可. Code 阅读全文
上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 39 下一页