当前位置:网站首页>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, }
边栏推荐
- Redis如何实现多可用区?
- D22:indeterminate equation (indefinite equation, translation + problem solution)
- 500 lines of code to understand the principle of mecached cache client driver
- 剑指 Offer 30. 包含min函数的栈
- [depth first search notes] Abstract DFS
- 机器学习训练与参数优化的一般过程 (讨论)
- Leetcode3. Implement strstr()
- Genius storage uses documents, a browser caching tool
- 1. Introduction to basic functions of power query
- 【机器人库】 awesome-robotics-libraries
猜你喜欢
Social networking website for college students based on computer graduation design PHP
A basic lintcode MySQL database problem
Pangolin Library: subgraph
Adapter-a technology of adaptive pre training continuous learning
1. Introduction to basic functions of power query
抓包整理外篇——————状态栏[ 四]
vs code保存时 出现两次格式化
Extracting key information from TrueType font files
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
好用的 JS 脚本
随机推荐
同一个 SqlSession 中执行两条一模一样的SQL语句查询得到的 total 数量不一样
[coppeliasim] efficient conveyor belt
HDU_p1237_简单计算器_stack
Method of changing object properties
It's wrong to install PHP zbarcode extension. I don't know if any God can help me solve it. 7.3 for PHP environment
Selenium waiting mode
Redis如何实现多可用区?
Comments on flowable source code (XXXV) timer activation process definition processor, process instance migration job processor
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
Easy to use js script
How does redis implement multiple zones?
Using SA token to solve websocket handshake authentication
Open source | Ctrip ticket BDD UI testing framework flybirds
Prepare for the autumn face-to-face test questions
Text editing VIM operation, file upload
ftp上传文件时出现 550 Permission denied,不是用户权限问题
Bidding promotion process
Dynamics 365 开发协作最佳实践思考
D22:indeterminate equation (indefinite equation, translation + problem solution)
模板_求排列逆序对_基于归并排序