
LeetCode
文章平均质量分 67
wheel_Y
这个作者很懒,什么都没留下…
展开
-
LeetCode 003 Longest Substring Without Repeating Characters
package ywheel.leetcode._003_longest_substring_without_repeating_characters;/** * Given a string, find the length of the longest substring without repeating * characters. For example, the longest原创 2015-02-15 00:34:08 · 366 阅读 · 0 评论 -
LeetCode 题目总结/分类
转载自豆瓣: http://www.douban.com/note/330562764/,的确需要有一个分类列表在指导自己在准备时间不够充分的情况下接触到更多考点的题欢迎参考我的leetcode代码利用堆栈:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/http://oj.leetcod转载 2015-03-11 01:36:02 · 890 阅读 · 0 评论 -
LeetCode 023 Merge K Sorted Lists
题:https://leetcode.com/problems/merge-k-sorted-lists/Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.解法一:将K个链表做K-1次归并,每次归并是对两个链表的归并,最终得到一个原创 2015-03-12 02:52:05 · 447 阅读 · 0 评论 -
LeetCode 088 Merge Sorted Array
题:https://leetcode.com/problems/merge-sorted-array/Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is原创 2015-03-12 00:36:28 · 396 阅读 · 0 评论 -
LeetCode 066 Plus one
题目:https://leetcode.com/problems/plus-one/Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit原创 2015-03-11 01:26:50 · 404 阅读 · 0 评论 -
LeetCode 021 Merge Two Sorted Lists
题:https://leetcode.com/problems/merge-two-sorted-lists/Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two li原创 2015-03-12 01:43:50 · 377 阅读 · 0 评论 -
LeetCode主题整理(4)链表及相关问题
转载自:http://blog.youkuaiyun.com/feliciafay/article/details/18944093Topic 1 反转链表Reverse Linked List II在第m~n个节点中反转单链表,注意这道题可以把代码写得很长,如果分为区间一[0,m-1],区间二[m-n],区间三[n+1,end]这三个区间的话。也可以写得很短,如果仔细观察发现转载 2015-03-11 01:32:34 · 459 阅读 · 0 评论 -
LeetCode 33 Search in Rotated Sorted Array 二叉查找(三)
题目:https://leetcode.com/problems/search-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 become 4 5 6 7 0 1原创 2015-03-10 01:45:13 · 578 阅读 · 0 评论 -
LeetCode 34 Search For A Range 二叉查找相关(二)
题目:https://leetcode.com/problems/search-for-a-range/Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must原创 2015-03-10 00:07:43 · 459 阅读 · 0 评论 -
LeetCode 35 Search Insert Position 二叉查找相关(一)
题目:https://leetcode.com/problems/search-insert-position/Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were原创 2015-03-09 23:41:02 · 322 阅读 · 0 评论 -
LeetCode 75 Sort Colors
public class Solution { public void sortColors(int[] A) { if (A == null || A.length == 0) return; int zero = 0; int two = A.length - 1; int i = 0; whil原创 2015-03-07 17:15:28 · 362 阅读 · 0 评论 -
LeetCode 32 Longest Valid Parentheses
题目大意是给定一个只有左右括号组成的字符串,求最长的valid字串长度,比如“()”的最长valid字串长度为2,“)()())”的最长valid字串为"()()",则长度为4.拿到这个题目第一反应就是用Stack,但是Stack里面装什么呢?如何表示Valid最大长度?后来想到是否能够把还没匹配好的括号的index放到stack中,如果有匹配的就pop,没有就push。当pop的时候原创 2015-03-08 22:20:28 · 384 阅读 · 0 评论 -
LeetCode 119 Pascal's Triangle II
题:https://leetcode.com/problems/pascals-triangle-ii/Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimiz原创 2015-03-17 00:16:20 · 532 阅读 · 0 评论 -
LeetCode 22 Generate Parentheses
连续两次随机到关于括号的题了,跟括号真有缘。。。好了,别的不多说,上代码:package ywheel.leetcode._22_generate_parentheses;import java.util.ArrayList;import java.util.List;/** * Given n pairs of parentheses, write a function to原创 2015-03-08 23:55:23 · 363 阅读 · 0 评论 -
LeetCode 129 Sum Root to Leaf Numbers
/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { publi原创 2015-03-07 16:33:49 · 323 阅读 · 0 评论 -
LeetCode 001 TwoSum
package ywheel.leetcode._001_two_sum;import java.util.Arrays;import java.util.Comparator;/** * Given an array of integers, find two numbers such that they add up to a * specific target number.原创 2015-02-14 01:10:00 · 439 阅读 · 0 评论 -
LeetCode 002 AddTwoNumbers
package ywheel.leetcode._002_add_two_numbers;/** * You are given two linked lists representing two non-negative numbers. The * digits are stored in reverse order and each of their nodes contain a原创 2015-02-14 16:52:00 · 423 阅读 · 0 评论 -
LeetCode 147 Insertion Sort List
题:https://leetcode.com/problems/insertion-sort-list/Sort a linked list using insertion sort./** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode原创 2015-03-12 00:16:05 · 371 阅读 · 0 评论