ARTS-week6

Algorithm

Given an ordered array is sorted in ascending order according to find the two numbers such that their sum is equal to the sum of the target number. Function should return the two index values ​​index2 and index1, index2 wherein index1 must be less than

Two Sum II - Input array is sorted

# 解1,时间复杂度O(n),空间复杂度O(1)
class Solution1:    
    def twoSum(self, numbers: List[int], target: int) -> List[int]:        
        l,r = 0,len(numbers)-1        
        while l < r:            
            if numbers[l] + numbers[r] == target:                
                return [l + 1, r + 1]            
            elif numbers[l] + numbers[r] < target:                
                l += 1            
            else:                
                r -= 1        
        return []
        
 # 解2,时间复杂度O(nlogn),空间复杂度O(1)
 class Solution2:    
    def twoSum(self, numbers: List[int], target: int) -> List[int]:        
        for n in range(len(numbers)):            
            l,r = n + 1,len(numbers) - 1            
            tmp = target - numbers[n]            
            while l <= r :                
                mid = l + (r - l) // 2                
                if numbers[mid] == tmp:                    
                    return [n + 1,mid + 1]                
                elif numbers[mid] < tmp:                    
                    l = mid + 1                
                else:                    
                    r = mid - 1        
        return []

Review

Chaining Requests in Postman — Part 1

  • postman create a collection, add request
  • Add environment variables and used in the Headers
  • Pre-requrest scripts using the access_token added (and other parameters)
  • A front and rear transmission request using a reference request return result
  • Set assertions, the test returns results

Tip

When appium start error, An unknow server-side error occurred while processing the command ...
into UiAutomator1 start properly, suspected UiAutomator2 problem. Reinstall appium problem has been solved (unable to locate the exact cause)

Share

Do not let your own "wall" himself

Guess you like

Origin www.cnblogs.com/felixqiang/p/12007046.html