Algorithms
Next Greater Element I
思路: num1中的元素是num2的子集,遍历num2中的的数字,当栈不为空且栈顶元素小于当前数字时,说明当前数字是栈顶元素右边第一个较大的数字,利用哈希表建立映射后去除当前栈顶元素,再将当前数字压入栈中。
1 | class Solution { |
Construct the Rectangle
思路: 先看看是不是正方形。
1 | class Solution { |
Review
本周阅读英文文章:
1、Illicit Trade in the Dark Web
2、Why Is There an F in Front of This String?
3、How To Boost Your Productivity as a Developer
Technique
Python中的字符串格式化,旧式的”%s”和新式的”format()”经常被使用,那么来看看另外两种方式:
格式化字符串字面值
在Python3.6之后的新功能f-strings,写法更加的简洁和优雅。
1 | 'Top' name = |
也可以嵌入Python表达式:
1 | 5 a = |
用在函数中:
1 | def greet(name, question): |
也支持format()
方法所使用的字符串格式化语法:
1 | 'Top' name = |
模板字符串
1 | 'Top' name = |
但是模板字符串不能使用格式说明符,需要将errno转换为十六进制字符串:
1 | 'Hello $name, there is a $errno error!' tmp = |
Share
可以看看天御攻防实验室关于ATT&CK™
的文章:
实战化ATT&CK™:引言
参考
https://docs.python.org/zh-cn/3.7/tutorial/inputoutput.html#fancier-output-formatting
https://www.python.org/dev/peps/pep-0498/
https://docs.python.org/zh-cn/3/reference/lexical_analysis.html#f-strings