leetcode mountain index array

【DP】LeetCode 70. 爬楼梯

题目链接 70. 爬楼梯 思路 分析动态规划题目的时候只需要考虑最后一个阶段,因为所有的阶段转化都是相同的,考虑最后一个阶段容易发现规律 表示状态 假设走到了最后一层台阶,考虑一下我们要存储的信息: 走到这最后一层台阶的方法数 当前台阶数,用于判断是否走到了最后一层台阶 这时候很容易想到使用一维数组 ......
楼梯 LeetCode 70

[LeetCode] 1338. Reduce Array Size to The Half 数组大小减半

You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum ......
数组 LeetCode 大小 Reduce Array

JS_Array

......
JS_Array Array JS

np.array和np.ndarry 的区别

np.array和np.ndarray都是NumPy中用于创建多维数组的函数。 np.ndarray是NumPy中的多维数组类,它是一种可变的数组,可以通过修改数组中的元素来改变其内容。使用np.ndarray创建的数组必须指定形状、元素类型和存储器位置等参数。例如,可以使用以下代码创建一个2x2的 ......
ndarry array np

VLOOKUP 、 INDEX 、MATCH

VLOOKUP : VLOOKUP函数是Excel中的一个纵向查找函数,它与LOOKUP函数和HLOOKUP函数属于一类函数,在工作中都有广泛应用,例如可以用来核对数据,多个表格之间快速导入数据等函数功能。功能是按列查找,最终返回该列所需查询序列所对应的值;与之对应的HLOOKUP是按行查找的。 V ......
VLOOKUP INDEX MATCH

Leetcode(剑指offer专项训练)——DP专项(4)

加减的目标值 给定一个正整数数组 nums 和一个整数 target 。 向数组中的每个整数前添加 '+' 或 '-' ,然后串联起所有整数,可以构造一个 表达式 : 例如,nums = [2, 1] ,可以在 2 之前添加 '+' ,在 1 之前添加 '-' ,然后串联起来得到表达式 "+2-1" ......
专项 Leetcode offer

代码随想录Day17-Leetcode110.平衡二叉树,257. 二叉树的所有路径,404.左叶子之和

110.平衡二叉树 题目链接:https://leetcode.cn/problems/balanced-binary-tree/ 一个显然但似乎不太高效的方法是: 通过递归获取左右子树高度,判断差; 然后递归判断左右结点; 那么一个显然的改进就是后序遍历 /** * Definition for ......
随想录 之和 随想 路径 Leetcode

LeetCode 85. Maximal Rectangle

class Solution { public: int method(vector<int> h)//求柱状图中最大的矩形 { int n=h.size(); vector<int> l=vector<int> (n),r=l; stack<int> st; //预处理l,r数组 for(int ......
Rectangle LeetCode Maximal 85

java方法-Arrays类

Arrays类 数组的工具类java.util.Arrays 由于数组对象本身并没有什么方法可以供我们调用,但API中提供了一个工具类Arrays供我们使用,从而可以对数据对象进行一些基本的操作 查看JDK帮助文档 Arrays类中的方法都是static修饰的静态方法,在使用的时候可以直接使用类名进 ......
方法 Arrays java

leetcode876. 链表的中间结点

876. 链表的中间结点 方法一: 最简单的做法,先求出整个链表的长度,再求1/2处节点的位置。 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode( ......
结点 leetcode 876

练习——Arrays类小练

package com.arrays_; import java.util.Arrays; import java.util.Comparator; public class ArraysExercise { public static void main(String[] args) { /* 案 ......
Arrays

Leetcode Practice --- 栈和队列

155. 最小栈 设计一个支持 push ,pop ,top 操作,并能在常数时间内检索到最小元素的栈。 实现 MinStack 类: MinStack() 初始化堆栈对象。 void push(int val) 将元素val推入堆栈。 void pop() 删除堆栈顶部的元素。 int top() ......
队列 Leetcode Practice

leetcode-733-easy

Flood Fill An image is represented by an m x n integer grid image where image[i][j] represents the pixel value of the image. You are also given three ......
leetcode easy 733

leetcode-1005-easy

Maximize Sum Of Array After K Negations Given an integer array nums and an integer k, modify the array in the following way: choose an index i and rep ......
leetcode 1005 easy

leetcode-724-easy

Find Pivot Index Given an array of integers nums, calculate the pivot index of this array. The pivot index is the index where the sum of all the numbe ......
leetcode easy 724

leetcode-762-easy

Prime Number of Set Bits in Binary Representation Given two integers left and right, return the count of numbers in the inclusive range [left, right] ......
leetcode easy 762

leetcode-744-easy

Find Smallest Letter Greater Than Target You are given an array of characters letters that is sorted in non-decreasing order, and a character target. ......
leetcode easy 744

LeetCode 100 相同的树

LeetCode | 100.相同的树 给你两棵二叉树的根节点 p 和 q ,编写一个函数来检验这两棵树是否相同。 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 示例 1: 输入:p = [1,2,3], q = [1,2,3] 输出:true 示例 2: 输入:p = [1, ......
LeetCode 100

LeetCode 94 二叉树的中序遍历

LeetCode | 94.二叉树的中序遍历 给定一个二叉树的根节点 root ,返回 它的 中序 遍历 。 示例 1: 输入:root = [1,null,2,3] 输出:[1,3,2] 示例 2: 输入:root = [] 输出:[] 示例 3: 输入:root = [1] 输出:[1] 提示: ......
LeetCode 94

反转链表-leetcode92

给你单链表的头指针 head 和两个整数 left 和 right ,其中 left <= right 。请你反转从位置 left 到位置 right 的链表节点,返回 反转后的链表 。 示例 1: 输入:head = [1,2,3,4,5], left = 2, right = 4 输出:[1,4 ......
leetcode 92

LeetCode 2367 算术三元组的数目

给你一个下标从 0 开始、严格递增 的整数数组 nums 和一个正整数 diff 。如果满足下述全部条件,则三元组 (i, j, k) 就是一个 算术三元组 : i < j < k , nums[j] - nums[i] == diff 且 nums[k] - nums[j] == diff 返回不 ......
算术 数目 LeetCode 2367

mysql Error:index column size too large. the maximum column size is 767 bytes

问题现象 mysql在执行脚本create创建表时,提示以下错误: index column size too large. the maximum column size is 767 bytes 异常原因 INNODB 引擎,UTF-8,主键字符串 默认最大 767,需要修改 解决方案 对数据库 ......
column size maximum mysql Error

【DP】LeetCode 62. 不同路径

题目链接 62. 不同路径 思路 代码 class Solution { public int uniquePaths(int m, int n) { int[][] dp = new int[m][n]; Arrays.fill(dp[0], 1); for(int i = 0; i < m; i ......
路径 LeetCode 62

leetcode top100-01

最好能说明一下为什么不怕重复。看评论里有很多人提出这个问题,说hash冲突。 我在这里解答一下这个问题。 1.每次写入时,判断条件 不是当前的key本身存不存在,而是key和 tag 之间的差值存不存在,这一点很重要。 2.题目命题说明了一点,假定只有一个解。也就是说重复元素再多都无所谓。 case ......
leetcode 100 top 01

leetcode top100 - 02

坑 转换成数字进行运算,最后转换成链表。可能会出现溢出的情况。 因为无论是int还是long类型表达的数字长度是有限的,而链表的长度是可以无限追加的。 解释是干扰你的,其实就是依次从低位到高位的进位过程 笔试思路 把链表依次填充到数组中,数组容易操作,然后逐位进行加法运算; 面试思路 使用链表的思路 ......
leetcode 100 top 02

Leetcode19. 删除链表的倒数第 N 个结点

19. 删除链表的倒数第 N 个结点 自己纯手写第一题,递归有点冗杂,开辟了虚拟头节点,而且要特别注意边界条件(当倒数第n个正好是头节点时)。 ** * Definition for singly-linked list. * struct ListNode { * int val; * ListN ......
结点 Leetcode 19

How to get indices of top-K values from a numpy array

How to get indices of top-K values from a numpy array np.argpartition(probs,-5)[-5:] ......
indices values array numpy top-K

代码随想录Day16-Leetcode104. 二叉树的最大深度,111.二叉树的最小深度 ,222.完全二叉树的节点个数

104. 二叉树的最大深度 首先是层序遍历 /** * Definition for a binary tree node. * function TreeNode(val, left, right) { * this.val = (val undefined ? 0 : val) * this.l ......
深度 随想录 节点 随想 个数

indices和Index的不同

Both "indexes" and "indices" are acceptable plural forms of the word "index" or to refer to more than one index. Index is one of those rare words that ......
indices Index

LeetCode 287. 寻找重复数

LeetCode 287. 寻找重复数 题目 \287. 寻找重复数 中等 2.1K 相关企业 给定一个包含 n + 1 个整数的数组 nums ,其数字都在 [1, n] 范围内(包括 1 和 n),可知至少存在一个重复的整数。 假设 nums 只有 一个重复的整数 ,返回 这个重复的数 。 你设 ......
LeetCode 287