- 博客(12)
- 收藏
- 关注
原创 leetcode_299. Bulls and Cows
You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint tha...
2018-02-08 16:28:59 182
原创 leetcode_230. Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.Follow up: What if the BST i...
2018-02-08 16:28:09 184
原创 leetcode_438. Find All Anagrams in a String
Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s.Strings consists of lowercase English letters only and the length of both strings s and p will not be large...
2018-02-08 16:26:37 184
原创 leetcode_198. House Robber
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house...
2018-02-08 16:25:42 170
原创 leetcode_193. Valid Phone Numbers
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers.You may assume that a valid phone number must appear in ...
2018-02-08 16:24:54 294 1
原创 leetcode_27. Remove Element
Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-plac...
2018-02-08 16:24:02 135
原创 leetcode_149. Max Points on a Line
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.提示:提交代码后,需要用简洁的语言解释一下代码思路~ 谢谢历史题目和总结见公众号「每日一道算法题」https://leetcode.com/problems/max-points-on-a-...
2018-02-08 16:22:46 138
原创 leetcode_476. Number Complement
Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note: The given integer is guaranteed to fit within the range of a 3...
2018-02-08 16:22:12 144
原创 leetcode_146. LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put.get(key) - Get the value (will always be positive) of the key if th...
2018-02-08 16:20:49 231
原创 最长公共子序列
题目见下图: 思路:首先要对子序列有一个认识,这里的子序列不是直接截取的,而是从原序列中取出若干字符,而字符间的相对次序不发生改变。这样求得的结果会出现歧义,也可能得到几个满足条件的结果,暂时不考虑。 很容易想到求解此题需要遍历、比较,关键是如何比较?采用“减而治之,分而治之”的思路。 见下图,先考虑序列A和B的最后一个字符是相等的情况,那么最后两个字符就可以凑出一个公共字符...
2018-02-08 16:18:16 164
原创 从数组中找出最大的两个数
题目:从数组区间A[lo, hi]中找出最大的两个整数A[x1]和A[x2],要求元素比较的次数,要求尽可能的少迭代版1: 如图所示,当整个扫描一遍数组A,找出最大的数x1后,再扫描一次数组剩下的除去x1的元素,算法代码如上图所示。第一个for循环扫描得到x1,第二个和第三个for循环扫描得到x2,第一个for循环扫描次数为n-1,后两次扫描n-1-1,所以算法复杂度O(2n-3)...
2018-02-08 16:10:57 11174 2
原创 图解操作系统启动
实模式启动时计算机内存和磁盘布局: 操作系统启动总过程: 将上述过程进行细化: 这个视频截图是从学堂在线清华大学《操作系统》课程截屏得到的,感觉讲的很好,感兴趣的可以自己去看看。
2018-02-06 22:11:01 578
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人