当前位置:网站首页>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));}}
边栏推荐
- 为什么以太网无法接收大于1500字节的数据包?
- Adds, deletes, searches, and changes the leading doubly circular linked list (implemented in C language)
- Program Performance Analysis - Complexity Analysis
- shardingsphere数据分片配置项说明和示例
- io.lettuce.core。RedisCommandTimeoutException命令超时
- IQ Products巨细胞病毒CMV感染检测试剂盒的特征和应用
- 中英文说明书丨CalBioreagents 醛固酮单克隆抗体
- 深度学习-神经网络原理2
- [R language] Normalize and organize files into folders of various file types
- 简单工厂模式
猜你喜欢
缓存技术使用
static静态关键字和继承
[MySQL] Second, the relationship between processes, MySQL password cracking, table building and database building related commands
Altium designer软件常用最全封装库,包含原理图库、PCB库和3D模型库
【Feel】In the Unity Feel plugin, Camera cannot display CameraShake correctly
Teach you how to make the Tanabata meteor shower in C language - elegant and timeless (detailed tutorial)
Integer 线程安全的
vs番茄助手的方便功能和便捷快捷键介绍
Use of PlantUML plugin in idea
Use baidu EasyDL intelligent bin
随机推荐
6 states of a thread
C语言实现顺序栈和链队列
推进产教融合 赋能教育创新发展 | 华云数据荣获“企业贡献奖”
我入职阿里后,才知道原来简历这么写
单例模式
SIGINT,SIGKILL,SIGTERM信号区别,各类信号总结
使用百度EasyDL实现智能垃圾箱
DDD 领域驱动设计
IQ Products CMV Brite Turbo试剂盒的原理
mmdetection源码解析--ResNet18
uniapp实现防抖搜索
shardingsphere数据分片配置项说明和示例
字节跳动面试题之镜像二叉树2020
如何 认识与学习BASH
Error jinja2.exceptions.UndefinedError: 'form' is undefined
leetcode 之 70 爬楼梯问题 (斐波那契数)
运放-运算放大器经典应用电路大全-应用电路大全
什么是excel文件保护
Simple to use Lambda expressions
中英文说明书丨CalBioreagents ACTH N端单克隆抗体