原创 LeetCode 90. Subsets II 遞歸
Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). No
原创 二叉樹的遍歷 迭代 LeetCode 94 144 145
這裏簡要介紹一下樹的迭代方式遍歷 前序遍歷 leetcode 94 使用棧來模擬遞歸,出棧時候訪問結點。前序遍歷先訪問左子樹,再訪問右子樹,那麼入棧時相反,即先入右子樹,再入左子樹。那麼出棧的時候就是前序遍歷的順序。 cla
原创 LeetCode 96. Unique Binary Search Trees 1&2
Given n, how many structurally unique BST’s (binary search trees) that store values 1…n? For example, Given n =
原创 LeetCode 93. Restore IP Addresses 遞歸,分治
Given a string containing only digits, restore it by returning all possible valid IP address combinations. For exa
原创 數據結構 鏈表知識及常用操作(Java)
先說一下線性表。 線性表:在邏輯上,數據是連續的。線性表有兩種存儲方式:順序存儲方式和鏈式存儲方式。 數組(array):數組就是線性表的順序存儲方式。數組的內存是連續分配的,並且是靜態分配的,即在使用數組之前需要分配固定大小的
原创 LeetCode 139. Word Break 字符串 DP
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be s
原创 藍橋杯 十六進制轉八進制 字符串處理
問題描述 給定n個十六進制正整數,輸出它們對應的八進制數。 輸入格式 輸入的第一行爲一個正整數n (1<=n<=10)。 接下來n行,每行一個由0~9、大寫字母A~F組成的字符串,表示要轉換的十六進
原创 Catch That Cow POJ 3278 BFS 廣度優先搜索
很久沒有寫bfs,wa了好多發。 注意點: 1 一定要加book標記 2 當n>k的時候只能進行-1的操作 (剪枝) 3 要判斷是否越界之後再判斷是否標記過 4 不超出最大邊界 #include <iostream> #inclu
原创 LeetCode 23.Merge k Sorted List 合併k個有序鏈表(後補)
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 題目描述 講k個有序鏈表合
原创 Not Equal on a Segment CodeForces - 622C
特殊處理!學習一發 #include <bits/stdc++.h> using namespace std; const int N = 2e5+10; int pre[N]; int data[N]; int main()
原创 Sudoku Extension UVALive - 4763 搜索
題目:思路非常明確, 九宮的深搜 ,一開始寫的時候一直是wa,因爲在從當前行換到下一行的時候座標變換一直有問題,學習了大神的一個變量的深搜,然後轉換成座標的辦法。 #include <bits/stdc++.h> using na
原创 LeetCode 4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arr
原创 LeetCode 25. Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positi
原创 HDU 1584 蜘蛛牌 搜索 回溯
題目: 深度優先搜索,一張牌只能放在比它大1的牌上面,i 是當前牌,遍歷從i+1到10 ,如果有未被標記的數字,就是放的位置。我一開始想的是i只能放在i+1上,仔細一想,在順着i+1像10的遍歷過程中,我們已經標記過的數字都放在了正確的
原创 超類 子類 java核心技術第五章
繼承關係! 以manager與employee爲例子,在manager與employee之間存在明顯的關係 - 每一個manager都是employee。即“ is-a ” 關係。這是繼承關係的一個明顯特徵。 public class