原创 leetcode 125. Valid Palindrome | 迴文string

Description Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring

原创 leetcode 121. Best Time to Buy and Sell Stock | 最大差值和最大子序列關係

Descrpition Say you have an array for which the ith element is the price of a given stock on day i. If you were onl

原创 【LDA|ML】西瓜書習題3.4

from XiguaData import * import numpy as np x, d = load_data_3d0a() # 已知西瓜數據3.0a前8個分類爲0,其餘分類爲1 x0 = x[:8] d0 = d[:8] x

原创 【python|ML】k-fold/leave-one-out 方法在對率迴歸實現(西瓜書習題3.4,數據UCI-iris)

# 經驗:梯度下降要讓目標確實減小(或者增大),此程序tempsum需要減小,故要着重檢查!! import numpy as np def dlhg(x, d): x = np.c_[x, np.ones(d.shape[

原创 [京東面試問題] 求n=100w個數裏面的前k=100個

# 基本思路   最複雜的方法莫過於全部排序, 複雜度nlgn. 結合求100w個數裏面最大的一個數(即求max), 不需全排序, 只需開一個變量, 遍歷一次記錄最大值即可.那麼很自然的想到, 求前k個就是開一個k大小的數組, 把歷史最大

原创 leetcode 205. Isomorphic Strings | str中字母計數(dict)與定位

Description Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters i

原创 leetcode 242. Valid Anagram | Map

# Description Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "an

原创 leetcode 202. Happy Number | 循環檢測

Description Write an algorithm to determine if a number is “happy”. A happy number is a number defined by the following

原创 leetcode 204. Count Primes

Description Count the number of prime numbers less than a non-negative number, n. My solution 原始方案 比較樸素的想法就是迭代的找下去, 然

原创 leetcode 167. Two Sum II - Input array is sorted

Descrpition Given an array of integers that is already sorted in ascending order, find two numbers such that they add u

原创 leetcode 234. Palindrome Linked List

Reversing a list is not considered “O(1) space” It is a common misunderstanding that the space complexity of a prog

原创 leetcode 203. Remove Linked List Elements | 遞歸的更多理解

Description Remove all elements from a linked list of integers that have value val. Example Given: 1 –> 2 –> 6 –> 3 –>

原创 leetcode 225. Implement Stack using Queues

Description Implement the following operations of a stack using queues. push(x) – Push element x onto stack. pop() – R

原创 leetcode 168. Excel Sheet Column Title | 進制轉化

Description Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1