首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
分割数组
[编程题]分割数组
热度指数:341
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
给定一个长度为 n 的非负整数数组 num ,和一个整数 m ,你需要把这个数组 num 分成 m 个非空连续子数组。
请你找出这些连续子数组各自的和的最大值最小的方案并输出这个值。
数据范围:
,
,
示例1
输入
[1,2,3,4,5,6],3
输出
9
说明
1,2,3 为一组 4,5为一组,6为一组
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(0)
邀请回答
收藏(14)
分享
纠错
提交结果有问题?
2个回答
1篇题解
开通博客
牛客32834685号
发表于 2024-02-29 17:06:28
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型ArrayList
展开全文
问题信息
贪心
动态规划
二分
难度:
2条回答
14收藏
1908浏览
热门推荐
通过挑战的用户
查看代码
酋非天
2022-09-12 21:29:08
牛客74836...
2022-09-09 20:59:02
牛客65226...
2022-09-09 18:46:31
柳少辰
2022-09-07 19:04:55
wmymartin
2022-09-01 21:41:28
相关试题
分组
基础数学
二分
评论
(11)
求序列里最长的非降序列 例如:输...
百度
贪心
评论
(12)
远亲不如近邻
排序
二分
评论
(13)
设某二叉树的先序遍历序列为abdg...
树
评论
(1)
2022 诺瓦科技 Perl re...
perl
System Verilog
评论
(1)
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型ArrayList * @param m int整型 * @return int整型 */ public int splitMin (ArrayList
num, int m) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型vector * @param m int整型 * @return int整型 */ int splitMin(vector
& num, int m) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param num int整型一维数组 # @param m int整型 # @return int整型 # class Solution: def splitMin(self , num , m ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param m int整型 * @return int整型 */ public int splitMin (List
num, int m) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param m int整型 * @return int整型 */ function splitMin( num , m ) { // write code here } module.exports = { splitMin : splitMin };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param num int整型一维数组 # @param m int整型 # @return int整型 # class Solution: def splitMin(self , num: List[int], m: int) -> int: # write code here
package main //import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param m int整型 * @return int整型 */ func splitMin( num []int , m int ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param numLen int num数组长度 * @param m int整型 * @return int整型 */ int splitMin(int* num, int numLen, int m ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param num int整型一维数组 # @param m int整型 # @return int整型 # class Solution def splitMin(num, m) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param m int整型 * @return int整型 */ def splitMin(num: Array[Int],m: Int): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param m int整型 * @return int整型 */ fun splitMin(num: IntArray,m: Int): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param m int整型 * @return int整型 */ public int splitMin (int[] num, int m) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param m int整型 * @return int整型 */ export function splitMin(num: number[], m: number): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param m int整型 * @return int整型 */ func splitMin ( _ num: [Int], _ m: Int) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param num int整型一维数组 * @param m int整型 * @return int整型 */ pub fn splitMin(&self, num: Vec
, m: i32) -> i32 { // write code here } }
[1,2,3,4,5,6],3
9