Sort by

recency

|

3704 Discussions

|

  • + 0 comments
      let max = -Infinity;
        for(let i=0;i<=3;i++){   
            for(let j= 0;j<=3;j++){
                
            let  sum= arr[i][j]+arr[i][j+1]+arr[i][j+2]
                          +arr[i+1][j+1]+
                    arr[i+2][j]+arr[i+2][j+1]+arr[i+2][j+2]
                         
                if(sum>max){
                    max=sum
                }
            }
        }
        return max
         
    
  • + 0 comments

    max_sum = -float("inf")

    for i in range(4):
        for j in range(4):
            top = arr[i][j]+arr[i][j+1]+arr[i][j+2]
            middle = arr[i+1][j+1]
            bottom = arr[i+2][j]+arr[i+2][j+1]+arr[i+2][j+2]
            total = top + middle + bottom
            max_sum = max(max_sum, total)
    return max_sum
    
  • + 0 comments

    The 2D Array – DS problem tests how you handle multi-dimensional arrays efficiently, especially for pattern extraction like hourglass sums. In the same way, planning an Umrah from Montréal requires organizing multiple elements (flights, hotels, guidance) in a structured way, ensuring everything fits together smoothly for the best experience.The 2D Array – DS problem tests how you handle multi-dimensional arrays efficiently, especially for pattern extraction like hourglass sums. In the same way, planning an Umrah from Montréal requires organizing multiple elements (flights, hotels, guidance) in a structured way, ensuring everything fits together smoothly for the best experience.

  • + 0 comments

    This python code worked.

    def hourglassSum(arr):
        # Write your code here
        addn=[] 
        for i in range(4): 
            for j in range(4): 
                top=arr[i][j]+arr[i][j+1]+arr[i][j+2] 
                middle=arr[i+1][j+1] 
                bottom=arr[i+2][j]+arr[i+2][j+1]+arr[i+2][j+2] 
                add=top+bottom+middle 
                addn.append(add)
        return max(addn)
    
  • + 0 comments

    When working with a 2D array, it’s fascinating how the data structure can be used beyond typical programming logic, even for something creative like aesthetic drawing. Each element in the array can represent a pixel, color value, or pattern detail, allowing intricate designs to emerge from organized data. By mapping numerical values to visual elements, a 2D array can essentially become a digital canvas where shapes, gradients, and patterns take form with precision.

    This approach bridges logic and creativity, transforming mathematical structure into visual art. Whether it’s generating symmetrical patterns, pixel-style illustrations, or experimenting with color combinations, the versatility of a 2D array provides a solid foundation for creating aesthetic drawing projects in a programmatic way.