当前位置:网站首页>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, }
边栏推荐
- 安装php-zbarcode扩展时报错,不知道有没有哪位大神帮我解决一下呀 php 环境用的7.3
- Global and Chinese market of wheelchair climbing machines 2022-2028: Research Report on technology, participants, trends, market size and share
- Formatting occurs twice when vs code is saved
- ftp上传文件时出现 550 Permission denied,不是用户权限问题
- Audio and video engineer YUV and RGB detailed explanation
- 论文笔记: 图神经网络 GAT
- Leetcode sum of two numbers
- Tensorflow customize the whole training process
- 阿裏測開面試題
- Use image components to slide through photo albums and mobile phone photo album pages
猜你喜欢
leetcode3、實現 strStr()
RDD conversion operator of spark
剑指 Offer 30. 包含min函数的栈
[Clickhouse] Clickhouse based massive data interactive OLAP analysis scenario practice
Computer graduation design PHP college student human resources job recruitment network
Derivation of Biot Savart law in College Physics
Paper notes: graph neural network gat
NumPy 数组索引 切片
Leetcode3, implémenter strstr ()
【社区人物志】专访马龙伟:轮子不好用,那就自己造!
随机推荐
Grabbing and sorting out external articles -- status bar [4]
[community personas] exclusive interview with Ma Longwei: the wheel is not easy to use, so make it yourself!
leetcode-两数之和
Redis list
Thinking about the best practice of dynamics 365 development collaboration
leetcode3、实现 strStr()
500 lines of code to understand the principle of mecached cache client driver
Sword finger offer 12 Path in matrix
Computer graduation design PHP college classroom application management system
Visualstudio2019 compilation configuration lastools-v2.0.0 under win10 system
Redis string type
D22:indeterminate equation (indefinite equation, translation + problem solution)
Use Scrollview and tabhost to realize vertical scrollbars and tabs
Computer graduation design PHP campus restaurant online ordering system
Get the relevant information of ID card through PHP, get the zodiac, get the constellation, get the age, and get the gender
安装php-zbarcode扩展时报错,不知道有没有哪位大神帮我解决一下呀 php 环境用的7.3
Numpy array index slice
How to generate rich text online
使用npm发布自己开发的工具包笔记
Dynamics 365 开发协作最佳实践思考