From 4b8249e57f10097759da0f0f6da5c1da31736ac2 Mon Sep 17 00:00:00 2001
From: 3119005212 <1136153224@qq.com>
Date: Tue, 11 May 2021 20:06:47 +0800
Subject: [PATCH] =?UTF-8?q?lc=20153,=20102=E6=8F=90=E4=BA=A4cpp=E4=BB=A3?=
 =?UTF-8?q?=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ...04\346\234\200\345\260\217\345\200\274.md" | 26 +++++++++++++++++
 ...11\346\240\221\345\237\272\347\241\200.md" | 29 +++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git "a/animation-simulation/\344\272\214\345\210\206\346\237\245\346\211\276\345\217\212\345\205\266\345\217\230\347\247\215/leetcode153\346\220\234\347\264\242\346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\345\200\274.md" "b/animation-simulation/\344\272\214\345\210\206\346\237\245\346\211\276\345\217\212\345\205\266\345\217\230\347\247\215/leetcode153\346\220\234\347\264\242\346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\345\200\274.md"
index b1c75c1..7e165f4 100644
--- "a/animation-simulation/\344\272\214\345\210\206\346\237\245\346\211\276\345\217\212\345\205\266\345\217\230\347\247\215/leetcode153\346\220\234\347\264\242\346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\345\200\274.md"
+++ "b/animation-simulation/\344\272\214\345\210\206\346\237\245\346\211\276\345\217\212\345\205\266\345\217\230\347\247\215/leetcode153\346\220\234\347\264\242\346\227\213\350\275\254\346\225\260\347\273\204\347\232\204\346\234\200\345\260\217\345\200\274.md"
@@ -60,6 +60,8 @@
 
 **题目代码**
 
+Java Code:
+
 ```java
 class Solution {
     public int findMin(int[] nums) {
@@ -85,3 +87,27 @@ class Solution {
 }
 ```
 
+C++ Code:
+
+```cpp
+class Solution {
+public:    
+    int findMin(vector <int> & nums) {
+        int left = 0;
+        int right = nums.size() - 1;
+        while (left < right) {
+            if (nums[left] < nums[right]) {
+                return nums[left];
+            } 
+            int mid = left + ((right - left) >> 1);
+            if (nums[left] > nums[mid]) {
+                right = mid;
+            } else {
+                left = mid + 1;
+            }
+        }
+        return nums[left];
+    }
+};
+```
+
diff --git "a/animation-simulation/\344\272\214\345\217\211\346\240\221/\344\272\214\345\217\211\346\240\221\345\237\272\347\241\200.md" "b/animation-simulation/\344\272\214\345\217\211\346\240\221/\344\272\214\345\217\211\346\240\221\345\237\272\347\241\200.md"
index 9185561..8bfe660 100644
--- "a/animation-simulation/\344\272\214\345\217\211\346\240\221/\344\272\214\345\217\211\346\240\221\345\237\272\347\241\200.md"
+++ "b/animation-simulation/\344\272\214\345\217\211\346\240\221/\344\272\214\345\217\211\346\240\221\345\237\272\347\241\200.md"
@@ -350,6 +350,8 @@ class Solution {
 
 **测试题目: leetcode 102 二叉树的层序遍历**
 
+Java Code:
+
 ```java
 class Solution {
     public List<List<Integer>> levelOrder(TreeNode root) {
@@ -378,6 +380,33 @@ class Solution {
 }
 ```
 
+C++ Code:
+
+```cpp
+class Solution {
+public:
+    vector<vector<int>> levelOrder(TreeNode* root) {
+      vector<vector<int>> res;
+      if (!root) return res; 
+      queue<TreeNode *> q;
+      q.push(root);
+      while (!q.empty()) {
+          vector <int> t;
+          int size = q.size();
+          for (int i = 0; i < size; ++i) {
+              TreeNode * temp = q.front();
+              q.pop();
+              if (temp->left != nullptr)  q.push(temp->left);
+              if (temp->right != nullptr) q.push(temp->right);
+              t.emplace_back(temp->val);
+          }
+          res.push_back(t);
+      }
+      return res;
+    }
+};
+```
+
 时间复杂度:O(n) 空间复杂度:O(n)
 
 大家如果吃透了二叉树的层序遍历的话,可以顺手把下面几道题目解决掉,思路一致,甚至都不用拐弯