当前位置:网站首页>Résumé de la méthode de déduction de la force 513 - trouver la valeur du coin inférieur gauche de l'arbre
Résumé de la méthode de déduction de la force 513 - trouver la valeur du coin inférieur gauche de l'arbre
2022-06-23 14:57:00 【L'été perdu】
Liens vers les répertoires:
Question de programmation de la boucle de force-Résumé de la solution_Partager+Enregistrement-CSDNBlogs
GitHubSynchroniser les éléments de brosse:
https://github.com/September26/java-algorithms
Lien vers la question originale:Boucle de force
Description:
Compte tenu d'un arbre binaire Noeud racine root,S'il vous plaît, trouvez l'arbre binaire En bas À gauche. Valeur du noeud.
Supposons qu'il y ait au moins un noeud dans l'arbre binaire.
Exemple 1:
Entrée: root = [2,1,3]
Produits: 1
Exemple 2:
Entrée: [1,2,3,4,null,5,6,null,null,7]
Produits: 7
Conseils:
La plage de nombre de noeuds dans l'arbre binaire est [1,104]
-231 <= Node.val <= 231 - 1
Source::Boucle de force(LeetCode)
Liens:https://leetcode.cn/problems/find-bottom-left-tree-value
Le droit d'auteur est la propriété du réseau de saisie.Pour les réimpressions commerciales, veuillez contacter l'autorisation officielle,Reproduction non commerciale Veuillez indiquer la source.
Comment résoudre le problème:
* Comment résoudre le problème: * Peut être résolu de manière séquentielle pratique , Prenez le plus bas list Le premier noeud de
Code:
public class Solution513 {
public int findBottomLeftValue(TreeNode root) {
List<TreeNode> list = new ArrayList<>();
list.add(root);
TreeNode treeNode = levelSearch(list);
return treeNode.val;
}
private TreeNode levelSearch(List<TreeNode> list) {
List<TreeNode> nextList = new ArrayList<>();
for (TreeNode node : list) {
if (node.left != null) {
nextList.add(node.left);
}
if (node.right != null) {
nextList.add(node.right);
}
}
if (nextList.size() == 0) {
return list.get(0);
}
return levelSearch(nextList);
}
}边栏推荐
- 系统设计与分析课程项目个人小结
- Self inspection is recommended! The transaction caused by MySQL driver bug is not rolled back. Maybe you are facing this risk!
- 百万奖金等你来拿,首届中国元宇宙创新应用大赛联合创业黑马火热招募中!
- Hot Recruitment! The second Tencent light · public welfare innovation challenge is waiting for you to participate
- 分布式数据库使用逻辑卷管理存储之扩容
- Gold three silver four, busy job hopping? Don't be careless. Figure out these 12 details so that you won't be fooled~
- 【深入理解TcaplusDB技術】TcaplusDB構造數據
- Problems during MySQL uninstallation
- 【云驻共创】制造业企业如何建设“条码工厂”
- Binding events of wechat applet in wx:for
猜你喜欢

2021-06-03

An idea plug-in for automatically generating unit tests

Technology sharing | do you understand the requirements of the tested project?

掌舵9年,艾伦研究所创始CEO光荣退休!他曾预言中国AI将领跑世界

2021-04-15

中国矿大团队,开发集成多尺度深度学习模型,用于 RNA 甲基化位点预测

The largest IPO of Hong Kong stocks this year, with a net worth of 66billion, is the "King" sitting on the mine

The first public available pytorch version alphafold2 is reproduced, and Columbia University is open source openfold, with more than 1000 stars

Babbitt | metauniverse daily must read: meta, Microsoft and other technology giants set up the metauniverse Standards Forum. Huawei and Alibaba joined. NVIDIA executives said that they welcomed partic

2021-05-22
随机推荐
中国矿大团队,开发集成多尺度深度学习模型,用于 RNA 甲基化位点预测
大厂架构师:如何画一张大气的业务大图?
Hot Recruitment! The second Tencent light · public welfare innovation challenge is waiting for you to participate
Introduction to helm basics helm introduction and installation
2022 ICT market in China continues to rise and enterprise digital infrastructure is imperative
Distributed database uses logical volume to manage storage expansion
首个大众可用PyTorch版AlphaFold2复现,哥大开源OpenFold,star量破千
去 OPPO 面试, 被问麻了。。。
Selenium Edge的IE模式
建議自查!MySQL驅動Bug引發的事務不回滾問題,也許你正面臨該風險!
golang--判断字符串是否相等
HCIA network foundation
2021-04-15
2021-06-03
[datahub] LinkedIn datahub learning notes
ts封装请求
小米为何深陷芯片泥潭?
Test article
WPF (c) new open source control library: newbeecoder UI waiting animation
Analysis and solution of connection failure caused by MySQL using replicationconnection