leetcode negative numbers matrix
LeetCode Top100: 合并两个有序链表 (python)
将两个升序链表合并为一个新的 升序 链表并返回。新链表是通过拼接给定的两个链表的所有节点组成的。 示例 1: 输入:l1 = [1,2,4], l2 = [1,3,4] 输出:[1,1,2,3,4,4] 示例 2: 输入:l1 = [], l2 = [] 输出:[] 示例 3: 输入:l1 = [] ......
abc250_d 250-like Number 题解
250-like Number 题意 给定一个整数 $n$,求有多少小于等于 $n$ 的满足以下条件的整数 $k$: $k$ 可以被表示为 $k = p \times q^3$,其中 $p \lt q$,并且 $p, q$ 均为质数。 数据范围 $1 \leqslant n \leqslant 10 ......
leetcode160-相交链表
leetcode160 方法一:哈希表 思路: 先创建一个unordered_set,存放ListNode*类型的变量 先遍历其中一个链表,把所有节点的指针放在set中 再遍历另一个链表,查找是否存在一个节点已经在set中,如果存在则说明这是它们的相交节点的指针,返回这个指针,如果不存在则说明不存在 ......
LeetCode-Top100: 有效的括号 (python)
给定一个只包括 '(',')','{','}','[',']' 的字符串 s ,判断字符串是否有效。 有效字符串需满足: 左括号必须用相同类型的右括号闭合。 左括号必须以正确的顺序闭合。 每个右括号都有一个对应的相同类型的左括号。 示例 1: 输入:s = "()" 输出:true 示例 2: 输入 ......
Minimum Number of Visited Cells in a Grid
Minimum Number of Visited Cells in a Grid You are given a 0-indexed m x n integer matrix grid . Your initial position is at the top-left cell (0, 0). ......
leetcode_打卡5
leetcode_打卡5 题目:345. 反转字符串中的元音字母 思路:双指针 class Solution { public String reverseVowels(String s) { int n=s.length(); char[] arr=s.toCharArray(); int i=0 ......
LeetCode-Top100:两数之和(python)
给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。 你可以按任意顺序返回答案。 示例 1: 输入:nums = [2,7, ......
B - Coloring Matrix
B - Coloring Matrix https://atcoder.jp/contests/abc298/tasks/abc298_b 思路 判断A矩阵是否满足条件, 不符合,对A矩阵逆时针旋转, 旋转后对A矩阵继续判断, 直到满足条件,或者A矩阵复位。 Code #include <ioman ......
LeetCode 双周赛 102,模拟 / BFS / Dijkstra / Floyd
本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 [彭旭锐] 提问。 大家好,欢迎来到小彭的 LeetCode 周赛解题报告。 昨晚是 LeetCode 双周赛第 102 场,你参加了吗?这场比赛比较简单,拼的是板子手速,继上周掉大分后算是回了一口血 😁。 2618. 查询网 ......
vscode number of cursors limited to 10000 bug All In One
vscode number of cursors limited to 10000 bug All In One
vscode 全局替换光标限制最多 10000 个 ❌
......
【前缀和】LeetCode 523. 连续的子数组和
题目链接 523. 连续的子数组和 思路 参考宫水三叶大佬题解 一开始以为和 Leetcode 53 Maximum Subarray 思路差不多,都是求子数组的值。但是后来发现在53题中并没有求出每个子数组的和,只是在贪心的情况下求出了可能的最大和 代码 class Solution { publ ......
[LeetCode] 1042. Flower Planting With No Adjacent
You have n gardens, labeled from 1 to n, and an array paths where paths[i] = [xi, yi] describes a bidirectional path between garden xi to garden yi. I ......
LeetCode 115. 不同的子序列
class Solution { public: long long f[1010][1010];//f[i][j]表示s前i个字符得到t前j个字符的所有方案 int numDistinct(string s, string t) { f[0][0]=1; int n=s.size(),m=t.si ......
TypeScript 报错:Type '({ filename: string; createTime: string; filePath: string; fileId: number; } | undefined)[]' is not assignable to type 'PiFile[]'.
问题: 因为TypeScript不支持直接给一个接口类型的变量 赋一个未知的值。 如 const a:A = { name:'s' }; 你需要给这样的对象或数组值使用as 指定一个类型。 正确写法: const a:A = { name:'s' } as A; 数组写法一样: const a:A[ ......
LeetCode/最大化城市的最小供电站数目
政府批准了可以额外建造 k 座供电站,你需要决定这些供电站分别应该建在哪里,这些供电站与已经存在的供电站有相同的供电范围。 给你两个整数 r 和 k ,如果以最优策略建造额外的发电站,返回所有城市中,最小供电站数目的最大值是多少。 ###一. 二分法+前缀和+贪心 分析:最大化最小值,首先考虑使用二 ......
UVA1650 数字串 Number String
对于任意一个只含数字1~n的有序数字串{a1,a2,……,an},比较数字串中所有相邻数字的大小,后者大于前者的用I表示,否则用D表示。例如,数字串{3,1,2,7,4,6,5},{2,1,3,7,4,6,5}和{3,1,2,7,5,6,4}就表示为'DIIDID'。"?"则表示两数的关系未知。例如 ......
leetcode-1337-easy
The K Weakest Rows in a Matrix You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers ......
leetcode-1342-easy
Number of Steps to Reduce a Number to Zero Given an integer num, return the number of steps to reduce it to zero. In one step, if the current number i ......
leetcode-1360-easy
Number of Days Between Two Dates Write a program to count the number of days between two dates. The two dates are given as strings, their format is YY ......
leetcode-766-easy
Toeplitz Matrix Given an m x n matrix, return true if the matrix is Toeplitz. Otherwise, return false. A matrix is Toeplitz if every diagonal from top ......
leetcode-806-easy
Number of Lines To Write String You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase ......
leetcode-812-easy
Largest Triangle Area Given an array of points on the X-Y plane points where points[i] = [xi, yi], return the area of the largest triangle that can be ......
leetcode-830-easy
Positions of Large Groups In a string s of lowercase letters, these letters form consecutive groups of the same character. For example, a string like ......
leetcode-844-easy
Backspace String Compare Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace c ......
leetcode-944-easy
Delete Columns To Make Sorted You are given an array of n strings strs, all of the same length. The strings can be arranged such that there is one on ......
代码随想录算法训练营Day01 | LeetCode704 二分查找、Leetcode27 移除元素
今日学习的视频和文章 代码随想录数组基础 复习基础知识 代码随想录 二分查找 代码随想录 移除元素 LeetCode704 二分查找 题目链接:704. 二分查找 - 力扣(Leetcode) 以前学二分查找的时候,真的一直搞不清楚怎么操作左边界和有边界,以及循环的终止条件是什么,总是自己慢慢调试出 ......
leetcode_打卡04
leetcode_打卡04 题目:605. 种花问题 解答: 三种情况: 第一个1的左边全是0的情况,此时 可以插入的位置为result=(i-1+1)/2 ,如【0,0,0,1,0,0,1】 两个1之间全是0的情况。此时 可以插入的位置为result=(i-flag-1-2+1)/2 第一个1的右 ......
LeetCode 周赛 340,质数 / 前缀和 / 极大化最小值 / 最短路 / 平衡二叉树
本文已收录到 AndroidFamily,技术和职场问题,请关注公众号 [彭旭锐] 提问。 大家好,我是小彭。 上周跟大家讲到小彭文章风格的问题,和一些朋友聊过以后,至少在算法题解方面确定了小彭的风格。虽然竞赛算法题的文章受众非常小,但却有很多像我一样的初学者,他们有兴趣参加但容易被题目难度和大神选 ......
LeetCode习题——有效的完全平方数(二分查找)
有效的完全平方数 力扣链接:367. 有效的完全平方数 题目 给你一个正整数 num 。如果 num 是一个完全平方数,则返回 true ,否则返回 false 。 完全平方数是一个可以写成某个整数的平方的整数。换句话说,它可以写成某个整数和自身的乘积。 不能使用任何内置的库函数,如 sqrt 。 ......
Q:oracle小于1的number,不显示小数点前的0?
oracle存储number类型数字 如果数字小于1 如0.35就会存储.35 省略掉前面的数字0 方法1: oracle 数据库字段值为小于1的小数时,转换到char类型处理,会丢失小数点前面的0 例如0.35就变成了.35 2.解决办法:用to_char函数格式化数字显示 select to_c ......