LeetCode刷题笔录Container With Most Water

相机标定-张正友棋盘格标定法 (X,Y,Z)为在世界坐标系下一点的物理坐标 ( u , v ) 为该点对应的在像素坐标系下的像素坐标 引入齐次坐标的原因:引入齐次坐标的目的是为了升维,将坐标从二维坐标变为三维坐标。 2.相机成像过程 相机成像系统中,共包含四个坐标系:世界坐标系、相机坐标系、图像坐标系、像素坐标系。 (1)世界坐标系(,,) 描述目标在真实世界中的位置引入的参考坐标系。 (2)相机坐标系(,,) ... 阅读详情

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 container, such that the container contains the most water.

Note: You may not slant the container.


只想出了O(n^2)的brute force解法。google了一下发现了这么个解法:

start 和end分别指向数组的头和尾。则当前的container的容积为area=min(height[start],height[end])*(end-start)。假设height[start]<height[end],那么无论end取任何一个值,以start为一条边的容器的area不可能比当前的这个area更大。原因是容器的容积是由较短的那条边决定的。因此这是做start++,进行下一次比较。对于height[end]<height[start]的情况同理end--。

public class Solution {
    public int maxArea(int[] height) {
        if(height.length < 2)
            return 0;
        int start = 0;
        int end = height.length - 1;
        int maxArea = 0;
        int area;
        while(start < end){
            if(height[start] < height[end]){
                area = height[start] * (end - start);
                start++;
            }
            else{
                area = height[end] * (end - start);
                end--;
            }
            if(maxArea < area)
                maxArea = area;
        }
        return maxArea;
    }
}


【异常】插入Milvus时出现无法插入的情况提示io.milvus.exception.ParamException: The field: meta is not provided. 在使用 Milvus 进行向量搜索时遇到 io.milvus.exception.ParamException: The field: meta is not provided 错误通常意味着在创建集合(Collection)或者插入数据(Insert)时,某些必需的元数据字段没有被正确提供。检查集合创建,确保在创建集合时,你已经定义了所有必需的字段,并且正确地使用了 SchemaField 来定义这些字段。例如,如果你在创建集合时没有正确设置元数据字段,就会出现这个错误。请严格按照这个表结构创建。 阅读详情

相关推荐

Hermes深入理解及源码解析(二):Hermes的记忆机制

源码位置:tools/memory_tool.py存储内容为两个文件,放在 ~/.hermes/memories/:MEMORY.md:Agent 自己的笔记(环境事实、项目约定、工具坑、学到的东西)—— 上限 2200 字符USER.md:关于用户的画像(角色、偏好、沟通风格)—— 上限 1375 字符作为一个独立的工具注册在系统中(为了让智能体正确使用它,System Prompt()中明确下达了禁令存储目标存储位置数据类型持久偏好/事实MEMORY.md我是谁、我喜欢什么、环境配置。

qq_41984117的博客 558

LeetCode刷题笔录 Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo

likecool21的专栏 1万+

LangChain4j + Milvus 从0-1实现会话管理与RAG检索的AIChat超详细教程

本教程将介绍如何使用LangChain4j和Milvus向量数据库构建一个具备流式输出、会话管理、会话隔离和基于文档RAG检索能力的AI机器人。我们将使用阿里百炼模型作为LLM后端,并通过Docker部署Milvus向量数据库。创建Assistant接口,定义聊天服务:LangChain4j 中文文档 | LangChain4j 中文文档wiringMode :这个属性一般两种,一种是自动装配,我们这里选择手动配置。

2301_80014343的博客 1434

LeetCode刷题笔录 Two Sum

Two Sum Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the

likecool21的专栏 1万+

避坑指南:在Linux服务器上用Conda安装antiSMASH 5.2.0(解决Jinja2报错和Matplotlib权限问题)

本文详细介绍了在Linux服务器上使用Conda安装antiSMASH 5.2.0的避坑指南,重点解决了Jinja2报错和Matplotlib权限问题。通过创建专用conda环境、安装指定版本依赖包和配置缓存目录,帮助用户顺利完成antiSMASH的本地部署,适用于批量处理基因组分析任务。

weixin_26911099的博客 314

linux redis7 完整的集群搭建过程

一。安装: 1.1 说明: Redis官方只提供了源码,并没有提供经过编译之后的安装包。 因此,安装Redis,要先编译、后安装。(即源码安装方式) 注意:需要联网安装 1.2 安装编译的工具: yum install gcc gcc-c++ -y 1.3 下载tar包,上传到linux服务器,解压配置环境变量 1.4 cd +解压的目录下:编译 make 注意:如果编译失败,请重新进行解压编译,...

m0_38028438的博客 719

LeetCode刷题笔录 Validate Binary Search Tree

Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key.Th

likecool21的专栏 6928

Manimgl 进阶笔记

目录 一、调整视频输出的纵横比 二、调整预览窗口的尺寸 三、在开发工具中直接调试 一、调整视频输出的纵横比 调整输出视频的纵横比,在日常开发中属于比较基本的需求。要使用 Manimgl 得到期望的分辨率的视频输出需要修改以下几个地方: 第一步:在 custom_config.yml 配置文件中通过 camera_qualities设置视频的输出分辨率。manimlib 框架已经在 default_config.yml 文件中设置了四种视频输出分辨率,default_qualities 参数.

gunnery的专栏 2856

Stanford Algorithms学习:Clustering 2

这是紧接上面的一道题,比较有趣 Question 2 In this question your task is again to run the clustering algorithm from lecture, but on a MUCH bigger graph. So big, in fact, that the distances (i.e., edge costs

likecool21的专栏 2567

手把手教你学PCIE--基本概念:PCIe 初始化流程概述

硬件上电复位:系统上电时,所有 PCIe 设备都会进行复位。链路训练(Link Training):主机和设备之间通过链路训练状态机(LTSSM)协商链路参数(如速度和宽度)。配置空间访问:主机通过配置空间读写来发现和配置设备。资源分配:主机为设备分配内存映射 I/O 区域(BARs)、中断向量等资源。驱动程序加载和高级配置:操作系统加载设备驱动程序,并进行更高级的配置和状态监控。硬件上电复位:确保所有设备处于已知的良好状态。链路训练:主机和设备通过 LTSSM 协商链路速度和宽度。

MHD0815的博客 1373

【车载以太网】【AVB/TSN】IEEE802.1Qav队列及转发协议

目录 一、概述 二、优先级排队算法 三、基于信用的流量整形算法 一、概述 IEEE 802.1Qav 队列及转发协议(Qav)针对不同数据流选择不同的传输选择算法来保障对时间敏感的 AV 数据流的实时传输。为了避免传统的异步以太网数据流量与 AVB 流量之间对网络资源的竞争,AVB 交换机内使用优先级排队算法和基于信用的流量整形算法实现数据流的调度。 二、优先级排队算法 优先级排队算法主要用于传统以太网数据流(BE, Best Effort)的调度传输,BE 流通过基于优先级...

专注汽车软件开发、AutoSAR、车载以太网、SOA、EE架构。 4687

Stanford Algorithms学习:Clustering

第二周的第一个编程作业,是利用贪婪算法来实现一个clustering的问题,和ML里学的unsupervised learning差不多。 Question 1 In this programming problem and the next you'll code up the clustering algorithm from lecture for computing a

likecool21的专栏 2507

【专栏必读】王道考研408操作系统+Linux系统编程万字笔记使用说明及章节导航

王道408考研操作系统)第一章计算机系统概述-第一节1、2:操作系统概念、概念和特征1:理解fork的作用prinf("还没有执行fork函数的本进程为:%d\n" , getpid());//其返回值是pid类型的 sleep(1);if(ret > 0) //父进程返回的是子进程ID {printf("我是父进程,我的id是:%d,我的孩子id是%d\n" , getpid() , ret);sleep(1);} } else if(ret == 0) //子进程fork返回值是0 {.........

快乐江湖的博客 3万+

LeetCode 刷题笔录 Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link

likecool21的专栏 1806

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

LeetCode刷题笔录Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word:

likecool21的专栏 1296

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

LeetCode刷题笔录Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.

likecool21的专栏 1109

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

LeetCode刷题笔录Unique Binary Search Trees

这里有个讲解(印度人口音真难懂)

likecool21的专栏 1043

LeetCode刷题笔录 Pascal's Triangle II

Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? 这题比较简单

likecool21的专栏 1043

LeetCode刷题笔录 Reverse Integer

Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 随手写的一个,正常的读出每一位的数字然后反序: import java.lang.Math; public class Solution { public int revers

likecool21的专栏 941

LeetCode刷题笔录Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the tota

likecool21的专栏 878

LeetCode刷题笔录Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the f

likecool21的专栏 865

LeetCode刷题笔录Convert Sorted Array to Balanced Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 这题可以kan'chu'lai

likecool21的专栏 855

求集合的交集/差集

先利用外部排序使两个磁盘文件有序,然后顺序读取两个文件,使用双指针求交集。在进阶 1 中,我们是通过双指针去做的,最坏情况下我们需要完整遍历。时,O(n log m) 可能明显优于 O(n + m)。的,这就使得我们可以通过从 1~1000 遍历来确定交集。,它们已经按非降序排序,请你返回两个数组的。和上一题的区别在于,这里需要找到重复的元素。返回一个数组,数组中的每个元素在。的每个字符串中都出现的共用字符(**注意:**列表中的整数可以按。较小,可以完整加载到内存,而。正整数组成的一个非空数组,按。

jyyyyx的算法之旅 112

LeetCode 面试经典 150_多维动态规划_交错字符串(97_C++_中等)

LeetCode 面试经典 150_多维动态规划_交错字符串(97_C++_中等) 题目描述: 给定三个字符串 s1、s2、s3,请你帮忙验证 s3 是否是由 s1 和 s2 交错 组成的。 两个字符串 s 和 t 交错 的定义与过程如下,其中每个字符串都会被分割成若干 非空 子字符串: - s = s1 + s2 + ... + sn - t = t1 + t2 + ... + tm - |n - m| <= 1 - 交错 是 s1 + t

huayimenghan的博客 204

LeetCode 每日一题 2026/11/2-2026/11/8

记录了初步解题思路 以及本地实现代码;并不一定为最优 也希望大家能一起探讨 一起进步

AlphaTao的博客 175

LeetCode Hot 100 二叉树专题(二)3 题(Java)

本篇文章共 3 题:543. 二叉树的直径、102. 二叉树的层序遍历、108. 将有序数组转换为二叉搜索树。 每道题都统一按「① 题目分析 & 解题思路 → ② 常见解法(附代码)及讲解 → ③ 知识点总结」的顺序组织;代码使用 Java 编写,节点定义沿用 LeetCode 默认的 TreeNode。

2401_88612756的博客 362
上一篇: LeetCode刷题笔录Search a 2D Matrix
下一篇: LeetCode刷题笔录Linked List Cycle II
likecool21
博客等级 码龄14年 14粉丝 123原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值