自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

shirleyleychen的博客

世界这么大,我想去看看 :D

  • 博客(19)
  • 收藏
  • 关注

原创 【Easy】28. Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.中心思想:解法一(暴力):class Solution {public: int strStr(string

2016-09-19 16:59:52 234

原创 【Medium】17. 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

2016-09-17 00:32:10 312

原创 【Medium】221. Maximal Square

Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0

2016-09-15 23:51:05 230

原创 【Hard】23. Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.中心思想:(此题应有多解)之前做过merge sorted lists的题,用那一题的方法,写一个Helper function,然后将此列表中的数组一一merge。此方法time compl

2016-09-15 00:00:44 163

原创 【Easy】88. Merge Sorted Array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.中心思想:用一个vector来将两个数组的数字依大小顺序推上去,最后将其赋值给nums1。class Solution {public: void merge(vector& num

2016-09-14 23:58:09 144

原创 【Medium】209. Minimum Size Subarray Sum

Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, given the array [2,3

2016-09-14 23:40:04 144

原创 【Medium】200. Number of Islands

Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assu

2016-09-14 15:37:21 244

原创 【Medium】50. Pow(x, n)

Implement pow(x, n).中心思想: 这题需要注意n有几种特殊情况:n = 1, return 0x = 0, n必须为非负数n n = -INT_MIN时,不能直接使用-n, 要用INT_MAX解法一:用递归方法将n个x乘起来解法二(O(logn)):利用对称性,pow(x,n) = pow(x,n/2)*pow(x,n-n/2)clas

2016-09-14 15:33:48 347

原创 【Medium】238. Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements ofnums except nums[i].Solve it without division and in O(

2016-09-14 14:29:33 136

原创 【Medium】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 nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fi

2016-09-14 14:25:35 146

原创 【Easy】26. 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 another array, you must do this in place with

2016-09-14 13:11:13 165

原创 【Easy】206. Reverse Linked List

Reverse a singly linked list./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solu

2016-09-14 13:08:30 157

原创 【Medium】75. Sort Colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers

2016-09-14 11:33:30 221

原创 【Medium】69. Sqrt(x)

Implement int sqrt(int x).Compute and return the square root of x.中心思想:二分查找sqrt(x) class Solution {public: int mySqrt(int x) { double begin = 0; double end =

2016-09-14 11:31:49 189

原创 【Medium】78. Subsets

Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:[ [3], [1],

2016-09-14 11:26:15 231

原创 【Easy】1. Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example:Given nums =

2016-09-14 11:23:20 236

原创 【Easy】125. Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a

2016-09-14 11:21:29 205

原创 【Medium】139. Word Break

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 words.For example, givens = "leetcode",dict = ["leet"

2016-09-14 11:18:16 239

原创 【Medium】79. Word Search

中心思想:resursive DFS, 为了不用把board中的每一个元素都试一遍probe, 先将开头字母放在一个stack上,要探索就取stack顶部元素之后,写一个helper function called probe, 把要探索的位置,board本身,word和word中字母的位置给传进去probe中,首先判断传进来的位置是不是invalid,然后判断位置上的字母是不是wor

2016-09-14 11:11:29 204

空空如也

空空如也

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

TA关注的人

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