Tag Archives: hackerank türkçe

HackerRank Çözümleri – Pangrams

HackerRank içerisinde bulunan “Pangrams” sorusunun açıklaması ve çözümü. Bu soruda size verilen string içerisinde, ingiliz alfabesindeki tüm harflerin bulunup bulunmadığı soruluyor.

► HackerRank – Pangrams: https://www.hackerrank.com/challenges/pangrams/problem

► Problem açıklaması:

A pangram is a string that contains every letter of the alphabet. Given a sentence determine whether it is a pangram in the English alphabet. Ignore case. Return either pangram or not pangram as appropriate.

Example

s = “The quick brown fox jumps over the lazy dog”

The string contains all letters in the English alphabet, so return pangram.

Function Description

Complete the function pangrams in the editor below. It should return the string pangram if the input string is a pangram. Otherwise, it should return not pangram.

pangrams has the following parameter(s):

string s: a string to test

Returns

string: either pangram or not pangram

Sample Input 0

We promptly judged antique ivory buckles for the next prize

Sample Output 0

pangram

Sample Explanation 0

All of the letters of the alphabet are present in the string.

Sample Input 1

We promptly judged antique ivory buckles for the prize

Sample Output 1

not pangram

Sample Explanation 0

The string lacks an x.

HackerRank Çözümleri – Alternating Characters

HackerRank içerisinde bulunan “Alternating Characters” sorusunun açıklaması ve çözümü. Soruda size verilen string içerisinde, yan yana hiçbir karakterin aynı olmaması için kaç defa karakter silme işlemi yapmanız gerektiği soruluyor.

► HackerRank – Alternating Characters: https://www.hackerrank.com/challenges/alternating-characters/problem

► Problem açıklaması:

You are given a string containing characters A and B only. Your task is to change it into a string such that there are no matching adjacent characters. To do this, you are allowed to delete zero or more characters in the string.

Your task is to find the minimum number of required deletions.

Example

s = AABAAB

Remove an A at positions 0 and 3 to make s = ABAB in 2 deletions.

Function Description

Complete the alternatingCharacters function in the editor below.

alternatingCharacters has the following parameter(s):

string s: a string

Returns

int: the minimum number of deletions required

Sample Input

5

AAAA

BBBBB

ABABABAB

BABABA

AAABBB

Sample Output

3

4

0

0

4