3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C#で1時間で解けなきゃ~その4

Posted at

例のアレ
http://www.softantenna.com/wp/software/5-programming-problems/

問題4

正の整数のリストを与えられたとき、数を並び替えて可能な最大数を返す関数を記述せよ。例えば、[50, 2, 1, 9]が与えられた時、95021が答えとなる

            int maxLen = int.MaxValue.ToString().Length;
            string zeros = new string('0', maxLen);
            int[] ss = args
                        .Select(a =>
                            new
                            {
                                orgValue = a,
                                padValue = (a + zeros).Substring(0, maxLen)
                            })
                        .OrderByDescending(a => a.padValue)
                        .Select(a => a.orgValue)
                        .ToArray();
            return string.Concat(ss);
3
3
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?