## Solution to Number Of One In Binary from Jobdu

2 Aug

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1513 Question Name: Number Of One In Binary Question Description: Give an integer, check how many 1(s) are there in its binary form. Input: may contains multiple test cases. The first line indicates how many test cases are … Read More »

## Solution to Fibonacci from Jobdu

1 Aug

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1387 Question Name: Fibonacci Question Description: find the Fibonacci number F(N). Input: may contains multiple test cases. Each case is a single line, including one integer as the N. Output: the Fibonacci number F(N).

The solution … Read More »

## Solution to Min Number In Rotated Array from Jobdu

1 Aug

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1386 Question Name: Min Number In Rotated Array Question Description: the input array is sorted and then rotated. Write a function to find the minimum value in the array. Input: may contains multiple test cases. For each … Read More »

## Solution to Queue With Two Stacks from Jobdu

1 Aug

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1512 Question Name: Queue With Two Stacks Question Description: simulate a queue class with two stacks. Write a test program for the queue. If queue is empty and pop, print -1. Input: the first list is an … Read More »

## Solution to Construct Binary Tree from Jobdu

31 Jul

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1385 Question Name: Construct Binary Tree Question Description: With the result of  pre-order and in-order traversal of a tree, construct the binary tree, and return its post-order traversal result.. Input: may contain multiple test cases. For each … Read More »

## Solution to Print List from End from Jobdu

31 Jul

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1511 Question Name: Print List from End Question Description: giving a single-linked list, print the values of its nodes from end to beginning. Input: multiple lines. Each line is an integer. -1 means reaching the end of … Read More »

## Solution to Expand Spaces from Jobdu

30 Jul

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1510 Question Name: Expand Spaces Question Description: giving a string, expand all spaces into “%20”. Input: a single line as the original string. Output: the expanded string. Example:

It is completely the same as the problem … Read More »

## Solution to Find an Integer in 2D Array from Jobdu

30 Jul

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1384 Question Name: Find an Integer in 2D Array Question Description: in a 2D array, independently every row/column is already sorted in ascending order. Given a such 2D array and an integer, write a function to check … Read More »