代码改变世界

650. 2 Keys Keyboard

2020-12-29 03:03 by Mux1, 50 阅读, 0 推荐, 收藏, 编辑
摘要:Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: Copy All: You can copy all the 阅读全文

991. Broken Calculator

2020-12-29 02:33 by Mux1, 60 阅读, 0 推荐, 收藏, 编辑
摘要:On a broken calculator that has a number showing on its display, we can perform two operations: Double: Multiply the number on the display by 2, or; D 阅读全文

Leetcode - 要你命100-15. 3sum 解题报告

2017-09-29 09:46 by Mux1, 124 阅读, 0 推荐, 收藏, 编辑
摘要:题目: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum 阅读全文

Leetcode - 57 Insert Interval 解题报告

2017-02-14 06:47 by Mux1, 219 阅读, 0 推荐, 收藏, 编辑
摘要:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initia 阅读全文

Leetcode - 189 Rotate Array

2017-01-14 06:53 by Mux1, 129 阅读, 0 推荐, 收藏, 编辑
摘要:题目: Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. 阅读全文

Leetcode - 186 Reverse Words in a String II

2017-01-14 06:46 by Mux1, 147 阅读, 0 推荐, 收藏, 编辑
摘要:题目: Given an input string, reverse the string word by word. A word is defined as a sequence of non-space characters. The input string does not contain 阅读全文

将博客搬至CSDN

2017-01-13 06:15 by Mux1, 144 阅读, 0 推荐, 收藏, 编辑
摘要:即日起,博客已搬家至CSDN. 立贴纪念! 阅读全文

Leetcode - 458 Poor Pigs

2017-01-12 00:40 by Mux1, 1664 阅读, 0 推荐, 收藏, 编辑
摘要:题目: 总共有1000个罐子,其中有且只有1个是毒药,另外其他的都是水. 现在用一群可怜的猪去找到那个毒药罐. 已知毒药让猪毒发的时间是15分钟, 那么在60分钟之内,最少需要几头猪来找出那个毒药罐? 分析: 为什么可怜不言而喻...本题可以这么考虑问题, 先是二维地排列罐子, 然后分别让两头猪去尝 阅读全文

LeetCode - 7 Reverse Integer

2017-01-11 22:33 by Mux1, 129 阅读, 0 推荐, 收藏, 编辑
摘要:题目: Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Have you thought about this? Here are some good questio 阅读全文

Python中enumerate()的使用方法

2016-10-07 10:25 by Mux1, 590 阅读, 0 推荐, 收藏, 编辑
摘要:enumerate 函数用于遍历序列中的元素以及它们的下标: >>> for i,j in enumerate(('a','b','c')): print i,j 0 a1 b2 c>>> for i,j in enumerate([1,2,3]): print i,j 0 11 22 3>>> f 阅读全文