Straight forward, but need to handle the string carefully. First, we need to store the roman characters to vector and treat it as hash table, then transfer the integer to roman, there are some cases: if n == 9, 5 <= n < 9, n == 4, 1 <= n < 4, n == 0. Handle these separately. Need to think about e.g. do not forget to know that we handle number from small to large, so every time we need to append our previous string to current transfer.
leetcode-12-Integer to Roman
最新推荐文章于 2019-10-17 09:22:58 发布