日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

阿里巴巴2021秋招笔试题20211119

發布時間:2024/10/5 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 阿里巴巴2021秋招笔试题20211119 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

源代碼:https://gitee.com/shentuzhigang/algorithm/tree/master/exam-alibaba/exam-alibaba-20211119

第一題

題目大意:
有長度為n的數組a
有k次機會在連續長度不超過m的區間每個元素+1使得數組全部元素變成偶數

import java.util.LinkedList; import java.util.Scanner;/*** @author ShenTuZhiGang* @version 1.0.0* @email 1600337300@qq.com* @date 2021-11-19 19:16*/ public class Exam2021111901 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int t = scanner.nextInt();for (int i = 0; i < t; i++) {int n = scanner.nextInt();int k = scanner.nextInt();int m = scanner.nextInt();int[] a = new int[n];int add = 0;LinkedList<Integer> q= new LinkedList<>();for (int j = 0; j < n; j++) {a[j] = scanner.nextInt();if ((a[j]+add)%2==1){if(q.isEmpty()){k--;add++;q.push(j+m-1);}else{add--;q.pop();}}if(q.peek()!=null&&q.peek()==j){q.pop();add--;}}System.out.println(k>=0?"Yes":"No");}} }

第二題

(未驗證正確性)
題目大意:
有 單詞組 strs
人數n,長度b
每個人按單詞組依次報【0,i】
例:
king
king hello
king hello wrold
king hello
king
king hello
king hello wrold
king hello

求單詞word第X次出現在第幾行

import java.util.Scanner;/*** @author ShenTuZhiGang* @version 1.0.0* @email 1600337300@qq.com* @date 2021-11-19 20:36*/ public class Exam2021111902 {public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int n = scanner.nextInt();int b = scanner.nextInt();scanner.nextLine();String[] s = scanner.nextLine().split(" ");String word = s[0];int c = Integer.parseInt(s[1]);String[] strs = scanner.nextLine().split(" ");if(b==1){System.out.println(b);System.exit(0);}int t = 0;for (int i = 0; i < 2*b-2; i++) {for (int j = 0; j <= i; j++) {if(word.equals(strs[j%n])){t++;}}}int k = c/t;int t0 = c%t;if(t0!=0){for (int i = 0; i < 2*b-2; i++) {for (int j = 0; j <= i; j++) {if(word.equals(strs[j%n])){t0--;if(t0==0){System.out.println(k*(2*b-2)+i);}}}}}else {System.out.println(k*(2*b-2));}}}

總結

以上是生活随笔為你收集整理的阿里巴巴2021秋招笔试题20211119的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。