Comments (2)
가독성을 높이기 위해 쓰는 기법입니다.
예를 들어 5부터 10까지 합을 구한다고 할때,
# 1)
for n in range(5, 11):
sums += n
# 2)
for n in range(5, 10 + 1):
sums += n
1)번처럼 만 해도 충분하지만 이 경우 11만 봐서는 10을 언뜻 떠올리기가 쉽지 않습니다. 반면 2)에서는 10 + 1
로 처리하여 10까지 진행한다는 명확한 의도를 코드에 표현했습니다. 이 처럼 가독성을 높이는 기법을 책에서는 곳곳에 활용하였고, 코딩 인터뷰 시에도 이 같은 내용을 설명할 수 있다면 훨씬 더 좋은 평가를 받을 수 있겠습니다. 다만, 이런 부분을 책에 직접적으로 설명하지 않은건 제가 놓친 부분 같네요. 추후 개정판에는 설명을 보완할 수 있도록 하겠습니다.
from python-algorithm-interview.
@likejazz
아하 이해가 됐습니다. 가독성을 높이기 위한 기법이었군요.
감사합니다. ^^
from python-algorithm-interview.
Related Issues (20)
- p257 스택을 이용한 큐 구현 HOT 1
- p.161 전체 코드 질문입니다. HOT 1
- p.233 페이지 18번 홀짝 연결 리스트 문제 관련 문의 입니다. HOT 1
- 67번 문제 질문입니다(leetcode 349) HOT 2
- 13번 팰린드롬 연결리스트 문제 runtime HOT 1
- p450 힙 구현에서 _percolate_up 함수 분기 HOT 1
- p. 578 문법 질문 드립니다 HOT 1
- p.696 5번줄 오타 HOT 1
- p. 581: `77. 가장 긴 반복 문자 대체` - 좀 더 가독성이 높은 코드 질문 HOT 1
- 26번 원형 데크 디자인 문제 깃허브 코드 오타
- 57번 문제 팰린드롬 페어 HOT 1
- 60번 1번 풀이 질문드립니다! HOT 1
- p. 307: `31. 상위 K 빈도 요소` - 최적화 & 파이써닉한 코드 질문 HOT 2
- P640 오타 HOT 1
- P391페이지 6번째줄 질문드립니다 HOT 1
- 31번 상위 K 빈도 요소 HOT 1
- 60번 삽입정렬 리스트 1번 풀이 질문 HOT 1
- [49]Group Anagrams 풀이 질문 HOT 1
- 이진 힙 vs 이진 탐색 트리 HOT 1
- 612p, 615p 83. 과반수 엘리먼트 구하는 문제. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-algorithm-interview.