注释 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. 函数调用方式--__thiscall调用方式和__cdecl,__stdcall有什么区别

    函数调用方式--__thiscall调用方式和__cdecl,__stdcall有什么区别 首先,__thiscall是关于类的一种调用方式,它与其他调用方式的最大区别是:    __thiscall ...

  2. python3调用哈工大ltp

    运行环境ubuntu+python3 安装pyltp sudo pip3 install pyltp 下载ltp_data_v3.4.0模型 http://ltp.ai/ 分句 from pyltp ...

  3. LeetCode 218. The Skyline Problem 天际线问题(C++/Java)

    题目: A city's skyline is the outer contour of the silhouette formed by all the buildings in that city ...

  4. JAVA SOCKET多线程等待接受客户端信息实现

    服务端程序: public class Demo { public static void main(String[] args) { // TODO 自动生成的方法存根 try { ServerSo ...

  5. tomcat 多端口 多容器 多域名 配置

    先强调一个原则: server下面可以有多个service,用于配置不同监听端口 service下面可以有多个Host,用于配置该端口下的不同域名 Host里可以包含多个Context,用于配置该端口 ...

  6. Windows服务器使用Telegraf采集服务器监控指标输出到influxdb

    1.环境说明 操作系统:Windows Server 2008 R2 IP:192.168.10.135 官方文档地址 :https://docs.influxdata.com/telegraf/v1 ...

  7. PWA 学习笔记

    深入学习网址:https://developer.mozilla.org/zh-CN/docs/Web/Progressive_web_apps 一. 基本介绍 1. 渐进式:适用所有浏览器,因为它是 ...

  8. 1058 - Parallelogram Counting 计算几何

    1058 - Parallelogram Counting There are n distinct points in the plane, given by their integer coord ...

  9. Java之——23种设计模式汇总

    在软件开发的历程中,正是无数前辈们本着追求完美的架构设计和代码设计的初心.经过无数前辈们的探索和努力,逐渐形成了一系列的设计原则和设计模式. 对于Java语言来说,通常包含有6大设计原则和23种设计模 ...

  10. 微信小程序仿朋友圈功能开发(发布、点赞、评论等功能)

    微信小程序仿朋友圈功能开发(发布.点赞.评论等功能) 1.项目分析 项目整体分为三个部分 发布 展示 详情页 graph LR 朋友圈发布 --内容发布--> 内容展示 内容展示 --点击展示卡 ...