| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12461 | Reservoir's Volume |
|
| 12559 | Characters Sort By Frequency With Specific Order |
|
| 12577 | Bank Data |
|
Description
As the member of Water resources bureau (水利局), Your job is to compute the total volume of Reservoir (水庫) by an elevation map.
Take an example below:

The above elevation map can be represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 unit of water is the total volume of Reservoir (水庫)
Note that: If you are using visual studio, add #pragma warning(disable:4996) in the first line so that you can use scanf on your local machine.
Input
N
S_1 S_2 ... S_N
Given an elvation map with the length of N ( 3 <= N < 3000) with each element S_i (0 <= S_i < 1000)
Output
Compute the total volume of Reservoir (水庫).(followed by an newline character at the end of output string)
Sample Input Download
Sample Output Download
Tags
Discuss
Description
(modified by leetcode)
Given a string, sort it in decreasing order based on the frequency of characters and with following rule:
If the frequency of characters is the same, then sort it with Uppercase > Lowercase > Digit.
if the frequency of characters is the same and have the same type(uppercase or lowercase or digit), then sort uppercase and lowercase type with dictionary order, and sort digit type with increasing order.
There are few examples below:
Input: "tree" Output: "eert" Explanation: 'e' appears twice while 'r' and 't' both appear once. So 'e' must appear before both 'r' and 't'. And 'r' is before 't' since it is dictionary order
Input: "aAbb54" Output: "bbAa45" Explanation: 'b' appears twice while 'a', 'A', '5' and '4' are appear once. So 'b' must appear before both 'a','A','5' and '4'. And Since the order with different type is upercase > lowercase > digit, then 'A' must appear before 'a','5' and '4', and 'a' must appear before '5' and '4'. Finally since '5' and '4' have same frequency then sort it by increasing order.
Note : you need to implement the sorting by yourself without using standard library!!!
Please raise you hand to notify TA when you get AC.
We will check all the student's code after the exam. If you violate the rule, we will find out !!!!!!!!!
Input
T
S1
...
Si
T: the number of string testcase ( 5 < T < 20)
Si : the given string (1 < length(S) < 400)
Note : the input string only contain three type of character (uppercase alpha , lowercase alpha and digit)
Note : Testcase hint
Testcase 1: same type with distinct different frequency. ex: 122333, abbccc, ABBCCC
Testcase 2: different type with distinct different frequency. ex: a22BBB
Testcase 3: same type with same frequency. ex: 321, cba, CBA
Testcase 4: differnt type with same frequency. ex: 012abcABC, ABC012abc
Testcase 5-8: random testcase with all possible combination
Output
Output the string is sorted by frequency with specific order. (each output string followed by a newline characters.)
Sample Input Download
Sample Output Download
Tags
Discuss
Description
One day, you are be assigned a task to write the program for bank. In this task, you are required to write two function below:
func1 : AccountData* createData(char* name, int money);
func2 : AccountData* userQuery(AccountData* data);
func1 help bank to store user's data and func2 help bank to return a copy data to user (In order to avoid user directly modify the money information in bank)
The bank give you a simple data struct to implement above two function.
typedef struct _AccountData {
char* name;
int money;
} AccountData;
main.c
function.h
note that: you can use strlen(const char* str) in string.h to get the length of string
hint: you should not directly assign name to data->name, you need to malloc some memory space to copy the name's value.
data->name = name (x)
Input
S N M
S: the username (2 < length(username) < 100)
N: the money in the bank
M: the number which user try to modify.
Output
Output the current money in the bank and other information. (if user try to modify the money in bank then output warning information otherwise output "query finish")