You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
###1. 两个数之和解题小结:
//for each num in nums , check (target - num) exists in nums
//解法1:check的过程,可以通过遍历逐个元素解决,复杂度O(n^2)
//解法2:check的过程,用hashMap解决, 只要put了每个num,两次hashMap,复杂度O(n)
###1. 两个数之和解题小结:
//for each num in nums , check (target - num) exists in nums
//解法1:check的过程,可以通过遍历逐个元素解决,复杂度O(n^2)
//解法2:check的过程,用hashMap解决, 只要put了每个num,两次hashMap,复杂度O(n)
###2. 字母异位词分组小姐:
输出的结果是一个list,每个元素是异位词的集合list,所以用key=异位词的一个map存储,在遍历源数据的时候直接put一个KV piar,O(n)复杂度
重点在于key怎么取?
for (str : stringList) {
key = compute(str);
if (!hasMap.contains(key)) hashMap.put(key, new ArrayList());
}
str转为char[],进行排序后,再toString,O(nlogn)
###3. 递归的代码模板
###4. 分治的模板
data = prepare_data(problem);
subproblems = split_problem(problem, data);
subres1 = self.
subres2 =
result = process_res(subres1, subres2, ...);
The text was updated successfully, but these errors were encountered: