8.23 cc 数组和字符串[pt2]

to do

  • cc150 array&string (6-11)/11
  • leetcode review day 1

1.6] Rotate N*N matrix by 90 degrees

Rotate Image

  • note how to use start and end to keep track easily
    void rotate(vector>& matrix) {
        int n = matrix.size();
        for (int layer=0; layer

1.7] Given M*N matrix, clear row and col where 0 occurs

Set Matrix Zeroes
check~ note the last for loop, to avoid repeatly setting zeros

    void setZeroes(vector>& matrix) {
        if (matrix.empty() || matrix[0].empty()) return;
        int m = matrix.size(), n = matrix[0].size();
        vector shouldSetRow(m, false);
        vector shouldSetCol(n, false);
        for (int i=0; i

1.8] 假设提供了isSubstring,可以检查strA是否为strB的子串。给定两个字符串s1和s2,判断是否s2由s1旋转而来,只可用isSubstring一次。

恩不剧透了,想不出看P116

你可能感兴趣的:(8.23 cc 数组和字符串[pt2])