ARTS:
- Algrothm: leetcode算法题目
- Review: 阅读并且点评一篇英文技术文章
- Tip/Techni: 学习一个技术技巧
- Share: 分享一篇有观点和思考的技术文章
Algorithm
【leetcode】13. Roman to Integer
https://leetcode.com/problems/roman-to-integer/
1)problem
Roman numerals are represented by seven different symbols: I
, V
, X
, L
, C
, D
and M
.
Symbol Value
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
For example, two is written as II
in Roman numeral, just two one's added together. Twelve is written as, XII
, which is simply X
+ II
. The number twenty seven is written as XXVII
, which is XX
+ V
+ II
.
Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII
. Instead, the number four is written as IV
. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX
. There are six instances where subtraction is used:
-
I
can be placed beforeV
(5) andX
(10) to make 4 and 9. -
X
can be placed beforeL
(50) andC
(100) to make 40 and 90. -
C
can be placed beforeD
(500) andM
(1000) to make 400 and 900.
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.
Example 1:
Input: "III"
Output: 3
Example 2:
Input: "IV"
Output: 4
Example 3:
Input: "IX"
Output: 9
Example 4:
Input: "LVIII"
Output: 58
Explanation: L = 50, V= 5, III = 3.
Example 5:
Input: "MCMXCIV"
Output: 1994
Explanation: M = 1000, CM = 900, XC = 90 and IV = 4.
2)answer
预想结果;
result = M + ( M - C ) + (C - X) + ( V - I) = 1000 + 900 + 90 + 4
由于罗马数字通常从左到右从最大到最小。
"MCMXCIV"的实际值应该是:
M = 1000,CM = 900,XC = 90,IV = 4。
具体计算是;
result = M + ( M - C ) + (C - X) + ( V - I) = 1000 + 900 + 90 + 4
C 100 被放在M 1000前面的时候,应该用减数M-C,然后:
# result = M + C
# temp = M - C
# result = M + C + temp = M + C + M - C = M + M
因为+C
和-C
抵消了,所以M+M=2000
,和计划中的result = M + (M-C)
就少了一个-C
的步骤。这是错误的。
为了使当小数放在大数的结果正确,所以就要将-C的值补充回来。也就是 *2 的由来,才是正确的解法。
result += numral_map[s[i]] - 2 * numral_map[s[i-1]]
3)solution
class Solution(object):
def romanToInt(self, s):
"""
:type s: str
:rtype: int
"""
numral_map ={ "I":1,"V":5, "X":10, "L":50, "C":100, "D":500, "M":1000 }
result = 0
for i in range(len(s)):
if i > 0 and numral_map[s[i]] > numral_map[s[i-1]]:
result += numral_map[s[i]] - 2 * numral_map[s[i-1]]
else:
result += numral_map[s[i]]
return result
Review
【漏洞挖掘】10个绕过反病毒的恶意用户技巧
1)场景
概述10个需要注意的问题。绕过杀毒软件
2)问题难点
10个绕过反病毒的恶意用户技巧
3)解决问题的方法
介绍
添加防病毒软件信任名单策略
通过GUI禁用反病毒
终止反病毒软件进程
停止并禁用反病毒服务
通过调试设置禁用反病毒软件
卸载反病毒软件
从UNC路径或可移动媒体执行(U盘)
从备用数据流执行
从DLL执行
从文件系统外部执行
总结
4)方法细节
10个绕过反病毒的恶意用户技巧
https://www.cnblogs.com/17bdw/p/10575815.html
Tip
【安全开发】爬虫基础
1)场景
爬虫知识基础知识
2)问题难点
基础框架整理
3)解决思路
0x1、基础框架原理
1.1、爬虫基础
1.1、基础原理
1.2、发起HTTP请求-Request
1.3、获取响应内容-Response
1.4、练手库-Urllib
4)方法细节
爬虫基础
https://www.cnblogs.com/17bdw/p/10735127.html
Share
【业务】极客时间-左耳听风-程序员攻略-软件设计
1)场景
软件设计学习
2)问题难点
软件设计学习的资源
3)解决思路
程序员练级攻略:软件设计
- 编程范式
- 一些软件设计的相关原则
- 一些软件设计的读物
4)方法细节
极客时间-左耳听风-程序员攻略-软件设计