注释 testcases

(1)简单一想O(n)算法,有可能通过二分查找变形优化成log(n)

(2)双指针:一快一慢 一静一动(数组中最小的长度满足条件,常常用于,确定了一个范围,然后一个指针静止,一个指针收缩) 一前一后

(3)二分查找可以一次性做完,也可以分两次来做,一次用于二分查找左边确定左边界,一次用于二分查找确定右边界。

(4)数字理解成二进制的方法,就是通过一个bitvector,简而言之一个32位的数组,循环每一位进行处理。

(5)Maximum Subarray 问题,用localMax 记录每一次局部最大值,全局的最大值是局部最大值的最大值。

(6)找一个数字[1,n]中满足某个条件的数字,也可以把数字看成一个数组,通过采用二分查找的方式解决。

(7)一个hashmap 不够就用两个,一个用于记录原始的key,value值,一个用于扫描式和原始的hashmap进行比对。

(8)对于数学规律题,一定要多写几个case观察规律,尤其是数组中的规律问题。

(9)在代码写完之时,一定一定一定不能急,要写好test case

(10)多用hashset hashmap 利用空间复杂度先解决问题为上策

(11)一旦涉及到两个数的关系( ret = (((dividend ^ divisor) >> 31) & 1) == 1 ? -ret: ret;),就要考虑到两个数是正负号问题,是否会溢出问题。

(12)stack的应用不一定要存value 也可以存index,存index的好处是 一方面可以通过index获取到value 另外一方面可以通过Index解决 最长  最短问题。

leetcode再次总结的更多相关文章

  1. [LeetCode] Longest Substring with At Least K Repeating Characters 至少有K个重复字符的最长子字符串

    Find the length of the longest substring T of a given string (consists of lowercase letters only) su ...

  2. Leetcode 笔记 98 - Validate Binary Search Tree

    题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...

  3. Leetcode 笔记 36 - Sudoku Solver

    题目链接:Sudoku Solver | LeetCode OJ Write a program to solve a Sudoku puzzle by filling the empty cells ...

  4. [LeetCode] Matchsticks to Square 火柴棍组成正方形

    Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match ...

  5. [LeetCode] Split Array Largest Sum 分割数组的最大值

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  6. [LeetCode] Coin Change 硬币找零

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  7. [LeetCode] Additive Number 加法数

    Additive number is a positive integer whose digits can form additive sequence. A valid additive sequ ...

  8. [LeetCode] Word Pattern II 词语模式之二

    Given a pattern and a string str, find if str follows the same pattern. Here follow means a full mat ...

  9. [LeetCode] Single Number III 单独的数字之三

    Given an array of numbers nums, in which exactly two elements appear only once and all the other ele ...

随机推荐

  1. 解决Apple Mobile Device USB Driver

    在设备管理器里找到便携设备:APPLE IPHONE 更新驱动 自定义更新:在设备管理器里找到便携设备:APPLE IPHONE 更新驱动 自定义更新:C:\Program Files\Common ...

  2. qt QTreeWidget使用

    itemwidget.h #ifndef ITEMWIDGET_H #define ITEMWIDGET_H #include <QtWidgets/QWidget> #include & ...

  3. web前端sprite,精灵图,雪碧图

    css sprite 俗称:精灵图,雪碧图,指将整个页面不同的图片or图标合并在一张图上:优点:使用CSS Sprite 可以减少网络请求,提高网页加载性能,不会出现网页上端加载完毕下面还在加载中这一 ...

  4. Python学习--内置函数isinstance()

    内置函数isinstance() isinstance() 函数来判断一个对象是否是一个已知的类型,类似 type(). isinstance() 与 type() 区别: type() 不会认为子类 ...

  5. Codeforces_839

    A.每天更新判断. #include<bits/stdc++.h> using namespace std; ]; int main() { ios::sync_with_stdio(); ...

  6. WARNING OGG-00706 Failed to add supplemental log group on table

    在配置OGG时,需要给同步的表添加补充日志,在ggsci命令行执行 add trandata user.table   SQL> desc jack.t1 Name Null? Type --- ...

  7. javascript js全部的 全局属性 和 方法-window

    window method: open(URL,窗口名称,窗口风格)//打开一个新的窗口,并在窗口中装载指定URL地址的网页 close()//close方法用于自动关闭浏览器窗口 alert(提示字 ...

  8. golang函数 和 条件语句

    /* if : if 语句 由一个布尔表达式后紧跟一个或多个语句组成 is else : if 语句 后可以使用可选的 else 语句, else 语句中的表达式在布尔表达式为 false 时执行 s ...

  9. File、FileStream、StreamWriter、StringWriter文件使用总结

    一.File 1.File为静态类 File类,是一个静态类,支持对文件的基本操作,包括创建,拷贝,移动,删除和打开一个文件.File类方法的参量很多时候都是路径path.主要提供有关文件的各种操作, ...

  10. lwip eth插拔网线自动维护接口状态

    硬件连线就是将dp83848的INT脚连到STM32的某个中断脚上,这里是PB14 PB14的中断处理函数中,会释放一个信号量,这里只是发生链路状态改变中断(网线插上或拔下) void EXTI15_ ...