注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
16道题:
4道coding:
第一题:
Given a string word, count the minimum number of characters that needs to be added to word to make it anadrome - a string which is an anagram of some palindrome.
For example, if word = "apple", it's possible to add two letters 'a' and 'e', which makes the resulting string an anadrome: "appleae" letters can be rearranged to become "apelepa", which is a palindrome.
Example
For word = "abcb", the output should be solution(word) = 1.
One can add either 'a' or 'c' to the string word: "abcba" is a palindrome already, "abcbc" is an anagram of a palindrome "cbabc".
For word = "abab", the output should be solution(word) = 0.
The string "abab" is already an anagram of a palindrome "abba".
For word = "abc", the output should be solution(word) = 2.
One can add, for example, characters 'a' and 'b' to the string word: "abcab" is an anagram of a palindrome "abcba".
For word = "apple", the output should be solution(word) = 2.
Input/Output
[execution time limit] 3 seconds (java)
[input] string word
A string consisting of lowercase English letters, which should be adjusted to become an anadrome.
Guaranteed constraints:
1 ≤ word.length ≤ 106.
[output] integer
The minimum number of characters that can be added to word to make it anadrome.
第二题:
You know what they say: "time is money." In today's markets, the price of a stock that you see on your computer might not be the price that you end-up trading at, since by the time your request reaches the exchange the price might have changed. Therefore, the quicker you can get your order to the exchange, the better the chances that you will trade at your expected price.
Picture a peer-to-peer computer network of n nodes that's supposed to route your request from your computer to a computer where the trade is actually registered. Let's assume that the network is not optimized yet, so it's your task to implement an algorithm that computes the shortest path from the source at index 1 (your computer) to the destination at index n.
Example
For n = 4 and
network = [[1, 4, 200],
[1, 2, 5],
[1, 3, 10],
[2, 3, 4],
time s
lowest duration of execution d
lowest index in the input
The input will consist of three arrays s, d, and p, all consisting of n elements (1 ≤ n ≤ 1000), where index i specifies the value for task i. The output should be an array of length n consisting of the order in which the tasks will be run, where a task is identified by its index i in the input.
For example, the input:
s: [0, 2, 2]
d: [1, 1, 1]
p: [0, 0, 1]
Defines three tasks. Task 0 is run first at time 0. Both task 1 and 2 can be run at time 2, however since task 2 has a higher priority, it's run next, followed by task 1. Therefore, the expected output is:
[0, 2, 1]
[execution time limit] 3 seconds (java)
[input] array.integer s
An array of length n, where task i's earliest start time is 0 ≤ s[i] ≤ 9999999.
[input] array.integer d
An array of length n, where task i's duration of execution is 1 ≤ d[i] ≤ 10000000.
[input] array.integer p
An array of length n, where task i's priority of execution is 0 ≤ p[i] ≤ 3.
[output] array.integer
An array of length n consisting of the order in which the tasks were run, where a task is identified by its index in the input.
其他都是data structure and algorithm,直接搜就可以
求大米哦 |