最近需要對乙個markdown**進行排序,關鍵字段是在第乙個的兩個|
中間,如下
|8|string to integer (atoi) | c++|medium|
|5|longest palindromic substring | c++|medium|
|17|letter combinations of a phone number | c++|medium|
|538|convert bst to greater tree | c++|medium|
|1122|relative sort array | c++|easy|
|40|combination sum ii | c++|medium|
|3|longest substring without repeating characters | c++|medium|
|1|two sum | c++|easy|
|925|long pressed name | c++|easy|
|7|reverse integer | c++|easy|
|113|path sum ii | c++|medium|
|2|add two numbers | c++|medium|
|9|palindrome number | c++|easy|
|6|zigzag conversion | c++|medium|
|1370|increasing decreasing string | c++|easy|
|78|subsets | c++|medium|
|208|implement trie (prefix tree) | c++|medium|
|1024|video stitching | c++|medium|
|529|minesweeper | c++|medium|
|39|combination sum | c++|medium|
|15|3sum | c++|medium|
|1291|sequential digits | c++|medium|
|11|container with most water | c++|medium|
|865|smallest subtree with all the deepest nodes | c++|medium|
|16|3sum closest | c++|medium|
|89|gray code | c++|medium|
|12|integer to roman | c++|medium|
|14|longest common prefix | c++|easy|
|402|remove k digits | c++|medium|
|856|score of parentheses | c++|medium|
|19|remove nth node from end of list | c++|medium|
|290|word pattern | c++, python3|easy|
|389|find the difference | c++|easy|
想到用shell指令碼通過awk
來進行排序,**如下:
思路就是:for i in
`awk
'' test.txt |
sort -n -k2 |
awk''`;
doawk
'nr=='
$i'' test.txt;
done
結果如下:
|1|two sum | c++|easy|
|2|add two numbers | c++|medium|
|3|longest substring without repeating characters | c++|medium|
|5|longest palindromic substring | c++|medium|
|6|zigzag conversion | c++|medium|
|7|reverse integer | c++|easy|
|8|string to integer (atoi) | c++|medium|
|9|palindrome number | c++|easy|
|11|container with most water | c++|medium|
|12|integer to roman | c++|medium|
|14|longest common prefix | c++|easy|
|15|3sum | c++|medium|
|16|3sum closest | c++|medium|
|17|letter combinations of a phone number | c++|medium|
|19|remove nth node from end of list | c++|medium|
|39|combination sum | c++|medium|
|40|combination sum ii | c++|medium|
|78|subsets | c++|medium|
|89|gray code | c++|medium|
|113|path sum ii | c++|medium|
|208|implement trie (prefix tree) | c++|medium|
|290|word pattern | c++, python3|easy|
|389|find the difference | c++|easy|
|402|remove k digits | c++|medium|
|529|minesweeper | c++|medium|
|538|convert bst to greater tree | c++|medium|
|856|score of parentheses | c++|medium|
|865|smallest subtree with all the deepest nodes | c++|medium|
|925|long pressed name | c++|easy|
|1024|video stitching | c++|medium|
|1122|relative sort array | c++|easy|
|1291|sequential digits | c++|medium|
|1370|increasing decreasing string | c++|easy|
效果如下:
#title
solution
difficulty
1two sum
c++easy
2add two numbers
c++medium
3longest substring without repeating characters
c++medium
5longest palindromic substring
c++medium
6zigzag conversion
c++medium
7reverse integer
c++easy
8string to integer (atoi)
c++medium
9palindrome number
c++easy
11container with most water
c++medium
12integer to roman
c++medium
14longest common prefix
c++easy
153sum
c++medium
163sum closest
c++medium
17letter combinations of a phone number
c++medium
19remove nth node from end of list
c++medium
39combination sum
c++medium
40combination sum ii
c++medium
78subsets
c++medium
89gray code
c++medium
113path sum ii
c++medium
208implement trie (prefix tree)
c++medium
290word pattern
c++, python3
easy
389find the difference
c++easy
402remove k digits
c++medium
529minesweeper
c++medium
538convert bst to greater tree
c++medium
856score of parentheses
c++medium
865smallest subtree with all the deepest nodes
c++medium
925long pressed name
c++easy
1024
video stitching
c++medium
1122
relative sort array
c++easy
1291
sequential digits
c++medium
1370
increasing decreasing string
c++easy
字串拆分,根據指定分隔符拆分字串
有時需要根據指定內容,完成對字串的拆分,針對這個需求,將字串函式進行整合,完成了拆分字串的功能 比如 我們有一組資料 splitxxlinexxtoxxarray 中間有固定分隔字串xx,執行下面子函式,就能獲得字串資料 split line to array。注意 拆分完成的字串陣列是由此函式完成...
根據指定字符集拆分任意字串
題目真不知道怎麼寫。我經常自己做一些小工具,所以並沒啥系統的東西可寫,這也並不是我想寫系統的東西,而且看別人寫的高大上的東西我也一點都不羨慕,真的 具體是這樣,有乙個列表,裡面存放的是一些不重複的字元,假定這些字元就是我需要找出的,或者說在我這個工具中,我需要在乙個任意字串中分別找出字元列表中有的和...
Pyhton 正則替換字串指定內容
top 正規表示式的sub模組,只能能提供正常全匹配,並進行替換。但有時我們需要精確匹配的時候就有點不太適用,比如 my friend and my friendship 我z只是想替換掉 my friend 的時候,可以使用正則 r my friend w 的檢索來精確找到 my friend 但...