【ARTS】01_16_左耳听风-20190225~20190303

ARTS:

  • Algrothm: leetcode算法题目
  • Review: 阅读并且点评一篇英文技术文章
  • Tip/Techni: 学习一个技术技巧
  • Share: 分享一篇有观点和思考的技术文章

Algorithm

【leetcode】890. Find and Replace Pattern

https://leetcode.com/problems/find-and-replace-pattern

1)problem

You have a list of words and a pattern, and you want to know which words in words matches the pattern.

A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word.

(Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.)

Return a list of the words in words that match the given pattern.

You may return the answer in any order.

Example 1:

Input: words = ["abc","deq","mee","aqq","dkd","ccc"], pattern = "abb"
Output: ["mee","aqq"]
Explanation: "mee" matches the pattern because there is a permutation {a -> m, b -> e, ...}.
"ccc" does not match the pattern because {a -> c, b -> c, ...} is not a permutation,
since a and b map to the same letter.

Note:

1 <= words.length <= 50
1 <= pattern.length = words[i].length <= 20

2)answer

  • 使用HashMap来搞定,直接把映射一一的放入map中,如果出现过这个映射的话,就看新的对应关系和原来的映射是否相同。

  • 代码中使用了set,这个set很重要,因为这个保证了不会出现ccc对应abb这种。

  • words里面的每个word都和pattern长度相同,省去了判断长度的过程

3)solution

class Solution(object):
    def findAndReplacePattern(self, words, pattern):
        """
        :type words: List[str]
        :type pattern: str
        :rtype: List[str]
        """
        ans = []
        set_p = set(pattern)
        for word in words:
            if len(set(word))!=len(set_p):
                continue
            fx = dict()
            equal = True
            for i,w in enumerate(word):
                if w in fx:
                    if fx[w] != pattern[i]:
                        equal = False
                        break
                fx[w] = pattern[i]
            if equal:
                ans.append(word)
        return ans

if __name__ == '__main__':
    words = ['abc', 'deq', 'mee', 'aqq', 'dkd', 'ccc','ddz']
    pattern = 'abb'
    solu = Solution()
    print solu.findAndReplacePattern(words, pattern)

Review

【漏洞挖掘】WinRAR代码执行漏洞CVE-2018-20250

1)场景

WinRAR代码执行漏洞

2)问题难点

分析应用软件逆向分析思路

3)解决问题的方法

0x01 分析思路
0x02 漏洞细节
0x03 利用方式
0x04 效果
0x05 相关样本IOC
0x06 参考

4)方法细节

WinRAR代码执行漏洞CVE-2018-20250

https://www.cnblogs.com/17bdw/p/10416145.html

Tip

【安全开发】30分钟关闭Tcpdump,开启Tcpdump、检测目录大小终止任务

1)场景

控制TcpDump的运行

2)问题难点

TcpDump定时开启关闭

3)解决思路

0x01 场景
0x02 思路
    查看文件个数
    显示文件大小
    关系运算符
    判断文件大小,超过大小终止程序
    sudo运行bash
    Windows与Linux文件转换
    计划任务部分
    检测文件目录大小
参考

4)方法细节

【Shell】30分钟关闭Tcpdump,开启Tcpdump、检测目录大小终止任务

https://www.cnblogs.com/17bdw/p/10441183.html

Share

【业务】极客时间-左耳听风-程序员攻略-编程语言

1)场景

编程语言学习重点与资源

2)问题难点

学习资源整合

3)解决思路

0x1 前言
  编程语言
  理论学科
  系统知识
0x2 Java
0x3 C/C++
0x4 GO

4)方法细节

极客时间-左耳听风-程序员攻略-编程语言
https://www.cnblogs.com/17bdw/p/10589140.html

上一篇:【ARTS】01_19_左耳听风-20190318~20190324


下一篇:C# - 多线程 之 异步编程