목록분류 전체보기 (959)
넘치게 채우기
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bBczff/btspXlrB4x1/ZpPbw3onrbAyukIO7gXqtK/img.png)
프로그래머라면 형식을 깔끔하게 맞춰 코드를 짜야 합니다. 코드 형식을 맞추기 위해 간단한 규칙을 정하고 그 규칙을 따라야 합니다. 필요하다면 규칙을 자동으로 적용하는 도구를 활용할 수 있습니다. 형식을 맞추는 목적 오늘 구현한 기능이 다음 버전에서 바뀔 확률은 매우 큽니다. 오늘 구현한 코드의 가독성은 앞으로 바뀔 코드의 품질에 지대한 영향을 미칩니다. 오랜 시간이 지나 원래 코드의 흔적을 찾기 어려울 정도로 코드가 바뀌어도 맨 처음 잡아놓은 구현 스타일과 가독성은 앞으로의 유지보수에 영향을 끼칩니다. 적절한 행 길이를 유지하라 자바에서 파일 크기는 클래스 크기와 밀접합니다. 위 사진은 각각 JUnit, FitNesse, testNG, TAM, JDepend, Ant, Tomcat 프로젝트를 조사한 결과..
https://leetcode.com/problems/reverse-words-in-a-string/description/?envType=study-plan-v2&envId=top-interview-150 Reverse Words in a String - LeetCode Can you solve this real interview question? Reverse Words in a String - Given an input string s, reverse the order of the words. A word is defined as a sequence of non-space characters. The words in s will be separated by at least one space. Retu..
https://leetcode.com/problems/longest-common-prefix/description/?envType=study-plan-v2&envId=top-interview-150 Longest Common Prefix - LeetCode Can you solve this real interview question? Longest Common Prefix - Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow" ..
잘 달린 주석은 무엇보다도 유용합니다. 그러나, 경솔하고 근거 없는 주석은 코드를 이해하기 어렵게 만듭니다. 오래되고 조잡한 주석은 거짓과 잘못된 정보를 퍼트립니다. 우리는 코드로 모든 의도를 표현하지 못해, 그러니 실패를 만회하기 위해 주석을 사용합니다. 주석은 언제나 실패를 의미합니다. 의도는 코드만으로 표현될수록 깨끗합니다. 코드는 변화하고 진화합니다. 일부가 여기서 저기로 옮겨지기도 하고, 조각이 나뉘고 갈라지고 합쳐지고를 반복합니다. 주석까지 함께 유지보수되는 경우는 정말 드물고, 언제나 따라가지 않습니다. 부정확한 주석은 아예 없는 주석보다 훨씬 나쁩니다. 부정확한 주석은 독자를 현혹시킵니다. 그러나 진실은 코드에 있습니다. 코드만이 자기가 하는 일을 진실되게 말합니다. 그러므로 우리는 주석을..
https://leetcode.com/problems/integer-to-roman/description/?envType=study-plan-v2&envId=top-interview-150 Integer to Roman - LeetCode Can you solve this real interview question? Integer to Roman - Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just tw leetcode.c..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/V9wuu/btspBAvoRAK/yWjanOzjl4GG7EneFhd0n1/img.png)
https://leetcode.com/problems/trapping-rain-water/description/?envType=study-plan-v2&envId=top-interview-150 Trapping Rain Water - LeetCode Can you solve this real interview question? Trapping Rain Water - Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: [https://assets.leetcode.com/upl leet..
작게 만들어라 함수를 만드는 첫 번째 규칙은 ‘작게!’ 입니다. 함수를 만드는 둘째 구칙은 ‘더 작게!’ 입니다. 함수에서의 들여쓰기 수준은 1단이나 2단을 넘어서면 읽기 매우 힘들어집니다. 한 함수에 많은 중첩 구조가 들어가지 않도록 해야합니다. 한 가지만 해라 “함수는 한 가지를 해야 한다. 그 한가지를 잘 해야 한다. 그 한가지만을 해야 한다.” 우리가 함수를 만드는 이유는 큰 개념을 다음 추상화 수준에서 여러 단계로 나눠 수행하기 위함입니다. 함수 당 추상화 수준은 하나로 함수가 확실히 ‘한 가지’ 작업만 하려면 함수 내 모든 문장의 추상화 수준이 동일해야 합니다. 한 함수 내에 추상화 수준을 섞으면 코드를 읽는 사람이 헷갈립니다. 특정 표현이 근본 개념인지 세부사항인지 구분하기가 어려워집니다. ..
https://leetcode.com/problems/candy/description/?envType=study-plan-v2&envId=top-interview-150 Candy - LeetCode Can you solve this real interview question? Candy - There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings. You are giving candies to these children subjected to the following requirements: * Each leetcode.com 문제 유형 : 그리디 문제 난이..
https://leetcode.com/problems/product-of-array-except-self/?envType=study-plan-v2&envId=top-interview-150 Product of Array Except Self - LeetCode Can you solve this real interview question? Product of Array Except Self - Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix o..
소프트웨어에서 이름은 어디나 쓰입니다. 우리는 변수, 함수, 인수, 클래스, 패키지, 파일과 폴더 등 모두 이름을 붙입니다. 이렇게 많이 쓰이는 이름을 처음에 한 번 잘지으면 앞으로의 개발이 편해집니다. 의도를 분명히 밝혀라 좋은 이름을 만드는데에는 시간이 걸릴 수 있으나, 그로인해 앞으로 절약될 시간은 더 큽니다. 개발을 하다가도, 더 나은 이름이 생각나면 모두 바꾸십시오. 변수나 함수, 클래스의 이름은 존재 이유 수행 기능 사용 방법 을 주석 없이 표현할 수 있어야 합니다. int d; // 경과 시간(단위: 날짜) 보다 int elapsedTimeInDays; int daysSinceCreation; 와 같이 의도가 드러나는 이름을 사용하면 코드 이해와 변경이 쉬워집니다. 그릇된 정보를 피하라 널리..