自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 资源 (1)
  • 收藏
  • 关注

原创 Leetcode NO.81 Search in Rotated Sorted Array II

题目要求如下: Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a function to determine if a given tar

2015-01-29 11:40:51 343

原创 Leetcode NO.33 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 2). You are given a target value to search. If found in th

2015-01-29 11:16:26 335

原创 Leetcode NO.34 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 be in the order of O(log n). If the target

2015-01-29 10:48:39 486

原创 Leetcode NO.147 Insertion Sort List

本题题目要求如下: Sort a linked list using insertion sort. 题目相当之简单,而且本题都把算法限定为insertion sort,所以也没有改进的余地,基本来讲,本题就考一个小技巧以及基本功。。 很可惜,我基本功很烂,当然跟没有想出那个小技巧简化问题也有关系。。。 题目代码如下: /** * Definition for singly-lin

2015-01-28 08:39:59 500

原创 Leetcode NO.169 Majority Element

题目要求如下: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the array is non-empty and the majo

2015-01-26 11:32:49 529

原创 Leetcode NO.43 Multiply Strings

题目要求如下: Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. 这题因为我一开始把题目想的太简单,导致一直都是ove

2015-01-26 06:34:46 466

原创 Stanford - Algorithms: Design and Analysis, Part 1 - Week 1 Assignment: number of inversions

题目要求如下: Download the text file here. (Right click and save link as) This file contains all of the 100,000 integers between 1 and 100,000 (inclusive) in some order, with no integer repeated. Y

2015-01-25 11:32:21 1083

原创 Leetcode NO.69 Sqrt(x)

题目要求如下: Implement int sqrt(int x). Compute and return the square root of x. 题意就是自己implement一个sqrt()函数,不过input,output都是int型,就是返回整数(不是四舍五入),比如sqrt(3) = 1 我写的代码如下: class Solution { public:

2015-01-25 06:31:30 390

原创 Leetcode NO.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 single digit. Add the two numbers and return

2015-01-24 06:51:47 394

原创 Leetcode NO.50 Pow(x, n)

本题要求如下: Implement pow(x, n). 就是实现C++自带的pow()函数,极其简单,就是用recursive的方法:pow(x,n) = pow(x*x, n/2)这样下来,当然有些情况(n的奇偶,正负),时间复杂度就是O(logN)。 代码如下: class Solution { public: double pow(double x, int n) {

2015-01-23 07:07:42 390

原创 Leetcode NO.60 Permutation Sequence

题目要求如下: The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): "123""132

2015-01-23 06:10:07 362

原创 Leetcode NO.78 Subsets

题目要求如下: Given 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 duplicate subsets.

2015-01-22 12:14:45 337

原创 Leetcode NO.166 Fraction to Recurring Decimal

题目要求如下: Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in pa

2015-01-22 09:41:08 468

原创 Leetcode NO.1 Two Sum

题目要求如下: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to th

2015-01-21 07:07:15 403

原创 Leetcode NO.49 Group Anagrams

本题要求如下: Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. 本题思路比较直接,但是还是耗费了我不少精力,一部分是语法,另一部分是看题不仔细: 代码如下: class Solution { pu

2015-01-21 05:44:44 406

原创 Leetcode NO.3 Longest Substring Without Repeating Characters

本题要求如下: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length

2015-01-20 08:06:52 446

原创 Leetcode NO.18 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:

2015-01-20 05:31:26 394

原创 Leetcode NO.16 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 input would

2015-01-19 09:06:00 504

原创 Leetcode NO.15 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 t

2015-01-19 08:14:47 549

原创 Leetcode NO.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 = 2, return 4->5->1->2->3->NULL. 这题的思路很简单,但是我觉得我的方法并不好,

2015-01-18 10:32:20 387

原创 Leetcode NO.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 preserve the original relative order of the nod

2015-01-18 06:15:37 430

原创 Leetcode NO.80 Remove Duplicates from Sorted Array II

题目要求如下: Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array A = [1,1,1,2,2,3], Your function should return length = 5, and A i

2015-01-17 08:48:37 486

原创 Leetcode NO.167 Two Sum II - Input array is sorted

本题题目要求如下: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of

2015-01-17 05:23:46 692

原创 Leetcode NO.142 Linked List Cycle II

题目要求如下: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using extra space? 其实就是原来做过的tow pointers问题,本题并不算难。

2015-01-16 09:28:11 392

原创 Leetcode NO.74 Search a 2D Matrix

本题要求如下: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right.The first in

2015-01-16 07:49:21 407

原创 Leetcode NO.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 forward solution using O(mn) space is pro

2015-01-16 07:01:21 462

原创 Leetcode NO.153 Find Minimum 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 2). Find the minimum element. You may assume no duplica

2015-01-14 12:25:14 386

Algorithm in C++, Part 1 - Part 4

这本书是我们上课时用的教材,质量应该还算不错吧,因为没有看完,只是看上课需要的部分,所以无权评价全部东西。但是本书以及本书作者还是比较有名的,学算法的肯定都知道的。MOOC上讲课的普林斯顿大牛 相比较于传说中经典的Intro to Algorithm,真本书更侧重于算法的C++实现,而非理论,对于纯CS的学生,可以绕道。。但是对于工程类专业,这本书应该是更好的选择。 P.S.如果谁有part 5图论,跟我联系下,求分享。。。另外,如果确实是跟我积分一样少的穷人,联系我,给个邮箱,我发给你。。

2014-02-23

空空如也

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

TA关注的人

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