File tree Expand file tree Collapse file tree 2 files changed +32
-25
lines changed
Expand file tree Collapse file tree 2 files changed +32
-25
lines changed Original file line number Diff line number Diff line change 11---
22title : 1664. Number of schemes to generate balance numbers One question daily
3- date : ' 2024.01.01 0:00'
3+ date : " 2024.01.01 0:00"
44tags :
55 - - Python
66 - - answer
77 - - Dynamic planning
88 - - One question daily
99abbrlink : 1978f474
10+ docId : ska0npc89ja1r4pdt2qow79u
1011---
1112
1213[ 1664. Number of schemes to generate balance numbers] ( https://leetcode.cn/problems/ways-to-make-a-fair-array/description/?orderBy=most_relevant )
@@ -17,15 +18,16 @@ See when you read the question medium I know that it is definitely not really go
1718But it's timeout。。
1819
1920然后看官方answer,用的Dynamic planning。中心Thought是:
20- > General nature,Now we will settle down i Delete elements,
21- Obviously the bidding i The previous element bidding will not change from this,Bidding i
22- The original was originally j,j>iThe array elements of the bid will move to the bidding j−1,
23- Immediately bidding i The subsequent bidding elements will become the rated element,
24- The even bidding element will become a strange number of bidding elements。
21+
22+ > General nature,Now we will settle down i Delete elements,
23+ > Obviously the bidding i The previous element bidding will not change from this,Bidding i
24+ > The original was originally j,j>iThe array elements of the bid will move to the bidding j−1,
25+ > Immediately bidding i The subsequent bidding elements will become the rated element,
26+ > The even bidding element will become a strange number of bidding elements。
2527
2628# Code
2729
28- ``` python slice
30+ ``` python slice
2931class Solution :
3032 def waysToMakeFair (self , nums : List[int ]) -> int :
3133 flag = 0
@@ -36,9 +38,7 @@ class Solution:
3638 return flag
3739```
3840
39-
40-
41- ``` python 官方answer
41+ ``` python 官方answer
4242class Solution :
4343 def waysToMakeFair (self , nums : List[int ]) -> int :
4444 res = odd1 = even1 = odd2 = even2 = 0
@@ -60,13 +60,3 @@ class Solution:
6060 even1 += num
6161 return res
6262```
63-
64-
65-
66-
67-
68-
69-
70-
71-
72-
Original file line number Diff line number Diff line change 11{
22 "repo" : " InvolutionHell/involutionhell" ,
3- "generatedAt" : " 2025-12-17T03:05:53.053Z " ,
3+ "generatedAt" : " 2025-12-18T03:07:56.884Z " ,
44 "docsDir" : " app/docs" ,
5- "totalDocs" : 145 ,
5+ "totalDocs" : 146 ,
66 "results" : [
77 {
88 "docId" : " ue27z7z95yzw3lhhfj7nit1c" ,
21062106 "docId" : " naxatag8x2nnvkhbwdfc1azc" ,
21072107 "path" : " app/docs/CommunityShare/Leetcode/[2562]找出数组的串联值_translated.md" ,
21082108 "contributorStats" : {
2109- "114939201" : 1
2109+ "114939201" : 2
21102110 },
21112111 "contributors" : [
21122112 {
21132113 "githubId" : " 114939201" ,
2114- "contributions" : 1 ,
2115- "lastContributedAt" : " 2025-12-17T03:00:04 .000Z" ,
2114+ "contributions" : 2 ,
2115+ "lastContributedAt" : " 2025-12-17T03:05:54 .000Z" ,
21162116 "login" : " longsizhuo" ,
21172117 "avatarUrl" : " https://avatars.githubusercontent.com/u/114939201?v=4" ,
21182118 "htmlUrl" : " https://github.com/longsizhuo"
22132213 }
22142214 ]
22152215 },
2216+ {
2217+ "docId" : " ska0npc89ja1r4pdt2qow79u" ,
2218+ "path" : " app/docs/CommunityShare/Leetcode/1664生成平衡数组的方案数_translated.md" ,
2219+ "contributorStats" : {
2220+ "114939201" : 1
2221+ },
2222+ "contributors" : [
2223+ {
2224+ "githubId" : " 114939201" ,
2225+ "contributions" : 1 ,
2226+ "lastContributedAt" : " 2025-12-18T03:00:39.000Z" ,
2227+ "login" : " longsizhuo" ,
2228+ "avatarUrl" : " https://avatars.githubusercontent.com/u/114939201?v=4" ,
2229+ "htmlUrl" : " https://github.com/longsizhuo"
2230+ }
2231+ ]
2232+ },
22162233 {
22172234 "docId" : " n38sohi8zlxesl82tgv854kj" ,
22182235 "path" : " app/docs/CommunityShare/Leetcode/1825求出 MK 平均值_translated.md" ,
You can’t perform that action at this time.
0 commit comments