Tag：Problem solving

Time：20211022
[No.1 minimum difference of student scores] Problem solving ideas Sort, and then enumerate every successive k elements. Code display class Solution { public int minimumDifference(int[] nums, int k) { if (nums.length < 2  k == 1) { return 0; } Arrays.sort(nums); int res = nums[k – 1] – nums[0]; for (int i = k; […]

Time：20211017
[No.1 statistical special Quad] Problem solving ideasCheck in questions, just enumerate. Code display class Solution { public int countQuadruplets(int[] nums) { int n = nums.length; int res = 0; for (int a = 0; a < n; a++) { for (int b = a + 1; b < n; b++) { for (int c = […]

Time：20211015
[No.1 reverse word prefix] Problem solving ideas Check in question. Code display class Solution { public String reversePrefix(String word, char ch) { int index = word.indexOf(ch); return new StringBuffer(word.substring(0, index + 1)).reverse().toString() + word.substring(index + 1); } } [No.2 number of groups of interchangeable rectangles] Problem solving ideas Classify the rectangles according to the aspect […]

Time：20211012
[No.1 variable value after operation] Problem solving ideasCheck in question. Code display class Solution { public int finalValueAfterOperations(String[] operations) { int v = 0; for (String op : operations) { if (op.contains(“++”)) { v++; } else { v–; } } return v; }} [No.2 sum of array values] Problem solving ideasThe beauty value of the […]

Time：20211011
[maximum difference between No.1 increment elements] Problem solving ideasThe traversal array maintains the global minimum value. If the current value is large, it is a reasonable answer. The traversal process can take the maximum reasonable answer. Code display public class Solution { public int maximumDifference(int[] nums) { if (nums == null  nums.length == 0) […]

Time：2021824
1. Introduction People will see many points of interest (POI) on Gaode map, such as restaurants, supermarkets, scenic spots, hotels, stations, parking lots, etc. The evaluation dimensions of POI data include current situation, accuracy, completeness and richness. Among them, the current situation is the extent to which the geospatial information provided by the map reflects […]

Time：202184
Problem description Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Link: https://leetcodecn.com/probl… Problem solving ideas Loop through the array to determine whether each element can be added to a subsequence that may become the largest subsequence sum.The judgment condition is that […]

Time：202178
To give you the number k, please return the minimum number of Fibonacci numbers for K. each Fibonacci number can be used multiple times. Fibonacci numbers are defined as: F1 = 1 F2 = 1 FN = fn1 + fn2, where n > 2. The data guarantee that the feasible solution can be found for […]

Time：202176
A – Bovine Dilemma Solution: think that the problem said is a triangle, and there is a certain point (0,1), so here only need to find two points can form a triangle, and these two points are on the X axis, so you can know (0,1) to X axis is high, X axis two points […]

Time：202174
Given a sequence containing N numbers in 0, 1, 2,…, N, find the number in 0.. n that does not appear in the sequence. Example 1: Input: [3,0,1] Output: 2 Example 2: Input: [9,6,4,2,3,5,7,0,1] Output: 8 explain:Your algorithm should have linear time complexity. Can you just use the extra constant space? Solution code:

Time：202172
In an integer array nums, except for two numbers, other numbers appear twice. Please write a program to find these two numbers that only appear once. The time complexity is O (n) and the space complexity is O (1). Example 1: Input: nums = [4,1,4,6] Output: [1,6] or [6,1] Example 2: Input: nums = [1,2,10,4,1,4,3,3] […]

Time：2021621
1. Input a positive integer target and output all the continuous positive integer sequences (at least two numbers) whose sum is target. The numbers in the sequence are arranged from small to large, and different sequences are arranged from small to large according to the first number. Example 1: Input: target = 9 Output: [[2,3,4], […]