
必会算法
weixin_42246923
这个作者很懒,什么都没留下…
展开
-
搜索旋转数组
LeetCode 33 仅旋转一次,数字之间不相等class Solution { public int search(int[] arr, int target) { int left = 0; int right = arr.length - 1; while (left <= right) { int mid = (left + right) / 2; if (arr[mid] == t原创 2021-04-27 19:46:25 · 58 阅读 · 0 评论 -
二叉树前序遍历
非递归前序遍历class Solution { public List<Integer> preorderTraversal(TreeNode root) { List<Integer> res = new ArrayList<Integer>(); if (root == null) { return res; } Deque<TreeNode> stac原创 2020-10-27 23:07:56 · 62 阅读 · 0 评论