原创 【Leetcode】1078. Occurrences After Bigram(第140周賽)(字符串處理)

Given words first and second, consider occurrences in some text of the form "first second third", where second comes im

原创 【劍指offer】棧的壓入、彈出序列(Python中List模擬棧隊列操作)

題目描述 輸入兩個整數序列,第一個序列表示棧的壓入順序,請判斷第二個序列是否可能爲該棧的彈出順序。假設壓入棧的所有數字均不相等。例如序列1,2,3,4,5是某棧的壓入順序,序列4,5,3,2,1是該壓棧序列對應的一個彈出序列,但4,3,5

原创 【Leetcode】1079. Letter Tile Possibilities(第140周賽)(字符串全排列)

You have a set of tiles, where each tile has one letter tiles[i] printed on it.  Return the number of possible non-empt

原创 【Leetcode】234. Palindrome Linked List(BN的遞歸)(判斷迴文鏈表)

Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1

原创 【Leetcode】342. Power of Four(二進制計算)(判定是否爲4的冪次方)

Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example 1: Input: 16 Output:

原创 【劍指offer】鏈表找環的入口

給一個鏈表,若其中包含環,請找出該鏈表的環的入口結點,否則,輸出null。   解題思路: 在鏈表判環的基礎上進行優化 追擊問題,一快一慢可以再環中相遇 p1=p1.next; p2=p2.next.next 那麼如何找到環的入口 針對

原创 【Python】pandas合併多個CSV表,去重表頭

我們有三個子表,每個表都有表頭但是沒有每行的索引,每一個表在csv文件中結構如下: name,age x,65 y,77 z,10 通過Pandas打開 data = pd.read_csv(r'test.csv'),默認會加上行索引,

原创 【劍指offer】數字在排序數組中出現的次數

統計一個數字在排序數組中出現的次數。 解題思路: 遍歷查找不是本題的最優解,既然給出的是有序數組,所以我們只需要找到目標的左側和右側的索引即可。所以我們可以找到本數組當中key+0.5和key-0.5的位置即可得到次數,二分查找將減少時間

原创 [LeetCode]1138. Alphabet Board Path(第147週週賽)(模擬)

On an alphabet board, we start at position (0, 0), corresponding to character board[0][0]. Here, board = ["abcde", "fgh

原创 【Leetcode】454. 4Sum II(算法時間複雜度)

Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C

原创 【Leetcode】1123. Lowest Common Ancestor of Deepest Leaves(二叉樹最深葉子結點的公共父節點)

Given a rooted binary tree, return the lowest common ancestor of its deepest leaves. Recall that: The node of a binary

原创 【Leetcode】524. Longest Word in Dictionary through Deleting(最長子序列)

Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some c

原创 【Leetcode】378. Kth Smallest Element in a Sorted Matrix(第k個大的數)(容器)

Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in

原创 【Leetcode】1109. Corporate Flight Bookings(第144週週賽)(線段樹模版題)

There are n flights, and they are labeled from 1 to n. We have a list of flight bookings.  The i-th booking bookings[i]

原创 【Leetcode】455. Assign Cookies(貪心思想)

Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most o