LeetCode Day 11】的更多相关文章

题目描述: Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note: You may assume the string contain only low…
原题链接:https://leetcode.com/problems/container-with-most-water/description/ 题目要求:给定n个非负整数a1,a2,...,an ,每一个整数对应一个坐标(i,ai ).以(i,0)和(i,ai )为端点画一条线段,现在选择两条线段,以x轴为底构成一个容器,请问选择那两条线段时可以使容器盛更多的水? 注意:“短板效应”,容量取决于短的那条边,以及两条线段之间的距离 思路:求出Max[min(line1,line2)*(i1-i…
ji那天居然早起了,惊呆我了,眼睛有点儿疼,一直流泪....继续保持 ========================================================== leetcode4 Median of Two Sorted Arrays leetcode11Container With Most Water leetcode153Sum ========================================================== 4讲的是给你n个…
题目 给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai) .在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0).找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水. 说明:你不能倾斜容器,且 n 的值至少为 2. 图中垂直线代表输入数组 [1,8,6,2,5,4,8,3,7].在此情况下,容器能够容纳水(表示为蓝色部分)的最大值为 49. 示例 输入: [,,,,,,,,] 输出: 解题 题目意思需要找到…
LeetCode0021 将两个有序链表合并为一个新的有序链表并返回.新链表是通过拼接给定的两个链表的所有节点组成的. 示例: 输入:1->2->4, 1->3->4 输出:1->1->2->3->4->4 利用哑节点,简单的合并两链表: /** * @param {ListNode} l1 * @param {ListNode} l2 * @return {ListNode} */ var mergeTwoLists = function (l1,…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 个人公众号:负雪明烛 本文关键词:盛水,容器,题解,leetcode, 力扣,python, c++, java 目录 题目描述 题目大意 解题方法 双指针 日期 题目地址:https://leetcode.com/problems/container-with-most-water/description/ 题目描述 Given n non-negative integers a1,…
题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a cont…
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a containe…
Problem: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a…
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a containe…