- 博客(18)
- 收藏
- 关注
原创 leetcode:Merge Intervals
Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18]./** * Definition for an interval. * struct
2014-08-31 21:46:43 389
原创 leetcode: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 off as
2014-08-31 20:22:47 383
原创 leetcode: Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",
2014-08-30 19:48:47 426
原创 leetcode: 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 buttons) is given below.Input:Digit st
2014-08-30 00:31:18 357
原创 leetcode:Gas Station
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 tank and it costs cost[i] of gas to travel from station i to
2014-08-28 13:54:28 386
转载 数组是首尾相连的,即相当于数组是一个环的结构,要求从这个环的结构中求出最大的和
解法:当数组是首尾相连时,求连续子数组最大和的方法可以归纳如下:1.将原数组进行扩充,即假设原数组为{1,2,-3,4,5},则扩充相当于{1,2,-3,4,5,1,2,-3,4,5}2.利用上述的解法在扩充后的数组进行遍历求其连续子数组的最大和,不过要做一些小改动,即保证子数组的长度在原数组的长度范围之内。这样求出来的结果即是原数组首尾相连后,连续子数组的最大和。注:当然,此处我们并
2014-08-24 20:37:31 2419
原创 字符串移动
字符串为*号和26个字母、阿拉伯数字的任意组合,把*号都移动到最左侧,把其他字母和数字都移到最右侧并保持相对顺序不变,返回字符*的个数,要求时间和空间复杂度最小。第一种方法:跟上面的重排问题是一样的
2014-08-20 10:03:02 547
原创 一道经典的额递归题目
函数 int func(int i ,int N);其中i 123454321要求:1、只能有1个语句,即一个分号2、不能使用do while until goto for if关键字,不能使用?:和逗号运算符3、唯一能使用的库函数为printf // recursive_print.cpp : Defines the ent
2014-08-19 22:10:14 599
转载 试着用最小的比较次数去寻找数组中的最大值和最小值。
每次比较相邻两个数,较大者与MAX比较,较小者与MIN比较,找出最大值和最小值。方法如下:先将一对元素互相进行比较,然后把最小值跟当前最小值进行比较,把最大值跟当前最大值进行比较。因此每两个元素需要3次比较。如果n为奇数,那么比较的次数是3*(n/2)次比较。如果n为偶数,那么比较的次数是3n/2-2次比较。因此,不管是n是奇数还是偶数,比较的次数至多是3*(n/2),具体的代码如下
2014-08-19 17:20:38 3007
转载 苹果官方文档:使用Autorelease Pools
转自: http://blog.csdn.net/workhardupc100/article/details/6933914翻译自:http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmAutoreleasePools.html%23//appl
2014-08-18 22:25:58 379
转载 如何在同一个UIAlertDelegate中区别不同的Alert
转自出处:IOS: two UIAlert with two different delegate methods
2014-08-16 09:44:48 495
转载 iPhone SDK difference between isKindOfClass and isMemberOfClass
转自 http://stackoverflow.com/questions/3653929/iphone-sdk-difference-between-iskindofclass-and-ismemberofclass
2014-08-16 09:00:04 457
转载 Objective-C 之 Literals(字面量)
转自出处 http://my.oschina.net/iamzkt/blog/127718
2014-08-16 08:43:57 529
原创 leetcode: Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu
2014-08-10 10:32:04 318
原创 字符交替
// 字符交替.cpp : Defines the entry point for the console application.///** "AB" "CD"* ABCD* ACBD* ACDB* CABD* CADB* CDAB**/#include "stdafx.h"#include #include using
2014-08-09 19:31:49 442
原创 leetcode: Anagrams
Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.
2014-08-09 16:41:53 429
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人