- 博客(13)
- 收藏
- 关注
原创 LeetCode232. Implement Queue using Stacks
Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front of queue. peek() -- Get the front element. em...
2018-11-30 21:22:17 114
原创 LeetCode231. Power of Two
Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: 20 = 1 Example 2: Input: 16 Output: true Explanation: 24 = 16 Example 3: ...
2018-11-30 20:58:24 99
原创 LeetCode226. Invert Binary Tree
Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 思路:颠倒二叉树,用递归方法很简单. # Definition for a binary t...
2018-11-28 23:15:12 106
原创 LeetCode225. Implement Stack using Queues
Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. empty() -- Return ...
2018-11-28 22:43:47 65
原创 LeetCode219. Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k. ...
2018-11-27 22:51:17 91
原创 LeetCode217. Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element i...
2018-11-27 20:12:12 101
原创 LeetCode206. Reverse Linked List
Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL 思路:倒置链表,用前插法原地倒置.每次把头结点摘出来. class Solution(object): def reverseLis...
2018-11-27 20:04:56 97
原创 LeetCode205. Isomorphic Strings
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with anoth...
2018-11-27 17:13:08 177
转载 Sublime Text3 快捷键
选择类 Ctrl+D 选中光标所占的文本,继续操作则会选中下一个相同的文本。 Alt+F3 选中文本按下快捷键,即可一次性选择全部的相同文本进行同时编辑。举个栗子:快速选中并更改所有相同的变量名、函数名等。 Ctrl+L 选中整行,继续操作则继续选择下一行,效果和 Shift+↓ 效果一样。 Ctrl+Shift+L 先选中多行,再按下快捷键,会在每行行尾插入光标,即可同时编辑这些行。 Ctrl+...
2018-11-22 18:36:24 120
原创 LeetCode204. Count Primes
Count the number of prime numbers less than a non-negative number, n. Example: Input: 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. 思路:一个找质数的算法.最开始的思路是将质数保...
2018-11-19 20:26:24 84
原创 LeetCode203. Remove Linked List Elements
Remove all elements from a linked list of integers that have value val. Example: Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4->5 思路:首先要保证链表不为空.其次,要找到真正的开头(...
2018-11-17 14:34:42 102
原创 LeetCode202. Happy Number
Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares o...
2018-11-17 13:35:50 151
原创 ubuntu16.04 设置双显示器屏幕
第一步: 打开终端,输入指令:xrandr 查看显示器链接端口名称 如图所示,我链接的两个屏幕分别是 HDMI-0 和 DP-4 第二步: xrandr --output HDMI-0 --primary 这里是选择其中一个显示器(我选的HDMI-0),将其设置为主屏幕(primary是设置主屏幕的意思) 第三步: xrandr --output DP-4 --left-of HDM...
2018-11-02 15:24:40 17501 3
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人