GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — LeetCode/Union_Find/1202.Smallest-String-With-Swaps at master · wisdompeak/LeetCode

Expand file tree

/

1202.Smallest-String-With-Swaps

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

1202.Smallest-String-With-Swaps

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
1202.Smallest-String-With-Swaps.cpp
1202.Smallest-String-With-Swaps.cpp
 
 
Readme.md
Readme.md
 
 

Readme.md

1202.Smallest-String-With-Swaps

很显然,将所有有联通关系的index都union成一个连通图,那么这些index对应的字符其实就可以任意调换顺序,想像成“冒泡法”就不难理解了。

将一个连通分量内的字符串抽取出来按照字典序重新排列,然后再依次放回这些index的位置,就是答案。

Leetcode Link

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.