自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Majority Element

五种方法:Hash table-Runtime: O(n), Space: O(n) Maintain a hash table of the counts of each element, then find the most common one.Randomization-Average runtime: O(n), Worst case runtime: Infinity: R

2016-03-14 06:44:19 322

原创 Kth Largest Element in an Array

123

2016-01-27 15:39:15 328

原创 DFS 总结

1 Subsets 2 Subsets II3 Combinations

2014-08-31 11:37:07 508

原创 2.2.9 Reverse Nodes in K-group

Link: https://oj.leetcode.com/problems/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 m

2014-08-25 06:50:06 354

原创 2.2.8 Swap Nodes in Pairs

Link: 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 const

2014-08-25 05:14:25 394

原创 2.2.7 Remove Nth Node From End of List

Link: https://oj.leetcode.com/problems/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

2014-08-25 01:30:53 385

原创 Chap2 Insertion Sort

Loop Invariant: At the start of each interation, A[1 .. j-1] con

2014-08-24 08:52:01 439

原创 CLRS 学习计划

I: 1, 2, 3, 4 (Master Theorem)II: 6-9III: 10 (Basic), 11-12, 13

2014-08-23 06:06:18 363

原创 2.2.6 Rotate List

Link: https://oj.leetcode.com/problems/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

2014-08-22 08:07:34 275

原创 2.2.5 Remove Duplicates from Sorted List II

Link: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original

2014-08-22 06:41:21 323

原创 2.2.4 Remove Duplicates from Sorted List

Link: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, r

2014-08-22 02:44:06 411

原创 2.2.3 Partition List

Link: 这是CC150原题,我的思路正确,但代码尤文

2014-08-22 01:56:56 266

原创 2.2.2 Reverse LinkedList II

Link: https://oj.leetcode.com/problems/reverse-linked-list-ii/Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n =

2014-08-22 01:45:46 338

原创 2.2.1 Add Two Numbers

Link: https://oj.leetcode.com/problems/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

2014-08-21 02:53:36 477

原创 2.1.24 Single Number II

Link: https://oj.leetcode.com/problems/single-number-ii/Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a lin

2014-08-21 01:34:05 286

原创 2.1.23 Single Number

Link: https://oj.leetcode.com/problems/single-number/Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runti

2014-08-19 08:46:20 259

原创 2.1.22 Candy

Link: https://oj.leetcode.com/problems/candy/There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following re

2014-08-19 08:31:07 388

原创 2.1.21 Gas Station

Link: https://oj.leetcode.com/problems/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 i

2014-08-19 07:53:13 425

原创 2.1.20 Set Matrix Zeroes

Link: https://oj.leetcode.com/problems/set-matrix-zeroes/

2014-08-19 05:05:06 702

原创 2.1.19 Gray Code

Link: https://oj.leetcode.com/problems/gray-code/The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the t

2014-08-19 02:26:43 426

原创 2.1.18 Climbing Stairs

Link: https://oj.leetcode.com/problems/climbing-stairs/You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways

2014-08-18 14:59:08 265

原创 2.1.17 Plus One

Link: Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.

2014-08-18 12:44:34 369

原创 2.1.16 Rotate Image

Link: You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?

2014-08-18 12:16:45 313

原创 2.1.15 Trapping Rain Water

Link: https://oj.leetcode.com/problems/trapping-rain-water/Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap a

2014-08-18 09:54:23 297

原创 2.1.14 Valid Sudoku

Link: https://oj.leetcode.com/problems/valid-sudoku/这题见

2014-08-18 07:58:30 240

原创 2.1.13 Permutation Sequence

Link: http://www.lifeincode.net/programming/leetcode-permutation-sequence-java/

2014-08-15 09:03:35 372

原创 2.1.12 Next Permutation

Link: https://oj.leetcode.com/problems/next-permutation/

2014-08-14 14:27:21 450

原创 2.1.11 Remove Element

Link: https://oj.leetcode.com/submissions/detail/9751364/

2014-08-14 09:00:09 298

原创 2.1.10 4Sum

Link: https://oj.leetcode.com/problems/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 whic

2014-08-14 07:49:29 296

原创 2.1.9 3Sum Closest

Link: 这题和3Sum 几乎一样。public class Solution { public int threeSumClosest(int[] num, int target) { Arrays.sort(num); int gap = Integer.MAX_VALUE; int result = Integer.MAX_V

2014-08-13 06:18:15 332

原创 2.1.8 3Sum

Link: https://oj.leetcode.com/problems/3sum/这题和2sumApproach I:

2014-08-13 05:43:39 660

原创 2.1.7 Two Sum

Link: https://oj.leetcode.com/problems/two-sum/

2014-08-12 08:45:33 447

原创 2.1.6 Longest Consecutive Sequence

Link: https://oj.leetcode.com/problems/longest-consecutive-sequence/Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4,

2014-08-12 07:14:58 388

原创 2.1.5 Median of Two Sorted Arrays

Link: https://oj.leetcode.com/problems/median-of-two-sorted-arrays/

2014-08-12 03:34:28 241

原创 2.1.4 Search in Rotated Sorted Array II

Link: 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 target is

2014-08-11 12:56:34 240

原创 2.1.3 Search in Rotated Sorted Array

Link: My code:public class Solution { public int search(int[] A, int target) { if(A == null || A.length == 0) return -1; return helper(A, target, 0, A.length); } p

2014-08-11 09:10:37 312

原创 2.1.2 Remove Duplicates from Sorted Array II

Link: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted arra

2014-08-11 04:27:44 211

原创 2.1.1 Remove Duplicates from Sorted Array

Link: https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/这题看起来简单。to do again

2014-08-10 15:01:28 268

原创 15.14 Text Justification

Link: https://oj.leetcode.com/problems/text-justification/

2014-08-08 07:48:43 302

原创 15.13 Divide Two Integers

Link: https://oj.leetcode.com/problems/divide-two-integers/My thought: subtract dividend

2014-08-08 03:15:35 436

Thinking in Java 4th Edition

Thinking in Java 4th Edition

2011-02-15

空空如也

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

TA关注的人

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