티스토리

대충이라도 하자
검색하기

블로그 홈

대충이라도 하자

kkokkoma-dev.tistory.com/m

....

구독자
0
방명록 방문하기

주요 글 목록

  • Design Guru(Day2) 3. Sqrt -> Binary Search approach -> Since the floor of the square root of a number x lies between 0 and x/2 for all x > 1, we can use binary search within this range to find the square root -> binary Search : O(logN) -> O(1) for space complexity class Solution { public int mySqrt(int x) { if(x 공감수 0 댓글수 0 2023. 8. 29.
  • Design Gurus(Day1) 2023.08.27 1. Contains Duplicate import java.util.HashSet; import java.util.Set; //0.242ms public class Solution { public boolean containsDuplicate(int[] nums) { // TODO: Write your code here Set set = new HashSet(); for(int i = 0; i Binary Search approach -> Since the floor of the square root of a number x lies between 0 and x/2 for all x > 1, we can use binary search within this range to find .. 공감수 0 댓글수 0 2023. 8. 28.
  • Python static method VS class method 파이썬에서 메소드는 세 가지 종류이다. - instance method - class method - static method 파이썬에서 사용되는 @classmethod 와 @staticmethod는 어떻게 다른 걸까??? --> 두 개가 서로 비슷하지만, 사용 방법이 조금 다르다. 클래스 메소드의 경우에는 클래스 객체가 첫번째 파라미터로 필요하지만, 스테틱 메소드의 경우에는 파라미터를 가지지 못한다. *** stackoverflow 참고 class Date(object): def __init__(self, day=0, month=0, year=0): self.day = day self.month = month self.year = year @classmethod def from_string(cls, d.. 공감수 0 댓글수 0 2023. 1. 23.
  • docker ps 시, permission denied 오류 docker ps를 터미널에서 실행했는데 아래와 같은 에러가 나왔다. Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied sudo chmod 666 /var/run/docker.sock 명령어 실행한 다음, 다시 docker ps 실행 공감수 0 댓글수 0 2023. 1. 5.
  • Docker 1. What is docker? - A platform for building, running and shipping applications *** 가끔 application이 작동하지 않을 수 있음 - configuration - some files are missing - software version mismatch -> To resolve this, docker is needed! Consistently, build, run and ship applications 2. Containers Vs VM Container - An isolated environment for running an application - allow running multiple apps in isolation - are.. 공감수 0 댓글수 0 2022. 8. 12.
  • Leetcode - Median of two sorted Arrays Hard!!! - too many variables - think about the edge cases - array index starts from 0, but length of array is the same with just the number. class Solution { public double findMedianSortedArrays(int[] nums1, int[] nums2) { //median 찾기 //sorted arrays int s1= 0, s2=0, index=-1; int m = nums1.length; int n = nums2.length; int [] result = new int[m+n]; while(index != (m+n)/2){ index++; if(s1>m-1) {.. 공감수 0 댓글수 0 2022. 7. 13.
  • Blind 75 Must Do Leetcode - Two sum https://leetcode.com/list/xi4ci4ig/ Favorite - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 1. Brute Force - O(N^2) class Solution { public int[] twoSum(int[] nums, int target) { int [] result = new int[2]; //1. for문 2개 for(int i =0; i 공감수 0 댓글수 0 2022. 6. 7.
  • 멱등(Idempotent) HTTP 메소드의 속성 - 안전 : 본질적으로 읽기 전용이며, 원본 서버의 리소스에 영향을 주지 않는 속성 - 멱등 : 요청을 재시도해도, 재실행해도 원래 의도한 바와 같이 동일하게 작동하는 속성을 의미 연산을 여러 번 반복해도 결과값은 변하지 않음. - 캐시가능 : 요청한 응답의 리소스를 향후 재사용을 위해 저장할 수 있는 속성을 의미 멱등한 메소드는? - GET : 같은 요청을 한 번 하든, 수 천 번 하든 클라이언트가 원하는 결과대로 작동 - PUT : 클라이언트가 요청을 반복할 경우, PUT의 특성 상 클라이언트가 원한 결과대로 무조건 리소스가 갱신되거나 생성 - DELETE : 클라이언트가 원한 결과대로 삭제 결국, POST 제외 전부 멱등 POST는 클라이언트가 요청을 반복할 경우, 클라이언트.. 공감수 0 댓글수 0 2022. 4. 24.
  • Session과 JWT Session 웹사이트에서 로그인을 한다고 생각해보자. - 이메일이랑 패스워드를 입력하고 브라우저는 서버에 요청을 보낸다. - 서버는 패스워드 해시랑 동일한지 비교하고, 동일하면, 특정 세션 ID를 만든다. + session storage에 저장 - 서버는 쿠키에 세션 ID를 담아 되돌려 보냄(HTTP only) => 내 것이 아닌 자바스크립트로 읽을 수 없음 => insecure한 connection으로 이전 불가능, encrypted되지 않음 => man in the middle attck이 가능 - 이 다음부터는 브라우저가 요청을 보낼 때마다, 쿠키에 세션 ID를 담고 서버는 session storage에서 정보 확인 JWT 마찬가지로, 브라우저가 요청을 보내고 서버는 패스워드 해쉬 매칭 확인 - .. 공감수 0 댓글수 0 2022. 4. 24.
  • 서블릿, 동시 요청 멀티쓰레드 1. 서블릿 @WebServlet(name="helloServlet", urlPatterns="/hello") public class HelloServlet extends HttpServlet { @Override protected void service(HttpServletRequest request, HttpServeltResponse response) { } } urlPatterns의 url이 호출되면 서블릿 코드가 실행 개발자는 http 스펙을 편리하게 활용 서블릿 컨테이너 톰캣처럼 서블릿을 지원하는 was를 서블릿 컨테이너라고 함 서블릿 객체를 생성, 초기화, 호출, 종료하는 생명 주기 관리 서블릿 객체는 싱글톤으로 관리 JSP도 서블릿으로 변환 되어서 사용 동시 요청을 위한 멀티 쓰레드 처리 .. 공감수 0 댓글수 0 2022. 3. 23.
  • Diagonal Traverse 4개의 edge에서 어떻게 대처할 것인가 On top bolder in up trend: go right On right bolder in up trend: go down On left bolder in down trend: go down On bottom bolder in down trend: go right *** 1번과 2번이 동시에 발생하면 2번을 따르고 3번과 4번이 동시에 발생하면 4번을 따라야 한다. 1. DFS 방법으로 하려고 했음 -> 왜인지 모르겠으나 아래와 같은 오류 발생 => FAILED WARNING: A command line option has enabled the Security Manager WARNING: The Security Manager is deprecated an.. 공감수 0 댓글수 0 2022. 3. 22.
  • 객체 지향 설계와 Spring - Based on Java language - 자바 언어의 가장 큰 특징 - 객체 지향 언어(Object-oriented language) - 스프링은 객체 지향 언어가 가진 강력한 특징을 살려내는 프레임워크 좋은 객체 지향??? 객체 지향 프로그래밍 - 객체들의 모임으로 파악 -각각의 객체는 메시지를 주고 받고, 데이터를 처리할 수 있따. - 유연하고 변경이 용이-> 대규모 소프트웨어 개발에 많이 사용 다형성(Polymorphism) -역할과 구현으로 세상을 구분 -역할과 구현으로 구분하면 세상이 단순해지고, 유연해지며 변경도 편리 자바 언어에서의 다형성 역할 = 인터페이스 구현= 인터페이스를 구현한 클래스, 구현 객체 - 객체 설계시 역할을 먼저 부여(인터페이스) -> 그 다음, 객체 생성 - 객체.. 공감수 0 댓글수 0 2022. 3. 22.
  • Best Time to Buy and Sell Stock ( Leetcode) At first, I used 2 for loops, but in aspects of time space, it was not efficient. I thought about several ways, then, chose to use dynamic programming.( Need to study more about dp) This is what I solved the problem. class Solution { public int maxProfit(int[] prices) { int min = Integer.MAX_VALUE; int max = 0; for(int i = 0; i 공감수 0 댓글수 0 2022. 2. 23.
  • API 설계 Method -PATCH : 부분 수정 ***PATCH를 쓰는 것이 좋음 -PUT : 기존에 있던 것을 덮어버림 ***덮어버리기에, 전체 정보가 누락 없이 보내야 함 -POST *** 2개 다 애매할 경우, 천하무적 POST 사용 파일관리시스템- 신규 자원 등록 : 등록은 POST, PUT 2가지 경우 있음 1. POST로 등록하는 것은 클라이언트가 서버에 요청 - 등록해달라고 그래서 서버가 만들어줌 ->컬렉션(Collections) : 서버가 리소스 URI 결정 2.하지만, PUT은 클라이언트가 리소스 URI를 알고 있어야 한다. -> 스토어(Store) ***대부분 POST 기반의 컬렉션 사용 API Vs HTML FORM : html form은 get, post만 사용 가능 -> AJAX 같은 기술.. 공감수 0 댓글수 0 2022. 2. 9.
  • Array and String - Introduction to Array Array & Dynamic Array What is the difference between array and dynamic array? What is the corresponding built-in data structure of array and dynamic array in your frequently-used language? How to perform basic operations (initialization, data access, modification, iteration, sort, etc) in an array? How to perform basic operations (initialization, data access, modification, iteration, sort, addit.. 공감수 0 댓글수 0 2022. 2. 7.
  • Stateless & Connectionless HTTP의 특징 중 2가지이다. 1. Stateless (클라이언트와 서버 사이의 상태를 유지하지 않는 것) 클라이언트가 현재 무엇을 사고 싶은지, 어떤 지불방법을 했는지 등등 고객의 상태를 저장하지 않음으로써 자원을 아낌 그렇기 때문에, 매번, 고객의 상태 및 정보를 request를 날릴 때마다, 알려줘야 한다. 자원의 낭비는 막을 수 있지만, 데이터를 너무 많이 보내게 됨. : 로그인이 필요 없는 단순한 서비스 소개 화면 등은 stateless로 구현 but, 로그인 같은 것은 stateful로 구현해야 한다. 하지만, 로그인한 사용자의 경우는 로그인했다는 상태를 서버에 유지 일반적으로 브라우저 쿠키와 서버 세션 등을 사용해서 상태 유지 -> 매번, 브라우저 쿠키에서의 정보를 서버로 보내고 서버에서는.. 공감수 0 댓글수 0 2022. 1. 27.
  • Leetcode - Graph Number of Provinces -> Here is how I solved this problem. class Solution { public int findCircleNum(int[][] isConnected) { int count = 0; boolean [] visited = new boolean[isConnected.length]; for(int i = 0; i 공감수 0 댓글수 0 2022. 1. 26.
  • Graph -chaper 1(2) Path Compression Optimization - Disjoint Set : find function을 최적화함 ***Recursion // UnionFind.class class UnionFind { private int[] root; public UnionFind(int size) { root = new int[size]; for (int i = 0; i < size; i++) { root[i] = i; } } public int find(int x) { if (x == root[x]) { return x; } return root[x] = find(root[x]); } public void union(int x, int y) { int rootX = find(x); int rootY = fi.. 공감수 0 댓글수 0 2022. 1. 20.
  • Elasticsearch 설치 및 사용 (Windows) Elasticsearch는 자바로 이루어져 있기 때문에 자바가 설치되어 있어야 한다. 그리고 그 중에서는 java8(내가 현재 가지고 있는 버전)이 아니라 java11이 설치되어 있어야 한다. 1. 자바 11 설치 - 이전 버전 삭제하고 , 오라클에서 java 11 다운 ( 오라클에 가입해야 다운받을 수 있다. 귀찮.....ㅜㅜ) - JAVA_HOME 및 Path 설정 꼭 필요!!! 2. Elasticsearch 설치 https://www.elastic.co/kr/downloads/elasticsearch Download Elasticsearch Download Elasticsearch or the complete Elastic Stack (formerly ELK stack) for free and st.. 공감수 0 댓글수 0 2022. 1. 18.
  • Graph - Disjoint Set Note that others might refer to it as an algorithm. In this Explore Card, the term “disjoint set” refers to a data structure. The primary use of disjoint sets is to address the connectivity between the components of a network. The “network“ here can be a computer network or a social network. For instance, we can use a disjoint set to determine if two people share a common ancestor. Parent node: .. 공감수 0 댓글수 0 2022. 1. 18.
  • Graph - overview There are many types of “graphs”. In this Explore Card, we will introduce three types of graphs: undirected graphs, directed graphs, and weighted graphs. Undirected graphs The edges between any two vertices in an “undirected graph” do not have a direction, indicating a two-way relationship. Directed graphs The edges between any two vertices in a “directed graph” graph are directional. Weighted g.. 공감수 0 댓글수 0 2022. 1. 18.
  • Arrays-chapter6 Height Checker 자꾸 단순 구현으로 풀려고 하넼ㅋㅋㅋ(32.12%, 16.85%) import java.util.*; class Solution { public int heightChecker(int[] heights) { int result= 0; int[] expected = new int[heights.length]; for(int i = 0;i 공감수 0 댓글수 0 2022. 1. 17.
  • Arrays - chapter5 In-Place Operations These are very important from an interviewing standpoint. In-place Array operations are where we modify an Array, without creating a new Array. : inserting and removing items by shifting existing items along. In programming interviews, the interviewer often expects you to minimise the time and space complexity of your implementation. In-place Array operations help to reduce s.. 공감수 0 댓글수 0 2022. 1. 13.
  • Arrays -chapter 4 Search in an Array There's more than one way of searching an Array, but for now, we're going to focus on the simplest way. Searching means to find an occurrence of a particular element in the Array and return its position. We might need to search an Array to find out whether or not an element is present in the Array. We might also want to search an Array that is arranged in a specific fashion to.. 공감수 0 댓글수 0 2022. 1. 12.
  • Arrays -chapter3 Now that we know how insertion works, it's time to look at its complement—deletion! Deletion in an Array works in a very similar manner to insertion, and has the same three different cases: Deleting the last element of the Array. Deleting the first element of the Array. Deletion at any given index. 1. Deleting From the End of an Array Deletion at the end of an Array is similar to people standing.. 공감수 0 댓글수 0 2022. 1. 12.
  • Arrays- Chapter2 Inserting a new element into an Array can take many forms: Inserting a new element at the end of the Array. Inserting a new element at the beginning of the Array. Inserting a new element at any given index inside the Array. Duplicate Zeros 이렇게 풀었는데 오류가 발생해서 문제를 다시 읽어보지 원래 존재하는 arr을 변경시켜야 하는 문제였다.ㅜㅜ 이렇게 해놓고 원래의 배열에 다시 넣는 방법도 있지만, 문제의 의도는 이를 지양하는 듯하다. 물론, 아래의 방법이 문제 푸는 시간은 훨씬 빠르다.ㅋㅋㅋ class Solutio.. 공감수 0 댓글수 0 2022. 1. 10.
  • Arrays -chapter1 An Array is a collection of items. The items could be integers, strings, DVDs, games, books—anything really. The items are stored in neighboring (contiguous) memory locations. Because they're stored together, checking through the entire collection of items is straightforward. In Java, we use the following code to create an Array to hold up to 15 DVDs. Note that we've also included a simple defin.. 공감수 0 댓글수 0 2022. 1. 10.
  • node.js unsupported engine 설치되어 있는 node.js의 버전이 최신 버전이 아니라서 작동되지 않는 것이 많아서 발생하는 문제인 듯 싶다. node.js 에서는 문제가 없는데 react를 실행하게 되면 맞지 않는 부분이 있는 거 같다. 결국 제거하고 재설치해야 함ㅜㅜㅜ 현재 node.js최신은 16. 13.1 인데 내가 가지고 있는 버전은 14.16.0이었다. npm cache clean -f npm cache clean --force npm install -g n 해도 안되서 결국 경로로 다 들어가서 삭제를 한 다음, ( 경로 중에 한글이 있으면 에러가 발생한다고 하는데 내 경로에는 없는 거 같은데..? Anyway...) 재설치!! 공감수 0 댓글수 0 2022. 1. 9.
  • internal/modules/cjs/loader.js:883 throw err; ^Error: Cannot find module './debug' 위의 에러를 발견하고 해결을 못하고 있었는데 한참 뒤에 깨달았다. 예를 들어 front와 back 두 가지를 한꺼번에 workspace에서 작업하고 있을 때, 각각의 디렉토리 안에 App.js, index.js와 같은 파일들이 공통적으로 존재하게 된다. 그런 경우에 이 에러가 발생하는 듯하다. 일단은, node_modules 폴더와 package.json-lock파일을 삭제한 뒤, npm install을 다시 해주면 에러가 사라진다. 공감수 0 댓글수 0 2022. 1. 8.
  • 프로그래머스-[1차] 추석 트래픽 1. Date 라이브러리 사용하지 않고 했었는데 하는 게 훨씬 쉽네...? 그런데 이번 문제에서 무엇보다 놀라운 건 throws Exception 사용이 가능한 듯하다.ㅋㅋㅋㅋ 윈도우를 활용잘해야 한다. 처음과 끝의 범위를 활용해서!! import java.util.*; import java.text.*; class Solution { public int solution(String[] lines) throws Exception { int answer = 0; SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss.SSS"); int len = lines.length; int[] counts = new int[len]; for(int i = 0; i 공감수 0 댓글수 0 2022. 1. 6.
    문의안내
    • 티스토리
    • 로그인
    • 고객센터

    티스토리는 카카오에서 사랑을 담아 만듭니다.

    © Kakao Corp.