随笔分类 -  leetcode

https://leetcode.com/problemset/all/
摘要:The count and say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "on 阅读全文
posted @ 2018-10-01 11:15 bernieloveslife 阅读(97) 评论(0) 推荐(0)
摘要:Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means t 阅读全文
posted @ 2018-10-01 11:13 bernieloveslife 阅读(125) 评论(0) 推荐(0)
摘要:In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue. For now, suppose you are a domin 阅读全文
posted @ 2018-10-01 11:12 bernieloveslife 阅读(160) 评论(0) 推荐(0)
摘要:Given a binary tree, return the bottom up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For 阅读全文
posted @ 2018-09-30 20:23 bernieloveslife 阅读(79) 评论(0) 推荐(0)
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree [ 阅读全文
posted @ 2018-09-30 20:22 bernieloveslife 阅读(105) 评论(0) 推荐(0)
摘要:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Exampl 阅读全文
posted @ 2018-09-30 20:21 bernieloveslife 阅读(76) 评论(0) 推荐(0)
摘要:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac 阅读全文
posted @ 2018-09-30 20:21 bernieloveslife 阅读(92) 评论(0) 推荐(0)
摘要:Given a collection of distinct integers, return all possible permutations. Example: Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1, 阅读全文
posted @ 2018-09-30 20:20 bernieloveslife 阅读(92) 评论(0) 推荐(0)
摘要:We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11). N 阅读全文
posted @ 2018-09-29 11:01 bernieloveslife 阅读(84) 评论(0) 推荐(0)
摘要:Count the number of prime numbers less than a non negative number, n. Example: Input: 10 Output: 4 Explanation: There are 4 prime numbers less than 10 阅读全文
posted @ 2018-09-29 11:01 bernieloveslife 阅读(87) 评论(0) 推荐(0)
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and num 阅读全文
posted @ 2018-09-29 11:00 bernieloveslife 阅读(98) 评论(0) 推荐(0)
摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr 阅读全文
posted @ 2018-09-29 10:58 bernieloveslife 阅读(86) 评论(0) 推荐(0)
摘要:Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. E 阅读全文
posted @ 2018-09-29 10:56 bernieloveslife 阅读(106) 评论(0) 推荐(0)
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the 阅读全文
posted @ 2018-09-28 11:57 bernieloveslife 阅读(82) 评论(0) 推荐(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 阅读全文
posted @ 2018-09-28 11:57 bernieloveslife 阅读(117) 评论(0) 推荐(0)
摘要:Given an integer n, return the number of trailing zeroes in n!. Example 1: Input: 3 Output: 0 Explanation: 3! = 6, no trailing zero. Example 2: Input: 阅读全文
posted @ 2018-09-28 11:55 bernieloveslife 阅读(96) 评论(0) 推荐(0)
摘要:Reverse bits of a given 32 bits unsigned integer. Example: Input: 43261596 Output: 964176192 Explanation: 43261596 represented in binary as 0000001010 阅读全文
posted @ 2018-09-28 11:54 bernieloveslife 阅读(99) 评论(0) 推荐(0)
摘要:Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non negative integer. Since the return type is an in 阅读全文
posted @ 2018-09-28 11:53 bernieloveslife 阅读(141) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Inpu 阅读全文
posted @ 2018-09-27 19:14 bernieloveslife 阅读(91) 评论(0) 推荐(0)
摘要:Validate if a given string can be interpreted as a decimal number. Some examples: "0" = true " 0.1 " = true "abc" = false "1 a" = false "2e10" = true 阅读全文
posted @ 2018-09-27 19:08 bernieloveslife 阅读(130) 评论(0) 推荐(0)