Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

max of 2d array python

>>> numbers = [0, 0, 1, 0, 0, 1], [0, 1, 0, 2, 0, 0], [0, 0, 2, 0, 0, 1], [0, 1, 0, 3, 0, 0], [0, 0, 0, 0, 4, 0]

>>> map(max, numbers)
<map object at 0x0000018E8FA237F0>
>>> list(map(max, numbers))  # max numbers from each sublist
[1, 2, 2, 3, 4]

>>> max(map(max, numbers))  # max of those max-numbers
4
Comment

how to find the max value in a 2d array

public class MyClass { 
    public static void main(String args[]) { 
        int arr[][] = { 
         {1,2,3,4,5}, 
         {100,101,102,103,10491}, 
         {2,80,70,57,66}, 
         {1000,10001,65,34,54} 
        }; 
 
        int max = Integer.MIN_VALUE; 
        for(int i = 0; i < arr.length; i++){ 
            for(int j = 0; j < arr[i].length; j++){ 
                if(arr[i][j] > max){ 
                    max = arr[i][j]; 
                } 
            } 
             
        } 
        System.out.println("Maximum Value : " + max); 
    } 
}
Comment

find max value in 2d array python

a = [1, 2, 3, 4, 5]
print(max(a))
# 5
Comment

PREVIOUS NEXT
Code Example
Python :: swap case python 
Python :: django model queries 
Python :: print numbers from 1 to 100 in python 
Python :: how to check if a string value is nan in python 
Python :: list operations in python 
Python :: how to make a do while in python 
Python :: função find python 
Python :: python loop over list 
Python :: opencv rgb to gray custom 
Python :: python iterate through list 
Python :: uninstall python kali linux 
Python :: diccionario python 
Python :: camp cretaceous.com 
Python :: three different randomn numbers python 
Python :: import messages 
Python :: remove last element in list python 
Python :: extract all file in zip in python 
Python :: get more than one decimal in python 
Python :: value_counts sort by index 
Python :: read text file python path open 
Python :: how to use visualize_runtimes 
Python :: In is_lodes_form( : Missing id-axis pairings. 
Python :: forgot password miguel grinberg 
Python :: tkinter yt downloader with resolution 
Shell :: remove steam from ubuntu 
Shell :: npm cache clean 
Shell :: ubuntu update chrome browser 
Shell :: uninstall wps office ubuntu 
Shell :: remove all docker images 
Shell :: ssh restart ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =