Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
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 }}
blastLittleTiger
algorithm-by-python
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
algorithm-by-python
/
joint_int.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
32 lines (20 loc) · 1.13 KB
master
Breadcrumbs
algorithm-by-python
/
joint_int.py
Copy path
Top
File metadata and controls
Code
Blame
32 lines (20 loc) · 1.13 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
23
24
25
26
27
28
29
30
#! /user/bin/env python
#coding:utf-8
"""
把一个int型数组中的数字拼成一个串,这个串代表的数字最小;
对这个问题的理解:
1、有一个元素是int类型的list;
2、将上述list中的每个元素的数字分别取出来,然后将这些数字的顺序进行从新排列,并将其中的最小整数输入,就是题目中要求的最小数字。
如果按照上述理解,在解题中,最应当小心的是数字如果很大,比如list中的某个int元素是:222222222222227777777777776666666666699999999999888888888...很大的整数,就不得不转化为字符串操作了。
所以,在本问题中,基本思路是:
1、将list中的int元素转换为str;
2、将所有数字(str类型)装入到一个list2
3、对list2进行排序
4、将list2中的数字(str类型)组装成一个数值(str类型)
"""
def joint_int(lst):
str_list = [str(i) for i in lst]
str_lonely = [str_list[i][j] for i in range(len(str_list)) for j in range(len(str_list[i]))]
sorted_str = sorted(str_lonely)
return "".join(sorted_str)
print joint_int([1230975,4087644567856])
You can’t perform that action at this time.