Flutter高级进阶实战 仿哔哩哔哩APP

273 阅读1分钟

XZ:Flutter高级进阶实战 仿哔哩哔哩APP

近年来各大公司对Flutter技能的要求越来越高,甚至设立了专门岗位,但掌握Flutter高阶技能的人才寥寥无几,市面上干货Flutter高阶课程少之又少,导致Flutter高阶人才缺口大。为此我们专门为大家设计了这门课程,助力你早日成为企业抢手的新一代工程师。

技术要求
具备Dart、Flutter基础,
对跨平台技术有追求的开发者

环境参数
Flutter 2.x
函數操作
對條件字段做函數操作走不了索引。

select * from t1 where date© =‘2019-05-21’;
優化:改成範圍查询

select * from t1 where c>=‘2019-05-21 00:00:00’ and c<=‘2019-05-21 23:59:59’;
隱式轉換
操作符與不同類型的操作對象一同運用時,就會發作類型轉換以使操作兼容。

select user_name,tele_phone from user_info where tele_phone =11111111111; / tele_phone varchar /
實践會做函數操作:

select user_name,tele_phone from user_info where cast(tele_phone as singed int) =11111111111;
優化:類型統一

select user_name,tele_phone from user_info where tele_phone =‘11111111111’;
含糊查询
通配符在前面

select * from t1 where a like ‘%1111%’;
優化:含糊查询必需包含條件字段前面的值

select * from t1 where a like ‘1111%’;
範圍查询
範圍查询數據量太多,需求回表,因而不走索引。

select * from t1 where b>=1 and b <=2000;
優化:降低單次查询範圍,分屢次查询。(實践可能速度沒得快太多,倡議走索引)

select from t1 where b>=1 and b <=1000;
show profiles;
±---------±-----------±-----------------------------------------+
| Query_ID | Duration | Query |
±---------±-----------±-----------------------------------------+
| 1 | 0.00534775 | select from t1 where b>=1 and b <=1000 |
| 2 | 0.00605625 | select * from t1 where b>=1 and b <=2000 |
±---------±-----------±-----------------------------------------+
2 rows in set, 1 warning (0.00 sec)
計算操作
即便是简單的計算

explain select * from t1 where b-1 =1000;
優化:將計算操作放在等號後面

explain select * from t1 where b =1000 + 1;

翻了很多题解,只能看懂这种解法,够直观够暴力。

class Solution {
public:
vector restoreIpAddresses(string s) {
vector res;

    for (int a = 1; a < 4; a ++ )
        for (int b = 1; b < 4; b ++ )
            for (int c = 1; c < 4; c ++ )
                for (int d = 1; d < 4; d ++ )           //abcd分别表示四段ip地址长度
                {
                    if (a + b + c + d == s.size())      //四段长度刚好
                    {
                        string s1 = s.substr(0, a);     //分别截取四段ip地址
                        string s2 = s.substr(a, b);
                        string s3 = s.substr(a + b, c);
                        string s4 = s.substr(a + b + c);

                        if (check(s1) && check(s2) && check(s3) && check(s4))
                        {
                            string ip = s1 + '.' + s2 + '.' + s3 + '.' + s4;
                            res.push_back(ip);
                        }
                    }
                }

    return res;
}

bool check(string s)        //判断ip地址每段的第一位不为0,或只有一位且该位为0
{
    if (stoi(s) <= 255)
        if (s[0] != '0' || (s[0] == '0' && s.size() == 1)) return true;

    return false;
}

};
下一篇:【切割问题都可以用回溯搜索来解决】详解!
© 著作权归作者所有
1
条评论

最热

编辑
预览

评论

阿兹卡班在逃犯
L2
2021-03-13
贴一个java的

class Solution {
public List restoreIpAddresses(String s) {
List list = new ArrayList();
for(int a=1; a<4; a++){
for(int b=1; b<4; b++){
for(int c=1; c<4; c++){
for(int d=1; d<4; d++){
if(a+b+c+d==s.length()){
String s1 = s.substring(0, a);
String s2 = s.substring(a, a+b);
String s3 = s.substring(a+b, a+b+c);
String s4 = s.substring(a+b+c, a+b+c+d);

                        if(check(s1)&&check(s2)&&check(s3)&&check(s4)){
                            String ip = s1+"."+s2+"."+s3+"."+s4;
                            list.add(ip);
                        }
                    }
                }
            }
        }
    }
    return list;
}

public boolean check(String s){
    if(Integer.valueOf(s)<=255){
        if(s.charAt(0)!='0' || s.charAt(0)=='0'&&s.length()==1) 
            return true;
    }
    return false;
}

}