avva: (Default)
[personal profile] avva
Ох, Adobe, Adobe...
Problem Summary

I'd like to determine the max value in an array, but I don't want to have to loop through the array and check each value.

Solution Summary

Put the array in an ArrayCollection, sort the collection, and then get the last value.

Гвозди бы делать из этих людей,
Всё б развалилось от этих гвоздей.

Date: 2009-01-13 02:29 pm (UTC)
From: [identity profile] renatm.livejournal.com
Да нормально всё. O(n*log(n)) не намного хуже, чем O(n). Да и к тому же в постановке задачи было сказано "without looping".
(deleted comment)

Date: 2009-01-13 03:54 pm (UTC)
From: [identity profile] renatm.livejournal.com
Как у них в листинге:
private var ac:ArrayCollection = new ArrayCollection(myArray);

Под условием "without looping" подразумевается, что программисту не надо самому писать циклы, но они могут присутствовать в вызываемых конструкторах и функциях.

January 2026

S M T W T F S
    1 2 3
4 5678910
11121314151617
18192021222324
25262728293031

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 6th, 2026 04:08 pm
Powered by Dreamwidth Studios