小米SRE团队负责XIAOMI所有核心业务系统的可用性、性能、容量相关的保障工作。因技术场景丰富,团队内部经常进行技术方案交流。 目前有个SRE工程师,在会议室围成一个圈,第个SRE工程师准备了数量的技术方案文档,你现在需要去收集技术文档,只有一个要求,不可以同时取相邻SRE工程师的技术文档。 给定一个非负整数数组,在不破坏要求的情况下,能够取到最多的技术文档。
示例1
输入
[1,2]
输出
2
说明
取第2个工程师的文档
示例2
输入
[4,7,4]
输出
8
说明
取第1,3个工程师的文档
加载中...
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @return int整型 */ public int getdoc (int[] a) { // write code here } }
class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型vector * @return int整型 */ int getdoc(vector
& a) { // write code here } };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param a int整型一维数组 # @return int整型 # class Solution: def getdoc(self , a ): # write code here
using System; using System.Collections.Generic; class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @return int整型 */ public int getdoc (List
a) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @return int整型 */ function getdoc( a ) { // write code here } module.exports = { getdoc : getdoc };
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param a int整型一维数组 # @return int整型 # class Solution: def getdoc(self , a ): # write code here
package main /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @return int整型 */ func getdoc( a []int ) int { // write code here }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @param aLen int a数组长度 * @return int整型 */ int getdoc(int* a, int aLen ) { // write code here }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @return int整型 */ def getdoc(a: Array[Int]): Int = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @return int整型 */ fun getdoc(a: IntArray): Int { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @return int整型 */ public int getdoc (int[] a) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @return int整型 */ export function getdoc(a: number[]): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @return int整型 */ func getdoc ( _ a: [Int]) -> Int { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param a int整型一维数组 * @return int整型 */ pub fn getdoc(&self, a: Vec
) -> i32 { // write code here } }
[1,2]
2
[4,7,4]
8