1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. 美團網筆試題目

        時間:2023-04-04 00:16:28 筆試題目 我要投稿
        • 相關推薦

        2014美團網筆試題目

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

        2014美團網筆試題目

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

          2、一個汽車公司的產品,甲廠占40%,乙廠占60%,甲的次品率是1%,乙的次品率是2%,現在抽出一件汽車時次品,問是甲生產的可能性

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

          3、k鏈表翻轉。給出一個鏈表和一個數k,比如鏈表1→2→3→4→5→6,k=2,則翻轉后2→1→4→3→6→5,若k=3,翻轉后3→2→1→6→5→4,若k=4,翻轉后4→3→2→1→5→6,用程序實現

          非遞歸可運行代碼:

          #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、利用兩個stack模擬queue

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

          #include

          #include

          #include

          typedef struct stack {

          int top;

          int seq[100000];

          } stack;

          /**

          * 入隊操作

          *

          * T = O(1)

          *

          */

          void pushQueue(stack *s1, int data)

          {

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

          }

          /**

          * 出隊操作

          *

          * 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) { // 入隊列

          scanf("%d", &data);

          pushQueue(s1, data);

          } else { // 出隊列

          popQueue(s1, s2);

          }

          }

          free(s1);

          free(s2);

          }

          return 0;

          }

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

          楊氏矩陣,簡單題目:

          #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列\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;

          // 構造矩陣

          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]);

          }

          // 查詢數據

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

          findKey(matrix, n, m, key);

          }

          return 0;

          }

        【美團網筆試題目】相關文章:

        美團網筆試經驗08-08

        美團網2014年 產品類 筆試08-10

        美團網2014年產品類筆試經驗07-20

        2014美團哈爾濱筆試題07-09

        美團校招筆試題題目整理03-16

        星網銳捷筆試題目12-12

        人人網筆試、面試題目經驗07-17

        做完家化網測筆試 分享題目11-21

        王興:“美團網”創業故事11-14

        美團2015校招研發筆試題12-13

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>