10 2013 档案

摘要:http://oj.leetcode.com/problems/linked-list-cycle/Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:这个问题是面试时很常见的问题,但是要求写代码的比较少。最简单的方法就是两个指针,一个每次走一步,一个每次走两步,等赶上了就说明有环。 1 class Solution { 2 public: 3 bool hasCycle(ListNode *head) { 4 ... 阅读全文
posted @ 2013-10-31 17:58 移山测试工作室黑灯老师 阅读(218) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/longest-valid-parentheses/Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", which has leng 阅读全文
posted @ 2013-10-31 17:34 移山测试工作室黑灯老师 阅读(383) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/next-permutation/Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).The replacement 阅读全文
posted @ 2013-10-30 21:34 移山测试工作室黑灯老师 阅读(538) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters.F 阅读全文
posted @ 2013-10-30 17:53 移山测试工作室黑灯老师 阅读(6553) 评论(2) 推荐(0)
摘要:http://oj.leetcode.com/problems/divide-two-integers/Divide two integers without using multiplication, division and mod operator.思路:典型的二分法。以87除4举例, (4 * 2 = 8) => (8 * 2 = 16) => (16 * 2 = 32) => (32 * 2) => 64,因为64 * 2 = 128大于87,现在我们可以确定4 * 16 = 64小于87,那么再处理87 - 64 = 23,23除4的话用上面方法可以得到5, 阅读全文
posted @ 2013-10-30 16:18 移山测试工作室黑灯老师 阅读(2336) 评论(1) 推荐(0)
摘要:http://oj.leetcode.com/problems/implement-strstr/Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.思路:太简单了,没什么好说的。 1 class Solution { 2 public: 3 char *strStr(char *haystack, char *needle) { 4 int len_haystack = strlen(haystack), l... 阅读全文
posted @ 2013-10-30 15:11 移山测试工作室黑灯老师 阅读(572) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/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.思路:和Remove Duplicates from Sorted Array类似,当已经删除n个元素后,需要保留的 阅读全文
posted @ 2013-10-30 14:14 移山测试工作室黑灯老师 阅读(551) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.For example,Given i 阅读全文
posted @ 2013-10-30 14:03 移山测试工作室黑灯老师 阅读(447) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/reverse-nodes-in-k-group/Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.You may not alter the values in the nodes, onl 阅读全文
posted @ 2013-10-30 13:39 移山测试工作室黑灯老师 阅读(432) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/swap-nodes-in-pairs/Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. You may not modify the values in the list 阅读全文
posted @ 2013-10-28 22:34 移山测试工作室黑灯老师 阅读(897) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/merge-k-sorted-lists/Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:不停的做两两合并就可以了。 1 class Solution { 2 public: 3 ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { 4 ListNode *head = NULL, *tail = NU... 阅读全文
posted @ 2013-10-28 21:40 移山测试工作室黑灯老师 阅读(900) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/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:"((()))", "(()())", "(())()", "()(())", "()()()"思路 阅读全文
posted @ 2013-10-28 18:17 移山测试工作室黑灯老师 阅读(1055) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/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 "()[]{}" 阅读全文
posted @ 2013-10-28 17:44 移山测试工作室黑灯老师 阅读(382) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3- 阅读全文
posted @ 2013-10-28 17:24 移山测试工作室黑灯老师 阅读(251) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string "23"Output: ["ad&quo 阅读全文
posted @ 2013-10-28 16:45 移山测试工作室黑灯老师 阅读(538) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/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 in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c 阅读全文
posted @ 2013-10-28 16:23 移山测试工作室黑灯老师 阅读(469) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/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 one solution. For example, given array S = {-1 2 1 ... 阅读全文
posted @ 2013-10-28 16:07 移山测试工作室黑灯老师 阅读(949) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/3sum/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 gives the sum of zero.Note:Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)The solution set must not 阅读全文
posted @ 2013-10-28 15:28 移山测试工作室黑灯老师 阅读(516) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/longest-common-prefix/Write a function to find the longest common prefix string amongst an array of strings.思路:没什么技巧,第一行第一个字符拿出来和其它所有行的第一个字符比,然后第二个,第三个。如果碰到不相等或某行结束就中断。 1 class Solution { 2 public: 3 string longestCommonPrefix(vector &strs) { 4 if (0 == st... 阅读全文
posted @ 2013-10-28 15:12 移山测试工作室黑灯老师 阅读(344) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/roman-to-integer/Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.思路:根据个十百千位分别作为一个状态机处理就可以了。 1 class Solution { 2 public: 3 int romanToInt(string s) { 4 int val = 0, mul = 0; 5 char one, five... 阅读全文
posted @ 2013-10-28 14:12 移山测试工作室黑灯老师 阅读(464) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/integer-to-roman/Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思路:先google一下罗马数字表示法。然后查表搞定。 1 static char* roman_table[4][9] = {{"I", "II", "III", "IV", "V", & 阅读全文
posted @ 2013-10-28 13:47 移山测试工作室黑灯老师 阅读(302) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/container-with-most-water/Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a 阅读全文
posted @ 2013-10-28 13:14 移山测试工作室黑灯老师 阅读(357) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/regular-expression-matching/Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input string (not par 阅读全文
posted @ 2013-10-28 12:20 移山测试工作室黑灯老师 阅读(1006) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/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 converting the integer to string, note the restriction of using extra s 阅读全文
posted @ 2013-10-26 06:41 移山测试工作室黑灯老师 阅读(396) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/string-to-integer-atoi/Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.Notes: It is intended for this problem to be 阅读全文
posted @ 2013-10-25 07:17 移山测试工作室黑灯老师 阅读(314) 评论(0) 推荐(0)
摘要:How the Google+ Team Tests Mobile Apps byEduardo Bravo Ortiz“移动第一”在当下已成为很多公司的口头禅。但是能够用一种合理的方法来测试移动应用却是非常有挑战的工作。今天Google+团队将和你一起分享iOS和Android平台上移动应用测试的成功经验和走过的弯路。平台无关部分深入理解你的平台。Andoird上的测试和iOS是不同的。无论是测试工具还是框架在这两个平台上都有巨大的差异。例如Andoird使用Java而iOS使用Objective-C,UI布局在不同平台上差别很大,而且UI自动化框架在不同平台上的工作方式也随着变化。稳定你的 阅读全文
posted @ 2013-10-23 03:51 移山测试工作室黑灯老师 阅读(1181) 评论(0) 推荐(0)
摘要:上个星期测试道的Monkey老师和我聊到测试用例参数过多的问题,其实这样的问题在我这里也同样经历过。比如我的测试用例必须面对不同的测试环境,每个环境有无数的参数,开发的最初阶段,因为参数少,所以就放在执行的命令行里,随着测试用例的不断增长,参数从4-5个增长到30多个,而且每个用例使用的参数也不完全相同,有使用ABCD的,有使用ADHJ的。另外有些参数想传一个数组进去,用命令行参数的方法就很难处理。经过考虑,果断的使用配置文件来解决问题。选择配置文件当时有两个方案,一个是直接写成Ruby代码,但是考虑到要和自动化测试框架共享配置文件,所以最后决定使用YAML格式。Ruby对YAML的支持非常好 阅读全文
posted @ 2013-10-17 11:26 移山测试工作室黑灯老师 阅读(1398) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/reverse-integer/Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before coding. Bonus points for you if you have already thought through this 阅读全文
posted @ 2013-10-17 10:40 移山测试工作室黑灯老师 阅读(549) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/zigzag-conversion/The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I I GY I RAnd then read line by line: "PAHNAPLSI 阅读全文
posted @ 2013-10-15 13:47 移山测试工作室黑灯老师 阅读(426) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/longest-palindromic-substring/Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.思路:这题有牛B的算法,大家可以自己Google。这里用一种比较简单的算法,虽然不够快但是也能过OJ。如果一个字符串已经是回文字 阅读全文
posted @ 2013-10-14 21:22 移山测试工作室黑灯老师 阅读(361) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/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 linked list.Input: (2 -> 4 -> 3) + (5 -> 6 -> 阅读全文
posted @ 2013-10-14 21:07 移山测试工作室黑灯老师 阅读(329) 评论(0) 推荐(0)
摘要:Why Are There So Many C++ Testing Frameworks? by Zhanyong Wan (Software Engineer)最近貌似有很多人正在开发他们自己的C++测试框架,如果还没能完工。Wiki上有一个此类框架的不完全列表。因为大多数面向对象编程语言只有1到2个主要的框架,对C++而言这就显得有趣了。例如,大多数Java开发者都使用JUnit或TestNG。难道C++程序员都是疯狂的DIY爱好者吗?当我们开发并将Google Test(Google的C++测试框架)开源后,人们开始好奇为什么我们要做这件事。简单的回答是我们没有能够找到一个已有的并且能够 阅读全文
posted @ 2013-10-11 18:21 移山测试工作室黑灯老师 阅读(2294) 评论(0) 推荐(0)
摘要:目前手里有个测试项目各个feature的测试用例都放在对应的子目录下,虽然有自动化测试框架的帮助执行起来很方便,但是偶尔也有需要在本地执行某个feature的全部测试用例集合。因为本人对shell脚本不熟悉,所以Ruby的问题还是用Ruby来解决。每个测试脚本的命名遵循如下规范:Testlink ID + 测试用例名字。比如100_invalid_signature.rb表示该测试用例在Testlink里的ID是100,用来测试无效签名。在脚本的实现中,测试用例的名字就对应为TC_100。例子代码如下:1 class TC_100 < Test::Unit::TestCase2 # .. 阅读全文
posted @ 2013-10-11 15:39 移山测试工作室黑灯老师 阅读(839) 评论(0) 推荐(0)
摘要:前几天看了Google Testing Blog上的一篇文章讲到C++因为没有反射机制,所以如何注册测试用例就成了一件需要各显神通的事情。从我的经验来看,无论是Google的GTest还是微软的LTM,都是通过宏来解决问题。但是对于Ruby之流的动态语言,这种事情太小菜一叠了。请看以下代码例子: 1 class Test 2 def test_001 3 puts 'test_001' 4 end 5 6 def test_002 7 puts 'test_002' 8 end 9 end10 11 t = Test.new12 test_method... 阅读全文
posted @ 2013-10-11 15:03 移山测试工作室黑灯老师 阅读(496) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/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. For & 阅读全文
posted @ 2013-10-11 15:01 移山测试工作室黑灯老师 阅读(290) 评论(0) 推荐(0)
摘要:http://oj.leetcode.com/problems/median-of-two-sorted-arrays/There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).思路:对一维数组的二分查找进行扩展(findKthNumber函数的实现)。先分别定位在A,B的中点。现在分两种情况:(mid = middle)A,B前 阅读全文
posted @ 2013-10-11 14:46 移山测试工作室黑灯老师 阅读(744) 评论(2) 推荐(0)
摘要:http://oj.leetcode.com/problems/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, where index1 must be less than index2. Please note that your return 阅读全文
posted @ 2013-10-11 14:31 移山测试工作室黑灯老师 阅读(764) 评论(0) 推荐(0)
摘要:Conversation with a Test Engineer by Alan FaulnerAlan Faulner谷歌的一名测试工程师,他工作在DoubleClick Bid Manager项目,该项目允许广告公司和广告客户对多个广告进行议价。你是一个测试工程师(Test Engineer - TE)还是测试软件工程师(Software Engineer in Test - SET)?你认为这两者有差别吗?就目前而言我是一个测试工程师,但是这两个角色是很相似的。作为一个测试工程师,你更关注产品的总体质量和发布速度,而作为一个测试软件工程师,你可能更关注测试框架,自动化以及为了可测试性的 阅读全文
posted @ 2013-10-11 14:04 移山测试工作室黑灯老师 阅读(933) 评论(0) 推荐(0)

count website visits
Buy Computers