原创 LeetCode 463: Island Perimeter(島嶼周長)
問題描述: You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Gri
原创 LeetCode 344: Reverse String (字符串翻轉)
Write a function that takes a string as input and returns the string reversed. Example: Given s = "hello", return "ol
原创 LeetCode 496: Next Greater Element I (下一個大的元素)
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all th
原创 LeetCode 136:Single Number(異或操作)
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm sh
原创 LeetCode 292:Nim Game(尼姆遊戲)
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you
原创 LeetCode 485:Max Consecutive Ones(連續1的最大個數,邊界條件)
Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: 設置兩個變量cons和max,分別用來統計
原创 CentOS上安裝 gcc-7
使用工具包devtoolset-7 下載工具包devtoolset-7 yum install devtoolset-7 yum install devtoolset-7-gcc-c++ yum install devtoolset
原创 解決MacOS升級後出現xcrun: error: invalid active developer path, missing xcrun的問題
今天升級macos mojave後,終端使用gcc時,彈出一行莫名其妙的錯誤 解決方法,重裝xcode command line: xcode-select --install 如果沒有解決,執行以下命令: sudo xcode-s
原创 LeetCode 599. Minimum Index Sum of Two Lists(map,unordered_map)
Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants repr
原创 LeetCode 283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the no
原创 LeetCode 349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2,
原创 LeetCode 404. Sum of Left Leaves(二叉樹)
Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are
原创 LeetCode 383. Ransom Note
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function
原创 LeetCode 389. Find the Difference(異或)
Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string
原创 LeetCode 448. Find All Numbers Disappeared in an Array(查找數組中沒有出現的數字)
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.