代码改变世界

[LeetCode] 20. Valid Parentheses_Easy tag: Stack

2018-08-25 00:55 by Johnson_强生仔仔, 222 阅读, 0 推荐, 收藏, 编辑
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: No 阅读全文

[LeetCode] 367. Valid Perfect Square_Easy tag:Math

2018-08-21 13:32 by Johnson_强生仔仔, 207 阅读, 0 推荐, 收藏, 编辑
摘要:Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library functio 阅读全文

[LeetCode] 868. Binary Gap_Easy

2018-08-20 10:43 by Johnson_强生仔仔, 208 阅读, 0 推荐, 收藏, 编辑
摘要:Given a positive integer N, find and return the longest distance between two consecutive 1's in the binary representation of N. If there aren't two co 阅读全文

[LeetCode] 577. Employee Bonus_Easy tag: SQL

2018-08-20 10:34 by Johnson_强生仔仔, 269 阅读, 0 推荐, 收藏, 编辑
摘要:Select all employee's name and bonus whose bonus is < 1000. Table:Employee Table: Bonus Example ouput: # 不能直接用JOIN, 相当于inner join, 如果bonus没有的, 那么就没有了, 阅读全文

[LeetCode] 860. Lemonade Change_Easy tag: Greedy

2018-08-20 10:21 by Johnson_强生仔仔, 217 阅读, 0 推荐, 收藏, 编辑
摘要:At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bil 阅读全文

[LeetCode] 859. Buddy Strings_Easy

2018-08-20 09:59 by Johnson_强生仔仔, 244 阅读, 0 推荐, 收藏, 编辑
摘要:Given two strings A and B of lowercase letters, return true if and only if we can swap two letters in A so that the result equals B. Example 1: Input: 阅读全文

[LeetCode] 876. Middle of the Linked List_Easy tag: Linked List ** slow, fast pointers

2018-08-20 09:37 by Johnson_强生仔仔, 233 阅读, 0 推荐, 收藏, 编辑
摘要:Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middl 阅读全文

[LeetCode] 788. Rotated Digits_Easy tag: **Dynamic Programming

2018-08-20 09:29 by Johnson_强生仔仔, 230 阅读, 0 推荐, 收藏, 编辑
摘要:基本思路建一个helper function, 然后从1-N依次判断是否为good number, 注意判断条件为没有3,4,7 的数字,并且至少有一个2,5,6,9, 否则的话数字就一样了, 比如88, 18等. Improve: 利用DP去判断, 时间和空间都能降为O(lgn) Code T: 阅读全文

[LeetCode] 620. Not Boring Movies_Easy tag: SQL

2018-08-20 09:17 by Johnson_强生仔仔, 215 阅读, 0 推荐, 收藏, 编辑
摘要:X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descrip 阅读全文

[LeetCode] 408. Valid Word Abbreviation_Easy

2018-08-20 09:11 by Johnson_强生仔仔, 228 阅读, 0 推荐, 收藏, 编辑
摘要:Given a non-empty string s and an abbreviation abbr, return whether the string matches with the given abbreviation. A string such as "word" contains o 阅读全文
上一页 1 ··· 19 20 21 22 23 24 25 26 27 ··· 39 下一页