freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

面試--微軟面試100題全部答案-展示頁

2025-07-07 22:51本頁面
  

【正文】 the auxiliary array. Otherwise an hashmap or bst may be needed. Lets assume it’s an ASCII string.int bm_strstr(char *str, char *sub) {int len = strlen(sub)。優(yōu)化速度。reverseFixlen(str, pstr)。amp。str = p。amp。char * p = str。ANSWER: Reverse the whole string, then reverse each word. Using the reverseFixlen() above.void reverseWordsInSentence(char * sen) {int len = strlen(sen)。 *p=c。while (str p) {char c = *str。void reverse(char *str) {reverseFixlen(str, strlen(str))。優(yōu)化速度。}return 0。}if (*str == ‘\0’) return 0。} while (*str != ‘\0’)。ANSWER:What is “Tongyongzifuchuan”... a string with “*” and “?”? If so, here is the code.int match(char * str, char * ptn) {if (*ptn == ‘\0’) return 1。ANSWER:I don’t understand what is “Chuanyue”.★用一種算法整理一個數(shù)組。return p。p = pnext。while (pnext != NULL) {pnext = previous。Node * p = head。return ph。headnextnext = head。if (headnext == NULL) return head?,F(xiàn)在在不用遞歸式的情況下做一遍。如果你只能將金條切割兩次,你怎樣分給這些工人?ANSWER:1+2+4。有什么辦法呢?ANSWER: Skip.,你要用一根金條作為報酬。,一間房里有三盞燈,另一間房有控制著三盞燈的三個開關(guān),這兩個房間是分割開的,從一間里不能看到另一間的情況。}第8 題此貼選一些比較怪的題,由于其中題目本身與算法關(guān)系不大,僅考考思維。if (p1 == p2) {return p1。 p2next!=NULL) {p1 = p1next。while (p2!=NULL amp。if (p==cylic1) return 0。p=pnextnext。Node *p = cylic1。amp。amp。if (cylic1+cylic2==0) return isJoinedSimple(h1, h2)。}// if there could exist cycleint isJoined(Node *h1, Node * h2) {Node* cylic1 = testCylic(h1)。}while (h2next != NULL) {h2 = h2 next。}。問題擴展:??ANSWER:struct Node {int data。上排的十個數(shù)如下:【0,1,2,3,4,5,6,7,8,9】舉一個例子,數(shù)值: 0,1,2,3,4,5,6,7,8,9分配: 6,2,1,0,0,0,1,0,0,00 在下排出現(xiàn)了6 次,1 在下排出現(xiàn)了2 次,2 在下排出現(xiàn)了1 次,3 在下排出現(xiàn)了0 次....以此類推..ANSWER:I don’t like brain teasers. Will skip most of them...第7 題微軟亞院之編程判斷倆個鏈表是否相交給出倆個單向鏈表的頭指針,比如h1,h2,判斷這倆個鏈表是否相交。i=l。 a[l+1] a[l]) l++。if (l+1n amp。i = p。 a[j]a[i]) i = j。if (jn amp。1==0 ? i1 : i+1)。例如輸入1,2,3,4,5,6,7 和8 這8 個數(shù)字,則最小的4 個數(shù)字為1,2,3 和4。sum = 。if (rootright!=NULL) helper(rootright, sum, path, top)。 rootright==NULL) {if (sum == 0) printPath(path, top)。if (rootleft == NULL amp。}void helper(TreeNode * root, int sum, int path[], int top) {path[top++] = 。void printPaths(TreeNode * root, int sum) {int path[MAX_HEIGHT]。TreeNode * right。ANSWER:Use backtracking and recurison. We need a stack to help backtracking the path.struct TreeNode {int data。 // left child of nodeBinaryTreeNode *m_pRight。二元樹節(jié)點的數(shù)據(jù)結(jié)構(gòu)定義為:struct BinaryTreeNode // a node in the binary tree{int m_nValue。打印出和與輸入整數(shù)相等的所有路徑。}題目:輸入一個整數(shù)和一棵二元樹。} else if (sum 0) {sum = 0。while (cur size) {sum += a[cur++]。int max = (1 31)。ANSWER: A traditional greedy approach.Keep current sum, slide from left to right, when sum 0, reset sum to 0.int maxSubarray(int a[], int size) {if (size=0) error(“error array size”)。要求時間復雜度為O(n)。數(shù)組中連續(xù)的一個或多個整數(shù)組成一個子數(shù)組,每個子數(shù)組都有一個和。return [].min。return [].data。top ++。pmin = (==0?d : [top1])。MinStackElement* p = []。}void MinStackFree(MinStack stack) {free()。 = 0。 = maxSize。int top。struct MinStack {MinStackElement * data。int min。要求函數(shù)min、push 以及pop 的時間復雜度都是O(1)。}} 函數(shù)的棧。rhm_pLeft = root。} else {head = root。if (lt!=NULL) {ltm_pRight = root。}helper(head, lt, rootm_pLeft)。if (root == NULL) {head = NULL, tail = NULL。 head, BSTreeNode *amp。return head。ANSWER:This is a traditional problem that can be solved using recursion. For each node, connect the double linked lists created from left and right child node to form a full list./*** param root The root node of the tree* return The head node of the converted list.*/BSTreeNode * treeToLinkedList(BSTreeNode * root) {BSTreeNode * head, * tail。 // left child of nodeBSTreeNode *m_pRight。首先我們定義的二元查找樹節(jié)點的數(shù)據(jù)結(jié)構(gòu)如下:struct BSTreeNode{int m_nValue。要求不能創(chuàng)建任何新的結(jié)點,只調(diào)整指針的指向。本文轉(zhuǎn)載自CSDN大牛的一篇博客:作者:July、阿財時間:二零一一年十月十三日。我能夠看到此文,還要多謝陳同學!讓我得以及時分享給大家微軟面試100題全部答案個人整理的前60題的答案可參見以下三篇文章:1. 微軟100題第1題20題答案 [博文 I] 2. 微軟100題第2140題答案 [博文II] 3. 微軟100題第4160題答案 [博文III]最新整理的全部100題的答案參見如下(重復的,以及一些無關(guān)緊要的題目跳過):題目:輸入一棵二元查找樹,將該二元查找樹轉(zhuǎn)換成一個排序的雙向鏈表。10/ \6 14/ \ / \4 8 12 16轉(zhuǎn)換成雙向鏈表4=6=8=10=12=14=16。 // value of nodeBSTreeNode *m_pLeft。 // right child of node}。helper(head, tail, root)。}void helper(BSTreeNode *amp。 tail, BSTreeNode *root) {BSTreeNode *lt, *rh。return。helper(rh, tail, rootm_pRight)。rootm_pLeft = lt。}if (rh!=NULL) {rootm_pRight=rh。} else {tail = root。定義棧的數(shù)據(jù)結(jié)構(gòu),要求添加一個min 函數(shù),能夠得到棧的最小元素。ANSWER:Stack is a LIFO data structure. When some element is popped from the stack, the status will recover to the original status as before that element was pushed. So we can recover the minimum element, too.struct MinStackElement {int data。}。int size。}MinStack MinStackInit(int maxSize) {MinStack stack。 = (MinStackElement*) malloc(sizeof(MinStackElement)*maxSize)。return stack。}void MinStackPush(MinStack stack, int d) {if ( == ) error(“out of stack space.”)。pdata = d。if (pmin d) pmin = d。}int MinStackPop(MinStack stack) {if ( == 0) error(“stack is empty!”)。}int MinStackMin(MinStack stack) {if ( == 0) error(“stack is empty!”)。}題目:輸入一個整形數(shù)組,數(shù)組里有正數(shù)也有負數(shù)。求所有子數(shù)組的和的最大值。例如輸入的數(shù)組為1, 2, 3, 10, 4, 7, 2, 5,和最大的子數(shù)組為3, 10, 4, 7, 2,因此輸出為該子數(shù)組的和18。int sum = 0。int cur = 0。if (sum max) {max = sum。}}return max。從樹的根結(jié)點開始往下訪問一直到葉結(jié)點所經(jīng)過的所有結(jié)點形成一條路徑。例如輸入整數(shù)22 和如下二元樹10/ \5 12/ \4 7則打印出兩條路徑:10, 12 和10, 5, 7。 // value of nodeBinaryTreeNode *m_pLeft。 // right child of node}。TreeNode * left。}。helper(root, sum, path, 0)。sum = 。amp。} else {if (rootleft != NULL) helper(rootleft, sum, path, top)。}top 。} 個元素題目:輸入n 個整數(shù),輸出其中最小的k 個。ANSWER:This is a very traditional question...O(nlogn): cat I_FILE | sort n | head n KO(kn): do insertion sort until k elements are retrieved.O(n+klogn): Take
點擊復制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1