René's URL Explorer Experiment


Title: 777.在lr字符串中交换相邻字符 · Issue #7 · feikerwu/algorithm-camp · GitHub

Open Graph Title: 777.在lr字符串中交换相邻字符 · Issue #7 · feikerwu/algorithm-camp

X Title: 777.在lr字符串中交换相邻字符 · Issue #7 · feikerwu/algorithm-camp

Description: 原题地址 在一个由 'L' , 'R' 和 'X' 三个字符组成的字符串(例如"RXXLRXRXL")中进行移动操作。一次移动操作指用一个"LX"替换 一个"XL",或者用一个"XR"替换一个"RX"。现给定起始字符串start和结束字符串end,请编写代码,当且仅当存在一系列移动 操作使得start可以转换成end时, 返回True。 题解 题目只需要求从start能否通过 'XL' => 'LX', 'RX' => 'XR' 操作到end, 观察到'XL'只能替换成...

Open Graph Description: 原题地址 在一个由 'L' , 'R' 和 'X' 三个字符组成的字符串(例如"RXXLRXRXL")中进行移动操作。一次移动操作指用一个"LX"替换 一个"XL",或者用一个"XR"替换一个"RX"。现给定起始字符串start和结束字符串end,请编写代码,当且仅当存在一系列移动 操作使得start可以转换成end时, 返回True。 题解 题目只需要求从start能否通过 'XL' =>...

X Description: 原题地址 在一个由 'L' , 'R' 和 'X' 三个字符组成的字符串(例如"RXXLRXRXL")中进行移动操作。一次移动操作指用一个"LX"替换 一个"XL",或者用一个"XR"替换一个"RX"。现给定起始字符串start和结束字符串end...

Opengraph URL: https://github.com/feikerwu/algorithm-camp/issues/7

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"777.在lr字符串中交换相邻字符","articleBody":"[原题地址](https://leetcode-cn.com/problems/swap-adjacent-in-lr-string/)\r\n\r\n\u003e 在一个由 'L' , 'R' 和 'X' 三个字符组成的字符串(例如\"RXXLRXRXL\")中进行移动操作。一次移动操作指用一个\"LX\"替换 一个\"XL\",或者用一个\"XR\"替换一个\"RX\"。现给定起始字符串start和结束字符串end,请编写代码,当且仅当存在一系列移动 操作使得start可以转换成end时, 返回True。\r\n\r\n### 题解\r\n题目只需要求从start能否通过 'XL' =\u003e 'LX', 'RX' =\u003e 'XR' 操作到end, 观察到'XL'只能替换成'LX', 'RX'只能替换成'XR', 也就是'L'只能向左移动,'R'只能向右移动,且'L'和'R'不能交换。\r\n所以要判断start 能否到达end,只需要满足以下两个条件即可\r\n1. start去掉'X'后的字符串 等于 end去掉'X'后的字符串\r\n2. 如果满足1,那么对每个满足start[p1] === end[p2] 的位置\r\n   1. 如果start[p1] === 'L', 那么 p1 必须 \u003e= p2, 因为 L 只能向左移动\r\n   2. 同理,如果end[p1] === 'R', 那么 p1 必须 \u003c= p2, 因为 R 只能向右移动\r\n\r\n### 代码实现\r\n```js\r\n/**\r\n * @param {string} start\r\n * @param {string} en\r\n * @return {boolean}\r\n */\r\nvar canTransform = function(start, end) {\r\n  let startCopy = start\r\n  let endCopy = end\r\n  if (startCopy.replace(/X/g, '') !== endCopy.replace(/X/g, '')) {\r\n    console.log('here')\r\n    return false\r\n  }\r\n  let p1 = p2 = 0;\r\n  while(p1 \u003c start.length \u0026\u0026 p2 \u003c end.length) {\r\n    while(start[p1] === 'X') {\r\n      p1++\r\n    }\r\n    while(end[p2] === 'X') {\r\n      p2++\r\n    }\r\n    if (start[p1] !== end[p2]) {\r\n      return false\r\n    } else {\r\n      if ((start[p1] === 'L' \u0026\u0026 p1 \u003c p2) || (start[p1] === 'R' \u0026\u0026 p1 \u003e p2)) {\r\n        return false\r\n      }\r\n    }\r\n    p1++;\r\n    p2++;\r\n  }\r\n  return true\r\n};\r\n```","author":{"url":"https://github.com/feikerwu","@type":"Person","name":"feikerwu"},"datePublished":"2020-03-04T09:19:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/7/algorithm-camp/issues/7"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:0523837f-74a7-8c8d-81fc-a0a7ba5bc520
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBE1C:360EE8:310357F:419384E:697AED07
html-safe-nonce8dcfc9fbd11355f8f334db82e2d5e4ab7c823a3ec20df9b4f00704c9450e30db
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTFDOjM2MEVFODozMTAzNTdGOjQxOTM4NEU6Njk3QUVEMDciLCJ2aXNpdG9yX2lkIjoiMzIwMzcxMDI2OTQ2NjE2NTgzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacc8ee60687ec12173b43194c33e1daf205905b5498ab80d4ab8ab36ca7ced379f
hovercard-subject-tagissue:575248430
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/feikerwu/algorithm-camp/7/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b9556036ebb7e718d029196976ea348a0c23a72ed9dd8c316f92a3605bfe71ba/feikerwu/algorithm-camp/issues/7
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b9556036ebb7e718d029196976ea348a0c23a72ed9dd8c316f92a3605bfe71ba/feikerwu/algorithm-camp/issues/7
og:image:alt原题地址 在一个由 'L' , 'R' 和 'X' 三个字符组成的字符串(例如"RXXLRXRXL")中进行移动操作。一次移动操作指用一个"LX"替换 一个"XL",或者用一个"XR"替换一个"RX"。现给定起始字符串start和结束字符串end,请编写代码,当且仅当存在一系列移动 操作使得start可以转换成end时, 返回True。 题解 题目只需要求从start能否通过 'XL' =>...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamefeikerwu
hostnamegithub.com
expected-hostnamegithub.com
None7ce8ed0a54c4730aeca4e6abacfc6490365fc42e25480b86883054df3f9181c8
turbo-cache-controlno-preview
go-importgithub.com/feikerwu/algorithm-camp git https://github.com/feikerwu/algorithm-camp.git
octolytics-dimension-user_id39146693
octolytics-dimension-user_loginfeikerwu
octolytics-dimension-repository_id242958294
octolytics-dimension-repository_nwofeikerwu/algorithm-camp
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id242958294
octolytics-dimension-repository_network_root_nwofeikerwu/algorithm-camp
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
released7bfc78137af9a4828305e52ab993fce981d7085
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/issues/7#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffeikerwu%2Falgorithm-camp%2Fissues%2F7
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffeikerwu%2Falgorithm-camp%2Fissues%2F7
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=feikerwu%2Falgorithm-camp
Reloadhttps://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/issues/7
Reloadhttps://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/issues/7
Reloadhttps://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/issues/7
feikerwu https://patch-diff.githubusercontent.com/feikerwu
algorithm-camphttps://patch-diff.githubusercontent.com/feikerwu/algorithm-camp
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Ffeikerwu%2Falgorithm-camp
Fork 0 https://patch-diff.githubusercontent.com/login?return_to=%2Ffeikerwu%2Falgorithm-camp
Star 3 https://patch-diff.githubusercontent.com/login?return_to=%2Ffeikerwu%2Falgorithm-camp
Code https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp
Issues 11 https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/issues
Pull requests 3 https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/pulls
Actions https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/actions
Projects 0 https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/projects
Security 0 https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/security
Insights https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/pulse
Code https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp
Issues https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/issues
Pull requests https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/pulls
Actions https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/actions
Projects https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/projects
Security https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/security
Insights https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/feikerwu/algorithm-camp/issues/7
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/feikerwu/algorithm-camp/issues/7
777.在lr字符串中交换相邻字符https://patch-diff.githubusercontent.com/feikerwu/algorithm-camp/issues/7#top
leetcodehttps://github.com/feikerwu/algorithm-camp/issues?q=state%3Aopen%20label%3A%22leetcode%22
智力题https://github.com/feikerwu/algorithm-camp/issues?q=state%3Aopen%20label%3A%22%E6%99%BA%E5%8A%9B%E9%A2%98%22
https://github.com/feikerwu
https://github.com/feikerwu
feikerwuhttps://github.com/feikerwu
on Mar 4, 2020https://github.com/feikerwu/algorithm-camp/issues/7#issue-575248430
原题地址https://leetcode-cn.com/problems/swap-adjacent-in-lr-string/
leetcodehttps://github.com/feikerwu/algorithm-camp/issues?q=state%3Aopen%20label%3A%22leetcode%22
智力题https://github.com/feikerwu/algorithm-camp/issues?q=state%3Aopen%20label%3A%22%E6%99%BA%E5%8A%9B%E9%A2%98%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.