zoukankan      html  css  js  c++  java
  • 每日算法

    每日算法

    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.22


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

    367. 有效的完全平方数

    处理关键在于:解决 int * int 的溢出问题
    要有效限定边界 并且扩充数字表示范围

    class Solution {
    public:
        long long q(long x){return x * x;}
        bool isPerfectSquare(int num) {
            if(num == 0)return 0;
            int l = 0,r = 96340, ans = 0;
            while(l < r)
            {
                long mid = (l + r) >> 1;
                if(q(mid) >= (long long)num)r = mid ;
                else l = mid + 1;
            }
            return (1ll *l * l ==  (long long)(num));
        }
    };
    

    392. 判断子序列

    快慢指针

    class Solution {
    public:
        bool isSubsequence(string s, string t) {
            int j = 0;
            for(int i = 0;i < t.size(); i++)
            {
                if(t[i] == s[j])j++;
            }
            if(j >= s.size())return 1;
            else return 0;
        }
    };
    
  • 相关阅读:
    C#多线程学习(四) 多线程的自动管理(线程池)
    CHR6dm 校准软件下载
    WinAPI打开串口失败
    AHRS(航姿参考系统)和IMU(惯性测量单元)的区别【转】
    课程1:开始Direct3D
    CHR6dm datasheet 中文翻译
    从D3D将画面渲染至桌面
    Hello GPU
    linux配置java环境变量(详细)
    java中的多线程
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12344995.html
Copyright © 2011-2022 走看看