
leetcode
文章平均质量分 58
瓶子的罐子
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Sort a linked list using insertion sort
题目描述:Sort a linked list using insertion sort.代码实现;package leetcoder;class ListNode { int val; ListNode next; public ListNode head1; ListNode(int x) { val = x; next = null; }}publi原创 2016-04-26 21:44:11 · 510 阅读 · 0 评论 -
sorts-colors
题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0原创 2017-06-04 21:49:59 · 225 阅读 · 0 评论 -
plus-one
题目描述 Given a number represented as an array of digits, plus one to the number.分析digits数组代表一个大整数,将这个大整数加1.如果末尾位上的数小于9,直接将该位加1.如果末尾位置上的数大于9,将该位置0,产生进位。public int[] plusOne(int[] digits) { for原创 2017-06-05 10:53:04 · 294 阅读 · 0 评论 -
spiral-matrix
题目描述Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You sh原创 2017-06-05 14:54:28 · 338 阅读 · 0 评论 -
旋转二维数组90度
题目You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?java实现public void rotate(int[][] matrix) { int row =原创 2017-06-05 15:51:33 · 643 阅读 · 0 评论 -
first-missing-positive
题目描述 Given an unsorted integer array, find the first missing positive integer. For example, Given[1,2,0]return3, and[3,4,-1,1]return2. Your algorithm should run in O(n) time and uses cons原创 2017-06-05 18:50:22 · 238 阅读 · 0 评论 -
Next Permutation
题目描述 Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest po原创 2017-06-05 22:37:20 · 248 阅读 · 0 评论 -
remove element
题目描述 Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn’t matter what you leave beyond the new length原创 2017-06-05 22:48:41 · 274 阅读 · 0 评论 -
remove-duplicates-from-sorted-array
题目描述 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 space for another array, you must do this in plac原创 2017-06-05 23:02:40 · 317 阅读 · 0 评论 -
clone-graph
复制无向图原创 2016-12-27 19:34:24 · 277 阅读 · 0 评论 -
candy
题目描述 There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: Each child must have at le原创 2016-11-30 15:29:28 · 405 阅读 · 0 评论 -
Word Break(Java)
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, given s = “leetcode”, dict = [“leet”, “co转载 2016-11-01 16:50:31 · 453 阅读 · 0 评论 -
reorder-list
题目描述:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given{1,2,3,4}, reor原创 2016-05-01 10:57:30 · 345 阅读 · 0 评论 -
evaluate-reverse-polish-notation
题目描述:Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression.Some examples: ["2", "1原创 2016-09-11 16:12:34 · 439 阅读 · 0 评论 -
binary-tree-postorder-traversal
题目描述:Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].Note: Recursive soluti原创 2016-04-27 14:55:38 · 479 阅读 · 0 评论 -
binary-tree-preorder-traversal(二叉树的前序遍历)
二叉树的前序遍历的递归实现:public static ArrayList preorderTraversal(TreeNode root) { if (root == null) return value; value.add(root.val); preorderTraversal(root.left); preorderTraversal(root.right);原创 2016-04-29 23:33:43 · 906 阅读 · 0 评论 -
判断单链表是否有环
题目描述:如何判断一个单链表是否有环?思路解析:如果定义两个指针,一个一次走两步,另一个一次走一步,那么经过若干步之后,两个指针必定在某一点相遇。class Solution {public: bool hasCycle(ListNode *head) { ListNode *fast = head; ListNode *slow = head原创 2016-10-04 14:25:06 · 344 阅读 · 0 评论 -
linked-list-cycle-ii(有环链表的第一个公共节点)
题目描述:Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space思路解析:首先我们看一张图;原创 2016-09-25 23:39:35 · 626 阅读 · 0 评论 -
word-break-ii(字符串分词)
题目描述: Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given s =原创 2016-10-19 14:49:10 · 608 阅读 · 0 评论 -
Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.解法一我们可以按如下步骤: 1.复制每一个节点 2.复制附翻译 2016-11-10 11:24:07 · 315 阅读 · 0 评论 -
word-ladder
题目描述Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word原创 2017-07-11 21:50:41 · 358 阅读 · 0 评论