[01.30] 내일배움캠프[Spring] TIL-61

박상훈·2023년 1월 30일
0

내일배움캠프[TIL]

목록 보기
61/72

[01.30] 내일배움캠프[Spring] TIL-61

1. CI/CD

  • CI (Continuous Integration)
    • 해석하면 "지속적 통합" 으로 여러 개발자가 하나의 프로젝트를 같이 개발할 때 발생하는 불일치를 최소화 해주는 개념입니다.
    • CI 를 제대로 구현하면 애플리케이션 변경 사항 반영 시 자동으로 빌드 및 테스트 되어 잘못된 코드가 공유되는 걸 방지합니다.
  • CD (Continuous Deployment)
    • "지속적 배포" 라는 뜻으로 프로젝트의 변경 사항을 가상 환경에 자동으로 배포하는 것을 의미합니다.
    • CD 를 구성해두면 변경 사항을 배포할 때 사용하는 파이프라인을 공유하여 번거로움을 없앨 수 있습니다.

GitHubAction

  • workFlow 선택

gradle.yml

name: Java CI with Gradle

on:
  pull_request:
    branches: [ "main" ]

permissions:
  contents: read

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 17
      uses: actions/setup-java@v3
      with:
        java-version: '17'
        distribution: 'temurin'
    - name: Grant execute permission for gradlew
      run: chmod +x gradlew
    - name: Test with Gradle # test application build
      run: ./gradlew --info test
    - name: Build with Gradle
      uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
      with:
        arguments: build
  • 나는 밑에 부분을 추가해주는 것을 망각해서 계속 해서 권한 오류가 발생
run: chmod +x gradlew
- name: Test with Gradle # test application build
run: ./gradlew --info test
  • 구글링을 통하여 이 명령어를 터미널에 직접 입력했고, 그 결과 gradle.yml파일의 수정이 감지되어, PR를 날렸다.
git update-index --chmod=+x gradlew

결과

2.Level - 0 (좀 어려웠던) 최빈 값 찾기

  public int solution(int[] arrays) {

        Map<Integer,Integer> countList = new HashMap<>();
        int[] sortedList = Arrays.stream(arrays).sorted().distinct().toArray();


        for(int i=0;i<sortedList.length;i++){
            int count = 0;
            for(int j=0;j<arrays.length;j++){
                if(sortedList[i]==arrays[j]){
                    count++;
                    countList.put(sortedList[i],count);
                }
            }
        }


        int maxValue = countList.get(sortedList[0]);
        int maxIndex = sortedList[0];

        for(int i=0;i<countList.size();i++) {

            if (countList.get(sortedList[i]) > maxValue) {
                maxValue = countList.get(sortedList[i]);
                maxIndex = sortedList[i];
            }
        }


        int numCount = 0;

      for(int count: countList.values()){
          if(count==maxValue){
              numCount++;
          }
      }

      if(numCount>1){
          return -1;
      }


        return maxIndex;
    }
}
  • 조금 비효율적으로 푼 것 같지만.. 통과..
  • stream().count()를 써서 풀면 효율적 일 것 같긴한데..하..
profile
기록하는 습관

0개의 댓글