Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
minbros
coding-test-practice
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
coding-test-practice
/
summaryb.txt
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
22 lines (18 loc) · 1.4 KB
main
Breadcrumbs
coding-test-practice
/
summaryb.txt
Copy path
Top
File metadata and controls
Code
Blame
22 lines (18 loc) · 1.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
List와 다르게 Dictionary에서의 요소 검색에 걸리는 시간 복잡도는 O(1)이다.
List는 순차적으로 요소를 확인하기 때문에 O(n)이지만
Dictionary는 해시 테이블을 이용해 O(1)의 시간 복잡도만 소요된다.
collections.Counter 객체를 이용하면 List 안에 존재하는 요소가 몇 개씩 존재하는지
Dictionary 형태로 반환해준다.
예를 들어서, Counter([1, 2, 1, 1])은 {1: 3, 2: 1}로 반환된다.
Set은 중복된 요소들을 제거하고, 중복되지 않는 요소들을 한 개 씩만 남긴다.
예를 들어서, set([1, 2, 1, 1])은 {1, 2}로 반환된다.
Set도 Dictionary와 마찬가지로 요소 검색에 걸리는 시간 복잡도는 O(1)이다.
2차원 이상의 배열을 정렬할 때, 안쪽 배열의 두 번째 값을 기준으로 정렬하고 싶으면
list = [(500, 4), (1000, 2), (100, 3)]과 같은 배열이 있을 때,
sorted 함수의 key에 lambda 함수를 사용해
sorted(list, key=lambda x: x[1]) == [(1000, 2), (100, 3), (500, 4)]와 같이 정렬된다.
(list의 요소에서 1번 인덱스 값을 추출해 정렬한다는 의미)
map 함수는 List와 같이 반복 가능한 객체를
map(적용할 함수, 반복 가능한 객체) 형식으로 인자로 받아서
각각의 요소들에 함수를 적용한다.
예를 들어서 list(map(lambda x: x + 2, [1, 2, 3, 4, 5])) == [3, 4, 5, 6, 7]이다.
You can’t perform that action at this time.