当前位置:网站首页>P7 Alibaba Interview Questions 2020.07 Sliding Window Algorithm (Alibaba Cloud Interview)
P7 Alibaba Interview Questions 2020.07 Sliding Window Algorithm (Alibaba Cloud Interview)
2022-08-09 06:33:00 【In the history of the strongest disciple】
The problem is that the numbers in a data may be positive and negative integers. Find the maximum value of the sum of n consecutive numbers.
In fact, it is the maximum value in the double pointer sliding recording cycle.
Implementation:
import java.math.BigDecimal;public class Test9 {/*public double test(Double x,int flage){double returnData = 0.0;double x1 = 0;double x2 = x;double point = ;while(new BigDecimal(x).)return returnData;}*//*public int test(int[] arr){int maxtotal = 0;for(int i = 0;isumTotalMax){sumTotalMax = sumTotal+arr[j];}sumTotal=sumTotal+arr[j];}if(sumTotalMax>maxtotal){maxtotal = sumTotalMax;}}return maxtotal;}*/public int test(int[] arr){int maxtotal = 0;for(int i = 0;isumTotalMax){sumTotalMax = sumTotal+arr[j];}sumTotal=sumTotal+arr[j];}if(sumTotalMax>maxtotal){maxtotal = sumTotalMax;}}return maxtotal;}public static void main(String[] args) {Test9 test9 = new Test9();int[] arr = {-2,11,-4,13,-5,2};System.out.println(test9.test(arr));}}
边栏推荐
- uniapp实现防抖搜索
- C# 利用iTextSharp画PDF
- MongDb的查询方式
- Introduction of convenient functions and convenient shortcut keys of vs tomato assistant
- Unity Gobang Game Design and Simple AI (2)
- 力扣刷题180
- AD画PCB板教程 20分钟讲清楚操作流程 铺铜 网络标号
- Deep Learning - Principles of Neural Networks 2
- SIGINT,SIGKILL,SIGTERM信号区别,各类信号总结
- 中英文说明书丨TRC 交替醇(Catalogue NumberA575760)
猜你喜欢
推进产教融合 赋能教育创新发展 | 华云数据荣获“企业贡献奖”
[GO], arrays and slices
C语言实现顺序栈和链队列
中英文说明书丨TRC D-阿卓糖(D-Altrose)
Unity 五子棋游戏设计和简单AI(2)
输入框最前面添加放大镜&&background-image和background-color冲突问题
CMake中INSTALL_RPATH与BUILD_RPATH问题
变压器的工作原理(图解,原理图讲解,一看就懂)
2022-08-08: Given an array arr, it represents the height of the missiles that will appear in order from morning to night.When the cannon shoots missiles, once the cannon is set to shoot at a certain h
Invalid argument(s) appears when redis runs lua script
随机推荐
使用百度EasyDL实现智能垃圾箱
leetcode 之盛水问题
Excel受保护的工作表怎么操作?
Fragments
IQ Products CMV Brite Turbo试剂盒的原理
VS2019常用快捷键
io.lettuce.core.RedisCommandTimeoutException Command timed out
Qt 学习(三) —— Qt 模块
Flask failed to create database without error
.NET高级技术
运算放大器(OPA)超详细参数讲解-运放---以及8个型号的运算放大器分析对比
db.sqlite3 has no "as Data Source" workaround
idea中PlantUML插件使用
Introduction of convenient functions and convenient shortcut keys of vs tomato assistant
报错:flask: TypeError: ‘function‘ object is not iterable
单例模式
05 多线程与高并发 - ThreadPoolExecutor 源码解析
Output method of list string print(*a) print(““.join(str(c) for c in a) )
Unity Gobang Game Design and Simple AI (2)
Service