string.erase的时间复杂度
时间: 2023-09-21 22:09:42 浏览: 397
排序算法的时间复杂度
根据引用,erase()函数可以用来删除单个元素或一个区间内的所有元素。对于字符串str,如果删除单个元素或者一个区间内的元素,时间复杂度均为O(n),其中n为字符串的长度。因此,string.erase的时间复杂度为O(n)。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* *3* [string 整理](https://blog.csdn.net/LovelyZhou/article/details/104420853)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
- *2* [C++之string定义、用法详解](https://blog.csdn.net/qq_33375598/article/details/88218117)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文