原创 並查集(union-find)

leetcode-1202. Smallest String With Swaps class Solution { public: int _find(unordered_map<int, pair<int, int>>& p

原创 扔雞蛋問題

問題:有m層的高樓,n個雞蛋,需要扔幾次雞蛋才能確定使雞蛋落地後變碎的最低樓層,雞蛋如果沒碎可以重複使用 int minTimes(int m, int n) { vector<vector<int>> dp(m + 1, ve

原创 連續質數序列

返回<=n的所有質數 // 埃拉托色尼的篩子 vector<int> sieve(int n) { vector<int> nums, result; for (int i = 0; i <= n; ++i)nums.e

原创 最大公約數

1. 蠻力法 // greatest common divisor int gcd(int m, int n) { int result = min(m, n); if (result == 0)return max(m

原创 ubuntu16開啓root賬號登錄

開啓root賬戶登錄 ubuntu16桌面版默認不開啓root賬戶登錄,按照以下步驟設置: sudo vi /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf 在末尾添加: greeter

原创 VirtualBox無法新建64位系統、VMware錯誤:VMware Workstation 與 Device/Credential Guard 不兼容

這是由於CPU的虛擬化功能未開啓或被佔用或受保護造成的,按以下步驟解決: 進入BIOS開啓CPU虛擬化功能 禁用Device/Credential Guard: vmware官網的解決方案 寫的比較清楚

原创 tomcat啓動閃退

在 tomcat/bin/startup.bat 文件末尾添加 pause 後重新啓動,可以看到錯誤原因,一般是沒有設置 JAVA_HOME 環境變量造成的,錯誤顯示: Neither the JAVA_HOME nor the J

原创 ubuntu16.04安裝SSH和Samba

安裝SSH ssh是一種安全協議,主要用於給遠程登錄會話數據進行加密,保證數據傳輸的安全 安裝 sudo apt-get update 更新源 sudo apt-get upgrade 升級源,這會花二十分鐘左右 sudo apt-g