久久久久无码精品,四川省少妇一级毛片,老老熟妇xxxxhd,人妻无码少妇一区二区

美團(tuán)網(wǎng)筆試題目

時(shí)間:2023-04-04 00:16:28 筆試題目 我要投稿
  • 相關(guān)推薦

2014美團(tuán)網(wǎng)筆試題目

  1、一堆硬幣,一個(gè)機(jī)器人,如果是反的就翻正,如果是正的就拋擲一次,無窮多次后,求正反的比例

2014美團(tuán)網(wǎng)筆試題目

  解答:是不是題目不完整啊,我算的是3:1

  2、一個(gè)汽車公司的產(chǎn)品,甲廠占40%,乙廠占60%,甲的次品率是1%,乙的次品率是2%,現(xiàn)在抽出一件汽車時(shí)次品,問是甲生產(chǎn)的可能性

  解答:典型的貝葉斯公式,p(甲|廢品) = p(甲 && 廢品) / p(廢品) = (0.4 × 0.01) /(0.4 × 0.01 + 0.6 × 0.02) = 0.25

  3、k鏈表翻轉(zhuǎn)。給出一個(gè)鏈表和一個(gè)數(shù)k,比如鏈表1→2→3→4→5→6,k=2,則翻轉(zhuǎn)后2→1→4→3→6→5,若k=3,翻轉(zhuǎn)后3→2→1→6→5→4,若k=4,翻轉(zhuǎn)后4→3→2→1→5→6,用程序?qū)崿F(xiàn)

  非遞歸可運(yùn)行代碼:

  #include

  #include

  #include

  typedef struct node {

  struct node *next;

  int data;

  } node;

  void createList(node **head, int data)

  {

  node *pre, *cur, *new;

  pre = NULL;

  cur = *head;

  while (cur != NULL) {

  pre = cur;

  cur = cur->next;

  }

  new = (node *)malloc(sizeof(node));

  new->data = data;

  new->next = cur;

  if (pre == NULL)

  *head = new;

  else

  pre->next = new;

  }

  void printLink(node *head)

  {

  while (head->next != NULL) {

  printf("%d ", head->data);

  head = head->next;

  }

  printf("%d\n", head->data);

  }

  int linkLen(node *head)

  {

  int len = 0;

  while (head != NULL) {

  len ++;

  head = head->next;

  }

  return len;

  }

  node* reverseK(node *head, int k)

  {

  int i, len, time, now;

  len = linkLen(head);

  if (len < k) {

  return head;

  } else {

  time = len / k;

  }

  node *newhead, *prev, *next, *old, *tail;

  for (now = 0, tail = NULL; now < time; now ++) {

  old = head;

  for (i = 0, prev = NULL; i < k; i ++) {

  next = head->next;

  head->next = prev;

  prev = head;

  head = next;

  }

  if (now == 0) {

  newhead = prev;

  }

  old->next = head;

  if (tail != NULL) {

  tail->next = prev;

  }

  tail = old;

  }

  if (head != NULL) {

  tail->next = head;

  }

  return newhead;

  }

  int main(void)

  {

  int i, n, k, data;

  node *head, *newhead;

  while (scanf("%d %d", &n, &k) != EOF) {

  for (i = 0, head = NULL; i < n; i ++) {

  scanf("%d", &data);

  createList(&head, data);

  }

  printLink(head);

  newhead = reverseK(head, k);

  printLink(newhead);

  }

  return 0;

  }

  5、利用兩個(gè)stack模擬queue

  劍指offer上的原題,九度oj有專門的練習(xí),這里貼一下我的ac代碼:

  #include

  #include

  #include

  typedef struct stack {

  int top;

  int seq[100000];

  } stack;

  /**

  * 入隊(duì)操作

  *

  * T = O(1)

  *

  */

  void pushQueue(stack *s1, int data)

  {

  s1->seq[s1->top ++] = data;

  }

  /**

  * 出隊(duì)操作

  *

  * T = O(n)

  *

  */

  void popQueue(stack *s1, stack *s2)

  {

  if (s2->top > 0) {

  printf("%d\n", s2->seq[-- s2->top]);

  } else {

  while (s1->top > 0) {

  s2->seq[s2->top ++] = s1->seq[-- s1->top];

  }

  if (s2->top > 0)

  printf("%d\n", s2->seq[-- s2->top]);

  else

  printf("-1\n");

  }

  }

  int main(void)

  {

  int data, n;

  stack *s1, *s2;

  char str[5];

  while (scanf("%d", &n) != EOF) {

  // 初始化

  s1 = (stack *)malloc(sizeof(stack));

  s2 = (stack *)malloc(sizeof(stack));

  s1->top = s2->top = 0;

  while (n --) {

  scanf("%s", str);

  if (strcmp(str, "PUSH") == 0) { // 入隊(duì)列

  scanf("%d", &data);

  pushQueue(s1, data);

  } else { // 出隊(duì)列

  popQueue(s1, s2);

  }

  }

  free(s1);

  free(s2);

  }

  return 0;

  }

  6、一個(gè)m*n的矩陣,從左到右從上到下都是遞增的,給一個(gè)數(shù)elem,求是否在矩陣中,給出思路和代碼

  楊氏矩陣,簡(jiǎn)單題目:

  #include

  #include

  /**

  * 有序矩陣查找

  *

  * T = O(n + n)

  *

  */

  void findKey(int **matrix, int n, int m, int key)

  {

  int row, col;

  for (row = 0, col = m - 1; row < n && col >= 0;) {

  if (matrix[row][col] == key) {

  printf("第%d行,第%d列\(zhòng)n", row + 1, col + 1);

  break;

  } else if (matrix[row][col] > key) {

  col -= 1;

  } else {

  row += 1;

  }

  }

  printf("不存在!\n");

  }

  int main(void)

  {

  int i, j, key, n, m, **matrix;

  // 構(gòu)造矩陣

  scanf("%d %d", &n, &m);

  matrix = (int **)malloc(sizeof(int *) * n);

  for (i = 0; i < n; i ++)

  matrix[i] = (int *)malloc(sizeof(int) * m);

  for (i = 0; i < n; i ++) {

  for (j = 0; j < m; j ++)

  scanf("%d", &matrix[i][j]);

  }

  // 查詢數(shù)據(jù)

  while (scanf("%d", &key) != EOF) {

  findKey(matrix, n, m, key);

  }

  return 0;

  }

【美團(tuán)網(wǎng)筆試題目】相關(guān)文章:

美團(tuán)網(wǎng)筆試經(jīng)驗(yàn)08-08

美團(tuán)網(wǎng)2014年 產(chǎn)品類 筆試08-10

美團(tuán)網(wǎng)2014年產(chǎn)品類筆試經(jīng)驗(yàn)07-20

2014美團(tuán)哈爾濱筆試題07-09

美團(tuán)校招筆試題題目整理03-16

星網(wǎng)銳捷筆試題目12-12

人人網(wǎng)筆試、面試題目經(jīng)驗(yàn)07-17

做完家化網(wǎng)測(cè)筆試 分享題目11-21

王興:“美團(tuán)網(wǎng)”創(chuàng)業(yè)故事11-14

美團(tuán)2015校招研發(fā)筆試題12-13