-
Notifications
You must be signed in to change notification settings - Fork 885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
一些建议 #53
Comments
这是我面试的时候学习用的,我给的解法肯定不是最优解法。而且我也不知道你标准的最优解法是啥。。 |
不是我标准的最优解法。。只是说面试考你算法的时候,面试官可能会问你如何优化。。如果说给不出最优解的话,可能分会给你较低一点。 |
比如你在《判断两个给定的字符串排序后是否一致》里面的解法, 再来看算法,表面上是一次迭代,时间复杂度为 O(N),但其实没考虑到 func isRegroup(s1,s2 string) bool {
sl1 := len([]rune(s1))
sl2 := len([]rune(s2))
if sl1 > 5000 || sl2 > 5000 || sl1 != sl2{
return false
}
for _,v := range s1 {
if strings.Count(s1,string(v)) != strings.Count(s2,string(v)) {
return false
}
}
return true
} 那面试官可能会问:“能实现时间复杂度为 O(N) 的算法吗?” |
@TheStarBoys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: