生成器模式(Builder)
阿新 • • 發佈:2020-12-26
標題1
標題2
標題3
插入一條引用測試
數學公式測試:
行內公式:\(O(n)\)
行間公式:
python程式碼塊
# # @param arr int整型一維陣列 the array # @return int整型 # class Solution: def maxLength(self , arr ): # write code here log = {} n, ans = len(arr), float('-inf') left, right = 0, 0 while right <= n-1: if not arr[right] in log: log[arr[right]] = right right += 1 else: ans = max(ans, right - left) for i in range(left, log[arr[right]]): log.pop(arr[i]) left = log[arr[right]]+1 log[arr[right]] = right right += 1 ans = max(ans, right - left) return ans
java程式碼塊
import java.util.*; import java.util.*; public class Solution { /** * * @param arr int整型一維陣列 the array * @return int整型 */ public int maxLength (int[] arr) { // write code here int[] lastPos = new int[100005]; int len = arr.length; int start = 0; int res = 0; for(int i =0;i<len;i++){ int now = arr[i]; start = Math.max(start,lastPos[now]); res = Math.max(res,i-start+1); lastPos[now] = i+1; } return res; } }
測試結果
editor數學公式用的Katex,顯示效果不好,而且有時候頁面的數學公式無法自動渲染,需要再次重新整理頁面。解決辦法:關閉編輯器的數學公式,這會導致在寫文章時無法預覽,用主題帶的MathjaxV3顯示效果很好
務必開啟編輯器的相容模式,如果在站點按F12看consle沒有任何報錯,說明正常
關閉編輯器程式碼高亮自動載入,不然可能會和主題高亮引擎衝突