Trapping Rain Water
Trapping Rain WaterProblem DescriptionGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Approach: Two PointersIntuitionThe key insight is that at any position, the water level is dtermined the minimum of the maximum heights to its left and right. We can use two pointers moving towards each other from both ends. Algorithm Initialize two pointer left and right at the beginning and each of the array. Ke...
Number of Visible People in a Queue
Number of Visible People in a Queue題目敘述There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] represents the height of the i person. A person can see another person to their right in the queue if everybody in between is shorter than both of them. More formally, the ith person can see the j person if i < j and min(heights[i], heights[j]) > max(heights[i+1], heights[i+2], ..., h...
K8s Development Tool
Kubernetes 是現在最常被使用的容器編排平台 (container orchestration platform),對於想要在 local 環境開發的開發者,選擇一套能夠模擬 Kubernetes 行為的工具,來進行本地的測試開發,變得越來越重要。 像是 Kind 和 Minikube 等工具就提供了方便的解決方式。該篇文章中會提及每一種工具所著重的地方在哪裡,而我們需要根據怎樣的情景選擇對應的工具進行開發。 接下來針對以下四套不同的開源軟體 kind, Minikube, k3s, kubeadm 進行介紹 kind 介紹 kind is a tool for running local Kubernetes clusters using Docker container “nodes”. kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI. kind 是 Kubernetes 底下的一個子專案,他的全名是 Kube...
Word Break
Word Break題目敘述Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the segmentation. Example1Input: s = “leetcode”, wordDict = [“leet”,”code”]Output: trueExplanation: Return true because “leetcode” can be segmented as “leet code”. Example 2:Input: s = “applepenapple”, wordDict = [“apple”,”pen”]Output:...
Longest Common Subsequence
Longest Common Subsequence題目敘述Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0. DefinitionsSubsequenceA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters. For example, “ace” is a subsequence of “abcde”. Common SubsequenceA common subsequence of two strings is a subsequence that...