注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
Q1末朋友帮内推的亚麻,OA两道题分享下
Question 1 : Minimal cost to strengthen password
A team of developers at Amazon is working on a feature that checks the strength of a password as it is set by a user.
Analysts found that people use their personal information in passwords, which is insecure. The feature searches for the presence of a reference string as a subsequence of any permutation of the password. If any permutation contains the reference string as a subsequence, then the feature determines the minimum cost to remove characters from password so that no permutation contains the string reference as a subsequence.
The removal of any character has a cost given in an array, ample
Given n = 4, size = [2, 3, 3, 2] and cost = [2, 4, 5, 1].
-- It costs 7 units to make the prices distinct.
We can also adjust size[1] to 5, which costs cost[1] * (5 - size[1]) = 8, and size[3] to 4, which costs cost[3] * (4 - size[3]) = 2. Therefore, the total cost is 8 + 2 = 10.
However, 7 is the minimum cost required to make all sizes distinct.
做完以后一直没有response,朋友从内网帮我看这个职位已经没了,估计是被内部转岗给fill了。
整理不易,求厚米! |