摘要:
lexicographical_compare - C++ Reference Returns true if the range [first1,last1) compares lexicographically less than the range [first2,last2). 阅读全文
摘要:
b站视频 : 【ACM】树状数组与ST表 int a[10005]; int c[10005]; int n; int lowbit(int x){ return x&(-x); } int getSum(int x){ int ans = 0; while(x > 0){ ans += c[x]; 阅读全文
摘要:
###463. 岛屿的周长 每有一个位置是1,则周长+4 如果上一个是1,则公用上边,周长-2;如果左一个是1,则公用左边,周长-2 class Solution { public: int islandPerimeter(vector<vector<int>>& grid) { int n = g 阅读全文
摘要:
###冒泡排序(bubble sort) 冒泡排序只会操作相邻的两个数据。每次冒泡操作都会对相邻的两个元素进行比较,看是否满足大小关系要求。如果不满足就让它俩互换。一次冒泡会让至少一个元素移动到它应该在的位置,重复 n 次,就完成了 n 个数据的排序工作。 冒泡排序还可以优化,比如本来要外循环6次, 阅读全文
摘要:
###正常求幂 PS:先不考虑异常输入, int溢出 int normalPow(int x, int n){ int res = 1; while(n){ res *= x; n --; } return res; } 问题: n值小的时候计算量可以接受,一旦大了,计算量非常大,于是要将这个O(n 阅读全文