【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() --
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