选定一个列,比如用户编号列 //欲插入的用户编号string ll_userID="xxxxxxxx"; //查询此编号是否存在SqlCommand mycmd = new SqlCommand("select 用户编号 from table where 用户编号='"+ll_userID+"'", mycon); SqlDataReader mysdr = mycmd.ExecuteReader(); if (mysdr.HasRows)  {…
Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K. If there is no non-empty subarray with sum at least K, return -1. Example 1: Input: A = [1], K = 1 Output: 1 Example 2: Input: A = [1,2], K = 4 Output: -1 Exa…
返回 A 的最短的非空连续子数组的长度,该子数组的和至少为 K 如果没有和至少为 K 的非空子数组,返回 -1 . 示例 1: 输入:A = [1], K = 1 输出:1 示例 2: 输入:A = [1,2], K = 4 输出:-1 示例 3: 输入:A = [2,-1,2], K = 3 输出:3 1 <= A.length <= 50000 -10 ^ 5 <= A[i] <= 10 ^ 5 1 <= K <= 10 ^ 9 这道题的关键在于我们要知道各个区间的…
862. 和至少为 K 的最短子数组 知识点:单调:队列:前缀和 题目描述 返回 A 的最短的非空连续子数组的长度,该子数组的和至少为 K . 如果没有和至少为 K 的非空子数组,返回 -1 . 示例 输入:A = [1], K = 1 输出:1 输入:A = [1,2], K = 4 输出:-1 输入:A = [2,-1,2], K = 3 输出:3 解法一:单调队列+前缀和 这个题目是求连续子数组,所以自然可以想到前缀和,也就是用一个数组统计到第i个位置的前缀和.所以问题就变成了 j>i &am…
Your are given an array of positive integers nums. Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than k. Example 1: Input: nums = [10, 5, 2, 6], k = 100 Output: 8 Explanation: The 8…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 判断排序后是否相等 统计字符出现次数 日期 题目地址:https://leetcode-cn.com/problems/make-two-arrays-equal-by-reversing-sub-arrays/ 题目描述 给你两个长度相同的整数数组 target 和 arr . 每一步中,你可以选择 arr 的任意 非空子数组 并将它翻转.你可以执行…
Given an array A of non-negative integers, return the maximum sum of elements in two non-overlapping (contiguous) subarrays, which have lengths L and M.  (For clarification, the L-length subarray could occur before or after the M-length subarray.) Fo…
<二分查找+双指针+前缀和>解决子数组和排序后的区间和 题目重现: 给你一个数组 nums ,它包含 n 个正整数.你需要计算所有非空连续子数组的和,并将它们按升序排序,得到一个新的包含 n * (n + 1) / 2 个数字的数组. 请你返回在新数组中下标为 left 到 right (下标从 1 开始)的所有数字和(包括左右端点).由于答案可能很大,请你将它对 10^9 + 7 取模后返回. 示例 1:输入:nums = [1,2,3,4], n = 4, left = 1, right…
Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty subarray of C. Here, a circular array means the end of the array connects to the beginning of the array.  (Formally, C[i] = A[i]when 0 <= i < A.lengt…
In an array A of 0s and 1s, how many non-empty subarrays have sum S? Example 1: Input: A = [1,0,1,0,1], S = 2 Output: 4 Explanation: The 4 subarrays are bolded below: [1,0,1,0,1] [1,0,1,0,1] [1,0,1,0,1] [1,0,1,0,1] Note: A.length <= 30000 0 <= S <…