1. 程式人生 > 資料庫 >Mysql8.0不支援grant all privileges on *.* to root@“%“ identified by “.“;

Mysql8.0不支援grant all privileges on *.* to root@“%“ identified by “.“;

import java.util.ArrayList;
public class Solution {
    public ArrayList<Integer> maxInWindows(int [] num, int size)
    {    
        //結果集
        ArrayList<Integer> res = new ArrayList<>();
        
        if(num.length < size || size <= 0) return res;
        
        int left = 0;
        
int right = size - 1; while(right < num.length){ //先將視窗最左邊的元素 給到max int max = num[left]; //遍歷視窗的每一個元素,找到最大值 for(int i = left;i <= right; i++){ if(max < num[i]){ max = num[i]; } }
//將當前視窗的最大值加入結果集 res.add(max); //整體往前滑 left++; right++; } return res; } }

這樣的話每次都要在視窗中找最大值,時間複雜度較高,劍指大神 Krahets 給出了O(1)時間的效率,截圖如下

https://leetcode-cn.com/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/solution/mian-shi-ti-59-i-hua-dong-chuang-kou-de-zui-da-1-6/