原创 Leetcode 295 Find Median from Data Stream

題目鏈接:https://leetcode.com/problems/find-median-from-data-stream/ 解題思路 既然是是找到中位數,我們就使用兩個堆,一個是大頂堆,一個小頂堆,保證兩個堆滿足以下條件: 大

原创 Leetcode: 241. Different Ways to Add Parentheses

題目鏈接 https://leetcode.com/problems/different-ways-to-add-parentheses/ 描述 Given a string of numbers and operators, ret

原创 Golang goroutine pool 的實現

Golang 語言很好的支持高併發場景,goroutine相比java的thread開銷更小。但是大量的goroutine會帶來內存開銷,如果無限的創建goroutine則會出現內存溢出的災難,所以萌生出了goroutine pool

原创 218. The Skyline Problem

題目鏈接 : https://leetcode.com/problems/the-skyline-problem/ 解題思路 先定義下:對於三元組(left,right,high) 我們可以認爲(left,high)爲開始的先計爲(l

原创 Leetcode 284. Peeking Iterator

題目描述 Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator tha

原创 Leetcode 287. Find the Duplicate Number

題目描述 Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at l

原创 Leetcode 289. Game of Life

題目描述 Game of Life Medium 647 131 Favorite Share According to the Wikipedia’s article: “The Game of Life, also known

原创 Tensorflow:Mac下的環境安裝和helloworld

Tensorflow安裝 (主要參考官網和他人blog) 官網上建議virtualenv安裝 我們建議使用 virtualenv 安裝。virtualenv 是一個和其它 Python 項目開發隔離的虛擬 Python 環境,在同一臺

原创 Leetcode:239. Sliding Window Maximum

Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very

原创 Coding interview:數組中未出現的最小正整數

題目描述 給定一個無序整型數組array,找出數組中未出現的最小正整數. 例如: [-1,2,3,4] 返回1 [1,2,3,4] 返回5 解題思路 對於給定數組長度爲N,我們希望數組中的數據爲1,2,3,4…,N,這樣最小的正整數則

原创 Flink:word count demo

flink 安裝 單機安裝flink非常簡單,在官網下載flink,並執行安裝包中bin文件下的start-cluster.sh即可,運行成功之後訪問http://localhost:8081,會出現flink 的管理頁面 Word

原创 Coding interview:位運算2

找出正數中二進制1出現的次數 public int count1(int n) { int res = 0; while (n!=0){ res += n&1;

原创 Coding interview:位運算

位運算總結 1.交換兩個數 2.選擇兩個數中較大的一個 3.位運算進行加減乘除 下面給出代碼 //交換兩個數 public void swap(int a,int b) { a = a^b; b = a

原创 leetcode:best time buy and sell stock系列

best time buy and sell stock系列 最近把leetcode上“best time buy and sell stock”系列一共5個問題整理了一下,題目就補貼出來了,在leetcode上面就能找到。 best

原创 Coding interview:添加最少字符使字符串整體爲迴文字符串

題目描述 給定一個字符串str,如果可以在str的任意位置添加字符,請返回添加字符最少的情況下,讓str整體都是迴文字符串的一種結果。 解題思路 本題可以使用動態規劃的思想,dp[i][j]表示子字符串(i,j)變成迴文字符串需要添