上一页 1 2 3 4 5 6 7 8 9 ··· 30 下一页
摘要: 下一个较大元素题目描述现在我们有一个int数组,请你找出数组中每个元素的下一个比它大的元素。给定一个int数组A及数组的大小n,请返回一个int数组,代表每个元素比他大的下一个元素,若不存在则为-1。保证数组中元素均为正整数。测试样例:[11,13,10,5,12,21,3],7返回:[13,21,... 阅读全文
posted @ 2015-07-26 21:06 Eason Liu 阅读(439) 评论(0) 推荐(0) 编辑
摘要: 单词最近距离题目描述有一篇文章内含多个单词,现给定两个单词,请设计一个高效算法,找出文中这两个单词的最短距离(即最少相隔的单词数,也就是两个单词在文章中位置的差的绝对值)。给定一个string数组article,代表所给文章,同时给定文章的单词数n和待查找的两个单词x和y。请返回两个单词的最短距离。... 阅读全文
posted @ 2015-07-26 14:20 Eason Liu 阅读(416) 评论(0) 推荐(0) 编辑
摘要: Sliding Window MaximumGiven an arraynums, there is a sliding window of sizekwhich is moving from the very left of the array to the very right. You can... 阅读全文
posted @ 2015-07-18 18:43 Eason Liu 阅读(303) 评论(0) 推荐(0) 编辑
摘要: 双栈排序题目描述请编写一个程序,按升序对栈进行排序(即最大元素位于栈顶),要求最多只能使用一个额外的栈存放临时数据,但不得将元素复制到别的数据结构中。给定一个int[]numbers(C++中为vector),其中第一个元素为栈顶,请返回排序后的栈。请注意这是一个栈,意味着排序过程中你只能访问到第一... 阅读全文
posted @ 2015-07-18 13:50 Eason Liu 阅读(470) 评论(0) 推荐(0) 编辑
摘要: Delete Node in a Linked ListWrite a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the l... 阅读全文
posted @ 2015-07-15 09:20 Eason Liu 阅读(255) 评论(0) 推荐(0) 编辑
摘要: Crossing BridgeDescriptionN people wish to cross a bridge at night. It’s so dark around there that they have to cross the bridge under the help of a l... 阅读全文
posted @ 2015-07-14 21:06 Eason Liu 阅读(338) 评论(0) 推荐(0) 编辑
摘要: N-QueensThe n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, retu... 阅读全文
posted @ 2015-07-14 19:11 Eason Liu 阅读(333) 评论(0) 推荐(0) 编辑
摘要: Lowest Common Ancestor of a Binary TreeGiven a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefin... 阅读全文
posted @ 2015-07-13 20:40 Eason Liu 阅读(4241) 评论(0) 推荐(0) 编辑
摘要: Lowest Common Ancestor of a Binary Search TreeGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.Ac... 阅读全文
posted @ 2015-07-11 17:27 Eason Liu 阅读(1675) 评论(0) 推荐(0) 编辑
摘要: Palindrome Linked ListGiven a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?将链表拆成两半,后一半反转后... 阅读全文
posted @ 2015-07-11 17:12 Eason Liu 阅读(200) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 30 下一页