摘要: Compare Version NumbersCompare two version numbersversion1andversion1.Ifversion1>version2return 1, ifversion1 22; return 1.Example2: version1=="11.22.... 阅读全文
posted @ 2015-01-26 23:19 H5开发技术 阅读(224) 评论(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开发技术 阅读(207) 评论(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开发技术 阅读(142) 评论(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开发技术 阅读(261) 评论(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开发技术 阅读(158) 评论(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开发技术 阅读(159) 评论(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开发技术 阅读(153) 评论(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开发技术 阅读(220) 评论(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开发技术 阅读(257) 评论(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开发技术 阅读(187) 评论(0) 推荐(0)
摘要: Invoke和InvokeRepeating方法,可以实现延迟调用,和周期调用第一个是执行一次,第二个是重复执行void Invoke(string methodName, float time);第一个参数是方法名(注意是字符串形式),并不是更方便的委托。第二个是延时多少秒。只执行一次。void ... 阅读全文
posted @ 2015-01-19 22:35 H5开发技术 阅读(1339) 评论(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开发技术 阅读(201) 评论(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开发技术 阅读(194) 评论(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开发技术 阅读(200) 评论(0) 推荐(0)
摘要: 在Unity3D中,有时候我们需要计算二维向量的夹角。二维向量夹角一般在0~180度之前,可以直接调用Vector2.Angle(Vector2 from, Vector2 to)来计算。但是在有些场景,我们需要-180~180度的夹角,此时可以用下面的脚本进行计算:1 float Vect... 阅读全文
posted @ 2015-01-18 18:40 H5开发技术 阅读(14097) 评论(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开发技术 阅读(231) 评论(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开发技术 阅读(153) 评论(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开发技术 阅读(171) 评论(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开发技术 阅读(218) 评论(0) 推荐(0)
摘要: 今天写一个demo,要用到鼠标键盘控制三维视角,因此写了个脚本用于控制。该脚本可以用于即时战略类游戏的视角,提供了缩进,拉伸,旋转。同时按住鼠标右键不放,移动鼠标可以实现第一人称视角的效果。 1 using UnityEngine; 2 using System.Collections; 3 4 ... 阅读全文
posted @ 2015-01-16 20:43 H5开发技术 阅读(15851) 评论(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开发技术 阅读(204) 评论(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开发技术 阅读(200) 评论(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开发技术 阅读(243) 评论(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开发技术 阅读(321) 评论(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开发技术 阅读(130) 评论(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开发技术 阅读(155) 评论(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开发技术 阅读(154) 评论(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开发技术 阅读(186) 评论(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开发技术 阅读(164) 评论(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开发技术 阅读(147) 评论(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开发技术 阅读(160) 评论(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开发技术 阅读(121) 评论(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开发技术 阅读(187) 评论(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开发技术 阅读(142) 评论(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开发技术 阅读(127) 评论(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开发技术 阅读(174) 评论(0) 推荐(0)
摘要: Insert IntervalGiven a set ofnon-overlappingintervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals... 阅读全文
posted @ 2015-01-09 16:30 H5开发技术 阅读(142) 评论(0) 推荐(0)
摘要: Spiral Matrix IIGiven an integern, generate a square matrix filled with elements from 1 ton2in spiral order.For example,Givenn=3,You should return the... 阅读全文
posted @ 2015-01-08 20:25 H5开发技术 阅读(122) 评论(0) 推荐(0)
摘要: Spiral MatrixGiven a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.For example,Given the following matrix:[... 阅读全文
posted @ 2015-01-07 23:29 H5开发技术 阅读(180) 评论(0) 推荐(0)
摘要: Merge IntervalsGiven a collection of intervals, merge all overlapping intervals.For example,Given[1,3],[2,6],[8,10],[15,18],return[1,6],[8,10],[15,18]... 阅读全文
posted @ 2015-01-07 21:56 H5开发技术 阅读(151) 评论(0) 推荐(0)