原创 線程安全和線程同步Synchronized

部分轉載: 線程安全:http://blog.csdn.net/ghevinn/article/details/37764791 Synchronized: http://blog.csdn.net/ghsau/article

原创 Ubuntu簡易配置dlna服務器

1. 安裝minidlna sudo apt-get install minidlna 2. 配置dlna 配置文件位於/etc/minidlna.conf,使用如下命令打開並編輯配置文件 sudo gedit /etc/min

原创 [225] Implement Stack using Queues

1. 題目描述 Implement the following operations of a stack using queues. push(x) – Push element x onto stack. pop()

原创 Android LayoutInflater.inflate詳解

1. 作用 官方釋義 Inflate a new view hierarchy from the specified xml resource 大概意思就是從給定的xml中加載view樹。 2. 用法 2.1 四種重載 1.

原创 [70] Climbing Stairs

1. 題目描述 You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2

原创 Android內存優化:用註解的方式替代枚舉

1. 問題起源 那天寫代碼的過程中,switch使用枚舉類作爲條件時,突然出現了一個報錯 枚舉 switch case 標籤必須爲枚舉常量的非限定名稱 public class UsbMsg { private Ms

原创 Ubuntu終端突然不能輸入中文

1. 問題 沒有做任何輸入法配置的修改,終端下輸入中文後,選擇對應項在terminal上無法顯示,複製粘貼也不行。 2. 解決方案 使用了參考博客中的方法解決了問題,在此記錄一下。 我是直接在/etc/inputrc中直接進行的修

原创 [121] Best Time to Buy and Sell Stock

1. 題目描述 Say you have an array for which the ith element is the price of a given stock on day i. If you were only p

原创 [169] Majority Element

1. 題目描述 Given an array of size n, find the majority element. The majority element is the element that appears more

原创 [232] Implement Queue using Stacks

1. 題目描述 Implement the following operations of a queue using stacks. push(x) – Push element x to the back of queue.

原创 [283] Move Zeroes

1. 題目描述 Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative orde

原创 [290] Word Pattern

1. 題目描述 Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, su

原创 [198] House Robber

1. 題目描述 You are a professional robber planning to rob houses along a street. Each house has a certain amount of mo

原创 [172] Factorial Trailing Zeroes

1. 題目描述 Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarith

原创 冒泡排序

1. 排序思路 相鄰元素兩兩進行比較,不滿足序列要求的則交換 一遍排序後,最後一個數字已經滿足條件,所以冒泡排序一共需要n-1次 冒泡排序最好的時間複雜度爲O(n),當所有數字爲正序只需要一趟排序,使用一個標記,當上一輪沒有交