Ying

个人博客:http://smartsi.club/

[LeetCode]143.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' v...

2014-01-31 23:05:04

阅读数:1754

评论数:0

[LeetCode]141.Linked List Cycle

【题目】 Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 【题意】 给定一个链表,确定它是否包含一个环。 【分析】 ...

2014-01-31 17:46:32

阅读数:1947

评论数:0

[LeetCode]25.Reverse Nodes in k-Group

【题目】 Given 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...

2014-01-31 11:04:54

阅读数:1965

评论数:0

[LeetCode]24.Swap Nodes in Pairs

【题目】 Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as...

2014-01-29 17:02:41

阅读数:1695

评论数:0

[LeetCode]19.Remove Nth Node From End of List

【题目】 Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->...

2014-01-29 14:39:25

阅读数:1708

评论数:0

[LeetCode]61.Rotate List

【题目】 Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k ...

2014-01-29 14:04:26

阅读数:2021

评论数:0

[LeetCode]82.Remove Duplicates from Sorted List II

【题目】 Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, ...

2014-01-28 22:31:51

阅读数:1713

评论数:0

[LeetCode]83.Remove Duplicates from Sorted List

【题目】 Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. ...

2014-01-28 13:16:38

阅读数:1521

评论数:0

[LeetCode]86.Partition List

【题目】 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 should pres...

2014-01-28 12:28:43

阅读数:1724

评论数:0

[LeetCode]92.Reverse Linked List II

【题目】 Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and ...

2014-01-28 11:06:09

阅读数:2953

评论数:0

[LeetCode]2.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...

2014-01-27 11:36:25

阅读数:2454

评论数:1

[LeetCode]*137.Single Number II

【题目】 Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear...

2014-01-26 16:37:49

阅读数:2128

评论数:0

[LeetCode]135.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 fol...

2014-01-25 16:39:03

阅读数:13175

评论数:0

[LeetCode]134.Gas Station

【题目】 There are N gas stations along a circular route, where the amount of gas at station i is  There are N gas stations along a circular route, wh...

2014-01-25 10:15:31

阅读数:3260

评论数:0

编程之美之二进制数中1的个数

问题: 对于一个字节(8bit)的变量,求其二进制中1的个数,要求算法的执行效率尽可能的高。 例如把9表示成二进制是1001,有2位是1,因此如果输入9,1的个数为2。 解法一: 可以举一个8位二进制的例子。对于二进制操纵,我们除以一个2,原来数字就会减少一个0...

2014-01-24 20:01:05

阅读数:1351

评论数:0

编程之美之斐波那契数列

【背景】 【思路1-递归】 int Fibonacci(int n){ if(n <= 2){ return n; } return Fibonacci(n - 1) + Fibonacci(n - 2); ...

2014-01-24 10:14:44

阅读数:2673

评论数:0

[LeetCode]73.Set Matrix Zeroes

【题目】 Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Follow up: Did you use extra space? A straight...

2014-01-23 20:45:33

阅读数:1952

评论数:0

[LeetCode]89.Gray Code

【题目】 The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the ...

2014-01-23 17:04:23

阅读数:2611

评论数:0

[LeetCode]70.Climbing Stairs

【题目】 You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways c...

2014-01-23 13:14:35

阅读数:2909

评论数:2

[LeetCode]66.Plus One

【题目】 Given a number represented as an array of digits, plus one to the number. 【题意】 给你一个用数组表示的数,求加一之后的结果,结果还是用数组表示。 【分析】 从低位到高位,连续遇到9才能加一进位。 【代码1】 /...

2014-01-22 17:29:15

阅读数:2239

评论数:1

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