私は次のクラスを持っています:
class A {
String s;
}
class A
そして、オブジェクトのリストの次のリスト:
[{1s, 3f, 46h}, {333s, 67b, 1d, 67m, 67h}, {3a, 3x}, {34n, 22o, 34s},
{40f, 22x, 4m}... and so on]
必要なのは、このリストを繰り返し処理し、結果を取得して、別の出力arrayListにプッシュすることだけです。ここで、結果のarrayListに含まれるものは次のとおりです。
1. Just skip those elements from the above input arrayList
which have more than one String with same prefix(only the last character
is the suffix here which will always be a single character alphabet; not digit).
For example: from the above input arrayList the first element({1s, 3f, 46h})
won't be skipped and will be pushed into the output arrayList
as it doesn't have any String with the same prefix; as 1, 3 and 46 are different.
But 2nd, 3rd and 4th elements will be skipped as they have matches
(three prefixes with same 67 in 2nd element, two prefixes with same 3 in 3rd element
and two prefixes with same 34 in 4th element).
So, for the above input arrayList the output arrayList will be:
[{1s, 3f, 46h}, {40f, 22x, 4m}]
誰かが私に上記の仕事を簡単かつ効率的な方法で行う方法を提案できますか?可能であればサンプルコードを教えてください。
ありがとう!