算法PHP函数的strlen的复杂性() [英] Algorithmic complexity of PHP function strlen()

查看:127
本文介绍了算法PHP函数的strlen的复杂性()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近有人问我在采访这个问题,我不知道该怎么回答。

Recently I was asked this question on interview and I didn't know how to answer it.

任何人都可以回答这个问题,并形容它?

Can anyone answer this question and describe it?

推荐答案

O(1),因为长度存储为一个属性:的来源

O(1) since the length is stored as an attribute: source

不过,这种小事是值得的反制有关微优化影院的讨论,因为承蒙我们的东道主提供的<一个href="http://www.codinghorror.com/blog/2009/01/the-sad-tragedy-of-micro-optimization-theater.html">here和这里;阅读这两个环节,你会找到一个很好的谈论的焦点,以改变会话下一次类似的问题上来的气势,不管你是否知道具体的答案!

However, this trivia is worth countering with a discussion about micro-optimising theatre, as kindly provided by our hosts here and here; read those two links and you'll find a good talking point to change the momentum of the conversation next time similar questions come up, regardless of whether you know the particular answer!

如何面试官的反应,以你的切线会告诉你很多关于你是多么想与他们合作。

How the interviewer reacts to your tangent will tell you a lot about how much you want to work with them..

这篇关于算法PHP函数的strlen的复杂性()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆