Skip to content

Commit

Permalink
Compare Version Numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
lftk committed Nov 1, 2016
1 parent c14a125 commit b8bf0cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
144 | [Binary Tree Preorder Traversal][144] | 4 ms | golang
145 | [Binary Tree Postorder Traversal][145] | 4 ms | golang
151 | [Reverse Words in a String][151] | 0 ms | c
165 | [Compare Version Numbers][165] | 0 ms | golang
168 | [Excel Sheet Column Title][168] | 0 ms | golang
169 | [Majority Element][169] | 34 ms | golang
171 | [Excel Sheet Column Number][171] | 16 ms | golang
Expand Down Expand Up @@ -140,6 +141,7 @@
[144]: ./leetcode/144.binary-tree-preorder-traversal.go
[145]: ./leetcode/145.binary-tree-postorder-traversal.go
[151]: ./leetcode/151.reverse-words-in-a-string.go
[165]: ./leetcode/165.compare-version-numbers.go
[168]: ./leetcode/168.excel-sheet-column-title.go
[169]: ./leetcode/169.majority-element.go
[171]: ./leetcode/171.excel-sheet-column-number.go
Expand Down
10 changes: 10 additions & 0 deletions leetcode/165.compare-version-numbers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@ func Test_compareVersion(t *testing.T) {
if n1 != -1 {
t.Error(n1, -1)
}

n2 := compareVersion("1.0.1", "1")
if n2 != 1 {
t.Error(n2, 1)
}

n3 := compareVersion("1.1", "1.2")
if n3 != -1 {
t.Error(n3, -1)
}
}

0 comments on commit b8bf0cf

Please sign in to comment.