본문으로 바로가기
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.



유튜브, 책, 구글검색, OKKY 토대로 작성해보았다. 추후 발견할 때마다 업데이트를 할 예정....  신입 또는 경력의 문제가 포함(경력 치고는 너무 쉬운 문제가 있을 수도 있지만 면접시간이 길지 않기 때문에 쉬운 문제로 출제되는 케이스가 있었음)


1. 재귀를 이용한 피보나치(fibo 함수)

2. 메모이제이션을 이용한 피보나치(memoFibo 함수)

3. 재귀를 이용한 팩토리얼 문제(fact 함수)

4. 10번 동안 1~10까지 랜덤한 숫자를 출력하여 중복된 숫자가 있을 경우 true, false를 리턴하라(randomQuiz)

(판교의 어느 대기업 손코딩 문제) 그닥 어렵지 않은 문제 랜덤함수 범위만 지정할 줄 알면 매우 쉬운 것 같다.

int a = (int)(Math.random()*10)+1; //1 ~ 10 랜덤 함수 뽑아내기


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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
public final class CodingExample {
    public static int[]table;
    public static void main(String[] args) {
        table = new int[7+1];
//        System.out.println(fibo(7));
//        System.out.println(memoFibo(7));
//        System.out.println(fact(5));
        
        randomQuiz();
    }
    
    //피보나치 
    public static int fibo(int data) {
        if(data <= 1) {
            return 1;
        }
            
        
        return fibo(data-1+ fibo(data-2);
    }
    
    //피보나치 
    public static int memoFibo(int data) {
        if(data <= 1) {
            table[data] = 1;
            return 1;
        }
        
        if(table[data] > 0) {
            
            return table[data];
        }
            
        table[data] = memoFibo(data-1+ memoFibo(data-2);
        
        return table[data];
    }
    
    //factorial
    public static int fact(int data) {
        if(data <= 1
            return 1;
        
        
        return fact(data-1* data;
    }
    
    //Math.Random();
    public static void randomQuiz() {
        
        for(int i=0; i < 50; i++) {
            
            int randomValue = (int)(Math.random()*10)+1;
            System.out.println(randomValue);
        }
    }
}



5. 각종 정렬

면접 시간에 따라 다르겠지만 짧다면 (삽입, 버블, 선택) 길다면(힙, 퀵, 합병)정렬을 예상한다.

블로그를 참조하면 된다.


6. 각종 자료구조 구현해보기(Stack, Queue, HashTable, LinkedList) 등등

블로그를 참조하면 된다.


7. Anagram

아나그램이란 ? 서로 다른 두 문자열이 있을때 두 문자열의 알파벳을 재배열하였을때 같은 단어 혹은 문장. 

예를 들어, apple과 ppale는 아나그램 abcd와 bacd는 아나그램


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
public static boolean checkAnagram(String str1, String str2) {
    //공백 제거
    str1 = str1.replaceAll("\\s""");
    str2 = str2.replaceAll("\\s""");
 
    //미리 문자열의 길이가 같은지 계산하여 1차적인 결과 수행
    if (str1.length() != str2.length()) {
        return false;
    }
 
    // 두 단어다 소문자로 변환 후 char 형식으로 변환해주는 toCharArray() 메서드 활용
    char[] char1 = str1.toLowerCase().toCharArray();
    char[] char2 = str2.toLowerCase().toCharArray();
 
    // Arrays.sort()를 이용하여 정렬을 한다.
    Arrays.sort(char1);
    Arrays.sort(char2);
 
    // String 비교를 위해 character 배열을 String으로 변환한다.
    String _str1 = new String(char1);
    String _str2 = new String(char2);
 
    // 비교한 결과를 리턴한다.
    return _str1.equals(_str2);
}



8. 문자열 안에 문자들이 고유한 문자인지 확인


주어진 문자열의 문자들이 모두 고유한지를 확인하는 함수를 구현하시오. 



담당자에게 질문해야할 것은 ?


해당 문자열이 아스키인지 유니코드를 포함하는지 확인을 해야한다.아스키일경우 128개의 배열을 사용해야한다. 

Unicode는 2의 20승 + 2의 16승의 1,114,112개의 문자를 가지기 때문에 자바의 HashMap을 구현해야한다.


아스키 코드


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public boolean isUnique(String str) {
    if(str.length() > 128return false;
    boolean[] char_set = new boolean[128];
    
    for(int i=0; i < str.length(); i++) {
        int val = str.charAt(i);            
        if(char_set[val]) {
            
            return false;
        }
        
        char_set[val] = true;
    }
    
    return true;
}



유니코드


1
2
3
4
5
6
7
8
9
10
11
12
13
public boolean isUnique(String str) {
    HashMap<Integer, Boolean> hashMap = new HashMap<Integer, Boolean>();
    for(int i=0; i < str.length(); i++) {
        int ch = str.charAt(i);
        if(hashMap.containsKey(ch)) {
            
            return false;
        }
        
        hashMap.put(ch, true);
    }
    return true;
}



9. 최소공배수 최소공약수 구하기

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class CommonNumber {
    static int a, b;
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner scan = new Scanner(System.in);
        a = scan.nextInt();
        b = scan.nextInt();
        if (b > a) {
            int temp = b;
            b = a;
            a = temp;
        }
        int result = gcd(a, b);
        System.out.println(result);
        System.out.println(a * b / result);
    }
 
    public static int gcd(int a, int b) {
        if (a % b == 0)
            return b;
        return gcd(b, a % b);
    }
}


추후 지속적인 업데이트 !!










'IT인터뷰면접질문' 카테고리의 다른 글

개발자 면접 질문(자바, 스프링)  (5) 2018.10.04
프로그래머 면접 질문2  (6) 2016.03.31
운영체제 시스템 개념  (0) 2016.03.26
데이터베이스 질문들  (0) 2016.03.26
데이터베이스 용어  (0) 2016.03.26