好吧,我一直在进行一些艰难的采访,但这很荒谬.给了我一个问题,给出了一个笔,纸,计算器,"URL安全"字符的定义,以及20分钟完成问题.问题是(我记得最好):
编写一个函数来生成一个唯一的URL安全字符串,该字符串表示我们明天要部署的IIS Web服务器上的文件修改的给定时间点."时间点"的分辨率是一秒.
"URL安全"字符的.NET RegEx模式=
[0-9a-zA-Z\$\-\_\.\+\!\*\'\(\)]
我惊慌失措,只是写出了我的想法,而不是写出实际的代码.他们在查看我的"答案"后解雇了我,因为我实际上并没有写任何代码.:(
我写的是这样的:
Run Code Online (Sandbox Code Playgroud)- 365 days in a year so "day of year" can be represented in 2 bytes - 4 digits in year (0 - 9999) so year can be represented in 3 bytes - 2 digits in hour (0 - 23) so year can be represented in 1 byte - 2 digits in minutes (0 - 59) so minutes can be represented in 1 byte - 2 digits in seconds (0 - 50) so seconds can be represented in 1 byte TOTAL: 2+3+1+1+1 = 8 bytes total that use 0 - 255 - URL-safe range == 10 + 24 + 24 + 10 == 0-9 + a-z + A-Z + special chars == 68 - 4 bits required to represent URL safe char ANSWER: - A byte is 8 bits - Only 4 bits per byte needed to represented the 8 bytes in a date - 8 / 2 = 4 FINAL ANSWER: - Only 4 actual bytes needed to represent hash
换句话说,时间戳哈希可以合理地表示为最多4个URL安全字符.
你怎么回答这个问题?!我觉得我是一个非常好的开发者,但是我已经很多年了,因为我不得不担心计算两个人的权力!
这似乎就像FizzBuzz问题......基于要求
DateTime.UtcNow.ToString("yyyyMMddhhmmss");
Run Code Online (Sandbox Code Playgroud)
或者与它非常相似的东西是一个很好的答案,作为一名采访者,我会对任何没有编写任何代码的人持怀疑态度,因为他们选择使问题变得不必要地复杂化.
| 归档时间: |
|
| 查看次数: |
2516 次 |
| 最近记录: |