분류 전체보기

// 원형 연결 리스트 (Circular Linked List) 구현 class CircularLinkedList { NodeBi head; NodeBi tail; CircularLinkedList(NodeBi node) { this.head = node; this.tail = node; this.head.prev = tail; this.head.next = tail; } // 전체 조회 void showData() { if (this.head == null) { System.out.println("List is Empty !!"); return; } NodeBi cur = this.head; while (true) { System.out.print(cur.data + " "); cur = cur.nex..
/** * 직관적인 느낌과 다르게 순열보다 조합이 계산이 더 복잡 * 조합 = 순열 / 줄 세우는 방법의 수 * * 조합(줄 세우지 않는 뽑기 경우의 수) * == 먼저 줄 세워서 뽑은 후(순열) 줄세우는 것을 취소함(줄세우는 방법 경우의 수로 나눔) * * 5C3 = (5P3 == 5 * 4 * 3) / (3! == 줄세우는 방법의 수) --> 3!의 의미는 뭐지? (줄 세우는 방법의 수?) * * cf) 5C3 과 5C2의 결과는 같음. * 5개중 3개를 뽑는 것이 곧 나머지 2개를 뽑는 것. */ public class Main { public static int combination(int n, int r) { int nResult = 1; for (int i = n; i >= n - r + 1;..
/** * 순열은 뽑아서 줄 세우기 -> 곱의법칙 응용 * 5명 중 3명 줄 세우기 -> 5*4*3 */ public class Main { public static void main(String[] args) { // 1. 팩토리얼 System.out.println("== 팩토리얼 =="); // 5! int result = 1; for (int i = 1; i 5 * 4 * 3 int n = 5; int r = 3; result = 1; for (int i = n; i >= n - r + 1; i--) { result *= i; } System.out.println(result); // 3. 중복 순열 /** * * 중복 순열 이론 (중복 허용 순열) * cf) 하나의 대상이 여러번 등장하므로 사람의..
·백엔드/Java
- 글의 순서 - 동시성 처리 이슈 상황 - 자바 동시성 처리 기초 정보 및 동시성 처리 테스트 코드 작성 방안 - java.lang.Thread & java.lang.Runnable - ExecutorFramework - Thread VS ExecutorFramework - CountDownLatch - 처리방안 - 트랜잭션 격리수준 - Uncommitted Read - Committed Read - Repeatable Read - Serializable - 데이터베이스 수준에서의 처리 방안 - 락 - 비관적 락 - 락관적 락 - 어플리케이션 수준에서의 처리 방안 - 왜 어플리케이션에서 처리할 수 있어야 하는가? - syncronized - ConcurrentHashMap - 레디스 - 분산락 - 스핀..
// 문자열 배열 strs 와 targets 가 주어졌을 때 // targets 내의 단어 중 한 문자만 바꾸면 strs 중의 단어가 되는지 판별하는 프로그램을 작성하세요. // 입출력 예시 // 입력 strs: "apple", "banana", "kiwi" // 입력 target: "applk", "bpple", "apple" // 출력: true, true, false public class Practice3 { public static void solution(String[] strs, String[] targets) { Practice2.Trie trie = new Practice2.Trie(); for (String s : strs) { trie.insert(s); } for (String ta..
·백엔드/Java
안녕하세요. 린내입니다~! 저번 게시글에선 주로 인터페이스와 추상클래스에 대해 알아보았습니다. 이번 게시글은 정적 클래스에 대해서 중점적으로 알아볼까요? 사실 자바에서는 정적 클래스가 따로 존재하진 않습니다. 자바에서 이너(혹은 중첩) 클래스가 아닌 일반 클래스는 static 키워드가 허용되지 않기 때문입니다. 통상적으로 정적 멤버(정적 필드, 정적 메소드)만 갖고 있는 클래스를 정적 클래스로 지칭하고 있습니다. // static class StaticExample { 일반 클래스에 static 키워드 사용 불가 class StaticExample { // 정적 멤버만 선언 } 정적 클래스의 멤버는 클래스 초기화 시 메서드 영역(클래스 영역)에 저장되어 프로그램이 종료될 때까지 유지됩니다. 따라서 프로그..
/** * * 순열 == 뽑아서 줄 세우는 경우의 수 -> 곱의법칙 응용 * 5명 중 3명 줄 세우기 -> 5*4*3 * */ // 1, 2, 3, 4 를 이용하여 세자리 자연수를 만드는 방법 (순서 O, 중복 x)의 각 결과를 출력하시오 // 방법 1 -> swap() 활용 // 방법 2 -> visited[] 활용 public class Practice1 { static int result; //결과 개수 // 방법 1 -> swap을 이용한 풀이.. public void permutationBySwap(int[] arr, int depth, int n, int r) { if (depth == r) { result++; for (int i = 0; i < r; i++) { System.out.prin..
·백엔드/Java
안녕하세요. 린내입니다~! 오늘은 추상클래스에 대해 알아보려고 합니다. 추상클래스는 그 명칭에서 느껴지듯이.. 실무에서도 상당히 추상적으로 사용되는 느낌이 강한듯한데요. 알듯 말듯한 추상클래스에 대해서 이번 기회에 제대로 정리해보겠습니다. 하지만 사실, 오늘의 주인공은 추상클래스가 아닐수도 있습니다. 이 글의 발단은 아래의 게시글에서 시작되었는데요. https://stackoverflow.com/questions/3340032/are-utility-classes-evil Are utility classes evil? I saw this question: If a "Utilities" class is evil, where do I put my generic code? And I thought, why ar..
class Node { Map child; //노드는 자식 Map과 터미널 여부를 갖고 있음.. boolean isTerminal; public Node() { this.child = new HashMap(); this.isTerminal = false; } } class Trie { Node head; public Trie() { this.head = new Node(); } public void insert(String data) { Node cur = this.head; for (int i = 0; i < data.length(); i++) { char c = data.charAt(i); cur.child.putIfAbsent(c, new Node()); cur = cur.child.get(c); ..
·미완성
https://hyeonic.github.io/study/agora/2022-06-16.html#%E1%84%8B%E1%85%A1%E1%84%80%E1%85%A9%E1%84%85%E1%85%A1
꾸준함의 미더덕
'분류 전체보기' 카테고리의 글 목록 (6 Page)