原创 LeetCode | 188. Best Time to Buy and Sell Stock IV DP難題

Say you have an array for which the ith elementis the price of a given stock on day i.Design an algorithm to find the m

原创 優化算法 | 使用Knn算法進行數據預測流程分析

現在給你一組數據{ a 1 ,a 2, ⋯ ,a n},比如這組數據表示的是第1個月到第n個月的電量使用情況現在讓你根據這組數據使用KNN算法去預測a n+1的值,也就是第n+1個月的電量使用情況由於任何一個月的用電量總是和前幾個月的用電

原创 python中的字典dict

Python中的字典dict是一組無序鍵值對的集合,其中每一個鍵的值都是獨一無二的>>>data = {1:"a", 2:'b', 3:'c', 4:'d'}>>>data{1: 'a', 2: 'b',3: 'c', 4: 'd'}>>

原创 LeetCode | 216. Combination Sum III BFS

Findall possible combinations of k numbers that add up to a number n,given that only numbers from 1 to 9 can be used an

原创 LeetCode | 424. Longest Repeating Character Replacement循環剪枝題

Givena string that consists of only uppercase English letters, you can replace anyletter in the string with another let

原创 計算機網絡 | IP地址的分類

首先需要明白,全0的地址也就是0.0.0.0對應於當前主機,全1的地址也就是255.255.255.255對應於當前子網的廣播地址下面是地址的分類A類地址:以0開頭,第一個字節的範圍爲1~127:1.0.0.0~127.255.255.2

原创 經典算法 | 求整數的全部質數因子分析與解答

有這麼一道題:功能:輸入一個正整數,按照從小到大的順序輸出它的所有質數的因子(如180的質數因子爲2 2 3 3 5 )最後一個數後面也要有空格 這一道題目讓你找給定整數N的全部的質數因子。一般的人可能會考慮每一次遍歷一遍2到N的全部的整

原创 leetcode Weekly Contest 77 804. Unique Morse Code Words

International Morse Code defines a standard encodingwhere each letter is mapped to a series of dots and dashes, as foll

原创 python中的集合set

Python中set是一種無序無重複元素的數據結構,叫做集合支持&(求交),|(聯合),-(求差),^(求對稱差集)的運算大括號和set()方法可以用來創建集合,想要常見空集合必須使用set()方法而不是{}方法,後面一種方法用來創建空字

原创 leetcode Weekly Contest 77 807. Max Increase to Keep City Skyline

In a 2 dimensional array grid, eachvalue grid[i][j] representsthe height of a building located there. We are allowed to

原创 python筆記 | python中的文件操作

1.文件打開我們使用open(),函數打開一個文件,這個函數有兩個參數,第一個參數爲文件名或者是路徑,這個路徑可以是絕對路徑,也可以是相對路徑,不過假如是文件名的話,需要在當前目錄下,比如Fobj = open(“mama.txt”),F

原创 LeetCode | 300. Longest Increasing Subsequence Dp

Given an unsorted array of integers, find the length of longestincreasing subsequence.For example,Given [10, 9, 2, 5, 3

原创 python中列表的操作以及使用列表實現棧和隊列

>>> a = [1, 2, 3, 4, 5, 6]>>> a.append(45)>>> a[1, 2, 3, 4, 5, 6,45]首先我們建立了一個列表 a。然後調用列表的方法 a.append(45) 添加元素 45 到列表末尾。

原创 複數類n次方原理以及C#代碼實現

完整代碼下載https://download.csdn.net/download/u012737193/10359608我們這裏將複數類表示爲complx = real + imag * i那麼要如何計算complex ^ n呢,這裏的n

原创 優化算法 | 灰色預測模型算法GM(1,1)流程分析

灰色預測模型(Gray Forecast Model)是通過少量的、不完全的信息,建立數學模型並做出預測的一種預測方法灰色預測模型適用於小樣本,含有不確定性因素的系統首先,假如給定一組數據X1={x11,x12,x13…x1n},你需要預