- 博客(53)
- 资源 (3)
- 收藏
- 关注
原创 LeetCode 45: Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] ha
2013-08-12 08:34:31
639
原创 Django url - view - template NOTE
Project: fruitApp: apple1. url -- view:fruit/urls.py:from django.conf.urls import patterns, include, urlurlpatterns = patterns('', url(r'^apple/', include('apple.urls')),)This map ur
2013-08-02 12:35:28
897
转载 Compile and use shared library
Source code of shared library:lib.c#include int count;void test(const char *m){ while(1) { printf("%s %d\n", m, ++count); sleep(1); }}
2013-07-29 12:02:21
854
原创 LeetCode 45: 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.LL's solution 1: 每位做乘法public cl
2013-05-25 05:56:49
1071
原创 Tree: DFS vs BFS
DFS (InOrder, PreOrder, PostOrder)-----------------------------------------------------------------------------------------------------------Recursive solution:InOrder:left -> middle -> right
2013-05-17 11:50:54
571
原创 LeetCode 44: 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 after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,
2013-04-20 02:46:23
547
原创 LeetCode 43: First Missing Positive
Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses consta
2013-04-19 05:29:57
675
原创 LeetCode 42: Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the c
2013-04-10 13:13:32
848
原创 LeetCode 41: Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited
2013-04-10 12:58:08
717
原创 LeetCode 40: 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
2013-04-10 11:58:31
930
原创 LeetCode 39: Surrounded Regions
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region .For example,X X X XX O
2013-04-10 11:32:59
553
原创 LeetCode 38: N-Queens
The n-queens puzzle is the problem of placing n queens on an n*n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens pu
2013-04-09 13:44:05
595
原创 LeetCode 38: 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 is not found
2013-04-09 00:49:08
573
原创 Leetcode 37: Sudoku solver
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudoku
2013-04-08 13:50:05
1577
原创 Leetcode 36: Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4
2013-04-07 00:46:01
790
转载 C++11: Move Semantics (Move Constructor)
// 转载自 stack overflowI find it easiest to understand move semantics with example code. Let's start with a very simple string class which only holds a pointer to a heap-allocated block of memory:
2013-03-06 08:11:03
1214
转载 The Rule of Big Three and half: Copy-and-swap Idiom
// 转载自 stack overflowOverviewWhy do we need it?Any class that manages a resource (a wrapper, like a smart pointer) needs to implement The Big Three. While the goals and implementatio
2013-03-06 07:56:38
804
转载 The Rule of Three
// 转载自Stack OverflowIf you need to explicitly declare either the destructor, copy constructor or copy assignment operator yourself, you probably need to explicitly declare all three of them.
2013-03-06 07:01:58
719
原创 LeetCode35:Valid Sudoku
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially fil
2013-02-25 13:11:05
613
原创 LeetCode34:Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.
2013-02-25 12:39:32
295
原创 LeetCode33: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 is not found
2013-02-25 10:41:21
286
原创 LeetCode32: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 the array ret
2013-02-25 05:01:58
510
原创 LeetCode31: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 "()",
2013-02-25 02:58:49
298
原创 LeetCode30:Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible
2013-02-25 02:22:02
322
原创 LeetCode29: Substring with Concatenation of All Words
You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without
2013-02-24 12:28:21
584
原创 LeetCode28:Divide Two Integers
Divide two integers without using multiplication, division and mod operator.public class Solution { public int divide(int dividend, int divisor) { // Start typing your Java solution be
2013-02-24 02:29:10
330
原创 LeetCode26: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.p
2013-02-23 06:41:25
254
原创 LeetCode25: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 wi
2013-02-23 06:18:29
347
原创 LeetCode24: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 as it is
2013-02-23 06:07:31
403
原创 LeetCode23: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 space.
2013-02-23 03:23:04
328
原创 LeetCode22: Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. * Definition for singly-linked list. * public class ListNode { * int val; * ListNo
2013-02-22 15:29:48
335
原创 LeetCode21: 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:"((()))", "(()())", "(())()", "()(())", "()
2013-02-22 14:56:13
295
原创 LeetCode20: 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 all va
2013-02-22 14:09:40
348
原创 LeetCode19: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 end, t
2013-02-22 11:20:26
326
原创 LeetCode18: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
2013-02-22 11:03:49
319
原创 LeetCode17: 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:
2013-02-22 06:08:16
438
原创 LeetCode 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 have exa
2013-02-20 14:04:55
564
原创 LeetCode15: 3 Sum
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 triplet
2013-02-20 12:42:17
317
原创 Leetcode14: Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.public class Solution { public String longestCommonPrefix(String[] strs) { // Start typing your
2013-02-20 09:54:57
277
System Analysis and Design with UML Version 2.0 (3rd edition)
2013-01-17
Digital Forensics with open source tools
2011-08-03
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人