• eBay OA挂经反思


    【俄罗斯方块的题】

    可以参考:https://blog.csdn.net/weixin_44337445/article/details/108971706

    思路:看能移动多少步数,数min step。然后把矩阵拼出来

    心得:妈的,网上有答案都没查到。搜答案的火候不到家啊。可能准备时间太仓促了吧。可以重新再投吗? 

    public char[][] figureUnderGravity(char[][] matrix) {
      if (matrix == null || matrix.lenght == 0 || matrix[0].length == 0) {
        return matrix;
      }
      int m = matrix.length;
      int n = matrix[0].length;
      int minstep = Integer.MAX_VALUE;
      for (int j = 0; j < n; j++) {
        int i = 0;
        while (i < m) {
          while (i < m && matrix[i][j] != 'F') {
            i++;
          }
          if (i == m) continue;
          while (i < m && matrix[i][j] == 'F') {
            i++;
          }
          if (i < m) {
            int cnt = 0;
            while (i < m && matrix[i][j] != '#') {
              i++;
              cnt++;
            }
            minstep = Math.min(minstep, cnt);
          }
        }
      }
      if (minstep == Integer.MAX_VALUE || minstep == 0) {
        return matrix;
      }
      for (int i = m - 1; i < minstep; i--) {
        for (int j = 0; j < n; j++) {
          if (matrix[i - minstep][j] == 'F') {
            matrix[i][j] = 'F';
            matrix[i - minstep][j] = '.';
          }
        }
      }
      reutrn matrix;
    }
    引用

     

    【矩阵消消乐查询】

    可以参考:https://www.1point3acres.com/bbs/interview/ebay-software-engineer-563612.html

    思路:用的两个hashset存disabled row 和 column

    rowset, colset 
    for (rowset) { //124
        for(colset) { //29
            //是的吧,都是在有效范围内的for循环。有道理。
        }
    }

    心得:又没想到hashset,怎么又忘了?

  • 相关阅读:
    关于python列表中的赋值问题
    $' ': command not found报错问题
    0day安全-软件漏洞分析技术(第二版)——Crack实验一
    PNI12927 学习笔记
    Mini2440串口通信之DMA
    Mini2440串口通信
    Mini2440的外部中断编写
    VM中设置redhat为静态IP
    ldr指令小记
    Makefile文件编写小记
  • 原文地址:https://www.cnblogs.com/immiao0319/p/14192809.html
Copyright © 2020-2023  润新知