提高查找三胞胎的时间复杂性
所讨论的程序是找到带有总和的数组/列表中的三重态数。
我的方法是首先排序阵列,然后使用两分点技术查找此类三胞胎。总体时间复杂性证明为O(n^2)。
有什么办法可以进一步改善时间复杂性?
The program in question is to find the number of triplets in an array/list with a given sum.
My approach has been to first sort the array and then use the two-pointer technique to find such triplets. The overall time complexity turns out to be O(n^2).
Is there any way how I can further improve the time complexity?.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论