We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Strings
- Pangrams
- Discussions
Pangrams
Pangrams
+ 0 comments golang:
func checker(s string , x rune) bool{ isTrue := false if x == 32{ isTrue=false }else{ for _,v := range s{ if v == 32{ isTrue=false }else if v==x{ isTrue=true break } } } return isTrue } func pangrams(s string) string { // Write your code here count := 0 alphabets := "abcdefghijklmnopqrstuvwxyz" output := "" str := strings.ToLower(s) for _,v := range alphabets{ if checker(str , v){ count ++ } } if count == 26{ output = "pangram" }else{ output= "not pangram" } return output }
+ 0 comments Easy C++ solution
string pangrams(string s) { map<char,int> m; transform(s.begin(), s.end(), s.begin(), ::tolower); int n = s.length(); for(int i = 0; i < n; i++){ m.insert({char(s[i]),i}); } for(char c = 'a'; c <= 'z' ; c++){ if(m.find((c)) == m.end()){ return "not pangram"; } } return "pangram"; }
+ 0 comments python solution
def pangrams(s): s = s.lower() letter = 'abcdefghijklmnopqrstuvwxyz' unique_letter = set(s) # only give unique letter in set for char in letter: if char not in unique_letter: return "not pangram" return "pangram"
+ 0 comments Java easy solution using hash map.\ Complexity(n)
public static String pangrams(String s) { // Write your code here s = s.replaceAll(" ", "").toLowerCase(); HashMap<Character,Integer> map=new HashMap<>(); for(int i=97;i<=122;i++){ map.put((char)i,0); } for(int i=0;i<s.length();i++){ char ch=s.charAt(i); map.put(ch,map.getOrDefault(map.get(ch),0)+1); } for (int i=97;i<=122;i++) { char ch=(char)i; if(map.get(ch)==0){ return "not pangram"; } } return "pangram"; }
+ 0 comments #swayam_singh #python3code def pangrams(s): f={} a=s.lower().replace(" ","") for i in a: f[i]=f.get(i,0)+1 a=len(f) if(a==26): return "pangram" else: return "not pangram"
Load more conversations
Sort 1816 Discussions, By:
Please Login in order to post a comment