Interview Practice 25 - Longest Consecutive Digits

Question Given a function prototype: int continumax(char *output_string,char *input_string). Implement it to find the longest consecutive digits. This function must return the length of the longest digits. The found longest digits should be written to the memory location that output_string is pointing. For example, if…

Interview Practice 02 - Stack with Minimum Function

Question Define a stack structure with “min” function — a function to get the minimum value within the stack. The time complexity of min, push and pop functions must be O(1). Solution 結合鍊錶一起做。首先我做插入以下數字: 10, 7, 3, 3, 8, 5, 2, 6 0: 10 -> NULL (MIN=10, POS=…

Interview Practice 01 - Convert Binary Tree into Doubly Linked List

Question Convert binary search tree into doubly linked list. It’s required not to create any new node, but only turning pointers. Solution The following shows the concept of this question. 8 / 6 0 -> 5 = 6 = 7 = 8 = 9 = 0 = 1 / / 5 7 9 1 First, since node…

Find the User Agent Strings of any Mobile Devices

It’s quite often for a developer to make use of the user agent to determine what browser does a user used, especially for those who develop web services and websites. Recently I found a website which has a huge database of mobile device information, including the user agent string…