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;
        }
    };
    
  • 相关阅读:
    sql导数据 自增长
    只能在执行 Render() 的过程中调用 RegisterForEventValidation
    JS获取DropDownList的值
    解决IE6、IE7、IE8、Firefox兼容的两种方案
    C#日期格式化
    页面弹出窗口刷新父页面方式小结
    Dictionary Queue Stack SortedList ArrayList
    asp.net水晶报表推模式加载报表数据代码段
    JS隐藏工具栏菜单栏
    解决在SQL Server 2000的存储过程不能调试
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12333095.html
Copyright © 2011-2022 走看看