网上海投的CaaS Capital的quantitative researcher岗,结果很意外的收到了Coding challenge
90道题 5分钟,因为之前自己没怎么刷过算法题,感觉还是挺难的。。。肯定是没戏了。
(怕被人肉,所以匿名发了这个贴子)
第一题 Stock Picker (Medium)
Have the function StockPicker(arr) take the array of numbers stored in arr which will contain integers that represent the amount in dollars that a single stock is worth, and return the maximum profit that could have been made by buying stock on day x and selling stock on day y where y > x. For example: if arr is [44, 30, 24, 32, 35, 30, 40, 38, 15] then your program should return 16 because at index 2 the stock was worth $24 and at index 6 the stock was then worth $40, so if you bought the stock at 24 and sold it at 40, you would have made a profit of $16, which is the maximum profit that could have been made with this list of stock prices.
If there is not profit that could have been made with the stock prices, then your program should return -1. For example: arr is [10, 9, 8, 2] then your program should return -1.
Examples
Input: [10,12,4,5,9]
Output: 5
Input: [14,20,4,12,5,11]
Output: 8
第二题 Blackjack Highest (hard)
Have the function BlackjackHighest(strArr) take the strArr parameter being passed which will be an array of numbers as a single alphabetic character, the ($) character represents a number between 1-9, and the asterisk (*) represents a sequence of the same character of length 3 unless it is followed by {N} which represents how many characters should appear in the sequence where N will be at least 1. Your goal is to determine if the second string exactly matches the pattern of the first string in the input.
For example: if str is "++*{5} jtggggg" then the second string in this case does match the pattern, so your program should return the string true. If the second string does not match the pattern your program should return the string false.
Examples
Input: "+++++* abcdehhhhhh"
Output: false
Input: "$**+*{2} 9mmmrrrkbb"
Output: true
|