ICode9

精准搜索请尝试: 精确搜索
  • 915.[C]分割数组2021-09-23 17:02:53

    题目描述 解题思路 假如按i分割,【0···i】为left,【i+1···numsSize-1】为right,maxLeft【i】为按i分割时left中的最大值,minRight【i】为按i分割时right中的最小值。遍历得到所有maxLfet【i】和minRight【i】,找出最小的i使maxLeft【i】<=minRight【i】即可 代码

  • LeetCode 5.最长回文子串 C#2021-06-06 23:58:17

    原题:https://leetcode-cn.com/problems/longest-palindromic-substring/ 给你一个字符串 s,找到 s 中最长的回文子串。 示例 1: 输入:s = "babad" 输出:"bab" 解释:"aba" 同样是符合题意的答案。 示例 2: 输入:s = "cbbd" 输出:"bb" 示例 3: 输入:s = "a" 输出:&qu

  • 【LeetCode】42.接雨水2020-12-26 23:01:06

    题目链接 42. 接雨水 题目描述 解题思路 暴力法(按列求取雨水值) 因为首尾元素不可能存在雨水,所以可以不用考虑首尾元素。 对于剩余的每个元素,分别计算从该元素开始,从左和从右开始开始的最大值,然后当前元素对应的能够接的雨水值 = Math.min(maxLeft,maxRight) - height[i]; 时间复杂

  • 915. Partition Array into Disjoint Intervals2020-05-23 12:07:18

    问题: 给定数组,切分为left和right,使得left的所有元素<=right的所有元素,返回left的长度 Example 1: Input: [5,0,3,8,6] Output: 3 Explanation: left = [5,0,3], right = [8,6] Example 2: Input: [1,1,1,0,6,12] Output: 4 Explanation: left = [1,1,1,0], right = [6,12] No

  • LeetCode刷题笔记-4. 寻找两个有序数组的中位数2020-03-07 10:36:03

    题目: 给定两个大小为 m 和 n 的有序数组 nums1 和 nums2。 请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。 你可以假设 nums1 和 nums2 不会同时为空。 示例 1: nums1 = [1, 3] nums2 = [2] 则中位数是 2.0 示例 2: nums1 = [1, 2] nums2 = [3,

  • 给定两个大小为 m 和 n 的有序数组 nums1 和 nums2。 请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。 你可以假设 nums1 和 nums2019-12-19 16:52:50

    class Solution { public double findMedianSortedArrays(int[] A, int[] B) { int m = A.length; int n = B.length; if (m > n) { // to ensure m<=n int[] temp = A; A = B; B = temp; int tmp = m; m = n; n =

  • 【Leetcode】4. 寻找两个有序数组的中位数(Median of Two Sorted Arrays)2019-06-02 14:47:49

    Leetcode - 4 Median of Two Sorted Arrays (Hard) 题目描述:要求时间复杂度为 O(log(m + n))。 nums1 = [1, 3] nums2 = [2] The median is 2.0 解题思路:二分。 left_part | right_part A[0], A[1], ..., A[i-1] | A[i], A[i+1], ..., A[m-1] B[

  • 垂直投影法分割验证码2019-04-20 10:48:56

    垂直投影法分割验证码 背景: 在在上一篇的文章中,我们获得了能够破解验证码的完整的步骤的程序,虽然很简单,但是整体的框架已经设计完毕,接下来只要对其中的算法进行改进即可。 老规矩,先附上缺的上一次的链接地址: 神经网络3.0(验证码识别) 其中是上一次的代码和五张测试用的图片。(为

  • Master公式计算递归时间复杂度2019-04-06 09:49:30

    我们在算递归算法的时间复杂度时,Master定理为我们提供了很强大的便利! Master公式在我们的面试编程算法中除了BFPRT算法的复杂度计算不了之外,其他都可以准确计算! 这里用求数组最大值的递归函数来举例: public static int getMax(int[] arr, int L, int R) { if (L == R) {

  • leecode第四题(寻找两个有序数组的中位数)2019-03-21 14:47:38

     题解:   class Solution {public: double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) { int m = nums1.size(); int n = nums2.size(); if (m > n) return findMedianSortedArrays(nums2, nums1);

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有