原创 頭條面試題-統計有序數組裏平方和的數目

給你一個有序整數數組,數組中的數可以是正數、負數、零,請實現一個函數,這個函數返回一個整數:返回這個數組所有數的平方值中有多少種不同的取值。舉例: nums = {-1,1,1,1}, 那麼你應該返回的是:1。因爲這個數組所有數

原创 [leetcode-in-go] 0056-Merge Intervals

Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Ou

原创 [leetcode-in-go] 0055-Jump Game

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element

原创 vscode golang 開發環境搭建

下載安裝 vscode 見官網:https://code.visualstudio.com/#alt-downloads 下載安裝 golang 見官網:https://golang.google.cn/dl/ 安裝配

原创 [leetcode-in-go] 0149-Max Points on a Line

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 記錄一種 n^2 解法: 掌

原创 [leetcode-in-go] 0151-Reverse Words in a String

Given an input string, reverse the string word by word. Example 1: Input: “the sky is blue” Output: “blue is sky th

原创 [leetcode-in-go] 0057-Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may as

原创 [leetcode-in-go] 0146-LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operatio

原创 [leetcode-in-go] 0054-Spiral Matrix

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example 1:

原创 [leetcode-in-go] 0058-Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ’ ', return the length of last w

原创 [leetcode-in-go] 0052-N-Queens II

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each oth

原创 [leetcode-in-go] 0069-Sqrt(x)

Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative inte

原创 [leetcode-in-go] 0009-Palindrome Number

Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward

原创 [leetcode-in-go] 0047-Permutations II

Given a collection of numbers that might contain duplicates, return all possible unique permutations. Example: Inpu

原创 [leetcode-in-go] 0046-Permutations

Given a collection of distinct integers, return all possible permutations. Example: Input: [1,2,3] Output: [ [1,2,3