随笔分类 -  Leetcode

摘要:公众号:爱写bug 给定一个二进制数组, 计算其中最大连续1的个数。 Given a binary array, find the maximum number of consecutive 1s in this array. 示例 1: 注意: 输入的数组只包含 和 。 输入数组的长度是正整数,且 阅读全文
posted @ 2019-07-01 16:07 爱写Bug 阅读(243) 评论(0) 推荐(0)
摘要:Leetcode 344:Reverse String 反转字符串 公众号:爱写bug Write a function that reverses a string. The input string is given as an array of characters . Do not allo 阅读全文
posted @ 2019-06-30 16:36 爱写Bug 阅读(431) 评论(0) 推荐(0)
摘要:Leetcode 67:Add Binary(二进制求和) (python、java) Given two binary strings, return their sum (also a binary string). The input strings are both non empty an 阅读全文
posted @ 2019-06-27 16:17 爱写Bug 阅读(117) 评论(0) 推荐(0)
摘要:54:Spiral Matrix 螺旋矩阵 Given a matrix of m x n elements ( m rows, n columns), return all elements of the matrix in spiral order. 给定一个包含 m x n 个元素的矩阵( m 阅读全文
posted @ 2019-06-25 14:23 爱写Bug 阅读(136) 评论(0) 推荐(0)
摘要:118:Pascal's Triangle 杨辉三角 Given a non negative integer numRows , generate the first numRows of Pascal's triangle. 给定一个非负整数 numRows, 生成杨辉三角的前 numRows 阅读全文
posted @ 2019-06-25 14:22 爱写Bug 阅读(128) 评论(0) 推荐(0)
摘要:对角线遍历 给定一个含有 M x N 个元素的矩阵(M 行,N 列),请以对角线遍历的顺序返回这个矩阵中的所有元素,对角线遍历如下图所示。 Given a matrix of M x N elements (M rows, N columns), return all elements of the 阅读全文
posted @ 2019-06-05 14:23 爱写Bug 阅读(507) 评论(0) 推荐(0)
摘要:加一 给定一个由 整数 组成的 非空 数组所表示的非负整数,在该数的基础上加一。 最高位数字存放在数组的首位, 数组中每个元素只存储一个数字。 你可以假设除了整数 0 之外,这个整数不会以零开头。 Given a non empty array of digits representing a no 阅读全文
posted @ 2019-06-03 22:41 爱写Bug 阅读(241) 评论(0) 推荐(0)
摘要:Leetcode747至少是其他数字两倍的最大数 在一个给定的数组 中,总是存在一个最大元素 。查找数组中的最大元素是否至少是数组中每个其他数字的两倍。如果是,则返回最大元素的索引,否则返回 1。 Given an array of integers , write a method that re 阅读全文
posted @ 2019-05-29 22:17 爱写Bug 阅读(146) 评论(0) 推荐(0)
摘要:寻找数组的中心索引 给定一个整数类型的数组 ,请编写一个能够返回数组 “中心索引” 的方法。 我们是这样定义数组 中心索引 的:数组中心索引的左侧所有元素相加的和等于右侧所有元素相加的和。 如果数组不存在中心索引,那么我们应该返回 1。如果数组有多个中心索引,那么我们应该返回最靠近左边的那一个。 示 阅读全文
posted @ 2019-05-29 16:45 爱写Bug 阅读(498) 评论(0) 推荐(0)