"virtual function is a member function declared with virtual keyword in a base class. It enables derived classes to redefine this function with their own specific implementations."
Sonia M. - "virtual function is a member function declared with virtual keyword in a base class. It enables derived classes to redefine this function with their own specific implementations."See full answer
"Bitshift the number to the right and keep track of the 1's you encounter. If you bitshift it completely and only encounter one 1, it is a power of two."
Nils G. - "Bitshift the number to the right and keep track of the 1's you encounter. If you bitshift it completely and only encounter one 1, it is a power of two."See full answer
"Function that is passed as an argument or parameter to another function and it gets executed when the function that it is passed to gets executed"
Susmita S. - "Function that is passed as an argument or parameter to another function and it gets executed when the function that it is passed to gets executed"See full answer
Software Engineer
Coding
+1 more
🧠Want an expert answer to a question? Saving questions lets us know what content to make next.
"
O(n) time, O(1) space
from typing import List
def maxsubarraysum(nums: List[int]) -> int:
if len(nums) == 0:
return 0
maxsum = currsum = nums[0]
for i in range(1, len(nums)):
currsum = max(currsum + nums[i], nums[i])
maxsum = max(currsum, max_sum)
return max_sum
debug your code below
print(maxsubarraysum([-1, 2, -3, 4]))
`"
Rick E. - "
O(n) time, O(1) space
from typing import List
def maxsubarraysum(nums: List[int]) -> int:
if len(nums) == 0:
return 0
maxsum = currsum = nums[0]
for i in range(1, len(nums)):
currsum = max(currsum + nums[i], nums[i])
maxsum = max(currsum, max_sum)
return max_sum
debug your code below
print(maxsubarraysum([-1, 2, -3, 4]))
`"See full answer
"Construct a min-heap either inplace, or by making a copy of the array and then applying heapify on that copy. This is done in O(n) time.
Maintain two zero-initialised variables - sum and count.
Keep popping off the heap while sum < k, and update count.
In the worst case you will have to do n pops, and each pop is O(log n), so the algorithm would take O(n log n) in total. Space complexity depends on whether you're allowed to modify inplace or not, so either O(1) or O(n) respectively."
Anonymous Wolf - "Construct a min-heap either inplace, or by making a copy of the array and then applying heapify on that copy. This is done in O(n) time.
Maintain two zero-initialised variables - sum and count.
Keep popping off the heap while sum < k, and update count.
In the worst case you will have to do n pops, and each pop is O(log n), so the algorithm would take O(n log n) in total. Space complexity depends on whether you're allowed to modify inplace or not, so either O(1) or O(n) respectively."See full answer
"Sorting is a technique to arrange data in either increasing order or decreasing order, and, the function that implements this functionality is called sort function"
Farhan -. - "Sorting is a technique to arrange data in either increasing order or decreasing order, and, the function that implements this functionality is called sort function"See full answer