原创 阿里一道面試題——完全二叉樹的最後一顆節點

今天和朋友聊天,說是阿里有道面試題。 已知一顆完全二叉樹,有N個節點 求最後一個節點,亦即最後一排最右邊的那個節點。 節點數目2^0+……2^(k-1)>=N >= 2^0+2^1+2^2+2^3……2^k 那麼樹深爲k

原创 多線程,互斥鎖

在 前一篇文章中 ,談到了會導致異常結果的線程代碼。兩個線程分別對同一個全局變量進行了二十次加一。變量的值最後應該是 40,但最終值卻是 21。這是怎麼回事呢?因爲一個線程不停地“取消”了另一個線程執行的加一操作,所以產生這個問題

原创 POSIX 線程詳解

線程是有趣的 瞭解如何正確運用線程是每一個優秀程序員必備的素質。線程類似於進程。如同進程,線程由內核按時間分片進行管理。在單處理器系統中,內核使用時間分片來模擬線程的併發執行,這種方式和進程的相同。而在多處理器系統中,如同多個進

原创 Largest Number

Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30

原创 計數排序、桶排序和基數排序

計數排序 當輸入的元素是 n 個 0 到 k 之間的整數時,它的運行時間是 Θ(n + k)。計數排序不是比較排序,排序的速度快於任何比較排序算法。 由於用來計數的數組C的長度取決於待排序數組中數據的範圍(等於待排序數組的最大值與最

原创 Excel Sheet Column Number

Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its correspond

原创 Fraction to Recurring Decimal

Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If

原创 機器學習的最佳入門學習資源

本文由 伯樂在線 - programmer_lin 翻譯自 Jason Brownlee。歡迎加入技術翻譯小組。轉載請參見文章末尾處的要求。 這是一篇很難寫的文章,因爲我希望這篇文章能對學習者有所啓發。我在空白頁前坐下,並且問自己了一個

原创 SecureCRT 絕佳配色方案, 保護你的眼睛

轉載的secureCRT的配置,設置完後確實很舒服。碼農也要對自己好一點 SecureCRT 絕佳配色方案, 保護你的眼睛 關鍵詞:SecureCRT配色, SecureCRT設置顏色, Linux終端配色,Linux終端顏

原创 Find Peak Element☆

A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a

原创 Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 ->

原创 Binary Search Tree Iterator

Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.

原创 hihoCoder#1015 KMP算法

原題地址 之前也學習瞭解過,可是一直糊里糊塗的,沒能真正瞭解其含義。 這次剛好在hiho上看到,就隨着小hi,小ho再一次瞭解了下。 算法的求解有兩個難點(前人真的太強大了) 1、KMP算法next數組的使用 2、nex

原创 Maximum Gap

Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve

原创 Compare Version Numbers

Compare two version numbers version1 and version1. If version1 > version2 return 1, if version1 < version2 return -1,