Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

개발 일지

1832. Check if the Sentence Is Pangram (문장이 Pangram인지 확인하기) C# 본문

코딩 테스트/LeetCode

1832. Check if the Sentence Is Pangram (문장이 Pangram인지 확인하기) C#

포카리tea 2022. 10. 17. 14:33

A pangram is a sentence where every letter of the English alphabet appears at least once.

Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.

pangram이란 영어 알파벳의 모든 글자가 적어도 한 번씩은 나타나는 문장입니다.

소문자만 포함한 문자열 sentence가 주어집니다. sentence pangram이면 true를 그렇지 않으면 false를 반환하십시오.

 

예시 1:

입력: sentence = "thequickbrownfoxjumpsoverthelazydog"
출력: true
설명: sentence는 모든 알파벳의 모든 글자를 적어도 하나씩을 포함합니다.

예시 2:

입력: sentence = "leetcode"
출력: false

 

조건:

  • 1 <= sentence.length <= 1000
  • sentence는 소문자로만 구성되어있습니다.

 

정답:

public class Solution {
    public bool CheckIfPangram(string sentence) {
        char[] charArray = sentence.ToCharArray();
        if (charArray.Distinct().ToArray().Length == 26)
            return true;
        else
            return false;
    }
}

해설: 모든 알파벳이 들어간다면 중복제거를 했을때 길이가 26이 나와야합니다