Skip to content

[String] Add Solution to Buddy Strings - #262

Open
zhyizhou wants to merge 9 commits into
soapyigu:masterfrom
zhyizhou:master
Open

[String] Add Solution to Buddy Strings#262
zhyizhou wants to merge 9 commits into
soapyigu:masterfrom
zhyizhou:master

Conversation

@zhyizhou

Copy link
Copy Markdown

No description provided.

@soapyigu soapyigu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi thanks for the contribution! Could you also update the Progress session in README file?

Comment thread String/BuddyStrings Outdated
Comment thread String/BuddyStrings Outdated
Comment thread String/BuddyStrings Outdated
Comment thread String/BuddyStrings Outdated
Comment thread README.md Outdated
@zhyizhou

zhyizhou commented Oct 6, 2019

Copy link
Copy Markdown
Author

Hi soapyigu, thanks for your reply. All resolved as requested, please review again. Thanks.

Comment thread String/BuddyStrings
* Memory Usage: 23.3 MB, less than 100.00% of Swift online submissions for Buddy Strings.
*/

class BuddyStrings {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably you don't want the whitespace before class.

Comment thread String/BuddyStrings
@@ -0,0 +1,38 @@
/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's strange that this file doesn't have a .swift file extension. However, you included .swift in the README. I believe that the link is broken.

Comment thread String/BuddyStrings
/**
* Question Link: https://leetcode.com/problems/buddy-strings/
* Primary idea:
1. return false/tru for absolute cases

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, there is a typo: return false/true.

Comment thread String/BuddyStrings
if aLength != bLength || aLength == 0 {
return false
}
if A == B && Array(Set(A)).count != aLength {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to convert the Set to Array to get the count, right?

Comment thread String/BuddyStrings
}
let aArray = Array(A), bArray = Array(B)
var diff = [Character]()
for index in 0...aLength-1 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say, a better practice in Swift would be:

for index in 0..<aLength

@soapyigu

Copy link
Copy Markdown
Owner

Could you please resolve the merge conflict?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants