question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
minimum-time-to-make-array-sum-at-most-x
Easy Iterative Solution
easy-iterative-solution-by-kvivekcodes-p6pc
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
kvivekcodes
NORMAL
2024-09-04T12:20:28.107236+00:00
2024-09-04T12:20:28.107268+00:00
4
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Array', 'Dynamic Programming', 'Sorting', 'C++']
0
minimum-time-to-make-array-sum-at-most-x
20 Lines Simple Bottom Up DP
20-lines-simple-bottom-up-dp-by-alex-e-x08d
Solution\nFor an optimal solution, if we have indices i1, i2... as a part of the optimal solution where we set the index to 0, then when doing the operation in
alex-e
NORMAL
2024-08-04T21:35:54.716826+00:00
2024-08-04T21:37:22.251401+00:00
27
false
# Solution\nFor an optimal solution, if we have indices i1, i2... as a part of the optimal solution where we set the index to 0, then when doing the operation in the problem, we should go in order of nums2[i1]<=nums2[i2]... because we want to pick the greatest value last and let the value accumulate before we set it to...
0
0
['Dynamic Programming', 'Python3']
0
minimum-time-to-make-array-sum-at-most-x
As hinted
as-hinted-by-maxorgus-61ep
Note the dp should not be done with python builtin memoization which would cause MLE, in stead, do the tabulation yourself\n\n# Code\n\nclass Solution:\n def
MaxOrgus
NORMAL
2024-05-14T02:52:38.130775+00:00
2024-05-14T02:52:38.130807+00:00
5
false
Note the dp should not be done with python builtin memoization which would cause MLE, in stead, do the tabulation yourself\n\n# Code\n```\nclass Solution:\n def minimumTime(self, nums1: List[int], nums2: List[int], x: int) -> int:\n n = len(nums1)\n nums = [(n1,n2) for n1,n2 in zip(nums1,nums2)]\n ...
0
0
['Python3']
0
minimum-time-to-make-array-sum-at-most-x
Space Efficient Solution ...
space-efficient-solution-by-gp_777-pxto
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
GP_777
NORMAL
2024-04-23T03:55:41.499004+00:00
2024-04-23T03:55:41.499038+00:00
7
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Java']
0
minimum-time-to-make-array-sum-at-most-x
Solution
solution-by-gp_777-d3gn
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
GP_777
NORMAL
2024-04-23T02:19:46.084231+00:00
2024-04-23T02:19:46.084251+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Java']
0
minimum-time-to-make-array-sum-at-most-x
Minimum Time to Process Arrays with Constraints Beats 81.20%
minimum-time-to-process-arrays-with-cons-949c
Intuition\nThe problem seems to involve finding the minimum time required to perform certain operations on two arrays while satisfying certain conditions. \n\n#
kumarritul089
NORMAL
2024-03-15T07:09:40.496951+00:00
2024-03-15T07:09:40.496980+00:00
29
false
# Intuition\nThe problem seems to involve finding the minimum time required to perform certain operations on two arrays while satisfying certain conditions. \n\n# Approach\n1. We start by calculating the total sums of both arrays, `nums1` and `nums2`, and storing the indices in a separate vector.\n2. If the sum of `num...
0
0
['Array', 'Dynamic Programming', 'Sorting', 'Python', 'C++', 'Python3', 'JavaScript']
0
minimum-time-to-make-array-sum-at-most-x
5 hours, mega failure
5-hours-mega-failure-by-user3043sb-ex8v
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
user3043SB
NORMAL
2024-01-21T14:06:03.398487+00:00
2024-01-21T14:06:03.398517+00:00
1
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Java']
0
minimum-time-to-make-array-sum-at-most-x
Alternative to DP, a Short, Straightforward O(N^2) Greedy Solution in Python
alternative-to-dp-a-short-straightforwar-4jv3
Approach\n Describe your approach to solving the problem. \nThe best solution with a length of l is based on the best solution with the length of l-1 and an ite
metaphysicalist
NORMAL
2023-12-26T19:27:38.514813+00:00
2023-12-26T21:57:29.250663+00:00
17
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nThe best solution with a length of `l` is based on the best solution with the length of `l-1` and an item that is not selected yet. \nThus, my solution builds the solution from length 1 to `n`, one by one. \nBased on the solution of `l-1`, my solution...
0
0
['Greedy', 'Python3']
0
minimum-time-to-make-array-sum-at-most-x
Most intuitive & Easyy Top Down solution || recursion+memoizaton
most-intuitive-easyy-top-down-solution-r-i3ov
Idea & thoughts...\n\nwhat will happen after t days if we don\'t delete anything the \ns1: sum of a1\ns2: sum of a2\n\nsum will be = s1 + t*s2\nso now if we wan
demon_code
NORMAL
2023-10-12T11:11:45.779308+00:00
2023-10-12T11:17:12.633698+00:00
26
false
Idea & thoughts...\n\nwhat will happen after t days if we don\'t delete anything the \ns1: sum of a1\ns2: sum of a2\n\nsum will be = ```s1 + t*s2```\nso now if we want to delete some index i element at time p then \nsum will be = ```s1+t*s2 - a1[i]- p*a2[i] ```\nSo what we see here is the ```s1+ t*s2 ```remains constan...
0
0
['Recursion', 'Memoization', 'C']
0
minimum-time-to-make-array-sum-at-most-x
O(n ^ 2) Propagation DP
on-2-propagation-dp-by-__beginner-ky8w
Intuition\n Describe your first thoughts on how to solve this problem. \nThe key observation about dp approach is that if we\'re selecting k positions to be ma
__Beginner_
NORMAL
2023-10-08T22:20:32.677959+00:00
2023-10-14T09:43:58.996026+00:00
21
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe key observation about dp approach is that if we\'re selecting $$ k$$ positions to be made $$0$$ at successive intervals then we should select the position with in increasing order of $$nums2[i]$$.\nLet\'s prove this below,\n# Approach...
0
0
['Dynamic Programming', 'C++']
0
minimum-time-to-make-array-sum-at-most-x
java script - Minimum Time to Make Array Sum At Most x
java-script-minimum-time-to-make-array-s-10d2
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
balakrishnanp
NORMAL
2023-10-06T11:26:02.452228+00:00
2023-10-06T11:26:02.452246+00:00
6
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['JavaScript']
0
minimum-time-to-make-array-sum-at-most-x
C++ DP solution | Intuitive
c-dp-solution-intuitive-by-aglakshya02-fivv
Approach\n Describe your approach to solving the problem. \nYou can watch Coding Mohan\'s YouTube video solution for this, it\'s really difficult to describe th
aglakshya02
NORMAL
2023-09-08T11:38:59.501321+00:00
2023-09-08T11:38:59.501344+00:00
16
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nYou can watch Coding Mohan\'s YouTube video solution for this, it\'s really difficult to describe the solution in a textual post for me.\nMy solution is inspired from his only.\n\n\n# Code\n```\nclass Solution {\npublic:\n\n vector<int>a,b;\n\n ...
0
0
['C++']
0
minimum-time-to-make-array-sum-at-most-x
Unraveling the Optimal Time Scheduler
unraveling-the-optimal-time-scheduler-by-tznv
Intuition\nImagine you have two lists of tasks with respective times required. You have a goal to optimize the sum of these tasks such that, at every step, you
janis__
NORMAL
2023-08-29T15:47:42.600716+00:00
2023-08-29T15:47:42.600733+00:00
11
false
# Intuition\nImagine you have two lists of tasks with respective times required. You have a goal to optimize the sum of these tasks such that, at every step, you can either use the time from one list or swap it with a time from the other list. The problem might sound tricky, but a methodical approach can reveal pattern...
0
0
['Array', 'Dynamic Programming', 'Sorting', 'Python']
0
minimum-time-to-make-array-sum-at-most-x
Somehow worked, help me optimise the code!
somehow-worked-help-me-optimise-the-code-5e8x
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Chhota_bheem
NORMAL
2023-08-23T15:30:57.567267+00:00
2023-08-23T15:30:57.567297+00:00
10
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-time-to-make-array-sum-at-most-x
Get the correct DP state before thinking of solution !
get-the-correct-dp-state-before-thinking-1uk8
Intuition\nYou need to think of correct dp state in this question.\nIf we calculate to what extent you can reduce the sum of nums1 in each operation we can get
pshreyansh26
NORMAL
2023-08-21T17:40:07.426443+00:00
2023-08-21T17:40:33.070053+00:00
22
false
# Intuition\nYou need to think of correct dp state in this question.\nIf we calculate to what extent you can reduce the sum of nums1 in each operation we can get the answer.\n\n# Approach\n* Let dp[i][j] represent the maximum total value that can be reduced if we do j operations on the first i elements\n* It can also b...
0
0
['Dynamic Programming', 'Sorting', 'C++']
0
minimum-time-to-make-array-sum-at-most-x
Python | DP | Concise Solution | O(n^2)
python-dp-concise-solution-on2-by-aryonb-ktre
Code\n\nclass Solution:\n def minimumTime(self, nums1: List[int], nums2: List[int], x: int) -> int:\n sum1 = sum(nums1)\n sum2 = sum(nums2)\n
aryonbe
NORMAL
2023-08-13T11:12:14.245439+00:00
2023-08-13T11:12:14.245461+00:00
21
false
# Code\n```\nclass Solution:\n def minimumTime(self, nums1: List[int], nums2: List[int], x: int) -> int:\n sum1 = sum(nums1)\n sum2 = sum(nums2)\n nums = sorted(list(zip(nums2, nums1)))\n n = len(nums)\n dp = [0]*(n+1)\n for i in range(n):\n for k in range(i+1, 0,...
0
0
['Python3']
0
minimum-time-to-make-array-sum-at-most-x
Python | DP | O(n^2)
python-dp-on2-by-aryonbe-i2ri
Code\n\nclass Solution:\n def minimumTime(self, nums1: List[int], nums2: List[int], x: int) -> int:\n sum1 = sum(nums1)\n if sum1 <= x: return
aryonbe
NORMAL
2023-08-13T09:14:24.727368+00:00
2023-08-13T09:14:56.548495+00:00
10
false
# Code\n```\nclass Solution:\n def minimumTime(self, nums1: List[int], nums2: List[int], x: int) -> int:\n sum1 = sum(nums1)\n if sum1 <= x: return 0\n sum2 = sum(nums2)\n nums = sorted(list(zip(nums2, nums1)))\n n = len(nums)\n dp = [0]*n\n for k in range(1,n+1):\n ...
0
0
['Python3']
0
minimum-time-to-make-array-sum-at-most-x
Easy to understand Recursive DP |Memorization✅
easy-to-understand-recursive-dp-memoriza-8kvp
\n# Complexity\n- Time complexity:\n- O(N^2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:\n- O(N^2)\n Add your space complexity here, e.g.
rahulhind
NORMAL
2023-08-12T10:55:23.535201+00:00
2023-08-12T10:56:07.419527+00:00
41
false
\n# Complexity\n- Time complexity:\n- O(N^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- O(N^2)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n\nvector<vector<long long> > dp;\nvector<pair<long long,long long> > arr;\nlong long f(int i,int k){\nif(i>=arr.siz...
0
0
['C++']
1
minimum-time-to-make-array-sum-at-most-x
Solution in Swift, DP
solution-in-swift-dp-by-sergeyleschev-38as
Approach\nWe begin by calculating the total sum of the arrays A and B as sa and sb respectively.\n\nIf no actions are taken, at i seconds, we would have a total
sergeyleschev
NORMAL
2023-08-12T06:16:50.832911+00:00
2023-08-12T06:16:50.832936+00:00
2
false
# Approach\nWe begin by calculating the total sum of the arrays A and B as sa and sb respectively.\n\nIf no actions are taken, at i seconds, we would have a total of sb * i + sa.\n\nDuring the t seconds, we select t elements. When we consider these selected elements, A[i] would be removed. The sum for these selected el...
0
0
['Swift']
0
minimum-time-to-make-array-sum-at-most-x
Dp solution - thinking process and detailed proof
dp-solution-thinking-process-and-detaile-26kp
Intuition\n Describe your first thoughts on how to solve this problem. \nFirst thing that came to my mind afer reading the problem statement was using binary se
horizon1006
NORMAL
2023-08-11T08:06:25.405927+00:00
2023-08-11T08:10:16.699230+00:00
30
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirst thing that came to my mind afer reading the problem statement was using binary search but found a counter example shortly thereafter. Take a glance at the constraints, it is not hard to deduce that a $$O(n^2)$$ approach should be us...
0
0
['Python3']
0
minimum-time-to-make-array-sum-at-most-x
Easy dp solution in c++.
easy-dp-solution-in-c-by-isheoran-oodk
Intuition\nDP\n\n\n# Complexity\n- Time complexity:\n O(n^2)\n\n- Space complexity:\n O(n) \n\n# Code\n\nclass Solution {\npublic:\n int minimumTime(vector<i
isheoran
NORMAL
2023-08-10T09:59:35.976926+00:00
2023-08-10T09:59:35.976952+00:00
20
false
# Intuition\nDP\n\n\n# Complexity\n- Time complexity:\n $$O(n^2)$$\n\n- Space complexity:\n $$O(n)$$ \n\n# Code\n```\nclass Solution {\npublic:\n int minimumTime(vector<int>& nums1, vector<int>& nums2, int x) {\n int n = nums1.size();\n\n vector<pair<int,int>>pr;\n for(int i=0;i<n;i++) pr.push_b...
0
0
['C++']
0
minimum-time-to-make-array-sum-at-most-x
Java
java-by-tetttet-p2di
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
tetttet
NORMAL
2023-08-09T13:41:48.292293+00:00
2023-08-09T13:41:48.292324+00:00
18
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Java']
0
minimum-time-to-make-array-sum-at-most-x
Rust | not DP
rust-not-dp-by-tifv-yn9x
Let $n$ be the length of the given arrays, and let $a_{i}$ and $b_{i}$ represent the values of the arrays nums1 and nums2, respectively, $i = 1, \ldots, n$.\n\n
tifv
NORMAL
2023-08-09T08:07:53.046607+00:00
2023-08-09T08:07:53.046629+00:00
16
false
Let $n$ be the length of the given arrays, and let $a_{i}$ and $b_{i}$ represent the values of the arrays `nums1` and `nums2`, respectively, $i = 1, \\ldots, n$.\n\nThere is no point in choosing the same index twice, or delaying operations in time. Therefore, if we are to minimize the obtained sum in time $T$, we will ...
0
0
['Rust']
0
minimum-time-to-make-array-sum-at-most-x
Binary Search + Dp solution
binary-search-dp-solution-by-aryanfit007-mwwg
Approach\nBinary Search + Dp\n\n# Complexity\n- Time complexity: nLogn\n\n# Code\n\nclass Solution {\npublic:\n int dp[1004][1004];\n int recur(int i,int
aryanfit007
NORMAL
2023-08-08T20:21:17.269819+00:00
2023-08-08T20:21:17.269848+00:00
81
false
# Approach\nBinary Search + Dp\n\n# Complexity\n- Time complexity: nLogn\n\n# Code\n```\nclass Solution {\npublic:\n int dp[1004][1004];\n int recur(int i,int k, vector<int> &v,vector<pair<int,int>> &p,int op){\n if(i==v.size() && k==0) return 0;\n if(i==v.size() && k!=0) return 100000;\n if(...
0
1
['Binary Search', 'Dynamic Programming', 'Greedy', 'C++']
2
minimum-time-to-make-array-sum-at-most-x
Recursive DP solution with intuition
recursive-dp-solution-with-intuition-by-bf58g
Intuition\n Describe your first thoughts on how to solve this problem. \nThe actual complication in the problem is in deciding which array should we sort.\nTo h
kartikeysemwal
NORMAL
2023-08-08T16:48:55.950351+00:00
2023-08-08T16:48:55.950383+00:00
82
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe actual complication in the problem is in deciding which array should we sort.\nTo help this simplify, understand that elements in nums1 contribute only once to every index while nums2 contribute at every second.\neg. nums1: [500, 100]...
0
0
['Dynamic Programming', 'Recursion', 'Java']
0
minimum-time-to-make-array-sum-at-most-x
2d DP | O(n^2) Time, O(n) space.
2d-dp-on2-time-on-space-by-xun6000-ozxn
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires us to find the minimum time needed to make the sum of the elements
xun6000
NORMAL
2023-08-08T00:32:27.655737+00:00
2023-08-08T00:32:27.655762+00:00
30
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires us to find the minimum time needed to make the sum of the elements in **nums1** less than or equal to **x**. Every second, we can increment the elements of **nums1** by corresponding values in **nums2**, and we can al...
0
0
['Python3']
0
minimum-time-to-make-array-sum-at-most-x
Ruby memoization & bsearch solution, explained (100%/100%)
ruby-memoization-bsearch-solution-explai-255x
Intuition\nIf you know how many numbers you\'re going to reset, you can check the total from resetting them in optimal order in O(n^2) time with memoization. U
dtkalla
NORMAL
2023-08-07T22:53:03.058855+00:00
2023-08-07T22:53:03.058876+00:00
24
false
# Intuition\nIf you know how many numbers you\'re going to reset, you can check the total from resetting them in optimal order in O(n^2) time with memoization. Use a binary search to figure out how many numbers to reset.\n\n# Approach\n1. Special cases: if the sum is already low enough return 0; if all numbers must be...
0
0
['Ruby']
0
minimum-time-to-make-array-sum-at-most-x
Easy C++ Solution || Memoization|| O(N^2)🔥🔥
easy-c-solution-memoization-on2-by-himan-d1fe
Intuition\nBasic intution is that we will iterate a loop over number of operations and at any instant if it satisfies condition of sum of both arrays less than
Himanshu2003
NORMAL
2023-08-07T13:22:26.217602+00:00
2023-08-07T13:22:26.217630+00:00
42
false
# Intuition\nBasic intution is that we will iterate a loop over number of operations and at any instant if it satisfies condition of sum of both arrays less than or equal to x the return operation else return -1 \n\n# Approach\nThe code defines a class named Solution. It uses two arrays named n1 and n2 to hold the numb...
0
0
['C++']
0
minimum-time-to-make-array-sum-at-most-x
Recursion to Tabulation | Java
recursion-to-tabulation-java-by-kumarnis-8h8e
Intuition\nAfter learnings all the important conclusions that :\n- At max we will do single operation on any index\n- for any two numbers a and b from nums2, if
kumarnis89
NORMAL
2023-08-07T11:14:19.772848+00:00
2023-08-07T11:14:19.772875+00:00
35
false
# Intuition\nAfter learnings all the important conclusions that :\n- At max we will do single operation on any index\n- for any two numbers a and b from nums2, if b>a then b will add more value in every second to the total sum.\nso we will opearate on index i with larger nums2[i] after we operate on all other indices w...
0
0
['Java']
0
minimum-time-to-make-array-sum-at-most-x
Chinese DP O(n^2)
chinese-dp-on2-by-wuzhenhai-mirs
n\u4E3A\u6570\u7EC4\u957F\u5EA6.\n\n \u89C2\u5BDF\n 1: \u540C\u4E00\u4E2A\u4F4D\u7F6E\u4E0D\u5FC5\u9009\u4E2D\u4E24\u6B21, \u53EA\u9700\u4FDD\u7559\u6
wuzhenhai
NORMAL
2023-08-07T03:04:35.515458+00:00
2023-08-07T03:09:59.088908+00:00
32
false
n\u4E3A\u6570\u7EC4\u957F\u5EA6.\n\n \u89C2\u5BDF\n 1: \u540C\u4E00\u4E2A\u4F4D\u7F6E\u4E0D\u5FC5\u9009\u4E2D\u4E24\u6B21, \u53EA\u9700\u4FDD\u7559\u6700\u540E\u4E00\u6B21\u9009\u4E2D\u5373\u53EF.\n 2: \u5728\u9009\u4E2D\u7684\u6570\u7EC4\u7D22\u5F15\u96C6\u5408\u4E2D, nums2[i]\u8D8A\u5927\uFF0C"i\u900...
0
0
['Dynamic Programming']
0
minimum-time-to-make-array-sum-at-most-x
My Solution
my-solution-by-hope_ma-72xo
\n/**\n * let `n` be the length of the vector `nums1`,\n * which is the length of the vector `nums2` as well.\n *\n * some observations\n * 1. if `accumulate(nu
hope_ma
NORMAL
2023-08-05T21:04:46.186654+00:00
2023-08-05T21:07:06.328804+00:00
21
false
```\n/**\n * let `n` be the length of the vector `nums1`,\n * which is the length of the vector `nums2` as well.\n *\n * some observations\n * 1. if `accumulate(nums1.begin(), nums1.end(), 0)` is less than or equal to `x`,\n * no operations are needed, so `0` should be returned.\n * 2. for any specific index `i`, 0 ...
0
0
[]
0
minimum-time-to-make-array-sum-at-most-x
Sort + greedy + DP problem, beat 100% C++
sort-greedy-dp-problem-beat-100-c-by-lon-i9qi
Intuition\n Describe your first thoughts on how to solve this problem. \n\n \n# Approach\n Describe your approach to solving the problem. \n sum = sum(num
longvatrong111
NORMAL
2023-08-05T19:59:09.033690+00:00
2023-08-05T19:59:09.033716+00:00
92
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n \n# Approach\n<!-- Describe your approach to solving the problem. -->\n sum = sum(nums1) + t * sums(nums2)\n Create a table:\n - Each row is values of nums1 after adding nums2 at time t\n - Element is sort by nums2\n\n``...
0
0
['C++']
0
minimum-time-to-make-array-sum-at-most-x
python with inline explaination
python-with-inline-explaination-by-sasha-6q51
Intuition\n Describe your first thoughts on how to solve this problem. \nWe can remove nums2 from small to big to let nums1 increase slower.\n\n# Approach\n Des
sashawanchen
NORMAL
2023-08-05T19:50:27.466875+00:00
2023-08-05T19:50:27.466897+00:00
17
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe can remove nums2 from small to big to let nums1 increase slower.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n^2)\...
0
0
['Python']
0
minimum-time-to-make-array-sum-at-most-x
Annotated C++ Solution
annotated-c-solution-by-gyrcpp-v74d
Bog standard c++ implementation based on the question hint.\n\n# Code\ncpp\nclass Solution {\npublic:\n int minimumTime(vector<int>& nums1, vector<int>& nums
gyrcpp
NORMAL
2023-08-05T17:05:23.480946+00:00
2023-08-05T17:06:27.615230+00:00
58
false
Bog standard c++ implementation based on the question hint.\n\n# Code\n```cpp\nclass Solution {\npublic:\n int minimumTime(vector<int>& nums1, vector<int>& nums2, int x) {\n \n // 1.0 Define number of nodes to be used throughout this function.\n int n = nums1.size();\n\n // 1.1 Create a m...
0
0
['C++']
0
minimum-time-to-make-array-sum-at-most-x
C# || Solution
c-solution-by-vdmhunter-g2ev
\npublic class Solution\n{\n public int MinimumTime(IList<int> nums1, IList<int> nums2, int x)\n {\n var n = nums1.Count;\n\n var p = Enumer
vdmhunter
NORMAL
2023-08-05T16:42:25.673668+00:00
2023-08-14T16:15:19.535122+00:00
28
false
```\npublic class Solution\n{\n public int MinimumTime(IList<int> nums1, IList<int> nums2, int x)\n {\n var n = nums1.Count;\n\n var p = Enumerable.Range(0, n)\n .Select(i => (a:nums1[i], b:nums2[i]))\n .OrderBy(t => t.b)\n .ToList();\n\n var dp = new int[n + ...
0
0
['C#']
0
minimum-time-to-make-array-sum-at-most-x
Java | Best Solution | Minimum Time to Make Array Sum At Most x
java-best-solution-minimum-time-to-make-fnsjg
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
shrey163
NORMAL
2023-08-05T16:28:26.646619+00:00
2023-08-05T16:28:26.646647+00:00
104
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Java']
0
online-election
[C++/Java/Python] Binary Search in Times
cjavapython-binary-search-in-times-by-le-t1he
Initialization part\nIn the order of time, we count the number of votes for each person.\nAlso, we update the current lead of votes for each time point.\nif (co
lee215
NORMAL
2018-09-23T03:06:50.194904+00:00
2021-07-25T08:27:42.440822+00:00
20,205
false
## **Initialization part**\nIn the order of time, we count the number of votes for each person.\nAlso, we update the current lead of votes for each time point.\n` if (count[person] >= count[lead]) lead = person`\n\nTime Complexity: `O(N)`\n<br>\n\n## **Query part**\nBinary search `t` in `times`,\nfind out the latest ti...
170
1
[]
35
online-election
[Java/Python 3] two methods with comment- using TreeMap and binary search, respectively
javapython-3-two-methods-with-comment-us-jvek
Method 1:\nTime complexity for constructor TopVotedCandidate(int[] persons, int[] times)\tis O(nlogn), and for q(int t) is O(logn).\n\n\tprivate TreeMap tm = ne
rock
NORMAL
2018-09-23T03:08:32.826941+00:00
2022-06-26T20:04:55.327025+00:00
5,486
false
Method 1:\nTime complexity for constructor `TopVotedCandidate(int[] persons, int[] times)`\tis O(nlogn), and for `q(int t)` is O(logn).\n\n\tprivate TreeMap<Integer, Integer> tm = new TreeMap<>(); // time and leading candidate\n\tpublic TopVotedCandidate(int[] persons, int[] times) {\n\t int[] count = new int[person...
43
0
[]
10
online-election
An extremely detailed explanation accompanied with Code.
an-extremely-detailed-explanation-accomp-hgvc
First lets understand the question input as I had a hard time to make sense of question input.\n\n\n ["TopVotedCandidate","q","q","q","q","q","q"], [[[0,1,1
amrx101
NORMAL
2020-06-11T04:06:13.101418+00:00
2020-06-11T04:08:33.100407+00:00
1,689
false
First lets understand the question input as I had a hard time to make sense of question input.\n\n\n ["TopVotedCandidate","q","q","q","q","q","q"], [[[0,1,1,0,0,1,0],[0,5,10,15,20,25,30]],[3],[12],[25],[15],[24],[8]]\n\t \nFirst list is the query. Now we have a list of lists. The very first list is a list of person...
21
0
['Binary Search']
5
online-election
C++ binary search solution beats 100%
c-binary-search-solution-beats-100-by-bw-qe2p
C++\nclass TopVotedCandidate{\npublic:\n TopVotedCandidate(vector<int> persons, vector<int> times) {\n int max_count = 0, candidate = 0, len = persons
bwv988
NORMAL
2019-02-23T09:31:54.245316+00:00
2019-02-23T09:31:54.245353+00:00
2,059
false
```C++\nclass TopVotedCandidate{\npublic:\n TopVotedCandidate(vector<int> persons, vector<int> times) {\n int max_count = 0, candidate = 0, len = persons.size();\n int count[len + 1];\n memset(count, 0, sizeof count);\n // candidates.first is the time[i], candidates.second is the top vote...
20
1
[]
2
online-election
Python readable short bisect solution
python-readable-short-bisect-solution-by-rbsn
There is a minor ambiguity in the question btw. If time is taken as zero, there is no chance to decide who is the winner.\n\nclass TopVotedCandidate:\n\n def
cenkay
NORMAL
2018-09-23T03:16:16.523659+00:00
2018-10-23T22:01:17.915677+00:00
1,463
false
There is a minor ambiguity in the question btw. If time is taken as zero, there is no chance to decide who is the winner.\n```\nclass TopVotedCandidate:\n\n def __init__(self, persons, times):\n votes = collections.defaultdict(int)\n winner = 0\n self.winners = [None] * len(times)\n self....
15
1
[]
4
online-election
JAVA TreeMap
java-treemap-by-caraxin-040c
\nclass TopVotedCandidate {\n TreeMap<Integer, Integer> map= new TreeMap<>();\n public TopVotedCandidate(int[] persons, int[] times) {\n int[] cnt=
caraxin
NORMAL
2018-09-23T03:07:03.368967+00:00
2018-10-02T08:41:14.068715+00:00
1,098
false
```\nclass TopVotedCandidate {\n TreeMap<Integer, Integer> map= new TreeMap<>();\n public TopVotedCandidate(int[] persons, int[] times) {\n int[] cnt= new int[persons.length];\n int maxCnt=0;\n for (int i=0; i<persons.length; i++){\n int p= persons[i], t= times[i];\n if ...
13
1
[]
1
online-election
Java || With good explaination
java-with-good-explaination-by-nobody10-7gb2
\n# Approach\nThe TopVotedCandidate class represents the online election system. The constructor takes two arrays as input: persons, which is an array of intege
nobody10
NORMAL
2023-03-02T07:53:30.312722+00:00
2023-03-02T07:53:30.312766+00:00
1,424
false
\n# Approach\nThe TopVotedCandidate class represents the online election system. The constructor takes two arrays as input: persons, which is an array of integers representing the ID of each person who voted, and times, which is an array of integers representing the time at which each vote was cast. The constructor ini...
6
0
['Array', 'Hash Table', 'Binary Search', 'Design', 'Java']
0
online-election
Java | TreeMap
java-treemap-by-tk-x-t8cq
\nclass TopVotedCandidate {\n TreeMap<Integer, Integer> timedWinner;\n int lead;\n public TopVotedCandidate(int[] persons, int[] times) {\n int
TK-X
NORMAL
2022-06-14T11:36:34.382475+00:00
2022-06-14T11:36:34.382513+00:00
1,038
false
```\nclass TopVotedCandidate {\n TreeMap<Integer, Integer> timedWinner;\n int lead;\n public TopVotedCandidate(int[] persons, int[] times) {\n int n = times.length;\n lead = -1;\n timedWinner = new TreeMap();\n Map<Integer, Integer> votes = new HashMap();\n for(int i=0; i<n; ...
5
0
['Tree', 'Java']
1
online-election
✅ [JS] Binary Search Approach w/ explanation 🔥
js-binary-search-approach-w-explanation-4lpcr
\uD83D\uDC4D In the event that you found my solution to be beneficial, I would be most grateful if you would consider UPVOTING IT. This action would serve as a
ad0x99
NORMAL
2024-06-18T15:23:25.308986+00:00
2024-11-27T08:58:03.661981+00:00
192
false
**\uD83D\uDC4D In the event that you found my solution to be beneficial, I would be most grateful if you would consider UPVOTING IT. This action would serve as a significant motivator for me to continue providing additional solutions in the future. \uD83D\uDE46\u200D\u2642\uFE0F**\n\n---\n\n# Binary Search Approach\n\n...
4
0
['Binary Search', 'Rust', 'JavaScript']
0
online-election
Python | Precompute + Binary Search
python-precompute-binary-search-by-sr_vr-pcl7
For __init__ we precompute the top voted person for each time in times in an ordered list topVoted.\n* For q we use Binary Search in topVoted (recycling code fr
sr_vrd
NORMAL
2022-05-14T06:40:57.776676+00:00
2022-05-14T06:48:05.115568+00:00
683
false
* For `__init__` we precompute the top voted person for each `time` in `times` in an ordered list `topVoted`.\n* For `q` we use Binary Search in `topVoted` (recycling code from <a href="https://leetcode.com/problems/search-insert-position/">35. Search Insert Position</a>) to find the top voted person at time `t`.\n\n``...
4
0
['Binary Tree', 'Python']
2
online-election
C++, 240ms , Map + Count Vector, Very Easy to understand, Explanation given
c-240ms-map-count-vector-very-easy-to-un-7c6p
This question was really confusing after couple of errors I figured out the question and also it took some time to figure out perfect working solution that didn
phaninderg
NORMAL
2021-12-23T05:11:40.386349+00:00
2021-12-23T05:11:40.386386+00:00
478
false
This question was really confusing after couple of errors I figured out the question and also it took some time to figure out perfect working solution that didn\'t result in TLE\n\nHere is the code snipped which is very easy to understand\nThe vector inside constructor holds the count of votes of each person\ncurrentMa...
4
0
[]
0
online-election
Anybody has a magic general formula for Binary Search?
anybody-has-a-magic-general-formula-for-seuvu
record each time, which person is leading using a hash map\n2. binary search current query time\n\nQuestion is:\nHow do you decide between\nwhile (lo <= hi) \nw
cheng_coding_attack
NORMAL
2018-11-10T23:01:58.448807+00:00
2018-11-10T23:01:58.448855+00:00
1,354
false
1. record each time, which person is leading using a hash map\n2. binary search current query time\n\nQuestion is:\nHow do you decide between\n``` while (lo <= hi) ``` \n``` while (lo < hi) ```\n``` while (lo < hi - 1) ```?\nI looked at couple binary search problems, each is different when it comes to the terminal cond...
4
0
[]
4
online-election
[java] Binary search
java-binary-search-by-big_news-ltm4
``` class TopVotedCandidate { int[] leading; int[] time; public TopVotedCandidate(int[] persons, int[] times) { time = times; leadin
big_news
NORMAL
2018-09-23T03:12:45.188699+00:00
2018-10-02T14:16:55.157868+00:00
959
false
``` class TopVotedCandidate { int[] leading; int[] time; public TopVotedCandidate(int[] persons, int[] times) { time = times; leading = new int[persons.length]; Map<Integer, Integer> map = new HashMap<>(); for (int n : persons){ map.put(n, 0); } in...
4
0
[]
0
online-election
[C++] Easy Upper_Bound Solution
c-easy-upper_bound-solution-by-makhonya-3q28
\nclass TopVotedCandidate {\npublic:\n unordered_map<int, int> m;\n vector<int> times;\n TopVotedCandidate(vector<int> persons, vector<int> times) {\n
makhonya
NORMAL
2022-09-03T09:21:00.273214+00:00
2022-09-03T09:21:00.273253+00:00
814
false
```\nclass TopVotedCandidate {\npublic:\n unordered_map<int, int> m;\n vector<int> times;\n TopVotedCandidate(vector<int> persons, vector<int> times) {\n int n = persons.size(), lead = -1;\n this->times = times;\n unordered_map<int, int> count;\n for (int i = 0; i < n; ++i) {\n ...
3
0
['C', 'C++']
0
online-election
✅ || python || using hashmap + binary search ||
python-using-hashmap-binary-search-by-ab-rdfq
\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n \n \n self.leading =[]\n \n self.ti
Abhishen99
NORMAL
2021-07-16T17:18:02.716011+00:00
2021-07-16T19:46:20.459979+00:00
535
false
```\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n \n \n self.leading =[]\n \n self.times = []\n \n count = defaultdict(int)\n ma = 0\n \n for i , p in enumerate(persons):\n \n count[p]+...
3
1
['Python', 'Python3']
0
online-election
Python3 precomputed + binary search
python3-precomputed-binary-search-by-red-l1tr
\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.times = times\n self.series = [0] * len(persons
redtree1112
NORMAL
2019-03-25T09:10:30.429480+00:00
2019-03-25T09:10:30.429537+00:00
433
false
```\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.times = times\n self.series = [0] * len(persons)\n vote = [0] * len(persons)\n win = -1\n for i, time in enumerate(times):\n person = persons[i]\n vote[person] +...
3
0
[]
0
online-election
✅✔️Easy implementation using upper bound || C++ Solution ✈️✈️✈️✈️✈️
easy-implementation-using-upper-bound-c-qz3mw
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
ajay_1134
NORMAL
2023-07-23T17:35:04.588794+00:00
2023-07-23T17:35:04.588816+00:00
754
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['Array', 'Hash Table', 'Binary Search', 'C++']
0
online-election
Python3 solution beats 91.11% 🚀 || quibler7
python3-solution-beats-9111-quibler7-by-bdi7i
\n\n# Code\n\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.persons = []\n self.times = []\n
quibler7
NORMAL
2023-05-15T06:29:19.024449+00:00
2023-05-15T06:29:19.024492+00:00
836
false
\n\n# Code\n```\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.persons = []\n self.times = []\n self.dic = collections.defaultdict(int)\n self.m = 0\n self.idx = -1\n\n for i in range(len(times)):\n self.times.append...
2
0
['Python3']
1
online-election
Solution
solution-by-deleted_user-tx4j
C++ []\nclass TopVotedCandidate {\npublic:\n TopVotedCandidate(vector<int> persons, vector<int> times) {\n int max_count = 0, candidate = 0, len = per
deleted_user
NORMAL
2023-05-12T04:20:48.894843+00:00
2023-05-12T05:21:24.489752+00:00
971
false
```C++ []\nclass TopVotedCandidate {\npublic:\n TopVotedCandidate(vector<int> persons, vector<int> times) {\n int max_count = 0, candidate = 0, len = persons.size();\n int count[len + 1];\n memset(count, 0, sizeof count);\n candidates = vector<pair<int, int>>(len);\n for(int i = 0;...
2
0
['C++', 'Java', 'Python3']
1
online-election
Easiest Java Solution || Binary Search on Times
easiest-java-solution-binary-search-on-t-xhpw
\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\n\nclass TopVotedCandidate {\n\n HashMap<Integer,Integer>time=new HashMap<>
jaiyadav
NORMAL
2023-01-13T07:43:24.228256+00:00
2023-01-13T07:43:24.228315+00:00
1,601
false
\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\n```\nclass TopVotedCandidate {\n\n HashMap<Integer,Integer>time=new HashMap<>();\n\n int[]arr=null;\n\n public TopVotedCandidate(int[] persons, int[] times) {\n \n int maxi=Integer.MIN_VALUE;\n arr=times;\n HashM...
2
0
['Array', 'Hash Table', 'Binary Search', 'Design', 'Java']
1
online-election
Easy JS Solution
easy-js-solution-by-dollysingh-bgqg
\n# Code\n\n/**\n * @param {number[]} persons\n * @param {number[]} times\n */\nvar TopVotedCandidate = function(persons, times) {\n let maxC = 0;\n let m
dollysingh
NORMAL
2023-01-07T17:04:30.983340+00:00
2023-01-07T17:04:30.983383+00:00
504
false
\n# Code\n```\n/**\n * @param {number[]} persons\n * @param {number[]} times\n */\nvar TopVotedCandidate = function(persons, times) {\n let maxC = 0;\n let maxP = null;\n\n let map = new Map();\n let tmap = new Map();\n\n for(let i = 0; i < persons.length; i++) {\n let p = persons[i];\n let...
2
0
['Binary Search', 'JavaScript']
0
online-election
Java || Beats 90% || Complete Explanation || Binary Search
java-beats-90-complete-explanation-binar-bz7v
```\nclass TopVotedCandidate {\n \n HashMap map = new HashMap<>();\n // declaring global arrays for the persons and times array\n int [] person;\n
kurmiamreet44
NORMAL
2022-12-14T07:30:53.707167+00:00
2022-12-14T07:30:53.707210+00:00
401
false
```\nclass TopVotedCandidate {\n \n HashMap<Integer, Integer> map = new HashMap<>();\n // declaring global arrays for the persons and times array\n int [] person;\n int [] time;\n // stores the winner at any point of time\n int [] winners;\n public TopVotedCandidate(int[] persons, int[] times) {\n...
2
0
['Java']
0
online-election
Easily Understandable
easily-understandable-by-pritamsinghsola-gm2h
1.Treemap is used to quickly serach on the times.\n2.mp_2 is used to store the ith person lead.\n3.lead is used just to maintain the lead for next time and assi
pritamsinghsolanki
NORMAL
2022-07-06T06:28:09.147384+00:00
2023-05-05T05:40:12.587290+00:00
455
false
1.Treemap is used to quickly serach on the times.\n2.mp_2 is used to store the ith person lead.\n3.lead is used just to maintain the lead for next time and assign it at the right time as said in the question .\n \n```\nclass TopVotedCandidate {\n TreeMap<Integer,Integer> mp=new TreeMap<>(); \n HashMap<Integer,Int...
2
0
['Java']
1
online-election
online election
online-election-by-ninjamonkey42-m6tk
\n#times: [0, 5, 10]\n#persons: [0, 1, 1]\n#leader: [0, 1, 1]\n#array item values represent the candidates\n#at a specific timestamp, the candidate
NinjaMonkey42
NORMAL
2022-06-16T10:39:38.316016+00:00
2022-07-11T16:22:25.244548+00:00
414
false
```\n#times: [0, 5, 10]\n#persons: [0, 1, 1]\n#leader: [0, 1, 1]\n#array item values represent the candidates\n#at a specific timestamp, the candidate was casted a vote by someone\n#each occurence of candidate in persons list represent the vote received by the candidate\n#https://leetcode.com/problems/onlin...
2
0
['Binary Tree', 'Python']
0
online-election
C++ | Segment Tree | O(log N) Query | O(Nlog N) preprocessing
c-segment-tree-olog-n-query-onlog-n-prep-c1yu
\n#define fi first\n#define se second\nusing piii = pair<pair<int,int>,int>;\nstruct SegmentTree{\n vector<piii> t;\n SegmentTree(int N){\n t.assig
shadow_47
NORMAL
2022-06-02T12:31:14.272839+00:00
2022-06-02T12:31:14.272874+00:00
58
false
```\n#define fi first\n#define se second\nusing piii = pair<pair<int,int>,int>;\nstruct SegmentTree{\n vector<piii> t;\n SegmentTree(int N){\n t.assign(4 * N + 10,{{0, -1}, 0});\n Build(0,0,N-1);\n }\n piii Combine(piii &a,piii &b){\n if(a.fi.fi!=b.fi.fi)return a.fi.fi > b.fi.fi ? a : b...
2
0
['Tree', 'Binary Tree']
0
online-election
[Java] simple solution using treetop
java-simple-solution-using-treetop-by-mw-f5h8
\nclass TopVotedCandidate {\n TreeMap<Integer, Integer> tm = new TreeMap<>();\n\n // get lader for each moment in time one by one\n public TopVotedCand
mwacc
NORMAL
2022-02-12T20:25:07.853928+00:00
2022-02-12T20:25:07.853972+00:00
127
false
```\nclass TopVotedCandidate {\n TreeMap<Integer, Integer> tm = new TreeMap<>();\n\n // get lader for each moment in time one by one\n public TopVotedCandidate(int[] persons, int[] times) {\n Map<Integer, Integer> votes = new HashMap<>(); // candidate -> number of votes\n int leader = -1;\n ...
2
0
['Tree']
0
online-election
100% faster than all C# submissions (at the time of writing)
100-faster-than-all-c-submissions-at-the-6alq
\n public class TopVotedCandidate\n {\n private List<Vote> votes = new List<Vote>();\n\n public TopVotedCandidate(int[] persons, int[] times
mojo1234
NORMAL
2022-02-10T13:24:23.855960+00:00
2022-02-10T13:24:40.977355+00:00
248
false
```\n public class TopVotedCandidate\n {\n private List<Vote> votes = new List<Vote>();\n\n public TopVotedCandidate(int[] persons, int[] times) \n {\n var tally = new Dictionary<int, int>();\n int lastPerson = -1;\n\n for (int i = 0; i < persons.Length; i+...
2
0
['C#']
1
online-election
Easy to understand - TreeMap Solution || O(N + Q*log(N))
easy-to-understand-treemap-solution-on-q-xli6
\nclass TopVotedCandidate \n{\n //Time Complexity: O(N + Q*logN), where N is the number of votes, and Q is the number of queries.\n \n TreeMap<Integer,
dhake_baba_met17
NORMAL
2021-07-31T21:30:36.694483+00:00
2021-08-27T11:41:41.538994+00:00
216
false
```\nclass TopVotedCandidate \n{\n //Time Complexity: O(N + Q*logN), where N is the number of votes, and Q is the number of queries.\n \n TreeMap<Integer, Integer> map; // Our main Red-Black tree for searching\n HashMap<Integer, Integer> store;\n int person, maxVotes; // Stores the person who could be th...
2
0
['Tree', 'Binary Search Tree', 'Java']
2
online-election
Python3 Binary Search with short explanation
python3-binary-search-with-short-explana-99tq
You\'re told that times is sorted, so you can already begin thinking of binary search. Now all you need to know is who is leading at what time which is why you
jsn667
NORMAL
2021-05-24T14:49:16.979088+00:00
2021-05-24T14:50:49.813214+00:00
168
false
You\'re told that times is sorted, so you can already begin thinking of binary search. Now all you need to know is who is leading at what time which is why you keep count of who is leading at each index of the "times" array. Then, when you are asked to find a leader for a certain time, you binary search for the time in...
2
0
[]
1
online-election
[Python3] binary search O(logN) for query
python3-binary-search-ologn-for-query-by-er1g
Algo\nWhile running initializer, we compute the frequency table of each candidates votes and decide winner at each time stamp. When running query, we binary sea
ye15
NORMAL
2020-12-01T03:41:52.658126+00:00
2020-12-01T03:41:52.658166+00:00
295
false
**Algo**\nWhile running initializer, we compute the frequency table of each candidates votes and decide winner at each time stamp. When running query, we binary search the proper moment to decide who the winner is at that time. \n\n**Implementation**\n```\nclass TopVotedCandidate:\n\n def __init__(self, persons: Lis...
2
0
['Python3']
0
online-election
C++ | Unordered_map | Upper bound
c-unordered_map-upper-bound-by-wh0ami-idpo
\nclass TopVotedCandidate {\n unordered_map<int, int>m;\n vector<int>time;\npublic:\n TopVotedCandidate(vector<int>& persons, vector<int>& times) {\n
wh0ami
NORMAL
2020-06-17T09:29:01.999455+00:00
2020-06-17T09:29:01.999484+00:00
110
false
```\nclass TopVotedCandidate {\n unordered_map<int, int>m;\n vector<int>time;\npublic:\n TopVotedCandidate(vector<int>& persons, vector<int>& times) {\n unordered_map<int, int>count;\n int lead = -1;\n time = times;\n for (int i = 0; i < persons.size(); i++) {\n count[per...
2
0
[]
0
online-election
C# Binary Search based implementation
c-binary-search-based-implementation-by-be90y
(Side note :By the time I submitted this solution it beated the existed solution 100%\nQuote: "Runtime: 696 ms, faster than 100.00% of C# online submissions for
captain_u
NORMAL
2019-01-20T00:29:09.799270+00:00
2019-01-20T00:29:09.799310+00:00
283
false
(Side note :By the time I submitted this solution it beated the existed solution 100%\nQuote: "Runtime: 696 ms, faster than 100.00% of C# online submissions for Online Election.")\n\n*Time Complexity:* \nFor Method ```TopVotedCandidate```: O(N) where N is the size of the times array. \nFor Method ```Q```: O(log(N)) for...
2
0
[]
0
online-election
[Java] TreeMap: O(NlogN) + O(logN) and Binary Search: O(N) + O(logN)
java-treemap-onlogn-ologn-and-binary-sea-ad63
Below its standard TreeMap solution, as map.put takes O(logN) so the constructor takes O(NlogN).\n\nclass TopVotedCandidate {\n\n TreeMap<Integer, Integer> m
goku_wukong
NORMAL
2018-10-01T06:37:11.336912+00:00
2018-10-01T06:42:05.852718+00:00
553
false
Below its standard TreeMap solution, as map.put takes O(logN) so the constructor takes O(NlogN).\n```\nclass TopVotedCandidate {\n\n TreeMap<Integer, Integer> map = new TreeMap<>();\n public TopVotedCandidate(int[] persons, int[] times) {\n \n HashMap<Integer, Integer> count = new HashMap<>();\n ...
2
0
[]
1
online-election
JavaScript solution
javascript-solution-by-dva2-ug6z
https://github.com/dva22/leetcode/blob/master/problems/911.%20Online%20Election/index.js\n\nvar TopVotedCandidate = module.exports = function(persons, times) {
dva2
NORMAL
2018-09-26T00:31:48.320237+00:00
2018-09-26T00:31:48.320286+00:00
299
false
https://github.com/dva22/leetcode/blob/master/problems/911.%20Online%20Election/index.js\n```\nvar TopVotedCandidate = module.exports = function(persons, times) {\n this.winningTimes = {};\n this.times = times;\n var votesCount = [];\n \n var currentWinningPerson = -1;\n var winningVotes = 0;\n for (var i = 0; ...
2
0
[]
0
online-election
Java solution using PriorityQueue and BinarySearch (O(n*log(n))
java-solution-using-priorityqueue-and-bi-94gd
Code
swapit
NORMAL
2025-03-21T12:04:49.507274+00:00
2025-03-21T12:04:49.507274+00:00
50
false
# Code ```java [] class TopVotedCandidate { public class Candidate { int id; int votes; int latestVoteIndex; public Candidate(int id, int votes, int latestVoteIndex) { this.id = id; this.votes = votes; this.latestVoteIndex = latestVoteIndex; } } HashMap<Integer, Candidate> db; PriorityQ...
1
0
['Java']
0
online-election
✅ 🎯 📌 Simple Solution || Dictionary || Prefix Sum || Binary Search || Fastest Solution ✅ 🎯 📌
simple-solution-dictionary-prefix-sum-bi-mn6h
Code\npython3 []\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.persons=[]\n self.times=[]\n
vvnpais
NORMAL
2024-09-14T19:34:09.371597+00:00
2024-09-14T19:34:09.371632+00:00
339
false
# Code\n```python3 []\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.persons=[]\n self.times=[]\n self.d=defaultdict(int)\n self.mx=0\n for person,time in zip(persons,times):\n self.times.append(time)\n self.d[pe...
1
0
['Array', 'Hash Table', 'Binary Search', 'Design', 'Python3']
0
online-election
Simple python solution beats 85% of users (HashMap-BinarySearch)
simple-python-solution-beats-85-of-users-o915
Code\n\nfrom collections import defaultdict\nimport bisect\n\nclass TopVotedCandidate:\n\n def __init__(self, persons, times):\n self.leadings = []\n
youssefkhalil320
NORMAL
2024-05-17T18:28:11.331704+00:00
2024-05-17T18:28:11.331731+00:00
197
false
# Code\n```\nfrom collections import defaultdict\nimport bisect\n\nclass TopVotedCandidate:\n\n def __init__(self, persons, times):\n self.leadings = []\n self.times = times\n self.vote_counts = defaultdict(int)\n leading = -1\n \n for i in range(len(persons)):\n ...
1
0
['Hash Table', 'Binary Search', 'Python3']
0
online-election
python3 solution beats 97% 🚀 || quibler7
python3-solution-beats-97-quibler7-by-qu-uek6
Code\n\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.persons = []\n self.times = []\n s
quibler7
NORMAL
2023-05-07T03:46:48.412533+00:00
2023-05-07T03:46:48.412562+00:00
518
false
# Code\n```\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.persons = []\n self.times = []\n self.dic = collections.defaultdict(int)\n self.m = 0\n self.idx = -1\n\n for i in range(len(times)):\n self.times.append(tim...
1
0
['Python3']
1
online-election
✅ beats 100% Java code
beats-100-java-code-by-abstractconnoisse-eeid
Java Code\n\nclass TopVotedCandidate {\n private final int[] time;\n private final int[] leader;\n public TopVotedCandidate(int[] persons, int[] times)
abstractConnoisseurs
NORMAL
2023-02-13T07:34:24.921300+00:00
2023-02-13T07:34:24.921334+00:00
224
false
# Java Code\n```\nclass TopVotedCandidate {\n private final int[] time;\n private final int[] leader;\n public TopVotedCandidate(int[] persons, int[] times) {\n LeaderChange head = new LeaderChange();\n LeaderChange tail = head;\n int n = persons.length;\n int[] votes = new int[n];\...
1
1
['Array', 'Hash Table', 'Binary Search', 'Design', 'Java']
0
online-election
C++✅ || Easy || Solution
c-easy-solution-by-prinzeop-4sfl
\nclass TopVotedCandidate {\npublic:\n map<int, int> m2;\n unordered_map<int, int> m;\n\tTopVotedCandidate(vector<int>& persons, vector<int>& times) {\n\t
casperZz
NORMAL
2022-08-16T11:01:42.134987+00:00
2022-08-16T11:04:17.510195+00:00
664
false
```\nclass TopVotedCandidate {\npublic:\n map<int, int> m2;\n unordered_map<int, int> m;\n\tTopVotedCandidate(vector<int>& persons, vector<int>& times) {\n\t\tint lead = -1;\n\t\tm[-1] = 0;\n\t\tint n = persons.size();\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tm[persons[i]]++;\n\t\t\tif (m[persons[i]] >= m[lead])...
1
0
['C', 'Binary Tree']
0
online-election
Easy Solution using a HashMap and a TreeMap
easy-solution-using-a-hashmap-and-a-tree-61bn
\nclass TopVotedCandidate {\n // <key: voting candidate, value: count of votes a candidate has received>\n HashMap<Integer, Integer> voteCount;\n // <k
oori3280
NORMAL
2022-08-08T06:48:25.653230+00:00
2022-08-08T06:48:25.653263+00:00
264
false
```\nclass TopVotedCandidate {\n // <key: voting candidate, value: count of votes a candidate has received>\n HashMap<Integer, Integer> voteCount;\n // <key: timestamp, value: who is the leader with max vote>\n TreeMap<Integer, Integer> timeToLeader;\n int currentLeader;\n public TopVotedCandidate(int...
1
0
[]
0
online-election
[Python] Clean, simple with explanation
python-clean-simple-with-explanation-by-widei
\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n counter = defaultdict(int)\n\n mostVotePersons = [0]
npq
NORMAL
2022-07-22T15:34:11.075381+00:00
2022-07-22T15:34:11.075418+00:00
322
false
```\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n counter = defaultdict(int)\n\n mostVotePersons = [0] * len(persons) # mostVotePersons[i] is the most vote person at times[i]\n largestVote = -1 # keep largest vote person index\n for i in range(l...
1
0
['Binary Tree', 'Python']
0
online-election
[Python 3] Binary Search
python-3-binary-search-by-gabhay-hlk7
We first Precompute all winners at a given time if the winner is not changed we don\'t consider to add it to our list of winners at a given time. after that we
gabhay
NORMAL
2022-07-07T13:56:15.512248+00:00
2022-07-07T13:56:15.512287+00:00
135
false
We first Precompute all winners at a given time if the winner is not changed we don\'t consider to add it to our list of winners at a given time. after that we will find the lower bound of the time for which we are querying and just provide the result from our precomputed list.\nO(N)-- to precompute\nO(log(N)--> to que...
1
0
['Binary Search']
0
online-election
C++ SOLUTION
c-solution-by-kunal_patil-dctc
\n unordered_map mp;\n map chk;\n vector times1;\n int maxi=0;\n int ele;\n \n int binser(int k)\n {\n int i = 0;\n int j
kunal_patil
NORMAL
2022-05-31T08:53:42.411838+00:00
2022-05-31T08:53:42.411877+00:00
104
false
\n unordered_map<int,int> mp;\n map<int,int> chk;\n vector<int> times1;\n int maxi=0;\n int ele;\n \n int binser(int k)\n {\n int i = 0;\n int j = times1.size()-1;\n \n while(i<=j)\n {\n int mid = (i+j)/2;\n if(times1[mid]==k)\n ...
1
0
['Binary Tree']
0
online-election
(C++) 911. Online Election
c-911-online-election-by-qeetcode-ezgu
\n\nclass TopVotedCandidate {\n vector<int> times, lead; \npublic:\n TopVotedCandidate(vector<int>& persons, vector<int>& times) : times(times) {\n
qeetcode
NORMAL
2021-12-10T20:30:10.545470+00:00
2021-12-10T20:30:10.545520+00:00
300
false
\n```\nclass TopVotedCandidate {\n vector<int> times, lead; \npublic:\n TopVotedCandidate(vector<int>& persons, vector<int>& times) : times(times) {\n unordered_map<int, int> freq; \n int pp = 0; \n for (auto& p : persons) {\n ++freq[p]; \n if (freq[p] >= freq[pp]) pp = ...
1
0
['C']
1
online-election
Precompute + Binary Search [Java]
precompute-binary-search-java-by-itkan-p3cl
\nimport java.util.HashMap;\n\npublic class TopVotedCandidate {\n int[] winners;\n int[] times;\n\n public TopVotedCandidate(int[] persons, int[] times
itkan
NORMAL
2021-11-20T09:52:31.374601+00:00
2021-11-20T09:52:31.374638+00:00
187
false
```\nimport java.util.HashMap;\n\npublic class TopVotedCandidate {\n int[] winners;\n int[] times;\n\n public TopVotedCandidate(int[] persons, int[] times) {\n this.times = times;\n winners = new int[times.length];\n\n HashMap<Integer, Integer> voteMap = new HashMap<>();\n int maxVo...
1
0
['Binary Tree', 'Java']
0
online-election
📌📌 Easy and Well Explained || 98% faster || Simple Approach 🐍
easy-and-well-explained-98-faster-simple-z78h
IDEA :\nIn the order of time, we count the number of votes for each person.\nAlso, we update the current lead of votes for each time point.\nif (count[person]
abhi9Rai
NORMAL
2021-11-06T14:36:21.442661+00:00
2021-11-06T14:36:21.442690+00:00
118
false
## IDEA :\nIn the order of time, we count the number of votes for each person.\nAlso, we update the current lead of votes for each time point.\n`if (count[person] >= count[lead]) lead = person`\n\nTime Complexity: O(N)\n\n**Implementation :**\n\n\'\'\'\n\n\tclass TopVotedCandidate:\n def __init__(self, persons: Lis...
1
0
[]
0
online-election
Pre-computation + Binary Search [C++]
pre-computation-binary-search-c-by-siddh-7wmq
\n unordered_map<int, int> mp;\n vector<int> pref, times;\n int best = -1;\n \n TopVotedCandidate(vector<int>& persons, vector<int>& times) {\n
siddhantchimankar
NORMAL
2021-11-04T13:52:36.978078+00:00
2021-11-04T13:52:36.978107+00:00
86
false
```\n unordered_map<int, int> mp;\n vector<int> pref, times;\n int best = -1;\n \n TopVotedCandidate(vector<int>& persons, vector<int>& times) {\n \n pref = vector<int>(persons.begin(), persons.end());\n this->times = times;\n \n for(int i = 0 ; i < times.size() ; i++) ...
1
0
[]
0
online-election
✔️ C# - Simple to understand With Comments. Map & Binary Search
c-simple-to-understand-with-comments-map-t682
Thumbs up if you find this helpful \uD83D\uDC4D\n\nThe main idea in this solution is to create a result array called leaders that keeps track of who the current
keperkjr
NORMAL
2021-09-30T07:19:50.645429+00:00
2021-09-30T07:40:47.120428+00:00
99
false
**Thumbs up if you find this helpful** \uD83D\uDC4D\n\nThe main idea in this solution is to create a result array called ```leaders``` that keeps track of who the current leader is up to that point, for each ```time[i]```.\n\nFor example:\n```\nleaders[i] = The current leading vote getter up to the point of time[i]\n``...
1
0
['Binary Tree']
0
online-election
C++ || Map || binary search
c-map-binary-search-by-priyanka1230-xqks
\n\npublic:\n mapmp;\n vector>v;\n TopVotedCandidate(vector& p, vector& times) {\n int maxx=0,curr=0;\n for(int i=0;i=maxx)\n
priyanka1230
NORMAL
2021-09-29T12:48:24.580399+00:00
2021-09-29T12:48:24.580425+00:00
82
false
```\n\n```public:\n map<int,int>mp;\n vector<pair<int,int>>v;\n TopVotedCandidate(vector<int>& p, vector<int>& times) {\n int maxx=0,curr=0;\n for(int i=0;i<p.size();i++)\n {\n mp[p[i]]++;\n if(mp[p[i]]>=maxx)\n {\n maxx=mp[p[i]];\n ...
1
0
[]
0
online-election
C# BinarySearch
c-binarysearch-by-nick_l-4dho
\npublic class TopVotedCandidate\n{\n private static int[] _top;\n private static int[] _times;\n \n public TopVotedCandidate(int[] persons, int[] t
nick_l
NORMAL
2021-07-19T15:42:49.437905+00:00
2021-07-19T15:42:49.437935+00:00
77
false
```\npublic class TopVotedCandidate\n{\n private static int[] _top;\n private static int[] _times;\n \n public TopVotedCandidate(int[] persons, int[] times)\n {\n _times = times;\n _top = new int[persons.Length];\n \n var map = new Dictionary<int, int>();\n var winner =...
1
0
[]
0
online-election
C++, Probably the easiest to understand, Binary Search for querying
c-probably-the-easiest-to-understand-bin-2uxo
Precomputing the maximum voted person at each possible timestep, and performing binary search on time to find the correct time. \n\nclass TopVotedCandidate {\np
aditya_trips
NORMAL
2021-05-30T12:20:11.324841+00:00
2021-05-30T12:20:11.324884+00:00
237
false
Precomputing the maximum voted person at each possible timestep, and performing binary search on time to find the correct time. \n```\nclass TopVotedCandidate {\npublic:\n vector<int> persons, times,topVoted;\n TopVotedCandidate(vector<int>& p, vector<int>& t) {\n persons = p; \n times = t; \n ...
1
0
['C']
0
online-election
Easy and simple solution by using map
easy-and-simple-solution-by-using-map-by-m6hp
class TopVotedCandidate {\n vectorp;\n vectort;\n vectorres;\n int sum=0;\npublic:\n TopVotedCandidate(vector& persons, vector& times) {\n
bhoomi12356789
NORMAL
2021-05-05T20:24:40.485542+00:00
2021-05-05T20:24:40.485582+00:00
88
false
class TopVotedCandidate {\n vector<int>p;\n vector<int>t;\n vector<int>res;\n int sum=0;\npublic:\n TopVotedCandidate(vector<int>& persons, vector<int>& times) {\n p=persons;\n t=times;\n unordered_map<int,int>mp;\n int mx=0,mval=-1;;\n for(int i=0;i<p.size();i++)\n ...
1
2
['C']
0
online-election
JavaScript Solution - Binary Search Approach
javascript-solution-binary-search-approa-flei
\nvar TopVotedCandidate = function(persons, times) {\n this.times = times;\n this.len = times.length;\n this.votes = new Array(this.len).fill(0);\n
Deadication
NORMAL
2021-03-22T17:16:46.188029+00:00
2021-03-22T17:19:07.280598+00:00
220
false
```\nvar TopVotedCandidate = function(persons, times) {\n this.times = times;\n this.len = times.length;\n this.votes = new Array(this.len).fill(0);\n \n let max = 0; // max votes received by any single candidate so far.\n let leader = -1l;\n \n this.leaders = persons.map((person, i) => {\n ...
1
0
['Binary Tree', 'JavaScript']
0
online-election
Java Using HashMap And TreeMap
java-using-hashmap-and-treemap-by-tara-9-s0rs
The question is quite simple.We just have to find which person is leading at a given time\n\nclass TopVotedCandidate {\n Map<Integer,Integer> voteCount = new
tara-97
NORMAL
2021-01-12T06:06:33.132294+00:00
2021-01-12T06:06:33.132329+00:00
101
false
The question is quite simple.We just have to find which person is leading at a given time\n```\nclass TopVotedCandidate {\n Map<Integer,Integer> voteCount = new HashMap<>();\n TreeMap<Integer,Integer> lead = new TreeMap<>();\n int maxVotes = 0;\n public TopVotedCandidate(int[] persons, int[] times) {\n ...
1
0
[]
0
online-election
C++ simple precompute and then query
c-simple-precompute-and-then-query-by-yo-zonk
\nclass TopVotedCandidate {\npublic:\n array<int,5001> votes = {};\n map<int,int> time2winner;\n \n TopVotedCandidate(vector<int>& persons, vector<in
youngkobe
NORMAL
2021-01-02T21:16:15.409216+00:00
2021-01-02T21:16:15.409260+00:00
98
false
```\nclass TopVotedCandidate {\npublic:\n array<int,5001> votes = {};\n map<int,int> time2winner;\n \n TopVotedCandidate(vector<int>& persons, vector<int>& times) {\n if(persons.empty())\n return;\n int currentWinner = persons[0];\n time2winner[times[0]] = currentWinner;\n ...
1
0
[]
0
online-election
Simple Java Solution using TreeMap
simple-java-solution-using-treemap-by-mi-7719
\nclass TopVotedCandidate {\n // Space is O(N)\n TreeMap<Integer, Integer> timeMaxVoteMap = new TreeMap<>();\n // 5000 is based on the limits provided
milind9179367800
NORMAL
2020-12-26T08:31:03.838628+00:00
2020-12-26T08:31:03.838678+00:00
203
false
```\nclass TopVotedCandidate {\n // Space is O(N)\n TreeMap<Integer, Integer> timeMaxVoteMap = new TreeMap<>();\n // 5000 is based on the limits provided in the question.\n int[] votes = new int[5000];\n int maxVotePerson = -1;\n int maxVote = 0;\n public TopVotedCandidate(int[] persons, int[] time...
1
0
['Tree', 'Java']
1
online-election
Java easy to understand binary search
java-easy-to-understand-binary-search-by-9ugz
```\nclass TopVotedCandidate {\n int[] persons;\n int[] times;\n\n public TopVotedCandidate(int[] persons, int[] times) {\n int max = persons[0]
zmz999
NORMAL
2020-10-24T07:16:32.143825+00:00
2020-10-24T07:16:32.143860+00:00
112
false
```\nclass TopVotedCandidate {\n int[] persons;\n int[] times;\n\n public TopVotedCandidate(int[] persons, int[] times) {\n int max = persons[0];\n Map<Integer, Integer> map = new HashMap<>();\n for (int i = 0; i < times.length; i++) {\n int count = map.getOrDefault(persons[i], ...
1
0
[]
0
online-election
Python 3 | Binary Search + Hash Table | Explanations
python-3-binary-search-hash-table-explan-18qt
Explanation\n- For binary search problem we often need hash table for help\n- Given persion and times, we can form a time-series data, which store the informati
idontknoooo
NORMAL
2020-09-11T00:57:58.859791+00:00
2020-09-11T00:57:58.859833+00:00
403
false
### Explanation\n- For binary search problem we often need hash table for help\n- Given `persion` and `times`, we can form a time-series data, which store the information indicates who\'s winning at time `t`\n\t- `times` is already an increasing series, but we need to know who\'s winning at these time points\n\t- `vote...
1
0
['Hash Table', 'Binary Search', 'Python', 'Python3']
0
online-election
C++ DP+Hash solution
c-dphash-solution-by-rom111-0lzq
\nclass TopVotedCandidate {\npublic:\n unordered_map<int,int>freq;\n unordered_map<int,int>votes;\n vector<int>ans;\n int maxi=INT_MIN;\n int a;\
rom111
NORMAL
2020-08-09T17:35:26.712896+00:00
2020-08-09T17:35:26.712931+00:00
74
false
```\nclass TopVotedCandidate {\npublic:\n unordered_map<int,int>freq;\n unordered_map<int,int>votes;\n vector<int>ans;\n int maxi=INT_MIN;\n int a;\n TopVotedCandidate(vector<int>& persons, vector<int>& times) {\n a=0;\n for(int i=0;i<times.size();i++){\n a=max(a,times[i]);\n ...
1
0
[]
0
online-election
[C++] 100% faster
c-100-faster-by-kangchunhung-4ork
\nclass TopVotedCandidate {\npublic:\n int *votes, *timestamp, last_time;\n TopVotedCandidate(vector<int>& persons, vector<int>& times) {\n ios_bas
kangchunhung
NORMAL
2020-07-16T08:33:23.541398+00:00
2020-07-16T08:33:23.541440+00:00
119
false
```\nclass TopVotedCandidate {\npublic:\n int *votes, *timestamp, last_time;\n TopVotedCandidate(vector<int>& persons, vector<int>& times) {\n ios_base::sync_with_stdio(0);\n cin.tie(0); cout.tie(0);\n last_time = times.back() + 1;\n int L = persons.size();\n votes = new int[L];...
1
0
[]
0
online-election
Python Clean Solution
python-clean-solution-by-olivia_xie_93-a1bm
python\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.nums = []\n count = collections.Counter()
olivia_xie_93
NORMAL
2020-07-05T03:32:44.325040+00:00
2020-07-05T03:32:44.325076+00:00
106
false
```python\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.nums = []\n count = collections.Counter()\n mx = 0\n major = None\n \n for people, time in zip(persons, times):\n count[people] += 1\n if count[peop...
1
0
[]
0
online-election
Python3 dict look up or array binary search - Online Election
python3-dict-look-up-or-array-binary-sea-1kfq
\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.times = times\n self.winner = {times[0]: person
r0bertz
NORMAL
2020-07-01T03:13:47.024067+00:00
2020-07-01T03:14:06.294853+00:00
259
false
```\nclass TopVotedCandidate:\n\n def __init__(self, persons: List[int], times: List[int]):\n self.times = times\n self.winner = {times[0]: persons[0]}\n c = Counter({persons[0]: 1})\n maxCount = 1\n for i in range(1, len(times)):\n p = persons[i]\n c[p] += 1\...
1
0
['Binary Search', 'Python', 'Python3']
0
online-election
O(N) + O(QLogN)
on-oqlogn-by-shivam529-qjih
\nclass TopVotedCandidate {\n int []leaders;\n int []times;\n public TopVotedCandidate(int[] persons, int[] times) {\n leaders=new int[persons.l
shivam529
NORMAL
2020-05-24T20:45:14.902053+00:00
2020-05-24T20:45:14.902107+00:00
108
false
```\nclass TopVotedCandidate {\n int []leaders;\n int []times;\n public TopVotedCandidate(int[] persons, int[] times) {\n leaders=new int[persons.length];\n this.times=times;\n Map<Integer,Integer> map=new HashMap<>();\n int leader=-1;\n int max=-1;\n for(int i=0;i<per...
1
0
['Java']
0