leetcode伪代码-maximum-product-of-two-elements-in-an-array:数组中两个元素的最大乘积

时间:2021-06-30 19:58:26
【文件属性】:
文件名称:leetcode伪代码-maximum-product-of-two-elements-in-an-array:数组中两个元素的最大乘积
文件大小:3KB
文件格式:ZIP
更新时间:2021-06-30 19:58:26
系统开源 leetcode伪代码maximum-product-of-two-elements-in-an-array 题目解读: 题目来源: 原文: Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1). 解读: 给定一个正整数阵列nums, 任意选两个index i,j 求出最大值的(nums[i]-1)* (nums[j]-1) 初步解法: 初步观察: 首先因为都是正整数 所以知道任意正整数a, b, a * b的值跟a,b值为正相关 a,b 值越大则a * b 值越大 所以这题相当于是在找寻阵列最大的两个值 初步设计: Given a integer array nums Step 0: let i = 0, max = 0, secondMax = 0 Step 1: if i >= len(nums) go to step 4 Step 2: if
【文件预览】:
maximum-product-of-two-elements-in-an-array-master
----maxProduct_test.go(644B)
----maxProduct.go(282B)
----README.md(3KB)
----.gitignore(269B)

网友评论