226. Invert Binary Tree--LeetCode Record
/**
* Definition for a binary tree node.
* public class TreeNode {
* public var val: Int
* public var left: TreeNode?
* public var right: TreeNode?
* public init(_ val: Int) {
* self.val = val
* self.left = nil
* self.right = nil
* }
* }
*/
class Solution {
func invertTree(root: TreeNode?) -> TreeNode? {
if root == nil {
return nil
}
let swapNode = invertTree(root?.left)
root?.left = invertTree(root?.right)
root?.right = swapNode
return root
}
}
相關文章
- Leetcode 226. Invert Binary TreeLeetCode
- [LeetCode] 226. Invert Binary TreeLeetCode
- 104. Maximum Depth of Binary Tree--LeetCode RecordLeetCode
- LeetCode Invert Binary TreeLeetCode
- 100. Same Tree--LeetCode RecordLeetCode
- Leetcode226.翻轉二叉樹 Invert Binary Tree(Java)LeetCode二叉樹Java
- react-recordReact
- Daily record-SeptemberAI
- 實戰 Java 16 值型別 Record - 2. Record 的基本用法Java型別
- pl/sql record 詳解SQL
- delete duplication record in sql serverdeleteSQLServer
- oracle plsql(一)_binary_float_binary_doubleOracleSQL
- Java 16 新特性:record類Java
- Erlang中的Record詳解
- 淺析 record 使用場景
- Record It for Mac錄屏軟體Mac
- Java 21 新特性:Record PatternsJava
- 脫離rails 使用Active RecordAI
- Homework record-Simple sorting
- gorm忽略報錯: record not foundGoORM
- Convert string to binary and binary to string in C#C#
- MySQL Binary LogMySql
- SIRF binary protocolProtocol
- Binary Colouring
- Warning:dns_get_record():AtemporaryservererroroccurredDNSServerError
- Record for Individual Project ( Word frequency program )Project
- Using Statspack to Record Explain Plan DetailsAI
- record:記錄(帶名元組)
- 不好分類的好題Record
- Camera List Record - 120
- Oracle Binary CloningOracle
- Mysql Binary Log (1)MySql
- Mysql Binary Log (2)MySql
- B. Quasi Binary
- 如何處理 No DMARC Record Found 問題
- supremum pseudo-record鎖影響REM
- Ext.js4.2.1 Ext.data.RecordJS
- 轉:Oracle 解鎖Record is locked by another useOracle