自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(88)
  • 收藏
  • 关注

sort link list

题目描述对一个单链表原地(in-place)排序。即直接对链表结点排序。返回排序后链表的头结点。链表结点的定义为(请不要在代码中再次定义该结构):C/C++struct ListNode { int val; ListNode *next;}渣做法!N^2ListNode* insert(ListNode* head, ListNode*...

2013-10-13 20:11:31 238

[Leetcode] Gas Station

Gas Station AC Rate: 1017/4717My Submissions There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas ...

2013-10-07 00:02:52 174

[Leetcode] Word Break 1 & 2

Word Break AC Rate: 2/13My Submissions 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 w...

2013-10-05 23:26:18 152

[Leetcode] Single Number 1 & 2

Single Number AC Rate: 1243/2713My Submissions Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a ...

2013-10-05 22:50:54 117

[Leetcode] Copy List with Random Pointer

Copy List with Random Pointer AC Rate: 350/1573My Submissions A linked list is given such that each node contains an additional random pointer which could point to any node in the ...

2013-10-05 22:43:13 93

原创 [Leetcode] Path Sum

Path Sum AC Rate: 872/2770My Submissions Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals t...

2013-10-03 23:52:53 99

[Leetcode] Remove Duplicates from Sorted List 1 & 2

Remove Duplicates from Sorted List AC Rate: 984/2755My Submissions Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1-...

2013-10-03 23:34:35 106

[Leetcode] Scramble String

Scramble String AC Rate: 318/1523My Submissions Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one p...

2013-10-03 16:55:11 74

原创 [Leetcode] Partition List

Partition List AC Rate: 428/1694My Submissions Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You s...

2013-09-29 23:38:02 74

[Leetcode] Word Search

Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or v...

2013-09-21 23:21:41 77

[Leetcode] Decode Ways

Decode WaysJun 25 '126747 / 26583A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded ...

2013-09-11 17:33:06 63

[Leetcode] Convert Sorted List to Binary Search Tree

Convert Sorted List to Binary Search TreeOct 3 '125768 / 16298Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.  /** * Defi...

2013-09-11 16:06:34 83

前k大个数

#include <cstdlib>#include <cstdio>#include <vector>#include <map>#include <algorithm>using namespace std;void qfind(vector<int>& a, int k, int l...

2013-09-11 14:48:25 87

大整数运算

#include <cstdlib>#include <cstdio>#include <vector>#include <map>#include <algorithm>using namespace std;void reverse(char*s) { if (s == NULL ) return;...

2013-09-11 14:47:07 168

[Leetcode] Binary Tree Level Order Traversal

Binary Tree Level Order TraversalSep 29 '125832 / 14746Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given b...

2013-09-10 14:39:15 88

[Leetcode] Subsets 1 ^& 2

SubsetsApr 18 '126226 / 16269Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain...

2013-09-09 21:42:58 66

[Leetcode] Unique Paths II

Unique Paths IIMar 29 '124573 / 11497Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is ...

2013-09-09 21:10:42 82

[Leetcode] Flatten Binary Tree to Linked List

Flatten Binary Tree to Linked ListOct 14 '127105 / 21371Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ ...

2013-09-09 02:35:44 83

[Leetcode] Triangle

TriangleOct 30 '126503 / 17796Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following tria...

2013-09-04 16:32:45 84

[Leetcode] Balanced Binary Tree

Balanced Binary TreeOct 9 '127722 / 18479Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth...

2013-08-27 20:53:01 96

[Leetcode] Rotate Image

Rotate ImageMar 18 '124182 / 9471You 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? 这题我第一次做时候,实现的非...

2013-08-22 15:54:25 69

[Leetcode] Permutations / Permutations II

Permutations IIMar 17 '124943 / 12877Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permuta...

2013-08-22 15:41:54 85

[Leetcode] Jump Game / Jump Game II

Jump GameMar 25 '126923 / 16241Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump len...

2013-08-22 10:31:25 78

[Leetcode] Wildcard Matching

Wildcard MatchingMar 16 '127489 / 29783Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the...

2013-08-22 10:07:47 81

[Leetcode] Multiply Strings

Multiply StringsMar 12 '124253 / 16074Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negativ...

2013-08-20 18:48:44 77

[Leetcode] Trapping Rain Water

Trapping Rain WaterMar 10 '124164 / 10550Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining....

2013-08-20 13:10:57 63

[Leetcode] First Missing Positive

First Missing PositiveMar 8 '125401 / 16835Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm...

2013-08-20 11:41:27 59

[Leetcode] Combination Sum / Combination Sum II

Combination SumMar 7 '125736 / 16047Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated nu...

2013-08-20 11:13:20 68

[Leetcode] Count and Say

Count and Say The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read ...

2013-08-19 20:35:41 53

[Leetcode] Longest Valid Parentheses

Longest Valid ParenthesesMar 1 '125700 / 20657Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", th...

2013-08-19 17:20:47 49

[Leetcode] Search for a Range / Search Insert Position

Search for a RangeMar 3 '125093 / 13502Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the orde...

2013-08-19 15:59:27 56

[Leetcode] Substring with Concatenation of All Words

Substring with Concatenation of All WordsFeb 24 '125071 / 18608You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S...

2013-08-19 11:26:42 61

[Leetcode] Next Permutation

Next PermutationFeb 25 '124235 / 11932Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, ...

2013-08-16 09:05:10 69

[Leetcode] Reverse Nodes in k-Group

Reverse Nodes in k-GroupFeb 16 '123953 / 13303Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k t...

2013-08-14 09:46:43 52

[Leetcode] Letter Combinations of a Phone Number

Letter Combinations of a Phone NumberJan 27 '124852 / 14644Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just li...

2013-08-14 09:06:11 64

[Leetcode] 3Sum / 3Sum Closet

3SumJan 18 '128685 / 33750Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:E...

2013-08-13 20:14:02 85

[Leetcode] Palindrome Number

Palindrome NumberJan 4 '126687 / 16659Determine whether an integer is a palindrome. Do this without extra space. 重来没有这么爽过! class Solution {public: int reverse(int x) { ...

2013-08-13 19:56:37 68

[Leetcode] String to Interger (atoi)

String to Integer (atoi)Dec 27 '116739 / 30948Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see be...

2013-08-13 19:35:30 76

[Leetcode] Reverse Integer

Reverse IntegerDec 26 '116571 / 11753Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Have you thought about this?Here are some good questions to a...

2013-08-07 22:59:10 57

[Leetcode] Longest Palindromic Substring

 Longest Palindromic SubstringNov 11 '116971 / 22796Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one un...

2013-08-07 22:29:44 67

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除