發表文章

[2019] Live in Seoul

圖片
Stay in Seoul for a week, here is the postcard I like to add into my blog.

[Java] Leetcode : 1 Two Sum, 167. Two Sum II - Input array is sorted 15. 3Sum

圖片
Time O(n) O(n^2)

TDD and BDD?

reference from: https://www.zhihu.com/question/20161970  软件开发过程中最常见的两个问题 需求和开发脱节: 用户想要的功能没有开发 开发的功能并非用户想要 用户和开发人员所说语言不同 开发和测试脱节: 开发和测试被认为割裂 从开发到测试周期过长 测试自动化程度低 3. 如何解决上面说的两个问题 使用BDD可以解决需求和开发脱节的问题,首先他们都是从用户的需求出发,保证程序实现效果与用户需求一致。

What Will Be the Toughest Obstacles for Test Teams in 2019?

reference: https://abstracta.us/blog/software-testing/expert-roundup-software-testing-trends-2019/ What Tools or Methodologies Are You Excited to Und erstand Better This Year? Janet Gregory: “I’m not sure there is a new methodology around, but I’d like to  explore a bit more about quality and what it means to different teams . For example, there is a difference between product quality and quality of your process and many teams get confused in what they measure. Also, there are different points of view in how we perceive quality of our products. I’d like to find better words to help teams define what they mean.” Jeff Martin:  “The most exciting new solutions for me are not technical, but process based. Adopting  Behavior Driven Development  (BDD) has proven extremely helpful in focusing both development and testing resources on working together in a common language. This greatly cuts communication overhead and helps deliver on the promises of Agil...

[ LeetCode ] 179. Largest Number

Given a list of non negative integers, arrange them such that they form the largest number. Example 1: Input: [10,2] Output: " 210" Example 2: Input: [3,30,34,5,9] Output: " 9534330" Note: The result may be very large, so you need to return a string instead of an integer. https://leetcode.com/problems/largest-number/description/ 這題其實是排序問題,A+B > B+A 是關鍵。用快速排序可以很漂亮的實現演算法。 class Solution: "" " @param num s: A list of non negative integers @return: A string "" " def largestNumber(self, num): num = [str( x ) for x in num] #num. sort (cmp=lambda x , y : cmp( y + x , x + y )) num = self.quickSort(num) largest = '' . join (num) return largest.lstrip( '0' ) or '0' def quickSort(self, num): if len (num) < 2 : return num pivot = num. pop () left = [] right = [] ...

[ LeetCode ] 337. House Robber III

# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution ( object ) : def rob ( self , root ) : """ :type root: TreeNode :rtype: int """ res = [ 0 ] d = {} def dfs ( node ) : if not node : return 0 if node in d : return d[ node ] col_1 = dfs( node .left) + dfs( node .right) col_2 = node .val if node .left : col_2 += dfs( node .left.left) + dfs( node .left.right) if node .right : col_2 += dfs( node .right.left) + dfs( node .right.right) d[ node ] = max (col_1 , col_2) return max (col_1 , col_2) return dfs( root )

String Summary

151 .  Reverse Words in a String     def reverseWords_02(self, s):         """         :type s: str         :rtype: str         """         def revS(start, end):             while start < end:                 s[start], s[end] = s[end], s[start]                 start, end = start + 1, end - 1         s = s.strip()         s = list(s)         space = 0         count = 0         for i in range(len(s)):             if s[i] == " " and space < 1:     ...