• 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;
        }
    };
    
  • 相关阅读:
    idea 快捷键
    vue.js
    破解idea
    如何进行反向迭代以及如何实现反向迭代?
    如何使用生成器函数实现可迭代对象?
    从一个实际小例子来看python中迭代器的应用
    MySql中常用的内置函数
    linux服务器重启oracle服务。
    oracle里面清除服务器上所有的oracle服务。
    刷机后的环境变量
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12333095.html
Copyright © 2020-2023  润新知