- 博客(43)
- 收藏
- 关注
转载 LeetCode: Gray Code
The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integernrepresenting the total number of bits in the code, print the sequence ...
2014-09-24 15:15:00
153
转载 LeetCode: 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: Elements...
2014-08-24 22:32:00
170
转载 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 ex...
2014-08-24 18:10:00
218
转载 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. ...
2014-07-05 14:50:00
161
转载 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 3....
2014-07-03 22:24:00
81
转载 LeetCode:Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given[100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is[1, 2, 3,...
2014-07-02 22:03:00
108
转载 LeetCode:Longest Common Prefix
Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. Solution: public class Solution { public String longestCommonPrefix(String[]...
2014-06-28 23:04:00
73
转载 LeetCode:Longest Palindromic Substring
Longest Palindromic Substring Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
2014-06-28 21:20:00
181
转载 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 converti...
2014-06-22 14:14:00
110
转载 LeetCode:Container With Most Water
Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0). Find...
2014-06-22 12:56:00
107
转载 LeetCode:Reverse Integer
Reverse digits of an integer. Example1:x = 123, return 321Example2:x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions to ask before codi...
2014-06-21 09:31:00
62
转载 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 as a...
2014-06-19 23:06:00
60
转载 LeetCode: Palindrome Partitioning
Given a strings, partitionssuch that every substring of the partition is a palindrome. Return all possible palindrome partitioning ofs. For example, givens="aab",Return [ ...
2014-04-06 15:13:00
126
转载 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"isnota p...
2014-04-04 11:05:00
62
转载 LeetCode: Path Sum 2
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree andsum = 22, 5 ...
2014-03-31 21:29:00
185
转载 LeetCode: Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example:Given the below binary tree ands...
2014-03-24 22:41:00
77
转载 LeetCode:Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. Solution: BinaryTree* sortedArrayToBST(int arr[], int start, int end) { if (start > end...
2014-03-23 17:35:00
115
转载 LeetCode:Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. Solution: /** * Definition for singly-linked list. * struct ListNode { * ...
2014-03-23 17:20:00
126
转载 LeetCode: Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never di...
2014-03-23 15:14:00
109
转载 LeetCode: Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 递归版本: class Solution { public...
2014-03-06 22:13:00
115
转载 LeetCode:Merge Sorted Array
Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements fr...
2014-03-06 21:08:00
143
转载 LeetCode:Single Number II
Given an array of integers, every element appearsthreetimes except for one. Find that single one. Note:Your algorithm should have a linear runtime complexity. Could you implement it without us...
2014-03-06 17:13:00
121
转载 LeetCode: Single Number
Given an array of integers, every element appearstwiceexcept for one. Find that single one. Note:Your algorithm should have a linear runtime complexity. Could you implement it without using ex...
2014-03-06 15:35:00
106
转载 LeetCode:3Sum
Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a tripl...
2014-03-05 22:06:00
102
转载 LeetCode:Binary Tree Preorder Traversal
Given a binary tree, return thepreordertraversal of its nodes' values. For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3 return[1,2,3]. Note:Recursive solutio...
2014-03-05 21:18:00
131
转载 LeetCode: Best Time to Buy and Sell Stock III
Say you have an array for which theithelement is the price of a given stock on dayi. Design an algorithm to find the maximum profit. You may complete at mosttwotransactions. Note:You may n...
2014-03-03 16:31:00
108
转载 LeetCode: Best Time to Buy and Sell Stock II
Say you have an array for which theithelement is the price of a given stock on dayi. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy...
2014-03-03 14:43:00
140
转载 Best Time to Buy and Sell Stock
Say you have an array for which theithelement is the price of a given stock on dayi. If you were only permitted to complete at most one transaction (ie, buy one and sell one share o...
2014-03-03 12:30:00
105
转载 LeetCode: Pow(x, n)
Pow(x, n) Implement pow(x,n). 1 public class Solution { 2 private double power(double x, int n) { 3 if (n == 0) 4 return 1; 5 double v = power(x, ...
2014-03-02 20:42:00
161
转载 LeetCode: Word Break
Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more dictionary words. For example, givens="leetcode",dict=["leet",...
2014-03-01 16:06:00
124
转载 LeetCode: LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset. get(key)- Get the value (will always be positive) of the key ...
2014-03-01 11:38:00
151
转载 LeetCode: Max Points on a Line
Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line. Solution: /** * Definition for a point. * struct Point { * int x; * ...
2014-02-22 14:56:00
133
转载 LeetCode: Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression inReverse Polish Notation. Valid operators are+,-,*,/. Each operand may be an integer or another expression. Some examples: ["2"...
2014-01-05 16:51:00
133
转载 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 target, ...
2013-12-22 20:58:00
107
转载 LeetCode: Binary Tree Postorder Traversal
Given a binary tree, return thepostordertraversal of its nodes' values. For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3 return[3,2,1]. Note:Recursive soluti...
2013-12-22 16:37:00
119
转载 LeetCode:Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example:Given the below binary tree, 1 / \ 2 3 Return6. ...
2013-12-22 09:49:00
131
转载 iOS开发 入门学习总结(二)Objective-C 语法特性总结
Objective-CEncapsulating Data 01. atomic // default02. nonatomic 03. strong=retain // default04. weak= unsafe_unretained 05. retain 06. assign ...
2013-12-21 19:28:00
137
转载 LeetCode: Minimum Depth of Binary Tree
Problem:Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf n...
2013-12-21 17:27:00
126
转载 iOS开发 入门学习总结(-)
这个礼拜应该算是踏上iOS学习的第一个礼拜,有必要对这段学习过程做一个简短的总结。 直观感觉:iOS 开发环境给我的直观印象非常cool,XCode许多酷炫的功能,iOS 7 SDK的优良的设计,其极其丰富的api,以及Objective-C 奇特的语法让我觉得非常新鲜有趣。 主要按照apple 官方的开发入门指导,完成一个 To-do—List app 通过实现这个小proj...
2013-12-12 20:58:00
204
转载 Java 并发编程基础学习
1.Java 并发编程的容器 ConcurrentHashMap,HashTable,Collections.synchronizedMap 三者比较。 HashTable,Collections.synchronizedMap 提供对hashmap的独占锁,当有一个线程对其remove,add,遍历,等操作时,即使cpu有空闲的资源,也不能访问该容器。可伸缩性比较差。 而C...
2013-11-30 23:19:00
73
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅