1.8k words 2 mins.

⭐️⭐️⭐️ # 題目敘述 Given a string s . In one step you can insert any character at any index of the string. Return the minimum number of steps to make s palindrome. A Palindrome String is one that reads the same backward as well as forward. # Example 1: Input: s = “zzazz” Output: 0 Explanation: The...
3.7k words 3 mins.

⭐️ # 題目連結 ZeroJudge 題目連結 Online Judge uDebug # 題目敘述 One of the preferred kinds of entertainment of people living in final stages of XX century is filling in the crosswords1. Almost every newspaper and magazine has a column dedicated to entertainment but only amateurs2 have enough after solving one...
4.3k words 4 mins.

C++ vector 是一個可以改變陣列大小的序列容器。C++ vector 是陣列的升級版,主要因為 vector 能高效地對記憶體進行管理以及動態增長。vector 其實就是將陣列和方法封裝形成的一個類別。 C++ 要使用 vector 容器的話,需要引入的標頭檔: <vector> # vector 初始化 這樣是宣告一個 int 整數類型的 vector,裡面沒有任何元素 (空),size 為 0 表示 vector 容器中沒有任何元素,capacity 也是 0。 #include...
1.7k words 2 mins.

⭐️ # 題目連結 ZeroJudge 題目連結 Online Judge uDebug # 題目敘述 Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. “Look, I’ve built a wall!”, he tells his older sister Alice. “Nah, you should make all stacks the same height. Then you...
2k words 2 mins.

⭐️⭐️⭐️ # 題目敘述 There is a group of n members, and a list of various crimes they could commit. The ith crime generates a profit[i] and requires group[i] members to participate in it. If a member participates in one crime, that member can’t participate in another crime. Let’s call a profitable scheme...
3.2k words 3 mins.

⭐️ # 題目連結 ZeroJudge 題目連結 Online Judge uDebug # 題目敘述 The medieval1 interest in mechanical contrivances2 is well illustrated by the development of the mechanical clock, the oldest of which is driven by weights and controlled by a verge, an oscillating3 arm engaging with a gear4 wheel. It dates back...
1.7k words 2 mins.

⭐️ # 題目連結 ZeroJudge 題目連結 Online Judge uDebug # 題目敘述 #include <stdio.h> main() { int i; char *suffix[]= { “st”, “nd”, “rd” }; char *item[]= { “Unix” , “cat”, “sed”, “awk”, “grep”, “ed”, “vi”}; printf(“In the beginning, there was nothing.\n”); for (i= 0; i < 7;...
884 words 1 mins.

queue 是具有 FIFO (First In, First Out) 特性的容器配接器,應用在有先進先出的情形。 需要引入的標頭檔: <queue> # 初始化 queue #include <queue>queue<int> q;# 加入元素 把元素加進 queue 的尾部使用 push() queue<int> q;q.push(1);q.push(2);q.push(3); q = [1, 2, 3] # 取出元素 把元素從 queue 頭部取出用 pop() ,注意取出會將該元素從 queue...
2.3k words 2 mins.

⭐️⭐️ # 題目敘述 Given the root of a binary tree, return the maximum width of the given tree. The maximum width of a tree is the maximum width among all levels. The width of one level is defined as the length between the end-nodes (the leftmost and rightmost non-null nodes), where the null nodes between...
2.4k words 2 mins.

C++ set 是一個關聯式容器, set 容器裡面的元素是唯一的,具有不重複的特性,而且是有排序的容器, set 容器裡面元素的值是不可修改,但 set 容器可以插入或刪除元素, set 的實作方式通常是用紅黑樹 (red-black tree) 實作的。 # set 初始化 C++ set 初始化用法如下, 需要引入 include<set> 標頭檔 set<int> st{1, 2, 3, 4, 5};從 c-style 陣列來初始化 int arr[] = {1, 2, 3, 4,...