![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构每日一练
菜鸡编程人
一个莫得感情的菜鸡初学者
展开
-
二分查找代码
二分查找原理 参数:顺序表 待查关键字 二分查找是基于顺序存储结构的一种高效的查找方式,也称折半查找; 顾名思义折半查找就是每次都将顺序表截取为当前的一半 具体代码如下 public class Binary_Search { int binarySearch(int list[], int low, int hign, int key) { if (list == null) { return -1; } while (l原创 2020-11-28 18:46:00 · 475 阅读 · 0 评论 -
每日一题之重新排列数组
给你一个数组 nums ,数组中有 2n 个元素,按 [x1,x2,…,xn,y1,y2,…,yn] 的格式排列。 请你将数组按 [x1,y1,x2,y2,…,xn,yn] 格式重新排列,返回重排后的数组。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/shuffle-the-array 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 public class Solution2 { public static int[原创 2020-11-19 22:50:00 · 198 阅读 · 0 评论 -
每日一题之两数相加
本文是刷力扣题库需要的进车道: https://leetcode-cn.com/ 1.两数相加 1.两次for循环 给定一个整数数组 nums 和一个目标值target,请你在该数组中找出和为目标值的那两个整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。 public class Demo10 { public static int[] twoSum(int[] nums, int target) { //创建一个数组,用原创 2020-11-18 22:24:56 · 116 阅读 · 0 评论