上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 28 下一页
摘要: Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.解题思... 阅读全文
posted @ 2015-09-15 16:50 TonyLuis 阅读(215) 评论(0) 推荐(0)
摘要: Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].解题思路:JA... 阅读全文
posted @ 2015-07-10 22:09 TonyLuis 阅读(394) 评论(0) 推荐(0)
摘要: Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators an... 阅读全文
posted @ 2015-07-10 21:41 TonyLuis 阅读(388) 评论(0) 推荐(0)
摘要: 给定一个包含红,白,蓝且长度为n的数组,将数组元素进行分类使相同颜色的元素相邻,并按照红、白、蓝的顺序进行排序。我们可以使用整数0,1和2分别代表红,白,蓝。解题思路:Java for LeetCode 075 Sort Colorspublic void sortColors(int[] nums... 阅读全文
posted @ 2015-06-15 21:42 TonyLuis 阅读(266) 评论(0) 推荐(0)
摘要: 用插入排序对链表排序解题思路:最省时间的方法是使用优先级队列,但是无法通过,那就直接插入排序好了。 public ListNode insertionSortList(ListNode head) { ListNode root = new ListNode(Integer.MIN_VALU... 阅读全文
posted @ 2015-06-15 21:39 TonyLuis 阅读(497) 评论(0) 推荐(0)
摘要: 将一个整数中的数字进行颠倒,当颠倒后的整数溢出时,返回 0 (标记为 32 位整数)。解题思路:JAVA实现如下: public int reverseInteger(int n) { Boolean isNeg = n >= 0 ? false : true; StringBuilder... 阅读全文
posted @ 2015-06-15 21:11 TonyLuis 阅读(356) 评论(0) 推荐(0)
摘要: 给定一个二叉树,判断它是否是合法的二叉查找树(BST)一棵BST定义为: 节点的左子树中的值要严格小于该节点的值。 节点的右子树中的值要严格大于该节点的值。 左右子树也必须是二叉查找树。解题思路:递归肯定是做不出来的,我的方法比较土,检验中序遍历是否有序,JAVA实现如下: public boole... 阅读全文
posted @ 2015-06-15 20:52 TonyLuis 阅读(515) 评论(0) 推荐(0)
摘要: Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by thi... 阅读全文
posted @ 2015-06-15 20:18 TonyLuis 阅读(194) 评论(0) 推荐(0)
摘要: Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()... 阅读全文
posted @ 2015-06-15 20:14 TonyLuis 阅读(237) 评论(0) 推荐(0)
摘要: Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or ... 阅读全文
posted @ 2015-06-15 20:11 TonyLuis 阅读(652) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 28 下一页