๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
CodingTest

์•Œ๊ณ ๋ฆฌ์ฆ˜::์‹œ๊ฐ„๋ณต์žก๋„:: ๊ณต๊ฐ„๋ณต์žก๋„::์™„์ „ํƒ์ƒ‰

by ๋„์บ๋ฆฌ๐Ÿฑ 2020. 10. 17.
๋ฐ˜์‘ํ˜•

Q) 1์ดˆ? ๋ช‡๋ฒˆ? 

 

 

1) ์™„์ „ํƒ์ƒ‰์‹์œผ๋กœ ์ƒ๊ฐ์„ ์šฐ์„  ํ•˜๊ณ , ์‹œ๊ฐ„์„ ์ค„์—ฌ๋‚˜๊ฐ„๋‹ค๋Š” ์‹์œผ๋กœ ์ƒ๊ฐ.

 

2)์™ธ์šธ ๊ฒƒ: sort์˜ ์‹œ๊ฐ„ ๋ณต์žก๋„? == nlogn

 

3)endl์€ ์‹œ๊ฐ„์„ ๋งŽ์ด ์“ด๋‹ค. endl ๋ณด๋‹ค๋Š” 
\n์‚ฌ์šฉํ•˜๊ธฐ.

 

4)๋ฐ˜๋“œ์‹œ ์ ๊ณ  ์‹œ์ž‘ํ•  ๊ฒƒ?

cin.tie(0)
cout.tie(0)
ios:sync_with_stdio(false);

 

 

5)long long 

 

6) pair<a,b>PPA : 2๊ฐœ์˜ ๊ฐ’์„ ํ•œ๋ฒˆ์— ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค.

PPA.first

PPA.second

์ด๋Ÿฐ์‹์œผ๋กœ ์ ‘๊ทผํ•œ๋‹ค.

 

7) input์ด ๋„ˆ๋ฌด ํฌ๋‹ค๋ฉด string ์œผ๋กœ ๋ฐ›์•„๋ผ.

 

8) ์ˆœ์—ด ์กฐํ•ฉ <algorithm> ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—, 

next_permutation

prev_permutation

:do while ()์‚ฌ์šฉ

์กฐํ•ฉ์˜ ๊ฒฝ์šฐ์—๋„ ์œ„์— ๊ฒƒ ์‚ฌ์šฉ

 

+@

๊นƒํ—™ ๋น„์ฃผ์–ผ ์ŠคํŠœ๋””์˜ค ์—ฐ๊ฒฐ ์ฐธ๊ณ ํ•œ ๊ณณ

it-earth.tistory.com/112

 

GitHub์™€ Visual Studio ์—ฐ๋™ํ•˜๊ธฐ

โ–ถ๋ชฉํ‘œ GitHub์™€ Visual Studio 2017์„ ์—ฐ๋™ํ•ด์„œ ๋‘ ๋Œ€ ์ด์ƒ์˜ PC์—์„œ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ๊ด€๋ฆฌํ•œ๋‹ค. Visual Studio IDE๋ฅผ ํ™œ์šฉํ•ด GitHub๋กœ ๋ฒ„์ „ ๊ด€๋ฆฌ๋ฅผ ํ•˜๋ฉฐ ํ˜‘์—…ํ•˜๋Š” ๊ฐœ๋ฐœ์ž ํ˜น์€ ๊ณต๋ถ€ํ•˜๋Š” ํ•™์ƒ/์ทจ์ค€์ƒ๋“ค์—๊ฒŒ ๋„์›€๏ฟฝ๏ฟฝ

it-earth.tistory.com

 

 

+@ ๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ค‘ ์ด๋ ‡๊ฒŒ ํ’€๋ฉด ์ฐธ ์ข‹์„ ํ…๋ฐ ์‹ถ์—ˆ๋˜ ๋ฌธ์ œ

int main()
{
	string str;
    int arr[26] = {0,};
    int max_cnt = 0;
    int index = 0;
    int count =0;
    
    cin >>str;
    
    for(int i = 0; i<str.length(); i++
    {
    	int n = str.at(i);
        if(n<97)
        	arr[n-65]++;
         else
         	arr[n-97]++;
    }
    
    for(int i=0; i<26; i++)
    {
    	if(arr[i] >max_cnt)
        {
        	max_cnt = arr[i];
            index = i;
        }
    }
    
    for(int i=0; i<26; i++)
    {
    	if(arr[i] == max_cnt)
        {
        	count++;
            if(count >=2)
            {
            	cout<< "?" <<"\n";
                return 0;
            }
        }
	}
    
    
    cout << (char) (index+65) <<"\n";
    
    return 0;
    
 }
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€