随笔分类 -  leetcode

摘要:给你一个长度为 n 的整数数组 nums 和一个整数 p,请你选出一个 非空 的子数组使得该子数组元素和对 p 的余数是 0,但不能选出全部元素。 计算这个子数组的长度,如果不存在这样的子数组,返回 -1。 一个数组的 子数组 定义为一个由数组中零个或者更多个连续元素组成的数组。 示例 1: 输入: 阅读全文
posted @ 2023-03-10 22:48 LYRiver 阅读(72) 评论(0) 推荐(0)
摘要:问题描述 在一个 m*n 的棋盘的每一格都放有一个礼物,每个礼物都有一定的价值(价值大于 0)。你可以从棋盘的左上角开始拿格子里的礼物,并每次向右或者向下移动一格、直到到达棋盘的右下角。给定一个棋盘及其上面的礼物的价值,请计算你最多能拿到多少价值的礼物? 示例 1: 输入: [ [1,3,1], [ 阅读全文
posted @ 2023-03-10 00:07 LYRiver 阅读(26) 评论(0) 推荐(0)
摘要:62. Unique Paths A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down 阅读全文
posted @ 2018-06-02 18:35 LYRiver 阅读(182) 评论(0) 推荐(0)
摘要:678. Valid Parenthesis String Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this strin 阅读全文
posted @ 2018-06-02 17:33 LYRiver 阅读(134) 评论(0) 推荐(0)
摘要:171. Excel Sheet Column Number Given a column title as appear in an Excel sheet, return its corresponding column number. For example: Example 1: Examp 阅读全文
posted @ 2018-06-01 22:36 LYRiver 阅读(204) 评论(0) 推荐(0)
摘要:172. Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. Example 1: Example 2: Note: Your solution should be in 阅读全文
posted @ 2018-06-01 22:18 LYRiver 阅读(190) 评论(0) 推荐(0)
摘要:75. Sort Colors Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the 阅读全文
posted @ 2018-05-30 21:36 LYRiver 阅读(140) 评论(0) 推荐(0)
摘要:55. Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represe 阅读全文
posted @ 2018-05-27 23:35 LYRiver 阅读(159) 评论(0) 推荐(0)
摘要:17. Letter Combinations of a Phone Number Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number 阅读全文
posted @ 2018-05-27 22:23 LYRiver 阅读(172) 评论(0) 推荐(0)
摘要:Longest Palindromic Substring Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Exam 阅读全文
posted @ 2018-05-25 18:55 LYRiver 阅读(93) 评论(0) 推荐(0)
摘要:3. Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. Examples: Giv 阅读全文
posted @ 2018-05-24 22:16 LYRiver 阅读(111) 评论(0) 推荐(0)
摘要:73. Set Matrix Zeroes Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Example 2: Follow up: A 阅读全文
posted @ 2018-05-23 00:01 LYRiver 阅读(168) 评论(0) 推荐(0)
摘要:49. Group Anagrams Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","e 阅读全文
posted @ 2018-05-21 23:48 LYRiver 阅读(95) 评论(0) 推荐(0)
摘要:15. 3Sum Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gi 阅读全文
posted @ 2018-05-20 15:16 LYRiver 阅读(145) 评论(0) 推荐(0)