摘要: Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".Hide TagsMathString先补全字符串,从末尾开始加,每次计算... 阅读全文
posted @ 2015-01-26 23:23 H5开发技术 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Search a 2D MatrixWrite an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row... 阅读全文
posted @ 2015-01-26 23:22 H5开发技术 阅读(209) 评论(0) 推荐(0) 编辑
摘要: Find Peak ElementA peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and ... 阅读全文
posted @ 2015-01-26 23:21 H5开发技术 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Unique Binary Search TreesGivenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a to... 阅读全文
posted @ 2015-01-26 23:20 H5开发技术 阅读(163) 评论(0) 推荐(0) 编辑
摘要: Compare Version NumbersCompare two version numbersversion1andversion1.Ifversion1>version2return 1, ifversion1 22; return 1.Example2: version1=="11.22.... 阅读全文
posted @ 2015-01-26 23:19 H5开发技术 阅读(215) 评论(0) 推荐(0) 编辑
摘要: AnagramsGiven an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.Anagrams:即字母个数和字母都相同,但是字母顺序不相... 阅读全文
posted @ 2015-01-26 23:18 H5开发技术 阅读(201) 评论(0) 推荐(0) 编辑
摘要: ZigZag ConversionThe string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern i... 阅读全文
posted @ 2015-01-26 23:17 H5开发技术 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Maximum GapGiven an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/spac... 阅读全文
posted @ 2015-01-24 15:20 H5开发技术 阅读(252) 评论(0) 推荐(0) 编辑
摘要: Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run... 阅读全文
posted @ 2015-01-24 15:19 H5开发技术 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ... 阅读全文
posted @ 2015-01-24 15:17 H5开发技术 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Word Ladder IIGiven two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter ... 阅读全文
posted @ 2015-01-21 22:21 H5开发技术 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Surrounded RegionsGiven 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... 阅读全文
posted @ 2015-01-21 20:46 H5开发技术 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Valid NumberValidate if a given string is numeric.Some examples:"0"=>true" 0.1 "=>true"abc"=>false"1 a"=>false"2e10"=>trueNote:It is intended for the ... 阅读全文
posted @ 2015-01-20 21:42 H5开发技术 阅读(249) 评论(0) 推荐(0) 编辑
摘要: Maximal RectangleGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.使用dpHeight[]数组来记... 阅读全文
posted @ 2015-01-20 19:57 H5开发技术 阅读(184) 评论(0) 推荐(0) 编辑
摘要: Invoke和InvokeRepeating方法,可以实现延迟调用,和周期调用第一个是执行一次,第二个是重复执行void Invoke(string methodName, float time);第一个参数是方法名(注意是字符串形式),并不是更方便的委托。第二个是延时多少秒。只执行一次。void ... 阅读全文
posted @ 2015-01-19 22:35 H5开发技术 阅读(1301) 评论(0) 推荐(0) 编辑
摘要: Scramble StringGiven a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible... 阅读全文
posted @ 2015-01-19 22:25 H5开发技术 阅读(190) 评论(0) 推荐(0) 编辑
摘要: Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the tot... 阅读全文
posted @ 2015-01-19 22:23 H5开发技术 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Fraction to Recurring DecimalGiven two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the ... 阅读全文
posted @ 2015-01-18 20:16 H5开发技术 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 在Unity3D中,有时候我们需要计算二维向量的夹角。二维向量夹角一般在0~180度之前,可以直接调用Vector2.Angle(Vector2 from, Vector2 to)来计算。但是在有些场景,我们需要-180~180度的夹角,此时可以用下面的脚本进行计算:1 float Vect... 阅读全文
posted @ 2015-01-18 18:40 H5开发技术 阅读(13703) 评论(0) 推荐(0) 编辑
摘要: Partition ListGiven a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should pres... 阅读全文
posted @ 2015-01-18 18:34 H5开发技术 阅读(224) 评论(0) 推荐(0) 编辑
摘要: Binary Tree Zigzag Level Order TraversalGiven a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then... 阅读全文
posted @ 2015-01-18 16:58 H5开发技术 阅读(145) 评论(0) 推荐(0) 编辑
摘要: Word Break IIGiven a stringsand a dictionary of wordsdict, add spaces insto construct a sentence where each word is a valid dictionary word.Return all... 阅读全文
posted @ 2015-01-17 21:28 H5开发技术 阅读(166) 评论(0) 推荐(0) 编辑
摘要: Substring with Concatenation of All WordsYou are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices o... 阅读全文
posted @ 2015-01-16 22:59 H5开发技术 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 今天写一个demo,要用到鼠标键盘控制三维视角,因此写了个脚本用于控制。该脚本可以用于即时战略类游戏的视角,提供了缩进,拉伸,旋转。同时按住鼠标右键不放,移动鼠标可以实现第一人称视角的效果。 1 using UnityEngine; 2 using System.Collections; 3 4 ... 阅读全文
posted @ 2015-01-16 20:43 H5开发技术 阅读(15658) 评论(0) 推荐(0) 编辑
摘要: Recover Binary Search TreeTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A sol... 阅读全文
posted @ 2015-01-15 22:57 H5开发技术 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Dungeon GameThe demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms l... 阅读全文
posted @ 2015-01-15 22:06 H5开发技术 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Text JustificationGiven an array of words and a lengthL, format the text such that each line has exactlyLcharacters and is fully (left and right) just... 阅读全文
posted @ 2015-01-14 22:44 H5开发技术 阅读(239) 评论(0) 推荐(0) 编辑
摘要: Largest NumberGiven a list of non negative integers, arrange them such that they form the largest number.For example, given[3, 30, 34, 5, 9], the larg... 阅读全文
posted @ 2015-01-13 21:05 H5开发技术 阅读(309) 评论(0) 推荐(0) 编辑
摘要: Merge k Sorted ListsMergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.采用优先队列priority_queue把ListNode放入优先队... 阅读全文
posted @ 2015-01-12 23:03 H5开发技术 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Reverse Nodes in k-GroupGiven a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a... 阅读全文
posted @ 2015-01-12 21:32 H5开发技术 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Multiply StringsGiven two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large ... 阅读全文
posted @ 2015-01-11 20:33 H5开发技术 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Unique Binary Search Trees IIGivenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your pr... 阅读全文
posted @ 2015-01-11 14:28 H5开发技术 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.... 阅读全文
posted @ 2015-01-11 13:39 H5开发技术 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.每次把中间元素当成根节... 阅读全文
posted @ 2015-01-11 11:17 H5开发技术 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Wildcard MatchingImplement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters... 阅读全文
posted @ 2015-01-10 21:41 H5开发技术 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Permutations IIGiven a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the follow... 阅读全文
posted @ 2015-01-10 16:49 H5开发技术 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Next PermutationImplement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangemen... 阅读全文
posted @ 2015-01-09 21:31 H5开发技术 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Rotate ImageYou are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?假设旋转的时候... 阅读全文
posted @ 2015-01-09 20:20 H5开发技术 阅读(135) 评论(0) 推荐(0) 编辑
摘要: N-Queens IIFollow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions. 1 class Solutio... 阅读全文
posted @ 2015-01-09 18:37 H5开发技术 阅读(123) 评论(0) 推荐(0) 编辑
摘要: N-QueensThen-queens puzzle is the problem of placingnqueens on ann×nchessboard such that no two queens attack each other.Given an integern, return all... 阅读全文
posted @ 2015-01-09 18:30 H5开发技术 阅读(166) 评论(0) 推荐(0) 编辑