전체 글 (282) 썸네일형 리스트형 Push후 Commit 취소하기 가장 최근 커밋 메시지 변경하고 싶은 경우git commit --amend -m "새로운 커밋 메시지"커밋 취소하고 싶은 경우git reset --soft 커밋만 취소, 파일들은 스테이징 영역에 그대로 남음커밋 메시지만 변경하고 싶은 경우에 사용git reset --mixed 커밋, 스테이징 영역 취소, 작업내용은 파일 디렉토리에 여전히 남음커밋, 스테이징 취소, 수정한 파일은 작업 디렉토리에 그대로 두고 싶을 때 사용git reset --hard 커밋, 스테이징 영역 취소, 작업 디렉토리 모두 날리기돌리고 싶은 커밋이후 변경사항을 작업 디렉토리, 스테이징, 커밋까지 다 삭제하고 싶을 때 사용push한 commit을 완전히 로컬 내용까지 싹 다 취소하고 싶은 경우git reset --hard 제네릭을 활용한 Double타입 계산이 가능한 계산기 만들기 여러 자료를 보며 내가 이해한 제네릭이란 메서드나 클래스의 타입에 대한 지정을 최초 생성시에 하는 것이 아닌 인스턴스를 만들 때 외부에서 지정해주는 것이었다. 한마디로 핵심은 외부에서 타입을 지정해 준다는 것! 1. 첫번째 시도계산의 결과를 담는 results 배열의 타입을 제네릭으로 지정해주고, 계산을 수행하는 calculate 메서드의 리턴타입과 매개변수 타입을 동일한 제네릭으로 선언Operator ‘+’ cannot be applied to ‘T’, ‘T’ 에러 발생public class A { private ArrayList results = new ArrayList(); public T calculate(T number1, T number2){ results.add(num.. 11286 절댓값 힙 / 우선순위 큐 절댓값이 만약 같은 경우에는 음수를 제거하는 부분에서 고민을 많이 했다그래서 처음에는 pop을 할 때 리스트를 순회해서 같은 수가 있는 경우를 체크 한 후, 음수가 루트보다 아래에 있다면 교환하는 방법으로 구현을 했다 def pop(self): if len(self.heap) == 0: return 0 if len(self.heap) == 1: return self.heap.pop() minimum = self.heap[0] idx = 0 for h in self.heap: if abs(h) == abs(minimum) and minimum > h: s.. 자바 알고리즘 연습(5) 하샤드 수class Solution { public boolean solution(int x) { boolean answer = false; int firstNumber = x; int numberSum = 0; while (x > 0) { numberSum += x % 10; x = x / 10; } if(firstNumber % numberSum == 0){ answer = true; } return answer; }} 두 정수 사이의 합class Solution { public long solution(int.. 다형성을 이용한 계산기 만들기 - 예외처리 추가 import java.util.Scanner;public class CalculatorApp { public static boolean start() throws Exception { //throws Exception : 위험하다는 표시, 이에 대한 메서드의 예외 처리를 해줘야 함 Parser parser = new Parser(); Scanner scanner = new Scanner(System.in); System.out.println("첫번째 숫자를 입력해주세요!"); String firstInput = scanner.nextLine(); parser.parseFirstNum(firstInput); System.out.. 다형성을 이용한 계산기 만들기 step 3까지 결과package org.tesk;public class Calculator { AddOperation addOperation; SubstractOperation substractOperation; MultiplyOperation multiplyOperation; DivideOperation divideOperation; public double calculate(String operator, int firstNumber, int secondNumber){ double answer = 0; char char_operator = operator.charAt(0); //연산 수행 if (char_operator ==.. 자바 알고리즘 연습(4) 문자열을 정수로 바꾸기class Solution { public int solution(String s) { int answer = Integer.parseInt(s); return answer; }} 정수 제곱근 판별class Solution { public long solution(long n) { long answer = 0; for (long i = 1; i 정수 내림차순으로 배치하기 앞으로 문제를 풀 때는 import java.util.*; 하기!import java.util.ArrayList;class Solution { public Long solution(long n) { long answer = .. 1927 최소 힙 / 우선순위 큐 class MinHeap: def __init__(self): self.heap = [] def push(self, value): self.heap.append(value) self.up_heap(len(self.heap) - 1) #추가한 값의 인덱스 전송 def up_heap(self, index): parent = (index - 1) // 2 if self.heap[parent] > self.heap[index] and index > 0: self.heap[parent], self.heap[index] = self.heap[index], self.heap[parent] self.u.. 이전 1 ··· 12 13 14 15 16 17 18 ··· 36 다음