<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[ghoshorn的专栏]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/ghoshorn</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; ghoshorn]]></copyright><item><title><![CDATA[编程之美2015资格赛 - 题目1 : 2月29日]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45099183</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45099183</guid><author>ghoshorn</author><pubDate>Fri, 17 Apr 2015 16:56:44 +0800</pubDate><description><![CDATA[时间限制:2000ms
单点时限:1000ms
内存限制:256MB






描述
给定两个日期，计算这两个日期之间有多少个2月29日（包括起始日期）。
只有闰年有2月29日，满足以下一个条件的年份为闰年：
1. 年份能被4整除但不能被100整除
2. 年份能被400整除

输入
第一行为一个整数T，表示数据组数。
之后每组数据包含两行。每一行格式为"mont]]></description><category></category></item><item><title><![CDATA[leetcode 18 4Sum]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45046129</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45046129</guid><author>ghoshorn</author><pubDate>Tue, 14 Apr 2015 18:24:25 +0800</pubDate><description><![CDATA[4Sum



Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d =
 target? Find all unique quadruplets in the array which gives the sum of target.

Note:]]></description><category></category></item><item><title><![CDATA[leetcode 25 Reverse Nodes in k-Group]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45044017</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45044017</guid><author>ghoshorn</author><pubDate>Tue, 14 Apr 2015 16:32:37 +0800</pubDate><description><![CDATA[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 k then left-out nodes i]]></description><category></category></item><item><title><![CDATA[leetcode 24 Swap Nodes in Pairs]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45042847</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45042847</guid><author>ghoshorn</author><pubDate>Tue, 14 Apr 2015 15:32:24 +0800</pubDate><description><![CDATA[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 2->1->4->3.

Your algorithm sho]]></description><category></category></item><item><title><![CDATA[leetcode 30 Substring with Concatenation of All Words]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45028115</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45028115</guid><author>ghoshorn</author><pubDate>Mon, 13 Apr 2015 16:29:44 +0800</pubDate><description><![CDATA[Substring with Concatenation of All Words



You 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 that is a concatenat]]></description><category></category></item><item><title><![CDATA[leetcode 29 Divide Two Integers]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45027725</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45027725</guid><author>ghoshorn</author><pubDate>Mon, 13 Apr 2015 16:07:41 +0800</pubDate><description><![CDATA[Divide Two Integers
 



Divide two integers without using multiplication, division and mod operator.

If it is overflow, return MAX_INT.
class Solution1:
    # @return an integer
    def divi]]></description><category></category></item><item><title><![CDATA[leetcode 28 Implement strStr()]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45027343</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45027343</guid><author>ghoshorn</author><pubDate>Mon, 13 Apr 2015 15:46:09 +0800</pubDate><description><![CDATA[Implement strStr()



Implement strStr().

Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
要注意特殊情况，比如strstr("","") 应该等于0 =_=


class]]></description><category></category></item><item><title><![CDATA[leetcode 27 Remove Element]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45026277</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45026277</guid><author>ghoshorn</author><pubDate>Mon, 13 Apr 2015 15:23:05 +0800</pubDate><description><![CDATA[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 be]]></description><category></category></item><item><title><![CDATA[leetcode 26 Remove Duplicates from Sorted Array]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45026105</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45026105</guid><author>ghoshorn</author><pubDate>Mon, 13 Apr 2015 15:14:01 +0800</pubDate><description><![CDATA[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]]></description><category></category></item><item><title><![CDATA[leetcode 23 Merge k Sorted Lists]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45011551</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45011551</guid><author>ghoshorn</author><pubDate>Sun, 12 Apr 2015 17:09:48 +0800</pubDate><description><![CDATA[Merge k Sorted Lists

Merge k sorted
 linked lists and return it as one sorted list. Analyze and describe its complexity.

可以通过leetcode 21的merge Two Lists来解决。
如果从头到尾依此合并，会超时。
改用分治法来调用。链表个数l>3时，]]></description><category></category></item><item><title><![CDATA[leetcode 22 Generate Parentheses]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45011303</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45011303</guid><author>ghoshorn</author><pubDate>Sun, 12 Apr 2015 16:45:12 +0800</pubDate><description><![CDATA[Generate Parentheses
 



Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

For example, given n = 3, a solution set is:

"((()))", "(()]]></description><category></category></item><item><title><![CDATA[leetcode 21 Merge Two Sorted Lists]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45010901</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45010901</guid><author>ghoshorn</author><pubDate>Sun, 12 Apr 2015 16:09:18 +0800</pubDate><description><![CDATA[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 lists.



# Definition for sin]]></description><category></category></item><item><title><![CDATA[leetcode 20 Valid Parentheses]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45010657</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45010657</guid><author>ghoshorn</author><pubDate>Sun, 12 Apr 2015 15:53:18 +0800</pubDate><description><![CDATA[Valid Parentheses



Given a string containing just the characters '(', ')', '{', '}', '[' and ']',
 determine if the input string is valid.

The brackets must close in the correct order, "()"]]></description><category></category></item><item><title><![CDATA[leetcode 19 Remove Nth Node From End of List]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45010179</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45010179</guid><author>ghoshorn</author><pubDate>Sun, 12 Apr 2015 15:05:59 +0800</pubDate><description><![CDATA[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->5, and n = 2.

   After]]></description><category></category></item><item><title><![CDATA[leetcode 17 Letter Combinations of a Phone Number]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45009883</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45009883</guid><author>ghoshorn</author><pubDate>Sun, 12 Apr 2015 14:32:27 +0800</pubDate><description><![CDATA[Letter Combinations of a Phone Number



Given a digit string, return all possible letter combinations that the number could represent.

A mapping of digit to letters (just like on the telephone]]></description><category></category></item><item><title><![CDATA[leetcode 16 3Sum Closest]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/45009509</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/45009509</guid><author>ghoshorn</author><pubDate>Sun, 12 Apr 2015 13:51:33 +0800</pubDate><description><![CDATA[3Sum Closest



Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each inpu]]></description><category></category></item><item><title><![CDATA[leetcode 15 3Sum]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/44943839</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/44943839</guid><author>ghoshorn</author><pubDate>Wed, 08 Apr 2015 17:26:11 +0800</pubDate><description><![CDATA[3Sum



Given 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:


Elements in a tr]]></description><category></category></item><item><title><![CDATA[leetcode 14 Longest Common Prefix]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/44938295</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/44938295</guid><author>ghoshorn</author><pubDate>Wed, 08 Apr 2015 11:17:20 +0800</pubDate><description><![CDATA[Longest
 Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.

需要注意的特殊情况：输入是个空列表
import unittest
class Solution:
    # @return a string
    def l]]></description><category></category></item><item><title><![CDATA[leetcode 13 Roman to Integer]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/44937913</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/44937913</guid><author>ghoshorn</author><pubDate>Wed, 08 Apr 2015 10:57:06 +0800</pubDate><description><![CDATA[Roman
 to Integer



Given a roman numeral, convert it to an integer.

Input is guaranteed to be within the range from 1 to 3999.
从字符串中每次处理一位，处理前需要先找到剩余串的枢纽（剩余串中最大的），以判断当前值在其左边还是右边，该相加还是相减。
i]]></description><category></category></item><item><title><![CDATA[leetcode 12 Integer to Roman]]></title><link>https://blog.youkuaiyun.com/ghoshorn/article/details/44924525</link><guid>https://blog.youkuaiyun.com/ghoshorn/article/details/44924525</guid><author>ghoshorn</author><pubDate>Tue, 07 Apr 2015 19:11:24 +0800</pubDate><description><![CDATA[数字转换为罗马数字]]></description><category></category></item></channel></rss>