【ARTS】打卡第五周

每周完成一个ARTS

  • 每周至少做一个 leetcode 的算法题
  • 阅读并点评至少一篇英文技术文章
  • 学习至少一个技术技巧
  • 分享一篇有观点和思考的技术文章。
  • (也就是 Algorithm、Review、Tip、Share 简称ARTS)

    Algorithm

    438. 找到字符串中所有字母异位词

    给定一个字符串 s 和一个非空字符串 p,找到 s 中所有是 p 的字母异位词的子串,返回这些子串的起始索引。

    字符串只包含小写英文字母,并且字符串 s 和 p 的长度都不超过 20100。

    思路:滑动窗口。将字符串中的元素及个数保存在数组中。维护一个长度与非空字符串相同的滑动窗口,窗口滑动时,将新添加到窗口的字母个数加1,移出窗口的字母个数减1。通过比较两数组(窗口数组与目标字符串数组)来判断是否是异位词。
    时间复杂度:O(n)

    vector<int> findAnagrams(string s, string p) {
      vector<int> vret;
      if (s.size() < p.size())
        return vret;
    
      vector<int> vm(26);
      vector<int> vn(26);
      for (int i = 0; i < p.size(); i ++)
      {
        vm[p[i] - 'a'] ++;
        vn[s[i] - 'a'] ++;
      }
    
      int l = 0, r = p.size() - 1;
    
      while(r < s.size())
      {
        if (vm == vn)
        {
          vret.push_back(l);
        }
    
        if (r + 1 < s.size())
        {
          vn[s[r + 1] - 'a'] ++;
          vn[s[l] - 'a'] --;
          l ++;
          r ++;
        }
        else
          break;
      }
      return vret;
    }

    Review

    Troubleshooting High I/O Wait in Linux

    介绍了几种定位io wait问题方法:

    1、top命令查看cpu的 i/o wait

    2、iostat -x 命令查看各个磁盘的io资源信息

    3、iotop命令查看是哪个进程会导致高io

    4、ps命令查看进程状态

    5、lsof命令查看哪个文件写操作频繁

    Tip

    shc gzexe 将shell脚本转换为二进制的可执行文件

    在生产环境中,不想暴露shell代码实现时,可以使用该方法,将shell脚本转换为二进制文件

    Share

    到底选择SOL还是NoSQL?看这里!

    对于各个数据库的优缺点有很详细的分析

原文地址:https://www.cnblogs.com/JesseTsou/p/11374432.html

时间: 2024-08-10 22:37:44

【ARTS】打卡第五周的相关文章

ARTS打卡计划第一周-Review

本周分享的文章来自于medium的 Testing Best Practices for Java + Spring Apps 这个文章主要讲的是java测试的一些最佳实践 1.避免函数返回void,返回void不利于写单元测试,因为返回void不知道方法执行的内部情况 2.使用有意义的 assertions,可以使用  https://google.github.io/truth/ 类库 3.记得测试异常 4.可以使用变量进行多次测试 5.使用Mockito进行mock测试 原文地址:http

ARTS打卡第三周

Algorithm 题目描述 Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. Example 1: Input: [1,2,3

ARTS打卡计划第二周-Review

本周review的文章是:https://medium.com/@hakibenita/optimizing-django-admin-paginator-53c4eb6bfca3 改篇文章的题目是:Optimizing Django Admin Paginator,How we finally made Django admin fast for large tables. django分页的时候,大部分时间都会消耗在求count上,本篇文章提到了几点用于提升大表分页的方法: 1.重写默认的分

ARTS打卡计划第二周-Algorithm

665. 非递减数列  https://leetcode-cn.com/problems/non-decreasing-array/ 给定一个长度为 n 的整数数组,你的任务是判断在最多改变 1 个元素的情况下,该数组能否变成一个非递减数列. 我们是这样定义一个非递减数列的: 对于数组中所有的 i (1 <= i < n),满足 array[i] <= array[i + 1]. class Solution { public boolean checkPossibility(int[]

ARTS打卡第1周

A:Add Two Numbers Medium You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.You ma

ARTS打卡第4周

A:Merge Intervals Medium Given a collection of intervals, merge all overlapping intervals. 解析:对给定的一个对象集合进行处理,将对象集合中存在交集的对象进行合并,行成一个新的集合 思路:优先将对象集合进行处理,将起始位置一致的对象先进行合并,返回一个map记录起始位置和对应的对象, 将对象进行排序,分析当前对象与下一对象的关系,判断下一位置的起始位置是否包含在当前的对象中,包含则合并对象的范围,不存在则新

ARTS打卡第6周

A:  Subsets 题目:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. 题意:求一个不重复的数组的所有不重复的子集 思路:使用递归的方式求解,在对一个长度为n的数组求所有不重复的子集时:先记录当前的结果集,循环调用n次,对应的情况有是否记录当前位置的值,

ARTS打卡第5周

A: Unique Paths II Medium A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the

ARTS打卡第3周

A:Rotate Image     Medium You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOTallocate ano