[Classic Interview Questions] [storm Audio and Video] Storm audio and video 2014 school strokes test questions, storm audio and video 2014

Source: Internet
Author: User

[Classic Interview Questions] [storm Audio and Video] Storm audio and video 2014 school strokes test questions, storm audio and video 2014

/* ------------------------------------------- * Date: 2015-02-23 * Author: SJF0115 * question: Merge sort linked list * Source: Storm video * blog: ------------------------------------------- */# include <iostream> # include <climits> using namespace std; struct ListNode {int val; ListNode * next; ListNode (int x): val (x ), next (NULL) {}}; // ListNode * MergeSortedList (ListNode * list1, ListNode * list2) {// ListNode * head = new ListNode (-1 ); ListNode * p = head; int val1, val2; // merge while (list1! = NULL | list2! = NULL) {val1 = (list1 = NULL )? INT_MAX: list1-> val; val2 = (list2 = NULL )? INT_MAX: list2-> val; // keep only one if (val1 = val2) {p-> next = list1; list1 = list1-> next; list2 = list2-> next;} // if // current linked list 1 small else if (val1 <val2) {p-> next = list1; list1 = list1-> next ;} // current linked list 2 small else {p-> next = list2; list2 = list2-> next;} p = p-> next ;} // while return head-> next;} int main () {int A [] = {, 9}; int B [] = {, 9, 11, 12}; // linked list 1 ListNode * head1 = new ListNode (A [0]); ListNode * p1 = head1; for (int I = 1; I <5; I ++) {ListNode * node = new ListNode (A [I]); p1-> next = node; p1 = node ;} /// for // linked list 2 ListNode * head2 = new ListNode (B [0]); ListNode * p2 = head2; for (int I = 1; I <7; I ++) {ListNode * node = new ListNode (B [I]); p2-> next = node; p2 = node ;} // for ListNode * head = MergeSortedList (head1, head2); // output ListNode * p = head; while (p) {cout <p-> val <""; p = p-> next;} // while cout <endl ;}

2. write a program to move m characters at the end of the original string to the header of the string. The length is n. The operation time is O (n), and the time complexity is O (1 ).
For example, if the original string is "Ilovebaofeng", m = 7, the output result is "baofengIlove ".

To be continued ....

3. storm audio and video source servers store two files a and B, each storing 5 billion URLs, each occupying 64 bytes, with a memory limit of 4 GB. Let you find, the URL of file B. Requirement: algorithm design.

To be continued ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.