one number

2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it

杀马特。学长 韩版系。学妹 提交于 2021-02-13 03:52:36
链接: https://www.nowcoder.com/acm/contest/163/F 来源:牛客网 2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 F Color it 时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 There is a matrix A that has N rows and M columns. Each grid (i,j)(0 ≤ i < N, 0 ≤ j < M) is painted in white at first. Then we perform q operations: For each operation, we are given (x c , y c ) and r. We will paint all grids (i, j) that meets to black. You need to calculate the number of white grids left in matrix A. 输入描述: The first line of the input is T(1≤ T ≤ 40), which stands for the number of test cases you need to

LeetCode

你。 提交于 2020-12-20 00:17:58
Topic Array Two Pointers Binary Search Description https://leetcode.com/problems/find-the-duplicate-number/ Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one duplicate number in nums, return this duplicate number. Follow-ups : How can we prove that at least one duplicate number must exist in nums ? Can you solve the problem without modifying the array nums ? Can you solve the problem using only constant, O(1) extra space? Can you solve the problem with runtime complexity less than O(n²) ? Example 1 : Input: nums =

容易的面试问题变得更加困难:给定数字1..100,在正好缺少k的情况下,找到缺失的数字

狂风中的少年 提交于 2020-10-19 04:36:22
问题: I had an interesting job interview experience a while back. 前一段时间我有一次有趣的面试经历。 The question started really easy: 这个问题开始很容易: Q1 : We have a bag containing numbers 1 , 2 , 3 , …, 100 . Q1: 我们有一个包含数字的包 1 , 2 , 3 ,..., 100 。 Each number appears exactly once, so there are 100 numbers. 每个数字仅出现一次,因此有100个数字。 Now one number is randomly picked out of the bag. 现在,从袋子中随机抽取一个号码。 Find the missing number. 查找丢失的号码。 I've heard this interview question before, of course, so I very quickly answered along the lines of: 我当然已经听过这个面试问题,所以我很快就回答了以下问题: A1 : Well, the sum of the numbers 1 + 2 + 3 + … + N is (N+1)(N/2

53. Maximum Subarray

隐身守侯 提交于 2020-08-18 08:45:08
Given an integer array nums , find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example: Input: [-2,1,-3,4,-1,2,1,-5,4], Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Follow up: If you have figured out the O( n ) solution, try coding another solution using the divide and conquer approach, which is more subtle. Solution Approach 1: o(n) currSum = max(nums[i], currSum+nums[i]) # The maximum value before the nums[i] maxSum = max(currSum, maxSum) #previous maximum class Solution: def maxSubArray(self, nums: List[int]) -> int:

[POJ2356]Find a multiple 题解(鸽巢原理)

霸气de小男生 提交于 2020-05-06 02:41:11
##[POJ2356]Find a multiple ###Description -The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000. This numbers are not necessarily different (so it may happen that two or more of them will be equal). Your task is to choose a few of given numbers ( 1 <= few <= N ) so that the sum of chosen numbers is multiple for N (i.e. N * k = (sum of chosen numbers) for some natural number k). -Input:The first line of the input contains the single number N. Each of next N lines contains one number from the given set. -Output: In case your

正则密码 Regex and Password complexity policy

こ雲淡風輕ζ 提交于 2020-04-21 17:48:31
Regex for password must contain at least eight characters, at least one number and both lower and uppercase letters and special characters Minimum eight characters, at least one letter and one number: "^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$" Minimum eight characters, at least one letter, one number and one special character: "^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$" Minimum eight characters, at least one uppercase letter, one lowercase letter and one number: "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$" Minimum eight characters, at least one uppercase letter, one