自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 收藏
  • 关注

原创 [LeetCode] Divide Two Integers

题目 Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 思路 这道题需要用到移位操作,这就涉及到一些二进制相关的概念,先普及一下: 1)二进制表示中,首位是符号位,1表示复数,0表示正数 2)二进制表示

2016-01-05 10:08:05 317

原创 [LeetCode] Implement strStr()

题目 Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 思路 按照下标递增的顺序比较haystack中的所有子字符串和needle。 代码 public class Solu

2016-01-05 10:04:09 250

原创 [LeetCode] 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 beyond the new length

2016-01-05 09:57:52 242

原创 [LeetCode] 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 pl

2016-01-04 20:18:52 219

原创 [LeetCode] 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 in the end should remain

2016-01-04 20:12:49 241

原创 [LeetCode] 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 should use only constant

2016-01-04 20:05:00 225

原创 [LeetCode] Regular Expression Matching

题目 Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding element. The matching should cover the entire

2016-01-04 19:57:05 240

原创 [LeetCode] Merge k 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. 思路 考察的是Two Pointers思想。开始这两个指针分别指向两个链表的头节点,每次取出这两

2016-01-04 19:47:28 213

原创 [LeetCode] 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: "((()))", "(()())", "(())()", "()(())

2016-01-04 19:37:50 247

原创 [LeetCode] 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

2015-12-08 16:37:06 292

原创 [LeetCode] 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, "()" and "()[]{}" are

2015-12-08 16:29:49 227

原创 [LeetCode] 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 removing the second node from the

2015-12-08 16:24:03 356

原创 [Leetcode] 4Sum

题目 Given anarray S of n integers, are thereelements a, b, c, and d in S suchthat a + b + c + d = target? Find allunique quadruplets in the array which gives the sum of target. Note: Elements in a

2015-12-08 16:21:43 271

原创 [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:

2015-11-30 22:25:48 313

原创 [LeetCode] 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 have

2015-11-25 11:51:28 267

原创 [LeetCode] 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 triple

2015-11-20 15:38:15 277

原创 [LeetCode] Longest Common Prefix

题目 Write a function to find the longest common prefix string among an array of strings. Subscribe to see which companies asked this question 思路 最长前缀,显然不可能比数组中任意一个字符串长。除去数组为空的特殊情况,选中第一个字符

2015-11-20 15:28:27 368

原创 [LeetCode] Roman to Integer

问题 Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. Subscribe to see which companies asked this question 思路 罗马数字的构造方式上一篇博客里面

2015-11-20 14:55:34 257

原创 [LeetCode] Integer to Roman

题目 Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 思路 首先需要了解罗马数字的构造规律: 罗马数字共有七个,即I(1),V(5),X(10),L(50),C(100),D(500),M(1000)。按照

2015-11-16 14:29:54 300

原创 [LeetCode] Container With Most Water

题目 Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (

2015-11-16 13:19:56 292

原创 [LeetCode] Palindrome Number

题目 Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of

2015-11-11 13:49:46 236

原创 [LeetCode] String to Integer (atoi)

题目 Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible

2015-11-10 17:55:45 293

原创 [LeetCode] Reverse Integer

题目 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions to ask

2015-11-10 16:28:42 380

原创 [LeetCode] ZigZag Conversion

题目 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A

2015-11-10 15:14:24 435

原创 [LeetCode] Longest Palindromic Substring

题目 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 思路1 最直接的思

2015-11-09 20:44:31 256

原创 [LeetCode] Median of Two Sorted Arrays

题目 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 思路 题目中已经给出了时间复杂度的要

2015-11-04 15:25:05 353

原创 [LeetCode] 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 is

2015-11-04 12:26:27 311

原创 [LeetCode] 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 it a

2015-11-03 17:04:00 340

原创 [LeetCode] 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 the t

2015-11-03 16:59:54 254

空空如也

空空如也

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

TA关注的人

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