![]() ![]() There's another way, and we can actually mathematically figure out a formula. Thir=thir+(yushu*yushu-yushu)/ 2 Įlse // Make sure that the sequence number is the same If(j= 30||j= 0) // Permutation with itself, minus pairing with itself twice, so divide by 2 var numPairsDivisibleBy60 = function( time) for( let j= 0 j= 30 j++) // Loop controls repetition There's a special case to consider, where the number we found is divisible by 60, and in that case we need to make a special judgment. ** the sum of the remainder is equal to 60 which means that their sum is divisible by 60. But if you use an array index, the time by subscript is O(1).Īnd we're looking for pairs where the sum of the remainder is equal to **60. CSbasics/pairs-of-songs-with-total-durations-divisible-by-60.py at master yennanliu/CSbasics GitHub My CS learning : algorithm, data structure, and system design SE - CSbasics/pairs-of-songs-with-total-durations-divisible-by-60.But if you're just storing these integers in an array, you're going to have to walk through the entire array to get a value.When you first store a finite number of integer types, consider using the index of the array to represent them. ![]() So how do we solve the problem of time? Let's analyze the problem. When we see a data set less than or equal to 60000, it's about 1e5, so the time complexity doesn't really matter in your n^2. Pairs of Songs with Total Durations Divisible by 60 Coding Question Explained Whole Minute Dilemma Code-Todays Exam. Input: Output: 3 Explanation: The total duration of all three pairs is 120 and can be rounded by 60. Input: Output: 3 explanation: The total duration of these three pairs can be integer by 60: (time = 30, time = 150): Total duration 180 (time = 20, time = 100): total duration 120 (time = 20, time = 40): total duration 60 Pairs of Songs With Total Durations Divisible by 60 LeetCode 1010 C++ - YouTube 0:00 / 16:36 Pairs of Songs With Total Durations Divisible by 60 LeetCode 1010 C++ Knowledge Center 45.1K. Formally, we want the index numbers I and j to satisfy I j and have (time + time) % 60 = 0. Returns the number of song pairs whose total duration, in seconds, is divisible by 60. In the song list, track I has a duration of time seconds. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source. GitHub: P-J27, CSDN: PJ wants to be a front-end siege lionĬopyright belongs to the author. Note: Part of the article content and pictures from the network, if there is infringement please contact me (homepage public number: small siege lion learning front)īy: Little front-end siege lion, home page: little front-end siege lion home page, source: Nuggets Check out the details: The Last Gwen Challenge in 2021." "This is the 26th day of my participation in the Gwen Challenge in November. Pairs of Songs With Total Durations Divisible by 60 - LeetCode Editorial Solutions (1.3K) Join LeetCode to Code View your Submission records here Register or Sign In : ( Sorry, it is possible that the version of your browser is too low to load the code-editor, please try to update browser to revert to using code-editor.
0 Comments
Leave a Reply. |