- Notifications
You must be signed in to change notification settings - Fork2
Added tests 236-394#67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletionssrc/main/python/g0001_0100/s0006_zigzag_conversion/Solution0006_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import unittest | ||
from Solution0006 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_convert(self): | ||
self.assertEqual(Solution().convert("PAYPALISHIRING", 3), "PAHNAPLSIIGYIR") | ||
def test_convert2(self): | ||
self.assertEqual(Solution().convert("PAYPALISHIRING", 4), "PINALSIGYAHRPI") |
6 changes: 6 additions & 0 deletionssrc/main/python/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/Solution0236.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions...main/python/g0201_0300/s0236_lowest_common_ancestor_of_a_binary_tree/Solution0236_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import unittest | ||
from Solution0236 import Solution, TreeNode | ||
class SolutionTest(unittest.TestCase): | ||
def test_lowestCommonAncestor(self): | ||
leftNodeLeftNode = TreeNode(6) | ||
leftNodeRightNode = TreeNode(2, TreeNode(7), TreeNode(4)) | ||
leftNode = TreeNode(5, leftNodeLeftNode, leftNodeRightNode) | ||
rightNode = TreeNode(1, TreeNode(0), TreeNode(8)) | ||
root = TreeNode(3, leftNode, rightNode) | ||
self.assertEqual( | ||
Solution().lowestCommonAncestor(root, TreeNode(5), TreeNode(1)).val, | ||
3 | ||
) | ||
def test_lowestCommonAncestor2(self): | ||
leftNodeLeftNode = TreeNode(6) | ||
leftNodeRightNode = TreeNode(2, TreeNode(7), TreeNode(4)) | ||
leftNode = TreeNode(5, leftNodeLeftNode, leftNodeRightNode) | ||
rightNode = TreeNode(1, TreeNode(0), TreeNode(8)) | ||
root = TreeNode(3, leftNode, rightNode) | ||
self.assertEqual( | ||
Solution().lowestCommonAncestor(root, TreeNode(5), TreeNode(4)).val, | ||
5 | ||
) | ||
def test_lowestCommonAncestor3(self): | ||
root = TreeNode(2, TreeNode(1), None) | ||
self.assertEqual( | ||
Solution().lowestCommonAncestor(root, TreeNode(2), TreeNode(1)).val, | ||
2 | ||
) |
2 changes: 2 additions & 0 deletionssrc/main/python/g0201_0300/s0238_product_of_array_except_self/Solution0238.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletionssrc/main/python/g0201_0300/s0238_product_of_array_except_self/Solution0238_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unittest | ||
from Solution0238 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_productExceptSelf(self): | ||
self.assertEqual( | ||
Solution().productExceptSelf([1, 2, 3, 4]), | ||
[24, 12, 8, 6] | ||
) | ||
def test_productExceptSelf2(self): | ||
self.assertEqual( | ||
Solution().productExceptSelf([-1, 1, 0, -3, 3]), | ||
[0, 0, 9, 0, 0] | ||
) |
3 changes: 3 additions & 0 deletionssrc/main/python/g0201_0300/s0239_sliding_window_maximum/Solution0239.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletionssrc/main/python/g0201_0300/s0239_sliding_window_maximum/Solution0239_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unittest | ||
from Solution0239 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_maxSlidingWindow(self): | ||
self.assertEqual( | ||
Solution().maxSlidingWindow([1, 3, -1, -3, 5, 3, 6, 7], 3), | ||
[3, 3, 5, 5, 6, 7] | ||
) | ||
def test_maxSlidingWindow2(self): | ||
self.assertEqual( | ||
Solution().maxSlidingWindow([1], 1), | ||
[1] | ||
) |
2 changes: 2 additions & 0 deletionssrc/main/python/g0201_0300/s0240_search_a_2d_matrix_ii/Solution0240.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletionssrc/main/python/g0201_0300/s0240_search_a_2d_matrix_ii/Solution0240_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import unittest | ||
from Solution0240 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_searchMatrix(self): | ||
matrix = [ | ||
[1, 4, 7, 11, 15], | ||
[2, 5, 8, 12, 19], | ||
[3, 6, 9, 16, 22], | ||
[10, 13, 14, 17, 24], | ||
[18, 21, 23, 26, 30] | ||
] | ||
self.assertEqual(Solution().searchMatrix(matrix, 5), True) | ||
def test_searchMatrix2(self): | ||
matrix = [ | ||
[1, 4, 7, 11, 15], | ||
[2, 5, 8, 12, 19], | ||
[3, 6, 9, 16, 22], | ||
[10, 13, 14, 17, 24], | ||
[18, 21, 23, 26, 30] | ||
] | ||
self.assertEqual(Solution().searchMatrix(matrix, 20), False) |
2 changes: 2 additions & 0 deletionssrc/main/python/g0201_0300/s0283_move_zeroes/Solution0283.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletionssrc/main/python/g0201_0300/s0283_move_zeroes/Solution0283_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import unittest | ||
from Solution0283 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_moveZeroes(self): | ||
array = [0, 1, 0, 3, 12] | ||
Solution().moveZeroes(array) | ||
self.assertEqual(array, [1, 3, 12, 0, 0]) | ||
def test_moveZeroes2(self): | ||
array = [0] | ||
Solution().moveZeroes(array) | ||
self.assertEqual(array, [0]) |
2 changes: 2 additions & 0 deletionssrc/main/python/g0201_0300/s0287_find_the_duplicate_number/Solution0287.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletionssrc/main/python/g0201_0300/s0287_find_the_duplicate_number/Solution0287_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unittest | ||
from Solution0287 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_findDuplicate(self): | ||
self.assertEqual(Solution().findDuplicate([1, 3, 4, 2, 2]), 2) | ||
def test_findDuplicate2(self): | ||
self.assertEqual(Solution().findDuplicate([3, 1, 3, 4, 2]), 3) | ||
def test_findDuplicate3(self): | ||
self.assertEqual(Solution().findDuplicate([1, 1]), 1) | ||
def test_findDuplicate4(self): | ||
self.assertEqual(Solution().findDuplicate([1, 1, 2]), 1) |
2 changes: 2 additions & 0 deletionssrc/main/python/g0201_0300/s0295_find_median_from_data_stream/MedianFinder.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletionssrc/main/python/g0201_0300/s0295_find_median_from_data_stream/MedianFinder_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import unittest | ||
from MedianFinder import MedianFinder | ||
class MedianFinderTest(unittest.TestCase): | ||
def test_medianFinder(self): | ||
medianFinder = MedianFinder() | ||
medianFinder.addNum(1) | ||
medianFinder.addNum(2) | ||
self.assertEqual(medianFinder.findMedian(), 1.5) | ||
medianFinder.addNum(3) | ||
self.assertEqual(medianFinder.findMedian(), 2.0) | ||
def test_medianFinder2(self): | ||
medianFinder = MedianFinder() | ||
medianFinder.addNum(1) | ||
medianFinder.addNum(3) | ||
medianFinder.addNum(-1) | ||
self.assertEqual(medianFinder.findMedian(), 1.0) |
1 change: 1 addition & 0 deletionssrc/main/python/g0201_0300/s0300_longest_increasing_subsequence/Solution0300.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletionssrc/main/python/g0201_0300/s0300_longest_increasing_subsequence/Solution0300_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import unittest | ||
from Solution0300 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_lengthOfLIS(self): | ||
self.assertEqual(Solution().lengthOfLIS([10, 9, 2, 5, 3, 7, 101, 18]), 4) | ||
def test_lengthOfLIS2(self): | ||
self.assertEqual(Solution().lengthOfLIS([0, 1, 0, 3, 2, 3]), 4) | ||
def test_lengthOfLIS3(self): | ||
self.assertEqual(Solution().lengthOfLIS([7, 7, 7, 7, 7, 7, 7]), 1) |
2 changes: 2 additions & 0 deletionssrc/main/python/g0301_0400/s0322_coin_change/Solution0322.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletionssrc/main/python/g0301_0400/s0322_coin_change/Solution0322_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import unittest | ||
from Solution0322 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_coinChange(self): | ||
self.assertEqual(Solution().coinChange([1, 2, 5], 11), 3) | ||
def test_coinChange2(self): | ||
self.assertEqual(Solution().coinChange([2], 3), -1) | ||
def test_coinChange3(self): | ||
self.assertEqual(Solution().coinChange([1], 0), 0) |
2 changes: 2 additions & 0 deletionssrc/main/python/g0301_0400/s0338_counting_bits/Solution0338.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletionssrc/main/python/g0301_0400/s0338_counting_bits/Solution0338_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import unittest | ||
from Solution0338 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_countBits(self): | ||
self.assertEqual(Solution().countBits(2), [0, 1, 1]) | ||
def test_countBits2(self): | ||
self.assertEqual(Solution().countBits(5), [0, 1, 1, 2, 1, 2]) |
1 change: 1 addition & 0 deletionssrc/main/python/g0301_0400/s0347_top_k_frequent_elements/Solution0347.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletionssrc/main/python/g0301_0400/s0347_top_k_frequent_elements/Solution0347_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unittest | ||
from Solution0347 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_topKFrequent(self): | ||
self.assertEqual( | ||
Solution().topKFrequent([1, 1, 1, 2, 2, 3], 2), | ||
[1, 2] | ||
) | ||
def test_topKFrequent2(self): | ||
self.assertEqual( | ||
Solution().topKFrequent([1], 1), | ||
[1] | ||
) |
15 changes: 15 additions & 0 deletionssrc/main/python/g0301_0400/s0394_decode_string/Solution0394_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unittest | ||
from Solution0394 import Solution | ||
class SolutionTest(unittest.TestCase): | ||
def test_decodeString(self): | ||
self.assertEqual(Solution().decodeString("3[a]2[bc]"), "aaabcbc") | ||
def test_decodeString2(self): | ||
self.assertEqual(Solution().decodeString("3[a2[c]]"), "accaccacc") | ||
def test_decodeString3(self): | ||
self.assertEqual(Solution().decodeString("2[abc]3[cd]ef"), "abcabccdcdcdef") | ||
def test_decodeString4(self): | ||
self.assertEqual(Solution().decodeString("abc3[cd]xyz"), "abccdcdcdxyz") |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.