Running Time of Algorithms

Sort by

recency

|

278 Discussions

|

  • + 0 comments

    Locksmith Selby provides reliable locksmith solutions, from emergency lockouts to fitting advanced locking systems for homes, businesses, and vehicles. With prompt service and skilled expertise, they ensure safety and peace of mind for every customer. Their professionalism and knowledge of both traditional and modern locks make them a trusted local choice. Just as security requires efficiency and precision, understanding the Running Time of Algorithms is essential for optimizing performance and achieving effective computational problem-solving.

  • + 0 comments
    def runningTime(arr):
        # Write your code here
        shifts = 0
        n = len(arr)
        
        for i in range(1, n):
            key = arr[i]
            j = i - 1
            while j >= 0 and key < arr[j]:
                arr[j+1] = arr[j]
                j -= 1
                shifts += 1
            arr[j+1] = key
        return shifts
    
  • + 0 comments

    Here is my python sollution

    def runningTime(a):
        dem =  0 
        for i in range(1,len(a)):
            for j in range(i-1,-1,-1):
                if a[i] < a[j] :
                    a[j],a[i] = a[i],a[j]
                    i -=1
                    dem += 1
        return dem
    
  • + 0 comments

    Did anyone try BASH solution it keep getting me Time limit exceeded?

  • + 0 comments

    Here is problem solution in python java c++ c and Javascript - https://programmingoneonone.com/hackerrank-running-time-of-algorithms-problem-solution.html