博客
关于我
力扣LeetCode 268. 缺失数字
阅读量:273 次
发布时间:2019-03-01

本文共 638 字,大约阅读时间需要 2 分钟。

???????????????????????????????0?n?????????????????????????

????

???????????????????????????????

  • ???????????????1?
  • ???????????????0?

???????

  • ???????res??????n?
  • ??????????????res????????????i?
  • ??res??????????
  • ???????????O(n)????????????O(1)?

    ????

    public int missingNumber(int[] nums) {    int res = nums.length; // ???????????    for (int i = 0; i < nums.length; ++i) {        res ^= nums[i]; // ?????????        res ^= i;     // ??????    }    return res; // ????}

    ????

  • ???res??????res?????????n?
  • ????????????????????
  • ??????????????res ^= nums[i]?res ^= i???????????????????res??
  • ???????res????????????res?????
  • ???????????????????????????

    转载地址:http://tmmx.baihongyu.com/

    你可能感兴趣的文章
    Netty工作笔记0014---Buffer类型化和只读
    查看>>
    Netty工作笔记0050---Netty核心模块1
    查看>>
    Netty工作笔记0084---通过自定义协议解决粘包拆包问题2
    查看>>
    Netty常见组件二
    查看>>
    netty底层源码探究:启动流程;EventLoop中的selector、线程、任务队列;监听处理accept、read事件流程;
    查看>>
    Netty核心模块组件
    查看>>
    Netty框架的服务端开发中创建EventLoopGroup对象时线程数量源码解析
    查看>>
    Netty源码—2.Reactor线程模型一
    查看>>
    Netty源码—4.客户端接入流程一
    查看>>
    Netty源码—4.客户端接入流程二
    查看>>
    Netty源码—5.Pipeline和Handler一
    查看>>
    Netty源码—6.ByteBuf原理二
    查看>>
    Netty源码—7.ByteBuf原理三
    查看>>
    Netty源码—7.ByteBuf原理四
    查看>>
    Netty源码—8.编解码原理二
    查看>>
    Netty源码解读
    查看>>
    Netty的Socket编程详解-搭建服务端与客户端并进行数据传输
    查看>>
    Netty相关
    查看>>
    Network Dissection:Quantifying Interpretability of Deep Visual Representations(深层视觉表征的量化解释)
    查看>>
    Network Sniffer and Connection Analyzer
    查看>>