随笔分类 -  leetcode

1 2 3 4 5 ··· 7 下一页
Solutions of Leetcode
摘要:LeetCode169. Majority Element Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋  阅读全文
posted @ 2016-12-28 21:17 wangxiaobao1114 阅读(263) 评论(0) 推荐(0)
摘要:136. Single Number Given an array of integers, every element appears twice except for one. Find that single one. (Easy) Note:Your algorithm should hav 阅读全文
posted @ 2016-12-28 21:02 wangxiaobao1114 阅读(164) 评论(0) 推荐(0)
摘要:Sort a linked list in O(n log n) time using constant space complexity. (Medium) 分析: 因为题目要求复杂度为O(nlogn),故可以考虑归并排序的思想。 归并排序的一般步骤为: 1)将待排序数组(链表)取中点并一分为二; 阅读全文
posted @ 2016-12-20 21:16 wangxiaobao1114 阅读(293) 评论(0) 推荐(0)
摘要:链表相关题 141. Linked List Cycle Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? (Easy) 分析: 阅读全文
posted @ 2016-12-16 21:58 wangxiaobao1114 阅读(266) 评论(0) 推荐(0)
摘要:二分法相关 153. Find Minimum in Rotated Sorted Array Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might 阅读全文
posted @ 2016-12-15 22:15 wangxiaobao1114 阅读(185) 评论(0) 推荐(0)
摘要:字典树(Trie树相关) 208. Implement Trie (Prefix Tree) Implement a trie with insert, search, and startsWith methods. (Medium) Note:You may assume that all inp 阅读全文
posted @ 2016-12-14 22:18 wangxiaobao1114 阅读(470) 评论(0) 推荐(0)
摘要:数学题 172. Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time c 阅读全文
posted @ 2016-12-13 22:32 wangxiaobao1114 阅读(167) 评论(0) 推荐(0)
摘要:位运算相关 三道题 231. Power of Two 位运算相关 三道题 231. Power of Two Given an integer, write a function to determine if it is a power of two. (Easy) 分析: 数字相关题有的可以考 阅读全文
posted @ 2016-12-12 20:05 wangxiaobao1114 阅读(148) 评论(0) 推荐(0)
摘要:Implement the following operations of a stack using queues. (Easy) push(x) -- Push element x onto stack. pop() -- Removes the element on top of the st 阅读全文
posted @ 2016-12-08 21:32 wangxiaobao1114 阅读(222) 评论(0) 推荐(0)
摘要:Evaluate the value of an arithmetic expression in Reverse Polish Notation. (Medium) Valid operators are +, -, *, /. Each operand may be an integer or 阅读全文
posted @ 2016-12-08 21:27 wangxiaobao1114 阅读(321) 评论(0) 推荐(0)
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. (Easy) For example,"A man, a plan, a can 阅读全文
posted @ 2016-12-06 22:06 wangxiaobao1114 阅读(189) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. (Hard) For example,Given [100, 4, 200, 1, 3, 2],The 阅读全文
posted @ 2016-12-05 21:55 wangxiaobao1114 阅读(248) 评论(0) 推荐(0)
摘要:Given a binary tree, find the maximum path sum. (Hard) For this problem, a path is defined as any sequence of nodes from some starting node to any nod 阅读全文
posted @ 2016-12-01 21:40 wangxiaobao1114 阅读(165) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2016-11-25 23:59 wangxiaobao1114 阅读(346) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. (Medium) Design an algorithm to find the maximum profit. You m 阅读全文
posted @ 2016-11-23 22:28 wangxiaobao1114 阅读(164) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. (Easy) Design an algorithm to find the maximum profit. You may 阅读全文
posted @ 2016-11-23 22:27 wangxiaobao1114 阅读(167) 评论(0) 推荐(0)
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.(Medium) For example, give 阅读全文
posted @ 2016-11-22 21:10 wangxiaobao1114 阅读(144) 评论(0) 推荐(0)
摘要:Given an index k, return the kth row of the Pascal's triangle. (Easy) For example, given k = 3,Return [1,3,3,1]. Note:Could you optimize your algorith 阅读全文
posted @ 2016-11-22 21:08 wangxiaobao1114 阅读(376) 评论(0) 推荐(0)
摘要:Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, (Easy)Return 分析: 求解杨辉三角形,按照其定义以此求解即可,注意优化写法使其能够更简洁(比如对 阅读全文
posted @ 2016-11-22 21:06 wangxiaobao1114 阅读(251) 评论(0) 推荐(0)
摘要:Given a string S and a string T, count the number of distinct subsequences of T in S. (Hard) A subsequence of a string is a new string which is formed 阅读全文
posted @ 2016-11-17 22:36 wangxiaobao1114 阅读(405) 评论(1) 推荐(0)

1 2 3 4 5 ··· 7 下一页