随笔分类 -  LeetCode

189. Rotate Array
摘要:1. 问题描述 189. Rotate ArrayRotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated 阅读全文

posted @ 2016-09-10 23:43 whl-hl 阅读(203) 评论(0) 推荐(1)

9. Palindrome Number
摘要:1. 问题描述 Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you ar 阅读全文

posted @ 2016-09-07 23:09 whl-hl 阅读(203) 评论(0) 推荐(0)

118. Pascal's Triangle
摘要:1. 问题描述 Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1] 阅读全文

posted @ 2016-09-05 23:17 whl-hl 阅读(181) 评论(0) 推荐(0)

172. Factorial Trailing Zeroes
摘要:1. 问题描述 Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.Tags: MathSimilar 阅读全文

posted @ 2016-09-01 22:05 whl-hl 阅读(188) 评论(0) 推荐(0)

345. Reverse Vowels of a String
摘要:1. 问题描述 Write a function that takes a string as input and reverse only the vowels of a string. Note:The vowels does not include the letter "y".Tags: T 阅读全文

posted @ 2016-08-29 23:02 whl-hl 阅读(121) 评论(0) 推荐(0)

58. Length of Last Word
摘要:1. 问题描述 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 la 阅读全文

posted @ 2016-08-26 23:37 whl-hl 阅读(173) 评论(0) 推荐(0)

383. Ransom Note
摘要:1. 问题描述 Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if 阅读全文

posted @ 2016-08-24 23:28 whl-hl 阅读(215) 评论(0) 推荐(0)

387. First Unique Character in a String
摘要:1. 问题描述 Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Note: You may assume the s 阅读全文

posted @ 2016-08-24 23:26 whl-hl 阅读(117) 评论(0) 推荐(0)

83. Remove Duplicates from Sorted List
摘要:1. 问题描述 Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2 阅读全文

posted @ 2016-08-24 23:24 whl-hl 阅读(129) 评论(0) 推荐(0)

101. Symmetric Tree
摘要:1. 问题描述 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). Note: Bonus points if you could solve it both r 阅读全文

posted @ 2016-08-20 23:43 whl-hl 阅读(167) 评论(0) 推荐(0)

198. House Robber
摘要:1. 问题描述 You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint sto 阅读全文

posted @ 2016-08-18 23:29 whl-hl 阅读(121) 评论(0) 推荐(0)

110. Balanced Binary Tree
摘要:1. 问题描述 Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which t 阅读全文

posted @ 2016-08-17 22:08 whl-hl 阅读(145) 评论(0) 推荐(0)

235. Lowest Common Ancestor of a Binary Search Tree
摘要:1. 问题描述 Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wi 阅读全文

posted @ 2016-08-16 22:35 whl-hl 阅读(124) 评论(0) 推荐(0)

263. Ugly Number
摘要:1. 问题描述 Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. 阅读全文

posted @ 2016-08-09 22:21 whl-hl 阅读(106) 评论(0) 推荐(0)

202. Happy Number
摘要:1. 问题描述 Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive 阅读全文

posted @ 2016-08-09 22:07 whl-hl 阅读(110) 评论(0) 推荐(0)

141. Linked List Cycle
摘要:1. 问题描述 Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Tags: Linked List Two PointersSimi 阅读全文

posted @ 2016-08-08 23:34 whl-hl 阅读(109) 评论(0) 推荐(0)

70. Climbing Stairs
摘要:1. 问题描述 You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can 阅读全文

posted @ 2016-08-08 22:39 whl-hl 阅读(119) 评论(0) 推荐(0)

28. Implement strStr()
摘要:1. 问题描述 Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Tags:Two Pointers 阅读全文

posted @ 2016-08-06 23:23 whl-hl 阅读(169) 评论(0) 推荐(0)

112. Path Sum
摘要:1. 问题描述 Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the give 阅读全文

posted @ 2016-08-05 23:22 whl-hl 阅读(162) 评论(0) 推荐(0)

371. Sum of Two Integers
摘要:1. 问题描述 Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example: Given a = 1 and b = 2, return 3.Tags:B 阅读全文

posted @ 2016-07-20 23:58 whl-hl 阅读(165) 评论(0) 推荐(0)

导航