diwu / leetcode-solutions-in-swift Goto Github PK
View Code? Open in Web Editor NEWLeetCode Solutions in Swift 5
License: MIT License
LeetCode Solutions in Swift 5
License: MIT License
What's the sense of initiating a extra Int inputX
?
https://github.com/diwu/LeetCode-Solutions-in-Swift/blob/master/Solutions/Solutions/Easy/Easy_009_Palindrome_Number.swift#L29
I think return palindromeX == x
just works.
The implementation of brute force will fail on haystakc: "mississippi" needle: "issispi"
Missing reset j = 0 on haystack[i+j] != needle[j]
ni niubi
In case you ignored the requirements:
The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value.
Thus, atoi("123-")
must be 123. But with your solution, the output is -123.
I think this is the proper answer:
https://github.com/haoel/leetcode/blob/master/algorithms/stringToIntegerAtoi/stringToIntegerAtoi.cpp#L51-L57
My translation in Swift:
https://github.com/lexrus/LeetCode.swift/blob/master/StringToIntegerAtoi/StringToIntegerAtoi.swift
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.