再寫循環隊列 class MyCircularQueue {
public:/** Initialize your data structure here. Set the size of the queue to be k. */MyCircularQueue(int k) {array (int *)malloc(sizeof(int)*k);capacity k;size 0;front 0;rear 0;}/** Insert an element into the circu…
前序遍歷 /*** Definition for a binary tree node.* struct TreeNode {* int val;* struct TreeNode *left;* struct TreeNode *right;* };*//*** Note: The returned array must be malloced, assume caller calls free().*/
int *array;
int size;void _preorde…
錯誤:[rootlocalhost ~]# systemctl start mariadb.service Job for mariadb.service failed because the control process exited with error code. See “systemctl status mariadb.service” and “journalctl -xe” for details.
解決辦法:
[rootl…
平衡二叉樹 /*** Definition for a binary tree node.* struct TreeNode {* int val;* struct TreeNode *left;* struct TreeNode *right;* };*/int MAX(int a,int b)
{return a > b ? a : b;
}//求高度
int getHeight(struct TreeNode *root){if(root NULL){…
前序中序遍歷構造二叉樹 思路
在前序中找根結點根據根結點 中序,分成左右兩棵子樹根據子樹長度,把前序分成左右兩顆子樹遞歸處理子樹
/*** Definition for a binary tree node.* struct TreeNode {* int val;* struct TreeNode *left;* s…