首页
题库
面试
求职
学习
竞赛
More+
所有博客
搜索面经/职位/试题/公司
搜索
我要招人
去企业版
登录 / 注册
首页
>
试题广场
>
掰花瓣
[编程题]掰花瓣
热度指数:723
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 256M,其他语言512M
算法知识视频讲解
手上有 n 朵花,每朵的花瓣数保存在一个数组中。我们每次可以选择任意一朵,拿走其中的一瓣或者两瓣,求掰完所有花的最少次数。
示例1
输入
[4,2,1]
输出
4
马上挑战
算法知识视频讲解
提交运行
算法知识视频讲解
添加笔记
求解答(3)
邀请回答
收藏(14)
分享
纠错
提交结果有问题?
6个回答
0篇题解
开通博客
暂无题解
问题信息
golang工程师
PHP工程师
深圳虾皮信息科技有限公司
Java工程师
信息技术岗
上传者:
小小
难度:
6条回答
14收藏
2325浏览
热门推荐
通过挑战的用户
一枚小学渣
2022-11-08 23:20:35
今天小于找到工作了吗
2022-09-25 22:28:42
默少
2022-09-10 20:53:26
cauchysch
2022-09-05 14:09:50
勇気のLJ
2022-09-03 15:56:17
相关试题
Windows中,以下关于动态链接...
2015
Java工程师
C++工程师
iOS工程师
安卓工程师
运维工程师
前端工程师
c#工程师
恒生电子
golang工程师
评论
(3)
来自
恒生公司2015秋招开发...
从网络纵深防护的角度看,下面哪一项...
Java工程师
C++工程师
iOS工程师
安卓工程师
运维工程师
前端工程师
算法工程师
测试工程师
安全工程师
大数据开发工程师
2018
奇安信
信息技术岗
评论
(0)
以下描述错误的是:()
Java工程师
C++工程师
iOS工程师
安卓工程师
运维工程师
前端工程师
算法工程师
测试工程师
安全工程师
大数据开发工程师
2018
奇安信
信息技术岗
评论
(0)
在大语言模型中,什么是"Gated...
大模型开发
评论
(1)
关于大模型“上下文窗口”的理解,以...
大模型概念
评论
(1)
掰花瓣
扫描二维码,关注牛客网
意见反馈
下载牛客APP,随时随地刷题
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @return int整型 */ public int petalsBreak (int[] petals) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型vector 花瓣数 * @return int整型 */ int petalsBreak(vector
& petals) { // write code here } };
#coding:utf-8 # # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param petals int整型一维数组 花瓣数 # @return int整型 # class Solution: def petalsBreak(self , petals ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @return int整型 */ public int petalsBreak (List
petals) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @return int整型 */ function petalsBreak( petals ) { // write code here } module.exports = { petalsBreak : petalsBreak };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param petals int整型一维数组 花瓣数 # @return int整型 # class Solution: def petalsBreak(self , petals ): # write code here
package main import "fmt" /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @return int整型 */ func petalsBreak( petals []int ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @param petalsLen int petals数组长度 * @return int整型 */ int petalsBreak(int* petals, int petalsLen ) { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param petals int整型一维数组 花瓣数 # @return int整型 # class Solution def petalsBreak(petals) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @return int整型 */ def petalsBreak(petals: Array[Int]): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @return int整型 */ fun petalsBreak(petals: IntArray): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @return int整型 */ public int petalsBreak (int[] petals) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @return int整型 */ export function petalsBreak(petals: number[]): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @return int整型 */ func petalsBreak ( _ petals: [Int]) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param petals int整型一维数组 花瓣数 * @return int整型 */ pub fn petalsBreak(&self, petals: Vec
) -> i32 { // write code here } }
[4,2,1]
4