随笔分类 -  LeetCode Solutions - Easy

摘要:Problem: Design a logger system that receive stream of messages along with its timestamps, each message should be printed if and only if it is not pri 阅读全文
posted @ 2017-01-04 12:42 SillyVicky 阅读(269) 评论(0) 推荐(0)
摘要:Problem: Count the number of prime numbers less than a non-negative number, n. Summary: 判断小于某非负数n的质数个数。 Solution: 用所谓的“刷质数表”的方式先用HashTable记录小于n的所有数是质数 阅读全文
posted @ 2017-01-04 10:00 SillyVicky 阅读(225) 评论(0) 推荐(0)
摘要:Problem: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All 阅读全文
posted @ 2017-01-04 08:54 SillyVicky 阅读(133) 评论(0) 推荐(0)
摘要:Problem: You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. 阅读全文
posted @ 2017-01-03 13:03 SillyVicky 阅读(221) 评论(0) 推荐(0)
摘要:Problem: Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection betwee 阅读全文
posted @ 2017-01-03 08:11 SillyVicky 阅读(317) 评论(0) 推荐(0)
摘要:Problem: Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are f 阅读全文
posted @ 2017-01-03 07:07 SillyVicky 阅读(194) 评论(0) 推荐(0)
摘要:Problem: Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant d 阅读全文
posted @ 2017-01-01 08:29 SillyVicky 阅读(199) 评论(0) 推荐(0)
摘要:Problem: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough space 阅读全文
posted @ 2016-12-31 13:42 SillyVicky 阅读(135) 评论(0) 推荐(0)
摘要:Problem: Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another ar 阅读全文
posted @ 2016-12-30 11:35 SillyVicky 阅读(92) 评论(0) 推荐(0)
摘要:Problem: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra 阅读全文
posted @ 2016-12-30 11:11 SillyVicky 阅读(156) 评论(0) 推荐(0)
摘要:Problem: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements o 阅读全文
posted @ 2016-12-30 09:20 SillyVicky 阅读(1597) 评论(0) 推荐(0)
摘要:Problem: Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] 阅读全文
posted @ 2016-12-29 11:26 SillyVicky 阅读(153) 评论(0) 推荐(0)
摘要:Problem: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Return Summary: 输出杨辉三角的前n行。 Solution: 方法类似于Lee 阅读全文
posted @ 2016-12-29 01:24 SillyVicky 阅读(179) 评论(0) 推荐(0)
摘要:Problem: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algori 阅读全文
posted @ 2016-12-28 12:19 SillyVicky 阅读(183) 评论(0) 推荐(0)
摘要:Problem: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input woul 阅读全文
posted @ 2016-12-28 09:18 SillyVicky 阅读(132) 评论(0) 推荐(0)
摘要:Problem: Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time 阅读全文
posted @ 2016-12-28 09:08 SillyVicky 阅读(187) 评论(0) 推荐(0)
摘要:Problem: Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. 阅读全文
posted @ 2016-12-28 05:28 SillyVicky 阅读(933) 评论(0) 推荐(0)
摘要:Problem: 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 阅读全文
posted @ 2016-12-18 12:07 SillyVicky 阅读(296) 评论(0) 推荐(0)
摘要:Problem: You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizo 阅读全文
posted @ 2016-12-16 12:58 SillyVicky 阅读(233) 评论(0) 推荐(0)
摘要:Problem: Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those lett 阅读全文
posted @ 2016-12-16 05:57 SillyVicky 阅读(613) 评论(0) 推荐(0)