刷題:greedy

55. 跳躍游戲

// 這題的循環(huán)條件index和maxIndex兩個都變,比較少見
class Solution {
    public boolean canJump(int[] nums) {
        int N = nums.length;
        int maxIndex = nums[0];
        int index = 0;
        while (index <= maxIndex) {         // 注意小于等于
            maxIndex = Math.max(maxIndex, index + nums[index]);
            if (maxIndex >= N - 1) return true;
            index++;
        }
        return false;
    }  
}

45. 跳躍游戲II

// 每一步找到下一次最大覆蓋范圍,也是下一次遍歷的終點
class Solution {
    public int jump(int[] nums) {
        int step = 0;
        int farest = 0;
        int index = 0;
        while (farest < nums.length - 1) {
            int tmp = farest;
            for (;index <= tmp; index++) {
                farest = Math.max(farest, index + nums[index]);
            }
            step++;
        }
        return step;
    }
}

781. 森林中的兔子

class Solution {
    public int numRabbits(int[] answers) {
        if (answers.length == 0) return 0;
        Map<Integer, Integer> counts = new HashMap<>();
        for (int ans : answers) {
            counts.put(ans, counts.getOrDefault(ans, 0) + 1);
        }
        int res = 0;
        for (Map.Entry<Integer, Integer> entry : counts.entrySet()) {
            int key = entry.getKey();
            int value = entry.getValue();
            res += (value + key) / (key + 1) * (key + 1);    // 向上取整
        }
        return res;
    }
}

11. 盛最多水的容器

// 頭尾雙指針删性,貪心策略移動指針
    class Solution {
        public int maxArea(int[] height) {
            int begin = 0;
            int end = height.length - 1;
            int ans = 0;
            while (begin < end) {
                int width = end - begin;
                if (height[begin] < height[end]) {
                    ans = Math.max(ans, width * height[begin]);
                    begin++;
                } else {
                    ans = Math.max(ans, width * height[end]);
                    end--;
                }
            }
            return ans;
        }
    }

179. 最大數(shù)

// 利用了字符串的字典排序
    class Solution {
        public String largestNumber(int[] nums) {
            String[] strings = new String[nums.length];
            for (int i = 0; i < nums.length; i++) {
                strings[i] = String.valueOf(nums[i]);
            }

            Comparator<String> cmp = (str1, str2) -> {
                String s1 = str1 + str2;
                String s2 = str2 + str1;
                return s2.compareTo(s1);
            };
            Arrays.sort(strings);

            if (strings[0].equals("0")) return "0";

            StringBuilder sb = new StringBuilder();
            for (String str : strings) {
                sb.append(str);
            }
            return sb.toString();
        }
    }

135. 分發(fā)糖果

// 一次遍歷,記錄上一次增長區(qū)間的長度秤掌,下一次減區(qū)間的長度大于這個長度時,需要多加1
class Solution {
    public int candy(int[] ratings) {
        int n = ratings.length;
        int ret = 1;
        int inc = 1, dec = 0, pre = 1;
        for (int i = 1; i < n; i++) {
            if (ratings[i] >= ratings[i - 1]) {
                dec = 0;
                pre = ratings[i] == ratings[i - 1] ? 1 : pre + 1;
                ret += pre;
                inc = pre;
            } else {
                dec++;
                if (dec == inc) {
                    dec++;
                }
                ret += dec;
                pre = 1;
            }
        }
        return ret;
    }
}
// 分別滿足左規(guī)則和有規(guī)則
    class Solution0 {
        public int candy(int[] ratings) {
            int N = ratings.length;
            int[] candies = new int[N];

            Arrays.fill(candies, 1);
            // 滿足左規(guī)則
            for (int i = 1; i < N; i++) {
                if (ratings[i] > ratings[i-1]) {
                    candies[i] = candies[i-1] + 1;
                }
            }

            int sum = 0;
            for (int i = N - 2; i >= 0; i--) {
                if (ratings[i] > ratings[i+1]) {
                    candies[i] = Math.max(candies[i], candies[i+1] + 1);
                }
                sum += candies[i];
            }

            return sum + candies[N-1];
        }
    }

678. 有效的括號字符串

// lo 和 hi表示取值的區(qū)間,維護(hù)好這兩個變量
class Solution {
    public boolean checkValidString(String s) {
        int lo = 0;
        int hi = 0;
        for (char c : s.toCharArray()) {
            lo += c == '(' ? 1 : -1;
            hi += c != ')' ? 1 : -1;
            if (hi < 0) return false;
            if (lo < 0) lo = 0;
        }
        return lo == 0;
    }
}

劍指Offer45. 把數(shù)組排成最小的數(shù)

// 字符串字典排序分蓖,類似與最大數(shù)
class Solution {
    public String minNumber(int[] nums) {
        int n = nums.length;
        String[] strings = new String[n];
        for (int i = 0; i < n; i++) {
            strings[i] = String.valueOf(nums[i]);
        }

        Comparator<String> cmp = (x, y) -> {
            String s1 = x + y;
            String s2 = y + x;
            return s1.compareTo(s2);
        };
        Arrays.sort(strings, cmp);
        
        StringBuilder sb = new StringBuilder();
        for (int index = 0; index < n; index++) {
            sb.append(strings[index]);
        }
        return sb.toString();
    }
}

134. 加油站

class Solution {
    public int canCompleteCircuit(int[] gas, int[] cost) {
        int res = 0;
        int total = 0;
        int curSum = 0;
        for (int i = 0; i < gas.length; i++) {
            int diff = gas[i] - cost[i];
            total += diff;
            curSum += diff;
            if (curSum < 0) {
                res = i + 1;
                curSum = 0;
            }
        }
        if (total < 0) return -1;
        return res;
    }
}

410. 分割數(shù)組的最大值

// 二分查找异吻,一次過
class Solution {
        public int splitArray(int[] nums, int m) {
            int left = 0;
            int right = 0;
            for (int num : nums) {
                right += num;
                if (left < num) {
                    left = num;
                }
            }

            while (left < right) {
                int mid = left + (right - left) / 2;
                int cnt = count(nums, mid);
                if (cnt <= m) { 
                    right = mid;
                } else {
                    left = mid + 1;
                }
            }
            return left;

        }

        public int count(int[] nums, int target) {
            int cnt = 1;
            int sum = 0;
            for (int num : nums) {
                if (sum + num > target) {
                    cnt++;
                    sum = num;
                } else {
                    sum += num;
                }
            }
            return cnt;
        }
    }

1011. 在D天內(nèi)送達(dá)包裹的能力

// 和410題一樣
class Solution {
        public int shipWithinDays(int[] weights, int days) {
            int left = 0;
            int right = 0;
            for (int num : weights) {
                right += num;
                if (left < num) {
                    left = num;
                }
            }

            while (left < right) {
                int mid = left + (right - left) / 2;
                int cnt = count(weights, mid);
                if (cnt <= days) {
                    right = mid;
                } else {
                    left = mid + 1;
                }
            }
            return left;

        }

        public int count(int[] nums, int target) {
            int cnt = 1;
            int sum = 0;
            for (int num : nums) {
                if (sum + num > target) {
                    cnt++;
                    sum = num;
                } else {
                    sum += num;
                }
            }
            return cnt;
        }
    }

122. 買賣股票的最佳時機(jī)II

// 利潤等于每次加上上升時候的差值
class Solution {
        public int maxProfit(int[] prices) {
            int sum = 0;
            for (int i = 0; i < prices.length - 1; i++) {
                sum += Math.max(prices[i+1] - prices[i], 0);
            }
            return sum;
        }
    }

402. 移掉K位數(shù)字

// 單調(diào)棧即可
    class Solution {
        public String removeKdigits(String num, int k) {
            Deque<Character> deque = new ArrayDeque<>();
            for (char c : num.toCharArray()) {
                while (!deque.isEmpty() && k > 0 && deque.peekLast() > c) {
                    deque.pollLast();
                    k--;
                }
                deque.offer(c);
            }
            while (!deque.isEmpty() && k > 0) {
                deque.pollLast();
                k--;
            }
            StringBuilder sb = new StringBuilder();
            boolean flag = true;
            while (!deque.isEmpty()) {
                if (deque.peekFirst() == '0' && flag) {
                    deque.poll();
                    continue;
                }
                flag = false;
                sb.append(deque.poll());
            }
            return sb.length() == 0 ? "0" : sb.toString();
        }
    }

763. 劃分字母區(qū)間

// 用數(shù)組記錄每個字符的最遠(yuǎn)位置裹赴,然后遍歷,記錄當(dāng)前遍歷過字符的最遠(yuǎn)字符下標(biāo)
class Solution {
    public List<Integer> partitionLabels(String s) {
        int n = s.length();
        int[] position = new int[26];
        for (int i = 0; i < n; i++) {
            int index = s.charAt(i) - 'a';
            position[index] = i;
        }

        int len = 0;
        int maxPosition = 0;
        List<Integer> res = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            len++;
            int index = s.charAt(i) - 'a';
            if (position[index] > maxPosition) maxPosition = position[index];
            if (i == maxPosition) {
                res.add(len);
                len = 0;
            }
        }
        return res;
    }
}

765. 情侶牽手

// 模擬交換即可诀浪,圖論可用來解釋
    class Solution {
        public int minSwapsCouples(int[] row) {
            int n = row.length;
            Map<Integer, Integer> map = new HashMap<>();
            for (int i = 0; i < n; i++) {
                map.put(row[i], i);
            }
            int res = 0;
            for (int i = 0; i < n; i += 2) {
                int cp = row[i] ^ 1;
                if (row[i + 1] != cp) {
                    res++;
                    int index = map.get(cp);
                    row[index] = row[i + 1];
                    map.put(row[index], index);
                }
            }
            return res;
        }
    }

409. 最長回文串

// 統(tǒng)計字符數(shù)量
class Solution {
    public int longestPalindrome(String s) {
        int[] counts = new int[128];
        for (char c : s.toCharArray()) {
            counts[c]++;
        }
        int sum = 0;
        for (int num : counts) {
            sum += num / 2 * 2;
        }
        if (sum < s.length()) sum++;
        return sum;
    }
}

44. 通配符匹配


316. 去除重復(fù)字母

// 單調(diào)棧 + flag數(shù)組
class Solution {
    public String removeDuplicateLetters(String s) {
        int[] counts = new int[26];
        boolean[] flag = new boolean[26];
        for (char c : s.toCharArray()) counts[c - 'a']++;
        Deque<Character> deque = new ArrayDeque<>();

        for (char c : s.toCharArray()) {
            int index = c - 'a';
            if (flag[index]) {
                counts[index]--;
                continue;
            }
            
            while (!deque.isEmpty() && deque.peekLast() > c) {
                if (counts[deque.peekLast() - 'a'] > 1) {
                    char out = deque.pollLast();
                    flag[out - 'a'] = false;
                    counts[out - 'a']--;
                } else {
                    break;
                }
            }
            flag[index] = true;
            deque.offer(c);      
        }
        StringBuilder sb = new StringBuilder();
        while (!deque.isEmpty()) {
            sb.append(deque.poll());
        }
        return sb.toString();
    }
}

680. 驗證回文字符串Ⅱ

class Solution {
    public boolean validPalindrome(String s) {
        int lo = -1;
        int hi = s.length() ;
        while (++lo < --hi) {
            if (s.charAt(lo) != s.charAt(hi)) return validPalindrome(s, lo - 1, hi) || validPalindrome(s, lo, hi + 1);
        }
        return true;
    }

    public boolean validPalindrome(String s, int left, int right) {
        while (++left < --right) {
            if (s.charAt(left) != s.charAt(right)) return false;
        }
        return true;
    }
}

670. 最大交換

// 找到右邊比左邊第一個要大的值棋返,交換即可
class Solution {
        public int maximumSwap(int num) {
            char[] digits = String.valueOf(num).toCharArray();
            int[] position = new int[10];
            for (int i = 0; i < digits.length; i++) {
                position[digits[i] - '0'] = i;
            }

            for (int i = 0; i < digits.length; i++) {
                int cur = digits[i] - '0';
                for (int k = 9; k > cur; k--) {
                    if (position[k] > i) {
                        char tmp = digits[i];
                        digits[i] = (char)('0' + k);   // 這里改成digits[position[k]]也行
                        digits[position[k]] = tmp;
                        return Integer.parseInt(new String(digits));
                    }
                }
            }
            return num;
        }
    }

435. 無重疊區(qū)間

// 左區(qū)間值排序
    class Solution {
        public int eraseOverlapIntervals(int[][] intervals) {
            Comparator<int[]> cmp = (x, y) -> {
                return x[0] - y[0];
            };
            Arrays.sort(intervals, cmp);
            int n = intervals.length;
            int res = 0;
            int left = intervals[n - 1][0];
            for (int i = n - 2; i >= 0; i--) {
                if (intervals[i][1] > left) {
                    res++;
                } else {
                    left = intervals[i][0];
                }
            }
            return res;
        }
    }

    // 右區(qū)間值排序
    class Solution0 {
        public int eraseOverlapIntervals(int[][] intervals) {
            Arrays.sort(intervals, (a, b) -> {
                if (a[1] == b[1]) return 0;
                else if (a[1] < b[1]) return -1;
                else return 1;
            });

            int right = intervals[0][1];
            int cnt = 0;
            for (int i = 1; i < intervals.length; i++) {
                if (intervals[i][0] < right) {
                    cnt++;
                } else {
                    right = intervals[i][1];
                }
            }
            return cnt;
        }
    }

406. 根據(jù)身高重建隊列

// 左順序,右降序雷猪,沒插入個空位就是比現(xiàn)在插入的要大的
    class Solution {
        public int[][] reconstructQueue(int[][] people) {
            Comparator<int[]> cmp = (x, y) -> {
                return x[0] != y[0] ? x[0] - y[0] : y[1] - x[1];
            };
            Arrays.sort(people, cmp);

            int[][] res = new int[people.length][];
            for (int[] arr : people) {
                int cnt = arr[1];
                for (int i = 0; i < people.length && cnt >= 0; i++) {
                    if (res[i] == null) {
                        cnt--;
                    }
                    if (cnt == -1) {
                        res[i] = arr;
                    }
                }
            }
            return res;
        }
    }

    // 右降序睛竣,左順新,插入法
    class Solution0 {
        public int[][] reconstructQueue(int[][] people) {
            Arrays.sort(people, (o1, o2) -> o1[0] == o2[0] ? o1[1] - o2[1] : o2[0] - o1[0]);

            ArrayList<int[]> link = new ArrayList<>();
            for (int[] arr : people) {
                if (arr[1] < link.size()) {
                    link.add(arr[1], arr);
                } else {
                    link.add(arr);
                }
            }
            return link.toArray(new int[people.length][]);
        }
    }

621. 任務(wù)調(diào)度器

// 桶思想 + 貪心
class Solution {
    public int leastInterval(char[] tasks, int n) {
        int[] counts = new int[26];
        for (char c : tasks) {
            counts[c - 'A']++;
        }

        Arrays.sort(counts);
        int buckets = counts[25];
        int maxCount = 1;
        for (int i = 25; i >= 1; i--) {
            if (counts[i] == counts[i - 1]) {
                maxCount++;
            } else {
                break;
            }
        }
        return Math.max(tasks.length, (buckets - 1) * (n + 1) + maxCount);
    }
}

611. 有效三角形的個數(shù)

    // 選排序后面用雙指針求摇,貪心策略為記錄之前以一次指針的位置
    class Solution {
        public int triangleNumber(int[] nums) {
            int n = nums.length;
            Arrays.sort(nums);
            int res = 0;
            for (int i = 0; i < n - 2; i++) {
                int start = i + 2;
                for (int j = i + 1; j < n - 1 && nums[i] != 0; j++) {
                    while (start < n) {
                        if (nums[start] >= nums[i] + nums[j]) break;
                        start++;
                    }
                    res += start - j - 1;
                }
            }
            return res;
        }
    }

    // 先排序然后用二分法
    class Solution0 {
        public int triangleNumber(int[] nums) {
            int n = nums.length;
            Arrays.sort(nums);
            int res = 0;
            for (int i = 0; i < n - 2; i++) {
                for (int j = i + 1; j < n - 1; j++) {
                    int index = binarySearch(nums, j + 1, n, nums[i] + nums[j]);
                    res += index - j - 1;
                }
            }
        return res;
        }

        // 找小于x的最大值
        public int binarySearch(int[] nums, int left, int right, int x) {
            while (left < right) {
                int middle = left + (right - left) / 2;
                if (x <= nums[middle]) right = middle;
                else left = middle + 1;
            }
            return left;
        }
    }

    // 暴力能過90%用例左右
    class Solution1 {
        public int triangleNumber(int[] nums) {
            int n = nums.length;
            int res = 0;
            for (int i = 0; i < n - 2; i++) {
                int a = nums[i];
                for (int j = i + 1; j < n - 1;j++) {
                    int b = nums[j];
                    for (int k = j + 1; k < n;k++ ) {
                        int c = nums[k];
                        if (a + b > c && Math.abs(a - b) < c) {
                            res++;
                        }
                    }
                }
            }
            return res;
        }
    }

1353. 最多可以參加的會議數(shù)目射沟,優(yōu)先隊列


1388. 3n塊披薩,優(yōu)先隊列


605. 種花問題

    // 貪心与境,模擬验夯,注意邊界時的處理即可
    class Solution {
        public boolean canPlaceFlowers(int[] flowerbed, int n) {
            int cnt = 0;
            for (int i = 0; i < flowerbed.length && cnt < n; i++) {
                if (flowerbed[i] == 1) continue;
                int pre = i == 0 ? 0 : flowerbed[i-1];
                int next = i == flowerbed.length - 1 ? 0 : flowerbed[i+1];
                if (pre == 0 && next == 0) {
                    cnt++;
                    flowerbed[i] = 1;
                }
            }

            return cnt >= n;
        }
    }

253. 會議室II,優(yōu)先隊列


1262. 可被三整除的最大和

    // remainder[i] 表示除三余數(shù)為i的當(dāng)前最大和
    class Solution {
        public int maxSumDivThree(int[] nums) {
            int[] remainder = new int[3];
            for (int num : nums) {
                int a = remainder[0] + num;
                int b = remainder[1] + num;
                int c = remainder[2] + num;
                remainder[a % 3] = Math.max(remainder[a % 3], a);
                remainder[b % 3] = Math.max(remainder[b % 3], b);
                remainder[c % 3] = Math.max(remainder[c % 3], c);
            }
            return remainder[0];
        }
    }

455. 分發(fā)餅干

class Solution {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int res = 0;

        for (int i = 0, j = 0; i < g.length && j < s.length; j++) {   // 這個是遍歷餅干摔刁,不是胃口
            if (s[j] >= g[i]) {
                i++;
                res++;
            }
        }
        return res;
    }
}

767. 重構(gòu)字符串

    // 貪心挥转,先排數(shù)量最多的字符,排在偶數(shù)下標(biāo)共屈,然后在排其他绑谣,注意排字符時的細(xì)節(jié)處理
    class Solution {
        public String reorganizeString(String s) {
            int n = s.length();
            int[] counts = new int[26];
            int maxCnt = 0;
            int maxCntIndex = 0;
            for (char c : s.toCharArray()) {
                counts[c - 'a']++;
                if(counts[c - 'a'] > maxCnt) {
                    maxCnt = counts[c - 'a'];
                    maxCntIndex = c - 'a';
                }
                if (maxCnt > (n + 1) / 2) return "";
            }

            int index = 0;
            char[] res = new char[n];
            for (int i = 0; i < maxCnt; i++) {
                res[index] = (char)(maxCntIndex + 'a');
                index += 2;
            }
            for (int i = 0; i < 26; i++) {
                while (counts[i]-- > 0 && i != maxCntIndex) {
                    if (index >= n) {
                        index = 1;
                    }
                    res[index] = (char)(i + 'a');
                    index += 2;
                }
            }
            return new String(res);
        }
    }

860. 檸檬水找零

 class Solution {
    public boolean lemonadeChange(int[] bills) {
        int five = 0;
        int ten = 0;
        for (int bill : bills) {
            if (bill == 5) {
                five++;
            } else if (bill == 10) {
                ten++;
                if (five > 0) five--;
                else return false;
            } else {
                if (ten > 0 && five > 0) {
                    ten--;
                    five--;
                } else if (five >= 3) {
                    five -= 3;
                } else {
                    return false;
                }
            }
        }
        return true;
    }
}

376. 擺動序列

class Solution {
    public int wiggleMaxLength(int[] nums) {
        int pre = 0;
        int res = 1;
        int n = nums.length;
        for (int i = 1; i < n; i++) {
            int cur = nums[i] - nums[i-1];
            if ((pre >= 0 && cur < 0) || (pre <= 0 && cur > 0)) {
                res++;
                pre = cur;   // 注意這里放里面,防止單調(diào)不增或者單調(diào)不減的情況
            }
        }
        return res;
    }
}

452. 用最少數(shù)量的箭引爆氣球

// 對右端進(jìn)行排序
class Solution {
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points, (x, y) -> {
            return x[1] > y[1] ? 1 : -1;    // 排序不能用x[1] - y[1], 否則可能整數(shù)溢出
        });
        int right = points[0][1];
        int res = 1;
        for (int[] point : points) {
            if (point[0] > right) {
                res++;
                right = point[1];
            }
        }
        return res;
    }
}

330. 按要求補(bǔ)齊數(shù)組拗引,困難遺留


714. 買賣股票的最佳時機(jī)含手續(xù)費

    // 維護(hù)好buyPrice
    class Solution {
        public int maxProfit(int[] prices, int fee) {
            int buyPrice = prices[0] + fee;
            int profit = 0;
            for (int price : prices) {
                if (buyPrice > price + fee) {
                    buyPrice = price + fee;
                } else if (buyPrice < price) {
                    profit += price - buyPrice;
                    buyPrice = price;
                }
            }
            return profit;
        }
    }

581. 最短無序連續(xù)子數(shù)組

// 一次遍歷
class Solution {
    public int findUnsortedSubarray(int[] nums) {
        int first = -1;
        int last = -1;
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] < max) {
                last = i;
            } else {
                max = nums[i];
            }

            int tmp = nums[nums.length - i - 1];
            if (tmp > min) {
                first = nums.length - i - 1;
            } else {
                min = tmp;
            }
        }
        return first == last ? 0 : last - first + 1;
    }
}

976. 三角形的最大周長

    class Solution {
        public int largestPerimeter(int[] nums) {
            Arrays.sort(nums);
            for (int i = nums.length - 1; i >= 2; i--) {
                if (nums[i - 1] + nums[i - 2] > nums[i]) {
                    return nums[i] + nums[i - 1] + nums[i - 2];
                }
            }
            return 0;
        }
    }

871. 最低加油次數(shù)借宵,困難遺留


面試題10.11. 峰與谷

// 確定峰谷峰順序,貪心交換即可
class Solution {
    public void wiggleSort(int[] nums) {
        for (int i = 1; i < nums.length; i++) {
            int pre = nums[i - 1];
            int cur = nums[i];
            if (i % 2 == 0) {
                if (cur < pre) {
                    nums[i] = pre;
                    nums[i - 1] = cur;
                }
            } else {
                if (cur > pre) {
                    nums[i] = pre;
                    nums[i - 1] = cur;
                }
            }
        }
    }
}

面試題16.16. 部分排序

// 同581題
class Solution {
    public int[] subSort(int[] array) {
        int first = -1;
        int last = -1;
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < array.length; i++) {
            if (array[i] < max) {
                last = i;
            } else {
                max = array[i];
            }

            int tmp = array[array.length - i - 1];
            if (tmp > min) {
                first = array.length - i - 1;
            } else {
                min = tmp;
            }
        }
        return new int[] {first, last};
    }
}

LCP15. 游樂園的迷宮,困難寺擂,遺留


1217. 玩籌碼

class Solution {
    public int minCostToMoveChips(int[] position) {
        int odd = 0;
        int even = 0;
        for (int pos : position) {
            if ((pos & 1) == 0) {
                odd++;
            } else {
                even++;
            }
        }
        return Math.min(odd, even);
    }
}

561. 數(shù)組拆分I

class Solution {
    public int arrayPairSum(int[] nums) {
        Arrays.sort(nums);
        int sum = 0;
        for (int i = 0; i < nums.length; i += 2) {
            sum += nums[i];
        }
        return sum;
    }
}

1505. 最多K次交換相鄰數(shù)位后得到的最小整數(shù)


LCP37. 最小矩形面積


502. IPO


945. 使數(shù)組唯一的最小增量


1363. 形成三的最大倍數(shù)


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末暇务,一起剝皮案震驚了整個濱河市泼掠,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌垦细,老刑警劉巖择镇,帶你破解...
    沈念sama閱讀 222,464評論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異括改,居然都是意外死亡腻豌,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,033評論 3 399
  • 文/潘曉璐 我一進(jìn)店門嘱能,熙熙樓的掌柜王于貴愁眉苦臉地迎上來吝梅,“玉大人,你說我怎么就攤上這事惹骂∷招” “怎么了?”我有些...
    開封第一講書人閱讀 169,078評論 0 362
  • 文/不壞的土叔 我叫張陵对粪,是天一觀的道長右冻。 經(jīng)常有香客問我,道長著拭,這世上最難降的妖魔是什么纱扭? 我笑而不...
    開封第一講書人閱讀 59,979評論 1 299
  • 正文 為了忘掉前任,我火速辦了婚禮儡遮,結(jié)果婚禮上乳蛾,老公的妹妹穿的比我還像新娘。我一直安慰自己鄙币,他們只是感情好肃叶,可當(dāng)我...
    茶點故事閱讀 69,001評論 6 398
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著爱榔,像睡著了一般被环。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上详幽,一...
    開封第一講書人閱讀 52,584評論 1 312
  • 那天,我揣著相機(jī)與錄音浸锨,去河邊找鬼唇聘。 笑死,一個胖子當(dāng)著我的面吹牛柱搜,可吹牛的內(nèi)容都是我干的迟郎。 我是一名探鬼主播,決...
    沈念sama閱讀 41,085評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼聪蘸,長吁一口氣:“原來是場噩夢啊……” “哼宪肖!你這毒婦竟也來了表制?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 40,023評論 0 277
  • 序言:老撾萬榮一對情侶失蹤控乾,失蹤者是張志新(化名)和其女友劉穎么介,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體蜕衡,經(jīng)...
    沈念sama閱讀 46,555評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡壤短,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,626評論 3 342
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了慨仿。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片久脯。...
    茶點故事閱讀 40,769評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖镰吆,靈堂內(nèi)的尸體忽然破棺而出帘撰,到底是詐尸還是另有隱情,我是刑警寧澤万皿,帶...
    沈念sama閱讀 36,439評論 5 351
  • 正文 年R本政府宣布摧找,位于F島的核電站,受9級特大地震影響相寇,放射性物質(zhì)發(fā)生泄漏慰于。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 42,115評論 3 335
  • 文/蒙蒙 一唤衫、第九天 我趴在偏房一處隱蔽的房頂上張望婆赠。 院中可真熱鬧,春花似錦佳励、人聲如沸休里。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,601評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽妙黍。三九已至,卻和暖如春瞧剖,著一層夾襖步出監(jiān)牢的瞬間拭嫁,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,702評論 1 274
  • 我被黑心中介騙來泰國打工抓于, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留做粤,地道東北人。 一個月前我還...
    沈念sama閱讀 49,191評論 3 378
  • 正文 我出身青樓捉撮,卻偏偏與公主長得像怕品,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子巾遭,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,781評論 2 361

推薦閱讀更多精彩內(nèi)容