- 博客(95)
- 收藏
- 关注
Very belief introduction
一、智能(Intelligence)定义:通过某些标准,采取正确的决策。(例如:对于大多数动物来说,生存和繁衍)采取决策需要知识,通过interpret sensory data and use that information to take decisions。 二、人工智能目前,计算机通过人们写的一些程序已经拥有了一些智能。但是有很多的任务,动物或者是人类非常容易能够做到,但
2015-04-27 09:08:18
160
原创 Find Minimum 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).Find the minimum element.You may assume no duplicate exists in the arra
2014-12-24 16:51:32
265
原创 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.题目解析:将整个过程看作是去链表的中值#include using namespace std;struct ListNode { i
2014-12-24 15:42:04
225
原创 Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element alw
2014-12-24 15:04:05
193
原创 Rotate Image
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?#include #include using namespace std;/*********
2014-12-24 15:02:04
215
原创 Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is
2014-12-16 09:41:58
204
原创 Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.基本的思路:递归解决。。。#include #include using names
2014-12-15 21:22:13
143
原创 Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.题目的基本思想:递归解决。#include #include using namesp
2014-12-15 20:56:16
133
原创 Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","b"],
2014-12-15 19:54:49
151
原创 Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node's key.The
2014-12-14 22:19:53
154
原创 Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The signature of the function had been updated to
2014-12-14 20:55:58
148
原创 Find Peak Element
A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in that
2014-12-12 22:16:40
169
原创 Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7},
2014-12-03 19:30:25
218
原创 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 ofevery node never differ
2014-12-03 19:06:45
284
原创 Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1", "+",
2014-12-03 18:07:07
163
原创 Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?思路:假设rowInde
2014-12-01 12:36:45
148
原创 Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following
2014-12-01 09:52:13
236
原创 Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,
2014-11-26 15:27:43
747
原创 Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convertword1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:
2014-11-24 14:59:07
162
原创 Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x.
2014-11-17 10:19:53
209
转载 理解矩阵-孟岩
理解矩阵一:转载自:http://blog.youkuaiyun.com/myan/article/details/647511前不久chensh出于不可告人的目的,要充当老师,教别人线性代数。于是我被揪住就线性代数中一些务虚性的问题与他讨论了几次。很明显,chensh觉得,要让自己在讲线性代数的时候不被那位强势的学生认为是神经病,还是比较难的事情。可怜的chensh,谁让你趟这个地雷阵?!色令智
2014-11-12 21:14:29
732
原创 Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order does
2014-11-07 21:25:00
259
原创 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.
2014-11-05 14:27:12
156
原创 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 pa
2014-11-04 15:39:32
152
原创 Pascal's Triangle
Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]
2014-11-04 09:05:46
210
原创 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.
2014-11-03 16:32:45
173
原创 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:"((()))", "(()())", "(())()", "()(())", "()()()"
2014-11-03 14:38:17
211
原创 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 exactly
2014-11-03 10:12:37
144
原创 Best Time to Buy and Sell Stock
Say you have an array for which the ith element 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 of the stock),
2014-10-31 18:14:23
163
原创 Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.#include #include #include using namespace std;string longestCommonPrefix(vector &strs) { str
2014-10-31 10:43:42
152
原创 Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to {1,4
2014-10-31 10:04:46
173
原创 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 valid b
2014-09-23 21:56:24
213
原创 Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.#include #include using namespace std;struct TreeNode { int val; TreeNode *l
2014-09-23 17:12:42
149
原创 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 from B
2014-09-23 16:23:50
205
原创 Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 ton2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [
2014-09-23 15:48:42
158
原创 Path Sum II
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 and sum = 22, 5 / \
2014-09-23 08:03:32
206
原创 Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations inC where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numbe
2014-09-22 23:05:36
219
原创 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 node.1、本来是想李彤#include #include us
2014-09-22 18:05:11
151
原创 Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".
2014-09-22 17:27:53
224
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人