当前位置:网站首页>Number conclusion LC skimming review - 1
Number conclusion LC skimming review - 1
2022-07-06 02:16:00 【Forina_ Han】
217. There are duplicate elements
- There are duplicate elements
- Use
Set
Ofsize
andArray
Oflength
Just judge . - At first, we tried to divide and conquer , But the problem cannot be decomposed into the smallest problem , Because there are no duplicate elements in the left array , There are no duplicate elements on the right , It does not mean that there are no duplicate elements in the original array ( That is, when the left and right arrays contain the same elements , Such as [1,2,3,1]
- Traversable arrays , Use
hashMap
Mark values , If duplicate marks are found, exit the traversal . - You can sort against arrays , Scan whether adjacent elements have the same value , Time for space .
53. Maximum subarray and
Dynamic gauge ,
dp[i]
The subscript in the input array isi
The largest subarray and .Divide and conquer , Bisection decomposition array , And derive the parent optimal solution from the child optimal solution
const mid = Math.floor((l + r) / 2); let L_res = R_res= { iSum: 0, lSum: 0, rSum: 0, aSum: 0 }; if(mid - 1 >= l) { L_res = getlmr(arr, l, mid - 1); } if(mid <= r) { R_res = getlmr(arr, mid, r) } const { iSum: L_iSum, lSum: L_lSum, rSum: L_rSum, aSum: L_aSum} = L_res const { iSum: R_iSum, lSum: R_lSum, rSum: R_rSum, aSum: R_aSum} = R_res; return { iSum: Math.max(L_iSum, R_iSum, L_rSum + R_lSum), lSum: Math.max(L_lSum, L_aSum + R_lSum), rSum: Math.max(R_rSum, R_aSum + L_rSum), aSum: L_aSum + R_aSum, }
边栏推荐
- Genius storage uses documents, a browser caching tool
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Thinking about the best practice of dynamics 365 development collaboration
- Extracting key information from TrueType font files
- PAT甲级 1033 To Fill or Not to Fill
- 0211 embedded C language learning
- 2022 PMP project management examination agile knowledge points (8)
- 更改对象属性的方法
- How to set an alias inside a bash shell script so that is it visible from the outside?
- Blue Bridge Cup embedded_ STM32 learning_ Key_ Explain in detail
猜你喜欢
A basic lintcode MySQL database problem
Formatting occurs twice when vs code is saved
SPI communication protocol
NumPy 数组索引 切片
Minecraft 1.18.1、1.18.2模组开发 22.狙击枪(Sniper Rifle)
同一个 SqlSession 中执行两条一模一样的SQL语句查询得到的 total 数量不一样
零基础自学STM32-复习篇2——使用结构体封装GPIO寄存器
Paper notes: graph neural network gat
Audio and video engineer YUV and RGB detailed explanation
[depth first search] Ji Suan Ke: Betsy's trip
随机推荐
NumPy 数组索引 切片
1. Introduction to basic functions of power query
[robot library] awesome robots Libraries
Get the relevant information of ID card through PHP, get the zodiac, get the constellation, get the age, and get the gender
Bidding promotion process
Genius storage uses documents, a browser caching tool
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
729. 我的日程安排表 I / 剑指 Offer II 106. 二分图
Campus second-hand transaction based on wechat applet
leetcode-2.回文判断
[solution] add multiple directories in different parts of the same word document
2022年版图解网络PDF
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Leetcode3. Implement strstr()
How does redis implement multiple zones?
selenium 元素定位(2)
Numpy array index slice
Compact lidar global and Chinese markets 2022-2028: technology, participants, trends, market size and share Research Report
SQL statement
Selenium element positioning (2)