# @param {String[]} words
# @param {String} order
# @return {Boolean}
def is_alien_sorted(words, order)
orig="abcdefghijklmnopqrstuvwxyz"
hsh=Hash[order.chars.zip(orig.chars)]
words==words.sort_by{|w|w.chars.map{|c|hsh[c]}}
end
아예 문자열이 원래 문자열이 가지고 있었을 순서를 반영하게 변환한 뒤에 정렬함
댓글 0