当前位置:网站首页>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, }
边栏推荐
- [solution] add multiple directories in different parts of the same word document
- Selenium waiting mode
- Kubernetes stateless application expansion and contraction capacity
- SSM assembly
- Easy to use js script
- Comments on flowable source code (XXXV) timer activation process definition processor, process instance migration job processor
- 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
- How to set an alias inside a bash shell script so that is it visible from the outside?
- Paper notes: limit multi label learning galaxc (temporarily stored, not finished)
- 2 power view
猜你喜欢
[solution] every time idea starts, it will build project
Computer graduation design PHP part-time recruitment management system for College Students
数据工程系列精讲(第四讲): Data-centric AI 之样本工程
Formatting occurs twice when vs code is saved
Blue Bridge Cup embedded_ STM32 learning_ Key_ Explain in detail
Online reservation system of sports venues based on PHP
How to generate rich text online
Lecture 4 of Data Engineering Series: sample engineering of data centric AI
Tensorflow customize the whole training process
Selenium waiting mode
随机推荐
2022 PMP project management examination agile knowledge points (8)
【无标题】数据库中一条查询SQL执行的过程
Minecraft 1.16.5 biochemical 8 module version 2.0 storybook + more guns
Have a look at this generation
Concept of storage engine
阿裏測開面試題
Shutter doctor: Xcode installation is incomplete
MySQL lethal serial question 1 -- are you familiar with MySQL transactions?
Compact lidar global and Chinese markets 2022-2028: technology, participants, trends, market size and share Research Report
2022年版图解网络PDF
Apicloud openframe realizes the transfer and return of parameters to the previous page - basic improvement
MySQL index
Executing two identical SQL statements in the same sqlsession will result in different total numbers
Use the list component to realize the drop-down list and address list
[depth first search] Ji Suan Ke: Betsy's trip
Computer graduation design PHP campus restaurant online ordering system
Regular expressions: examples (1)
[width first search] Ji Suan Ke: Suan tou Jun goes home (BFS with conditions)
怎么检查GBase 8c数据库中的锁信息?
Using SA token to solve websocket handshake authentication