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 :: python find closest value in list to zero 
Python :: count number of occurrences of all elements in list python 
Python :: string pattern matching pandas 
Python :: Extract Date from Datetime object 
Python :: md5 hash python 
Python :: how to find shortest string in a list python 
Python :: convert base64 to image python 
Python :: python invert dictionary 
Python :: python subtract one list from another 
Python :: all column except pandas 
Python :: python game over screen 
Python :: how to find how many processors you have with python 
Python :: printing a range of no one line in python 
Python :: python hello wrold 
Python :: delete space in string python 
Python :: codeforces 677a python solution 
Python :: pygame window 
Python :: linux command on python 
Python :: how to reverse array in ruby 
Python :: while loop countdown python 
Python :: pandas new df from groupby 
Python :: what is the purpose of the judiciary 
Python :: Pyo example 
Python :: parquet pyspark 
Python :: python selenium save cookies 
Python :: python file name from absolute path 
Python :: python list comma separated string 
Python :: log of number python 
Python :: python datetime date only 
Python :: print all of dataframe 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =