原创 java併發編程,Thread類的使用

Java併發編程:Thread類的使用   在前面2篇文章分別講到了線程和進程的由來、以及如何在Java中怎麼創建線程和進程。今天我們來學習一下Thread類,在學習Thread類之前,先介紹與線程相關知識:線程的幾種狀態、上下文切

原创 41. Maximum Subarray

41. Maximum Subarray Description Given an array of integers, find a contiguous subarray which has the largest sum.

原创 66. Binary Tree Preorder Traversal

66. Binary Tree Preorder Traversal Description Given a binary tree, return the preorder traversal of its nodes' val

原创 67. Binary Tree Inorder Traversal

67. Binary Tree Inorder Traversal Description Given a binary tree, return the inorder traversal of its nodes' value

原创 3. Digit Counts

3. Digit Counts Description Count the number of k's between 0 and n. k can be 0 - 9. Example if n = 12, k = 1 in [0

原创 Swing與線程

swing與線程 使用線程是爲了提高程序的響應速度,當程序需要做某些很耗時的任務時,不應阻塞用戶接口而應啓動另一個工作器線程。但是我們必須小心工作器線程所做的事情。 Swing不是線程安全的,不要嘗試在多個線程中操作用戶界面元素

原创 1. A + B Problem

1. A + B Problem Description Write a function that add two numbers A and B. You should not use + or any arithmetic

原创 全排列的編碼與解碼——康託展開及其逆展開

一、康託展開:全排列到一個自然數的雙射   X=an*(n-1)!+an-1*(n-2)!+...+ai*(i-1)!+...+a2*1!+a1*0!   ai爲整數,並且0<=ai<i(1<=i<=n)    適用範圍:沒

原创 爲Hexo添加音樂

爲Hexo添加音樂 本來打算自己寫個插件,無奈有點費時間,主要是後天要考試試啦,頭有點大。於是使用了音樂外鏈播放器。一開始直接用的網易雲單首歌曲的播放器,但是隻能播放同一首歌曲,而且切換歌曲很麻煩,想着加個音樂搜索功能,然後發現

原创 同餘定理(求餘數)

現在給你一個自然數n,它的位數小於等於一百萬,現在你要做的就是求出這個數除10003之後的餘數輸入第一行有一個整數m(1<=m<=8),表示有m組測試數據;隨後m行每行有一個自然數n。輸出輸出n整除10003之後的餘數,每次輸出佔一行。樣

原创 Java開發中的23種設計模式詳解(轉)

設計模式(Design Patterns)——可複用面向對象軟件的基礎 設計模式(Design pattern)是一套被反覆使用、多數人知曉的、經過分類編目的、代碼設計經驗的總結。使用設計模式是爲了可重用代碼、讓代碼更容易被他人理

原创 A+B問題

A+B問題 描述 給出兩個整數a和b, 求他們的和, 但不能使用 + 等數學運算符。 說明 a和b都是 32位 整數,可以使用位運算 樣例 輸入1和2,輸出爲3 實現 class Solution { public: /*

原创 97. Maximum Depth of Binary Tree

97. Maximum Depth of Binary Tree Description Given a binary tree, find its maximum depth. The maximum depth is the

原创 java多線程

多線程 進程 進程的概念主要有兩點:第一,進程是一個實體。每一個進程都有它自己的地址空間,一般情況下,包括文本區域(text region)、數據區域(data region)和堆棧(stack region)。文本區域存儲處理器

原创 155. Minimum Depth of Binary Tree

155. Minimum Depth of Binary Tree Description Given a binary tree, find its minimum depth. The minimum depth is the