0

バランスアルゴリズムを取得しようとしていますが、これを達成する方法を理解するのに苦労しています。

以下のような HashMap があります。

Map criteria = new HashMap();
criteria.put("0",5);
criteria.put("1",8);
criteria.put("2",0);
criteria.put("3",7);
...

また、HashMap から値を取得し、バランスの取れた方法で配列に入れる必要がある 2 次元配列があります。

String[][] arr = new String[3][1];

私が探している最終結果は次のようなものです。

arr[0][0]="0"; (the key of the hashmap)
arr[1][0]="1";
arr[2][0]="2,3"; (as the key "2" has the value less among the first two entries, the key "3" should be appended top this node)

したがって、基本的に HashMap のキーは、その値に基づいて配列に均等に分散される必要があります。

助けてくれてありがとう。

4

0 に答える 0