题面: Coins Problem Description: Duoxida buys a bottle of MaiDong from a vending machine and the machine give her n coins back. She places them in a line randomly showing head face or tail face o
思路 滑动窗口:如果用left和right表示连续1的左右边界,那么意味着可以把0修改为1的次数为k次 解题过程 用一个变量num记录left和right之间0的个数,当num<=k时,right++,num>k时,将left向右移动,直到不再满足num>k Code class Solution {public int longestOnes(int[] nums, int k) {in
编写程序,读入未指定个数的整数,判断读入的整数有多少个,读入的负数有多少个,输入0表示程序结束,计算总和和平均值。 import java.util.Scanner; public class chapt3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.