zoukankan      html  css  js  c++  java
  • # LeetCode 4 ## problem4

    # LeetCode
    ## problem4
    ---
    There is a very obscure condition here:

    * i + j == m - i + n - j or i + j = m - i + n - j + 1,the former is taken when the sum of m and n is even,otherwise the latter.
    * i is the index of the first array who cut the first array into two subarrays,and i is the frist index of the right subarray.
    * j is the index of the second array who cut the second array into two subarrys,and i is the frist index of the right subarray.
    * m and n means length of the two arrays,and m is the greater one whose first right index is i.

    And the second condition is that :

    * If the a[i] >= b [j-1] && b[j] >= a[i-1],the i and j are the final result that we want.
    * The a[] and b[] are the two arrays.

    Then we can apply these two conditions into our binary search.

    The time complexity of the solution is O(min(m,n)).

  • 相关阅读:
    48-最长不含重复字符的子字符串
    51-数组中的逆序对
    字符串的排列
    二叉树转链表
    求根
    构造二叉树
    二叉树中序遍历
    反转链表系列
    斐波那契系列
    f.lux
  • 原文地址:https://www.cnblogs.com/xintt/p/8850291.html
Copyright © 2011-2022 走看看