原创 28. Implement strStr()

主要是注意badcase. class Solution { public:     int strStr(string haystack, string needle) {         if(needle == "" && hays

原创 遠程umount 硬盤 note

先用df -h 找到相應的硬盤掛載點。 有可能在遠程遇到解決類似umount target is busy掛載盤卸載不掉問題 用https://www.cnblogs.com/ding2016/p/9605526.html 提供的如下辦法

原创 66. plus one C++ 版本

從後往前遍歷,由於最初始加一,進位剛開始設爲1,每一位去判斷下,注意最後要判斷下add位是否爲1,然後再逆序輸出。時間複雜度O(n), 空間複雜度O(1). 剛開始想將輸入的數字解析出來,加上再輸出,會發生一些溢出的判斷,所以最好是每位去

原创 83. Remove Duplicates from Sorted List

class Solution { public:     ListNode* deleteDuplicates(ListNode* head) {         if(head == NULL) return head;        

原创 88. Merge Sorted Array

雙指針法:先將其中一個放到一個tem vector 裏面去,注意這裏的語法,不是(0,m), 而是 tem_nums1.assign(nums1.begin(), nums1.begin() + m);   class Solution

原创 14. Longest Common Prefix

採用的是比較傳統的解法。這裏需要注意substr(0,i+1),這裏截取的是0->i個元素。 class Solution { public:     string longestCommonPrefix(vector<string>&

原创 21. Merge Two Sorted Lists

參考了討論區的解法,用的遞歸的思想,很巧妙。 class Solution { public:     ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {              

原创 Leetcode 69 sqrt(x)

採用了二分法,參考了https://blog.csdn.net/u012884015/article/details/77619457,戰勝了97.5%,還不錯。 class Solution(object):     def mySqr

原创 Leetcode # [13] Roman to Integer

戰勝了81%,還不錯。 class Solution(object):     def romanToInt(self, s):         """         :type s: str         :rtype: int  

原创 【原創】leetcode .73.set-matrix-zeroes.py

https://blog.csdn.net/lemon_tree12138/article/details/51176153 這一篇對這個問題進行了比較詳細的描述。下面是我寫的高時間複雜度,低空間複雜度的python 腳本。性能一般,勝在

原创 LeetCode : 15.3sum

參考了: https://www.cnblogs.com/zuoyuan/p/3699159.html 但是裏面的子while循環,來判斷相鄰兩個數相等其實可以不要,因爲在第一個while 裏面判斷了。這樣可以提高運算速度。 class

原创 pytorch error:Run time error: tensors are on different GPUs

根據git 上的回覆,應該是模型和variable 沒有load 到gpu 上,下面可解決。Most likely that the net is not on GPU, try adding the following, just af

原创 keras 數據增強

Example of using .flow(x, y):(x_train, y_train), (x_test, y_test) = cifar10.load_data() y_train = np_utils.to_categoric

原创 tensorflow 1.4 latest_checkpoint bug

def latest_checkpoint(checkpoint_dir, latest_filename=None):   """Finds the filename of latest saved c

原创 pytorch 基礎- variable 以及function定義等

https://zhuanlan.zhihu.com/p/27783097