11 2012 档案
摘要:转自 http://www.php-oa.com/2009/04/04/perl_getopt-long.html 写在前面,支持长参和短参,较为简单好用。 optionname 可以是字母,数字和 dash(-),不允许连续的dash,和dash结尾。更详细见:h...
阅读全文
摘要:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 ...
阅读全文
摘要:Divide two integers without using multiplication, division and mod operator.思路:先想到的是做减法,但是效率在两数差距大的时候复杂度很高, 之后想到移位的方式,把除数和余数提...
阅读全文
摘要:Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which i...
阅读全文
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an enc...
阅读全文
摘要: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...
阅读全文
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.由于链表不能随机访问,只能修改链表结构,要不就只能...
阅读全文
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.平分,递归。/** * Definition for binary tre...
阅读全文
摘要:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such th...
阅读全文
摘要:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree...
阅读全文
摘要:Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.N...
阅读全文
摘要:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers 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....
阅读全文
摘要:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ...
阅读全文
摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the...
阅读全文
摘要:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from lea...
阅读全文
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given...
阅读全文
摘要:Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / ...
阅读全文
摘要:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit....
阅读全文
摘要:题为:股票最佳买卖时机Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to co...
阅读全文
摘要: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 i...
阅读全文
摘要: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...
阅读全文
摘要:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.先查了一下单词,意思是单词重排, abc ...
阅读全文
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes c...
阅读全文
摘要:Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".思路: 对齐, 计算当前位和进位; ...
阅读全文
摘要: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...
阅读全文
摘要: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 g...
阅读全文
摘要:1.串匹配的朴素方式; 已知两个串,源 abcde 模式串 de ; 用3个指针, 开头匹配,然后分别 增加,直到全匹配为止;否则 移动 de。代码如下: int brutal_force(char *s,char*t){ int slen= strl...
阅读全文

浙公网安备 33010602011771号