今天安装了Gephi后,发现打开就显示下欢迎界面,就消失了。
leetcode Find Median from Data Stream
leetcode Find Median from Data Stream
Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.
Examples:
[2,3,4]
, the median is3
[2,3]
, the median is(2 + 3) / 2 = 2.5
Design a data structure that supports the following two operations:
- void addNum(int num) - Add a integer number from the data stream to the data structure.
- double findMedian() - Return the median of all elements so far.
For example:
- add(1)
- add(2)
- findMedian() -> 1.5
- add(3)
- findMedian() -> 2
leetcode Nim Game
leetcode Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.
Both of you are very clever and have optimal strategies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.
For example, if there are 4 stones in the heap, then you will never win the game: no matter 1, 2, or 3 stones you remove, the last stone will always be removed by your friend.
leetcode Word Pattern
leetcode Word Pattern
Given a
pattern
and a stringstr
, find ifstr
follows the same pattern.Examples:
- pattern =
"abba"
, str ="dog cat cat dog"
should return true.- pattern =
"abba"
, str ="dog cat cat fish"
should return false.- pattern =
"aaaa"
, str ="dog cat cat dog"
should return false.- pattern =
"abba"
, str ="dog dog dog dog"
should return false.Notes:
- Both
pattern
andstr
contains only lowercase alphabetical letters.- Both
pattern
andstr
do not have leading or trailing spaces.- Each word in
str
is separated by a single space.- Each letter in
pattern
must map to a word with length that is at least 1.
leetcode Find the Duplicate Number
leetcode Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.
Note:
- You must not modify the array (assume the array is read only).
- You must use only constant, O(1) extra space.
- Your runtime complexity should be less than
O(n2)
.- There is only one duplicate number in the array, but it could be repeated more than once.
leetcode Game of Life
leetcode Game of Life
According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."
Given a board with m by n cells, each cell has an initial state live (1) or dead (0). Each cell interacts with its eight neighbors (horizontal, vertical, diagonal) using the following four rules (taken from the above Wikipedia article):
- Any live cell with fewer than two live neighbors dies, as if caused by under-population.
- Any live cell with two or three live neighbors lives on to the next generation.
- Any live cell with more than three live neighbors dies, as if by over-population..
- Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
Write a function to compute the next state (after one update) of the board given its current state.
Follow up:
- Could you solve it in-place? Remember that the board needs to be updated at the same time: You cannot update some cells first and then use their updated values to update other cells.
- In this question, we represent the board using a 2D array. In principle, the board is infinite, which would cause problems when the active area encroaches the border of the array. How would you address these problems?
大端序和小端序
windows 10 出现 关键错误:开始菜单和cortana停止工作 解决办法
今天遇到了一个win 10 的 BUG,
就是开机的时候出现 关键错误:开始菜单和Cortana停止工作。我们将尝试在你下一次登录后修复这一问题”的提示。
然而无论怎么重启都无效。
解决方法如下:
按ctrl + alt + del 打开任务管理器
点击服务标签
在下方点击 打开服务
在服务列表找到User Manager,右键属性,将启动类型改为自动
重启电脑即可
Lumia 1020 (windows 10 mobile build 10512) 安装 APK 是怎样的一种体验
身为手握Lumia 1020的拍照神器,又身为windows insider会员,昨天升级10512,发现国行还是没有安卓子系统,怒刷港版,然后升级之~于是开始玩起APK。
保研夏令营
参加完RUC和ISCAS的夏令营......