ARTS completed a week
Do at least a week leetcode algorithm problem
Read and review at least one technical articles in English
At least one technical skill learning
Share ideas and think there is a technical article.
(That is, Algorithm, Review, Tip, Share short ARTS)
Algorithm
76. Minimum Window Substring
Give you a string S, a string T, please find inside the string S: T contains all the letters of the smallest sub-string.
string minWindow(string s, string t) { if (s.size() < t.size()) return ""; int szdst[256] = {0}; int szsub[256] = {0}; for (int i = 0; i < t.size(); i ++) { szdst[t[i]] ++; } int minlen = s.size() + 1; int l = 0, r = -1; int start = -1; int count = 0; while (l < s.size()) { if (count < t.size() && r + 1 < s.size()) { szsub[s[++r]] ++; if (szdst[s[r]] >= szsub[s[r]]) count ++; } else { if (count == t.size()) { if (r - l + 1 < minlen) { minlen = r - l + 1; start = l; } } szsub[s[l]] --; if (szdst[s[l]] > szsub[s[l]]) count --; l ++; } } if (start == -1) return ""; return s.substr(start, minlen); }
Review
It describes how to delete lines from a large mysql table data.
Tip
How to test Linux IO performance (disk read and write speed)
1. Test IO read
hdparm -t --direct / dev / sda3IO test can be read using the above command, but this tool hdparm need to install their own, but also the root user to perform.
2.测试IO写
sync;/usr/bin/time -p bash -c "(dd if=/dev/zero of=test.dd bs=1000K count=20000;sync)"dd bs = 1M count = 20000 if = / dev / zero of = test.dd conv = fdatasync dd IO command to test sequential write and read mode.
Share