# [Golang][Leetcode][Array]刷題系列-704-Binary Search

704. Binary Search Level : Easy 原題連結 :Click 題目 : Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1. You must write an algorithm with O(log n) runtime complexity. Example : Note Input: nums = [-1,0,3,5,9,12], target = 9 Output: 4 Explanation: 9 exists in nums and its index is 4

# [Golang][Leetcode][Array]刷題系列-16-Two Pointers

16. 3Sum Closest Level : Medium 原題連結 :Click 題目 : Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example : Note Input: nums = [-1,2,1,-4], target = 1 Output: 2 Explanation: The sum that is closest to the target is 2.

# [Golang][Leetcode][Array]刷題系列-15-Two Pointers

15. 3Sum Level : Medium 原題連結 :Click 題目 : Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets. Example : Note Input: nums = [-1,0,1,2,-1,-4] Output: [[-1,-1,2],[-1,0,1]] 解題思路 : 這個題目需要考慮的事情: 他不能有重複的組合出現 他回傳的是value本身不是index 根據以上原因，使用two pointers的解法較為方便，他有點像第11題的Container的問題，就是不斷縮小範圍 所以我們需要先將nums array先做排序(小到大) 接下來，由於不能有重複所以我們設定base, low, high，sum = base + high + low，讓所有元素除了最後兩個都當一輪base 那 high 跟 low 呢?

# [Golang][Leetcode][Array]刷題系列-11-Two Pointers

11. Container With Most Water Level : Medium 原題連結 :Click 題目 : Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.

# 理解 Dynamic Programming 3 - 用 連續矩陣相乘 例子來了解(未完成)

Dynamic Programming - 解決連續矩陣相乘效率問題 這次要來討論的案例是連續矩陣相乘 !! 此案例的前景知識 大家都知道矩陣(matrix)之間相乘是不滿足交換律的 也就是說 Assume there are a “matrix A” and a “matirx B” A x B 不等於 B x A， 平常數字的所滿足的 3 x 4 = 4 x 3 = 12 ，在矩陣的世界是不能用的 舉例 假設矩陣A為 p0 X p1 的矩陣， 矩陣B為 p1 X p2的矩陣，由上圖得知 p0 = 2， p1 = 3， p2 = 2 矩陣A為 2 (row) X 3 (column) 乘以 矩陣B為 3 (row) X 2 (column) 會得到一個 2 X 2 的矩陣C