zoukankan      html  css  js  c++  java
  • leetcode-每日打卡-day 9

    leetcode 每日打卡

    those times when you get up early and you work hard; those times when you stay up late and you work hard; those times when don’t feel like working — you’re too tired, you don’t want to push yourself — but you do it anyway. That is actually the dream. That’s the dream. It’s not the destination, it’s the journey. And if you guys can understand that, what you’ll see happen is that you won’t accomplish your dreams, your dreams won’t come true, something greater will. mamba out


    那些你早出晚归付出的刻苦努力,你不想训练,当你觉的太累了但还是要咬牙坚持的时候,那就是在追逐梦想,不要在意终点有什么,要享受路途的过程,或许你不能成就梦想,但一定会有更伟大的事情随之而来。 mamba out~

    2020.2.19


    记录下来自己做题时得思路,并不一定是最优解

    1351. 统计有序矩阵中的负数

    class Solution {
    public:
        // 最小值中找最大 (又半区间) l = mid ,l + r + 1 >> 1
        int merge(vector<int> nums)
        {
            int l = 0,r = nums.size() - 1;
            while(l < r)
            {
                int mid = l + r + 1 >> 1;
                if(nums[mid] >= 0)l = mid;
                else r = mid - 1;
            }
            if(nums[l] >= 0){
                return nums.size() - l - 1;
            }else return nums.size() - l;
            return 0;
        }
        int countNegatives(vector<vector<int>>& grid) {
            int ans = 0;
            for(int i = 0;i < grid.size();i ++)
                ans += merge(grid[i]);
            return ans;
        }
    };
    

    面试题 08.03. 魔术索引

    class Solution {
    public:
        //只需要找到第一个 A[i] = i的元素的下标
        int findMagicIndex(vector<int>& nums) {
           for(int i = 0;i < nums.size();i ++){
               if(i == nums[i])return i;
           }
           return -1;
        }
    };
    
  • 相关阅读:
    使用Python从Workflowy同步大纲到印象笔记
    使用Jenkins自动部署博客
    使用有限状态机原理实现英文分词
    TeamFlowy——结合Teambition与Workflowy提高生产力
    技巧收集-M1709
    Tenacity——Exception Retry 从此无比简单
    记住 Python 变量类型的三种方式
    Python 装饰器装饰类中的方法
    技巧收集-W1701
    DotnetSpider爬虫简单示例 net core
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12333095.html
Copyright © 2011-2022 走看看