The problem of finding an algorithm

[{"averse: 123123123}, {" baked: 123123123}, {"crested: 231212}]

find out the one with the largest value, and then find out how that key writes the algorithm through the largest value-sharp-sharp-sharp topic description

Dec.13,2021

traversal

cycle pairwise comparison, record the larger value and the corresponding key, to the end, and then record the value and key is the largest


an idea: with reference to bubble sorting, you can filter out the maximum or minimum values in just one traversal. Take the head or tail to get the maximum or minimum item. If there are multiple items with the same value, they must also be concentrated at both ends.


In [20]: a=[{'a': 123123123}, {'b': 123123123}, {'c': 231212}]

In [21]: max(a, key=lambda d:list(d.values())[0])
Out[21]: {'a': 123123123}

In [22]: list(max(a, key=lambda d:list(d.values())[0]).keys())[0]
Out[22]: 'a'
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c0fc-2c2dd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c0fc-2c2dd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?