Example #1
0
from SolutionA import Solution
S = Solution()
nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
print(S.maxSubArray(nums))
Example #2
0
from SolutionA import Solution
S = Solution()
w = [
    "b", "br", "bre", "brea", "break", "breakf", "breakfa", "breakfas",
    "breakfast", "l", "lu", "lun", "lunc", "lunch", "d", "di", "din", "dinn",
    "dinne", "dinner"
]
print(S.longestWord(w))
Example #3
0
from SolutionA import Solution
S = Solution()
nums = [3, 2, 1]
print(S.nextPermutation(nums))
Example #4
0
from SolutionA import Solution
S = Solution()
flowerbed = [0, 0, 1, 0, 1]
n = 1
print(S.canPlaceFlowers(flowerbed, n))
Example #5
0
from SolutionA import Solution
S = Solution()
s1 = "()"
s2="){"
print(S.isValid(s2))
Example #6
0
from SolutionA import Solution
S=Solution()
print(S.toHex(0))
Example #7
0
import SolutionA
from SolutionA import Solution
num = -599
S = Solution()
print(S.isPalindrome(num))
Example #8
0
from SolutionA import Solution
S = Solution()
num = 3
print(S.intToRoman(num))

        
Example #9
0
from SolutionA import Solution
S = Solution()
s = 'AA'
print(S.titleToNumber(s))
Example #10
0
from SolutionA import Solution
S = Solution()
nums = [
    91277418, 66271374, 38763793, 4092006, 11415077, 60468277, 1122637,
    72398035, -62267800, 22082642, 60359529, -16540633, 92671879, -64462734,
    -55855043, -40899846, 88007957, -57387813, -49552230, -96789394, 18318594,
    -3246760, -44346548, -21370279, 42493875, 25185969, 83216261, -70078020,
    -53687927, -76072023, -65863359, -61708176, -29175835, 85675811, -80575807,
    -92211746, 44755622, -23368379, 23619674, -749263, -40707953, -68966953,
    72694581, -52328726, -78618474, 40958224, -2921736, -55902268, -74278762,
    63342010, 29076029, 58781716, 56045007, -67966567, -79405127, -45778231,
    -47167435, 1586413, -58822903, -51277270, 87348634, -86955956, -47418266,
    74884315, -36952674, -29067969, -98812826, -44893101, -22516153, -34522513,
    34091871, -79583480, 47562301, 6154068, 87601405, -48859327, -2183204,
    17736781, 31189878, -23814871, -35880166, 39204002, 93248899, -42067196,
    -49473145, -75235452, -61923200, 64824322, -88505198, 20903451, -80926102,
    56089387, -58094433, 37743524, -71480010, -14975982, 19473982, 47085913,
    -90793462, -33520678, 70775566, -76347995, -16091435, 94700640, 17183454,
    85735982, 90399615, -86251609, -68167910, -95327478, 90586275, -99524469,
    16999817, 27815883, -88279865, 53092631, 75125438, 44270568, -23129316,
    -846252, -59608044, 90938699, 80923976, 3534451, 6218186, 41256179,
    -9165388, -11897463, 92423776, -38991231, -6082654, 92275443, 74040861,
    77457712, -80549965, -42515693, 69918944, -95198414, 15677446, -52451179,
    -50111167, -23732840, 39520751, -90474508, -27860023, 65164540, 26582346,
    -20183515, 99018741, -2826130, -28461563, -24759460, -83828963, -1739800,
    71207113, 26434787, 52931083, -33111208, 38314304, -29429107, -5567826,
    -5149750, 9582750, 85289753, 75490866, -93202942, -85974081, 7365682,
    -42953023, 21825824, 68329208, -87994788, 3460985, 18744871, -49724457,
    -12982362, -47800372, 39958829, -95981751, -71017359, -18397211, 27941418,
    -34699076, 74174334, 96928957, 44328607, 49293516, -39034828, 5945763,
    -47046163, 10986423, 63478877, 30677010, -21202664, -86235407, 3164123,
Example #11
0
from SolutionA import Solution
S=Solution()
s = "LLLRLLLRLLGLLGGRGLLLGGLRRRRRGLRLRLRLGGRGRGRLLLLLLGLLRLGLGLRLGGGRR"
print(S.isRobotBounded(s))
Example #12
0
from SolutionA import Solution
S = Solution()
s = "0P"
print(S.isPalindrome(s))
Example #13
0
from SolutionA import Solution

S = Solution()
nums = [1, 2, 2, 3, 1, 4, 2]
print(S.findShortestSubArray(nums))
Example #14
0
from SolutionA import Solution
a = [1,2,9,9]
S = Solution()
print(S.plusOne(a))
Example #15
0
import SolutionA
from SolutionA import Solution
test = Solution()
s = 'MCMXCIV'
print(test.romanToInt(s))
Example #16
0
from SolutionA import Solution
S = Solution()
A = [-5]
K = 5
print(S.subarraysDivByK(A, K))
Example #17
0
from SolutionA import Solution
S = Solution()
n = 28
print(S.findNthDigit(n))
Example #18
0
from SolutionA import Solution
S = Solution()
l1 = [4, 1, 2]
l2 = [1, 3, 4, 2]
print(S.nextGreaterElement(l1, l2))
Example #19
0
from SolutionA import Solution

print(Solution().hammingDistance(1, 4))
Example #20
0
from SolutionA import Solution
S = Solution()
s = 'cdabababef'
p = 'cd*abef'
print(S.isMatch(s, p))
Example #21
0
from SolutionA import Solution
S = Solution()
nums = [0, 1, 1, 3, 3]
k = 4
print(S.findMaxAverage(nums, k))
Example #22
0
from SolutionA import Solution

S = Solution()
nums = [5, 4, 20, 2, 100]
print(S.findRelativeRanks(nums))
Example #23
0
from SolutionA import Solution
S = Solution()
s = "abcdefg"
print(S.reverseStr(s, 2))
Example #24
0
import SolutionA
from SolutionA import Solution
s1 = ["flower", "flow", "flight"]
s = Solution()
#s2 = ["", "b"]
s3 = ["aa", "aa"]
s4 = ["dog", "racecar", "car"]
print(s.longestCommonPrefix(s3))
print(5)
#print(s.longestCommonPrefix(s2))
Example #25
0
from SolutionA import Solution
S = Solution()
a = [[0, 1, 0, 0], [1, 1, 1, 0], [0, 1, 0, 0], [1, 1, 0, 0]]
print(S.islandPerimeter(a))
Example #26
0
from SolutionA import Solution
S = Solution()
print(S.fizzBuzz(10))
Example #27
0
from SolutionA import Solution
S = Solution()
s = "cbbcc"
print(S.validPalindrome(s))
Example #28
0
from SolutionA import Solution
import re
S = Solution()
s = "qqq     +1234    344"
#s1 = (re.match('[\s]*[\+]?[\-]?\d+', s))
#s= s1.group() if s1!=None else 0
#print(s)
print(S.myAtoi(s))
Example #29
0
from SolutionA import Solution
S = Solution()
a = [1, 2, 3, 4]
b = [1, 4]
print(S.findRadius(a, b))
Example #30
0
from SolutionA import Solution
S = Solution()
num = 5
print(bin(60), bin(~60))