[자바 알고리즘 노트]

marongrong·2022년 2월 7일
0
  • 배열의 오름차순 정렬 : Arrays.sort();
    배열의 내림차순 정렬 : Arrays.sort(arr, Collections.reverseOrder());

  • Hashset 정렬하려면 list로 변환 후에 그 list를 정렬해주면 됨
    HashSet set = new HashSet<>();
    List list = new ArrayList(set);
    Collections.sort(list);
    배열만 Arrays.sort(), 그 나머지는 모두 Collections.sort()

  • 배열의 임의의 두 수 뽑기 -> 이중for문, j = i+1로 초기화 생각
    백트래킹 알고리즘으로도 풀 수 있음 --- 공부하기

  • 중복 안됨 -> HashSet set = new HashSet<>(); 생각

  • 소수 판별 -> 방법이 많지만 함수 선언이 가장 쉽네
    public boolean isPrimeNum(int num){
    return "";}

profile
what moves you makes you

0개의 댓글