Category: 算法
2 posts
Leetcode解题笔记——搜索Search(持续更新)
题目17:Letter Combinations of a Phone Number 内容: Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digit to letters (just like on... Read More
Comments: 0 Category: 算法 Time:算法的复杂度定义
不同算法的优劣,通过以下两个维度来衡量: 时间复杂度:是指执行当前算法所消耗的时间 空间复杂度:是指执行当前算法需要占用多少内存空间 时间复杂度: 定义:在进行算法分析时,语句总的执行次数T(n)是关于问题规模n的函数。定性描述该算法的运行时间。 通常使用 大O符号表示法来衡量其时间复杂度,,可看作是算法的渐进时间复杂度。 公式:T(n) = O (f(n))。 T(n)表示随输入规模n的增大,算法执行时间的增长率。其中f(n) 表示每行代码执行次数之和。 以下面例子为例: for(i=1;... Read More
Comments: 0 Category: 算法 Time: