【LeetCode從零單刷】Single Number,leetcodesingle沒錯我就是伍聲2009的粉絲,從今天起,模仿《從零單排》系列,菜雞單刷LeetCode!題目:Given an array of integers, every element appears twice except for one. Find that single one.解答:其實就是找不同。這題需要一個比較trick的思路:位元運算。試想,任何兩個相同的數,進行異或操作答案是啥?是0. 4^8
LeetCode Subsets,leetcodesubsetsGiven a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,If S = [1,2
LeetCode OJ Number of Islands,leetcodeojGiven a 2d grid map of '1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all
[LeetCode] Min Stack Min Stack,leetcodeminstackMin StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() --
兩種快速排序演算法效能的比較,排序演算法效能先來看看第一種快速排序演算法(QuickSort1):#include <iostream>#include <fstream>#include <ctime>#define MAXNUM 1024using namespace std;void QuickSort(int A[], int low, int high){if(low>=high)return;int first = low;int last
URAL 1928 1962 1939 1994,ural1939 XGG BlogURAL1928 Another Ecology ProblemURAL1962 In Chinese RestaurantURAL1939 First SealURAL1994 The Emperor’s planURAL1928 Another Ecology ProblemLet dp[n][centra][0] be the maximum money the centra can get
Number of Islands,numberofislandsGiven a 2d grid map of '1's (land) and'0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges