![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
力扣刷题
文章平均质量分 55
力扣刷题
lyw4631
这个作者很懒,什么都没留下…
展开
-
【1】两数之和
题目地址 https://leetcode-cn.com/problems/two-sum/ 暴力解决 class Solution { public int[] twoSum(int[] nums, int target) { int[] answerArr = new int[2]; for (int i = 0; i < nums.length; i++) { for (int j = i + 1; j < nums.leng原创 2022-03-27 18:13:35 · 444 阅读 · 0 评论 -
寻找数组的中心索引
数组和字符串寻找数组的中心索引 寻找数组的中心索引 原题地址:寻找数组的中心索引 给定一个整数类型的数组 nums,请编写一个能够返回数组 “中心索引” 的方法。 我们是这样定义数组 中心索引 的: 数组中心索引的左侧所有元素相加的和等于右侧所有元素相加的和。 如果数组不存在中心索引,那么我们应该返回 -1。如果数组有多个中心索引,那么我们应该返回最靠近左边的那一个。 示例 1: 输入: nums = [1, 7, 3, 6, 5, 6] 输出:3 解释: 索引 3 (nums[3] = 6) 的左侧数之原创 2020-11-30 10:48:15 · 77 阅读 · 0 评论