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;
        }
    };
    
  • 相关阅读:
    关于截取字符串substr和substring两者的区别
    cancelbubble和stoppraopagation区别
    字符串转json以及获取域名的参数
    JSON.parse()和JSON.stringify()
    jq获取今天、昨天、一周时间
    浏览器是如何渲染网页的
    React入门一
    Json 查看Json的插件
    wireshark
    iOS开发 Android开发 移动Web开发
  • 原文地址:https://www.cnblogs.com/wlw-x/p/12344995.html
Copyright © 2011-2022 走看看