原创 LeetCode279. Perfect Squares

Description: Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ..

原创 貪心三兩道

1、餅乾分配 Description: Assume you are an awesome parent and want to give your children some cookies. But, you should give

原创 LeetCode695. Max Area of Island

Description: Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected

原创 LeetCode127. Word Ladder

Description: Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transf

原创 Class.forName 和 ClassLoader 的區別

       在java中Class.forName()和ClassLoader都可以對類進行加載,但是二者有存在一定等區別。ClassLoader就是遵循雙親委派模型最終調用啓動類加載器的類加載器,實現的功能是“通過一個類的全限定名來獲

原创 @Autowire和@Resource註解的區別

@Autowire和@Resource二者都是註解方式動態裝配bean,但是二者又有所區別。 1、@Autowire 默認按照類型(by-type)裝配,默認情況下要求依賴對象必須存在。     ①如果允許依賴對象爲null,需設置req

原创 爲什麼有關MongoDB採用B樹索引,以及Mysql B+樹做索引?

原文鏈接:https://www.zhihu.com/question/28774706 MySQL 中的許多概念在 MongoDB 中具有相近的類比。下表是一些常見概念: MySQL Mong

原创 HttpClient封裝

import com.alibaba.dubbo.common.json.JSON; import org.apache.http.*; import org.apache.http.client.HttpRequestRetryHan

原创 java時間複雜度計算

時間複雜度是指算法執行語句執行的次數。 常見的時間複雜度有以下幾種: 描述 時間複雜度 常數階 O(1) 對數階 O(logn) 線性階 O(n) 線性對數階 O(nlogn) 平方階 O(n²) 立方階 O(n³) n次方階 O(mⁿ)

原创 codevs1014 裝箱問題

題目描述 Description 有一個箱子容量爲V(正整數,0<=V<=20000),同時有n個物品(0<n<=30),每個物品有一個體積(正整數)。 要求n個物品中,任取若干個裝入箱內,使箱子的剩餘空間爲最小。 輸入描述 Inp

原创 codevs3162 抄書問題

題目描述 Description 現在要把M本有順序的書分給K個人複製(抄寫),每一個人的抄寫速度都一樣,一本書不允許給兩個(或以上)的人抄寫,分給每一個人的書,必須是連續的,比如不能把第一、第三、第四本數給同一個人抄寫。現在請你設計

原创 PT07Z - Longest path in a tree

題目信息: You are given an unweighted, undirected tree. Write a program to output the length of the longest path (from one

原创 LeetCode(17):電話號碼的字母組合

題目描述: 給定一個僅包含數字 2-9 的字符串,返回所有它能表示的字母組合。 給出數字到字母的映射如下(與電話按鍵相同)。注意 1 不對應任何字母。 分析:其實這個題就是要找出對應數字的字母的所有組合。從所有組合這個性質來思考,應該用

原创 git的常用命令整理

創建倉庫 git init 提交的文件的信息添加到索引庫中 git add [file] git add . #'.'或'*'表示全部添加 提交git 默認分支master git commit [flie] -m [messa

原创 codevs1166 矩陣取數遊戲

題目描述 Description 【問題描述】 帥帥經常跟同學玩一個矩陣取數遊戲:對於一個給定的n*m 的矩陣,矩陣中的每個元素aij均 爲非負整數。遊戲規則如下: 1. 每次取數時須從每行各取走一個元素,共n個。m次後取完矩陣所有元