Loading

文章分类 -  算法

算法
摘要:二叉树的层序遍历-广度优先搜索二叉树的层序遍历-广度优先搜索 class Solution { public List<List<Integer>> levelOrder(TreeNode root) { if(root == null){ return null; } List<List<Integer>> list = ne 阅读全文
posted @ 2023-09-25 09:56 花园SON 阅读(11) 评论(0) 推荐(0)
摘要:常见排序算法常见排序算法 冒泡 /** * 冒泡排序 时间复杂度 */ public static void sort1(int[] nums) { for (int i = 0; i < nums.length - 1; i++) { for (int j = 0; j < nums.length - i - 阅读全文
posted @ 2023-09-24 11:23 花园SON 阅读(9) 评论(0) 推荐(0)
摘要:二叉树的前序,中序,后序遍历class Solution { /** * 前序遍历 中 左 右 */ public List<Integer> preorderTraversal(TreeNode root) { List<Integer> result = new ArrayList<Integer>(); preorder 阅读全文
posted @ 2023-09-23 09:26 花园SON 阅读(11) 评论(0) 推荐(0)
摘要:反转链表/** * 翻转链表非递归 */ public ListNode q1(ListNode head){ ListNode left =null; ListNode right =head; ListNode right2=head; while(right!=null){ right2 = righ 阅读全文
posted @ 2023-09-22 11:10 花园SON 阅读(7) 评论(0) 推荐(0)