본문 바로가기

[JAVA] LeetCode 412 - Fizz Buzz Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. 1부터 n까지의 숫자를 문자열 표현으로 출력하는 프로그램을 작성하라. 3의 배수에 대해서는 "Fizz", 5의 배수에 대해서는 "Buzz", 3의 배수이고 또한 5의 배수인 경우 "FizzBuzz"를 출력하라. 풀이 방법 1. ..
[JAVA] LeetCode 237 - Delete Node in a Linked List Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list. 단순 연결 리스트에서 노드를 삭제하는 함수를 작성하라. 너는 리스트의 head에 대한 접근 권한 대신에 삭제할 노드에 대한 접근 권한을 가진다. 삭제할 노드가 리스트 내 tail이 아니라는 것이 보장된다. (영알못 주의) 풀이 방법 1. 삭제할 노드..
[JAVA] LeetCode 136 - Single Number Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. Follow up: Could you implement a solution with a linear runtime complexity and without using extra memory? 비어있지 않은 정수형 배열이 주어진다. 모든 요소는 한 개를 제외하고 두 번씩 나타난다. 한 개인 요소를 찾아라. Follow up : 추가 메모리를 사용하지 않고 구현해라! 풀이 방법 1. 주어진 배열을 오름차순으로 정렬한다. 2. 배열의 길이가 1이라면 첫 번째 요소를 리턴한다. (탐색할 필요가 없으므로) 3. 반복문 : ..
[JAVA] LeetCode 104 - Maximum Depth of Binary Tree Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 주어진 이진(binary) 트리의 최대 깊이를 구하여라 최대 깊이는 루트 노드부터 가장 먼 노드까지 거쳐가는 노드의 개수이다. 풀이 방법 (재귀) 1. 루트 노드부터 탐색을 시작한다. 2. 현재 노드의 왼쪽 노드와 오른쪽 노드를 탐색하여, 함수를 호출할 때마다 depth를 1 증가시켜 depth의 최대 값을 구한다. 3. 노드가 null일 경우, depth 값을 반환한다. class Solution { public int ..
[JAVA] LeetCode 344 - Reverse String Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. You may assume all the characters consist of printable ascii characters. 문자열을 반전시키는 함수를 작성해라. 입력 문자열은 char 타입의 배열로 주어진다. 다른 배열에 추가 공간을 할당하지 말고, 입력 배열을 수정하여 O(1)이 되게끔 하여라. ..
a태그 클릭 시 팝업 띄우기 클릭 시 팝업 창으로 이동합니다
[Apache POI] The maximum column width for an individual cell is 255 characters. Error. The maximum column width for an individual cell is 255 characters Apache POI를 사용하여 엑셀 파일을 만들던 중 위와 같은 오류가 발생하였다. 셀의 너비가 255자가 초과하여 발생한 오류였다. 기존 코드는 다음과 같이 작성되어 있었다. sheet.setColumnWidth(i, (sheet.getColumnWidth(i)) + 1200); 무언가.. 데이터의 길이만큼 셀의 너비를 지정하다가 최대값을 초과하여 발생한 오류 같았다. 최대값 255를 초과하지않도록, min 함수를 이용하여 다음과 같이 처리하였다. sheet.setColumnWidth(i, Math.min(255 * 256, sheet.getColumnWidth(i) + 1..
ES - ECMAScript ES(ECMAScript) Ecma 인터내셔널의 ECMA-262 기술 규격에 정의된 표준화된 스크립트 프로그래밍 언어 자바스크립트를 표준화하기 위해 만들어졌고, 자바스크립트 이외에도 액션스크립트와 J스크립트 등 다른 구현체도 포함하고 있다. (출처 - wiki ECMA 스크립트) 1996년 Netscape는 자바스크립트의 표준화를 위해 ECMA-262라는 이름의 기술 규격을 ECMA International에 제출하였고, 이렇게 ECMAScript(ES)라는 새로운 언어 표준이 만들어졌다. ECMAScript 초기 버전 이후에 언어에 대한 연구가 계속되었고, 여러 버전을 거쳐, 2009년 우리가 잘 알고있는 ES5가 등장한다. ES5는 위와 같은 브라우저에서 지원하였는데, 2015년에 출시된 ES6 버전..