若是连着的"++", 就把这段用"--"替代放到res中. Note: 当i == s.length()-1走到最后一位时. s.substring(i+1), 不会out of index, 会返回"". 但再大就不行了. Time Complexity: O(n). Space: O(1) re ...
分类:
其他好文 时间:
2018-07-30 00:36:13
阅读次数:
104
与Group Anagrams类似. 维护一个HashMap, key是每个string 的 base型. Time Complexity: O(n * strings.length), n 是每个string的平均长度. Space: O(hm.size()), HashMap size. ...
分类:
其他好文 时间:
2018-07-23 00:07:36
阅读次数:
145
领域驱动设计之领域模型 加一个导航,关于如何设计聚合的详细思考,见这篇文章。 2004年Eric Evans 发表Domain-Driven Design –Tackling Complexity in the Heart of Software (领域驱动设计),简称Evans DDD。领域驱动设 ...
分类:
其他好文 时间:
2018-07-20 11:38:37
阅读次数:
159
Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. Examp ...
分类:
其他好文 时间:
2018-07-16 23:11:51
阅读次数:
185
可维护性的常见度量指标 Cyclomatic complexity 圈复杂度 Lines of Code LoC 代码行数 Maintainability Index (MI) 可维护性指数 Depth of Inheritance 继承的层次数 Class Coupling 类之间的耦合度 Uni... ...
分类:
其他好文 时间:
2018-06-24 10:28:25
阅读次数:
222
问题描述: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in O(n) complexity. ...
分类:
其他好文 时间:
2018-06-17 10:57:20
阅读次数:
142
问题描述: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Note: If t ...
1、 时间复杂度(Time Complexity) 一般情况下,算法中的基本操作重复执行次数是问题规模n的某个函数 f(n) ,算法的时间度量记作: T(n) = O(f(n)) 它表示随问题规模n的增大,算法执行时间的增长率和 f(n) 的增长率相同,称做算法的逐渐时间复杂度,简称时间复杂度。 在 ...
分类:
编程语言 时间:
2018-06-12 22:57:49
阅读次数:
202
描述Follow up for ”Search in Rotated Sorted Array”: What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a functi ...
分类:
编程语言 时间:
2018-06-11 17:07:51
阅读次数:
103
问题描述: Sort a linked list in O(n log n) time using constant space complexity. Example 1: Example 2: 解题思路: 说到O(nlogn)那就必然想到快速排序和归并排序和堆排序 参考大佬整理的方法 代码: 归 ...
分类:
其他好文 时间:
2018-06-11 11:01:16
阅读次数:
176