摘要:
今天在学习浙大的数据结构课程,陈越老师让我们写代码来比较迭代和递归的性能差别,遂使用了ctime or time.h中的clock函数来计算程序运行耗时。 方法 #include<ctime> int main(){ clock_t start, finish; // 用来保存当前时钟的变量类型 s 阅读全文
摘要:
BF算法(暴力法) 不多解释,直接上代码: // BF算法 O(mn) int bf(SString s, SString t, int pos){ int i = pos, j = 0; while (i < s.length && j < t.length){ if (s.ch[i] == t. 阅读全文
摘要:
题目 题解 解题思路是先将输入的矩阵转置,然后按中心列(第$n/2$列)对称反转。 class Solution { public: void rotate(vector<vector<int>>& matrix) { int n = matrix.size(); for (int i = 0; i 阅读全文