胡言乱语

记录一些无聊的日常


Leetcode20

Published at April 23, 2019 ·  1 min read

Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]....

周总结20190422

Published at April 22, 2019 ·  1 min read

上周计划完成情况 翻译 Julia Evas 的一篇质量高的博客 (未完成) 刷 Leetcode 3 道 (完成) 动手编译 Swoole 源码,搭建本地环境 (未完成) 动手写 Angular tutorial (完成90%) 工作 参加公司 PHP 技术培训,了解到公司目前正在推行内部开源,这是个机会 阅读了 【UNIX 高级环境编程】 第一章,并进行了实践 需要反思的地方 自控力不好,总是在拖延要干的事,用完成小目标去激励自己,完成后给自己奖励,用大目标防止自己迷失 总是在逃避要执行的问题,把问题分解成小块,逐步执行,找出自己的节奏 做事的时候很容易分心,可以尝试下番茄钟 下周计划 3 道 leetcode...

Leetcode19

Published at April 21, 2019 ·  1 min read

Permutation II Given a collection of numbers that might contain duplicates, return all possible unique permutations. Example: Input: [1,1,2] Output: [ [1,1,2], [1,2,1], [2,1,1] ] 排列组合,给出一组可能重复的数字,求所有可能的排列组合。 之前有刷过一道,给出一组不可能重复的数字求排列组合的问题,Permutation, 第一反应就是套用之前的解法加上判断重复的逻辑。 class Solution(object): def permuteUnique(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ res = [] # 此处的排序可以想下作用是什么 numd.sort() self.dfs(nums, [], res) return res def dfs(self, choices, path, res): if not choices: res....

Leetcode18

Published at April 19, 2019 ·  1 min read

ZigZag Conversion The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR"...

Leetcode17

Published at April 15, 2019 ·  1 min read

Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string “”. Example 1: Input: ["flower","flow","flight"] Output: "fl" Example 2: Input: ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings....

周总结20190415

Published at April 15, 2019 ·  1 min read

本周收获 工作 Redash 安装成功,阅读了数据源部分代码,好的代码都是易读的 参加了公司的 PHP 人才通道考试,了解了 PHP 目前在公司的占比 个人 搬家,路遇金融行业多年经验大佬借手机,闲聊几句,加深了对金融行业的一点理解 开始向好的方向想,不再悲观了 需要反思的地方 工作效率较低,抵触前端 Angular 知识,最好列出一个 List,可以帮助消化问题,不会因为事情太多就开始有抵触心里 没有继续之前刷 Leetcode 的频率,又开始刷电影偷懒,需要给自己树立个目标,到达之后可以给些小奖励,先定刷够 30 道之后给自己放一周假吧(不用刷 Leetcode ) 精力管理不好,需要根据自己目前的情况定一套完整的管理机制 下周计划 翻译 Julia Evas 的一篇质量高的博客 刷 Leetcode 3 道...

Leetcode16

Published at April 9, 2019 ·  1 min read

N-Queens The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-queens’ placement, where ‘Q’ and ‘....

Leetcode15

Published at April 3, 2019 ·  1 min read

Subset Power set 接着上回提到的求子集合的问题,继续说位操作解法。 class Solution: def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ res = [] for i in range(1<<len(nums)): tmp = [] for j in range(len(nums)): # 判断对应位是否为1 if i & 1 << j: tmp.append(nums[j]) res.append(tmp) return res 可以把每一个结果转换为二进制,然后遍历 000 到 111 ,把对应位置为1的元素保留到临时list,最终结果就是全部子集合 比如说 [‘a’, ‘b’, ‘c’] a 代表 第一位为 1 的情况 100,b 代表 第二位为 1 的情况 010,c 代表第三位为 1 的情况,...

Leetcode14

Published at April 1, 2019 ·  1 min read

Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned. Example 1: Input: 4 Output: 2 Example 2:...

Leetcode13

Published at March 27, 2019 ·  1 min read

Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index. Example 1: Input: [2,3,1,1,4] Output: true Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index....


Recent posts

Leetcode30

ElasticSearch 系列(一)

Mysql 分区表实践

Kafka 入门

Hugo 安装


Archives

2020 (11)
2019 (56)