import sys sys.path.append('../..') from typing import Set, Dict, Tuple, Sequence, List, Any from src.py_sol import Solution sol = Solution() example_nums = [1, 3, 5, 6] target = 5 assert (2 == sol.searchInsert(example_nums, target)) target = 7 assert (4 == sol.searchInsert(example_nums, target)) target = 2 assert (1 == sol.searchInsert(example_nums, target)) example_nums = [1, 3] target = 1 assert (0 == sol.searchInsert(example_nums, target)) example_nums = [1, 3, 5] target = 4 print("here") assert (2 == sol.searchInsert(example_nums, target)) example_nums = [ -5000, -4999, -4998, -4997, -4996, -4995, -4990, -4989, -4988, -4986, -4982, -4980, -4979, -4977, -4976, -4975, -4974, -4973, -4972, -4969, -4968, -4966, -4965, -4964, -4963, -4961, -4959, -4957, -4956, -4955, -4952, -4949, -4947, -4946, -4945, -4944, -4943, -4942, -4941, -4940, -4939, -4938, -4937, -4933, -4929, -4928, -4927, -4925, -4924, -4923, -4922, -4921, -4920, -4919, -4918, -4917, -4916, -4915, -4913, -4912, -4910, -4908, -4907, -4906, -4905, -4903, -4902, -4900, -4899, -4898, -4895, -4892, -4891, -4889, -4887, -4885, -4884, -4883, -4880, -4879, -4878, -4877, -4876, -4875, -4874, -4872, -4871, -4869, -4867, -4865, -4864, -4862, -4861, -4860, -4859, -4858, -4857, -4855, -4854, -4853,
import sys sys.path.append('../..') from typing import Set, Dict, Tuple, Sequence, List, Any from src.py_sol import Solution sol = Solution() input_str = "42" assert (42 == sol.myAtoi(input_str)) input_str = " -42" assert (-42 == sol.myAtoi(input_str)) input_str = "4193 with words" assert (4193 == sol.myAtoi(input_str)) input_str = "-91283472332" assert (-2147483648 == sol.myAtoi(input_str)) input_str = "91283472332" assert (2147483647 == sol.myAtoi(input_str)) input_str = "3.14159" assert (3 == sol.myAtoi(input_str)) input_str = "3........14159" assert (3 == sol.myAtoi(input_str)) input_str = ".1" assert (0 == sol.myAtoi(input_str)) input_str = "" assert (0 == sol.myAtoi(input_str)) input_str = "1" assert (1 == sol.myAtoi(input_str)) input_str = "+" assert (0 == sol.myAtoi(input_str)) input_str = "+1" assert (1 == sol.myAtoi(input_str)) input_str = "00000000000000000123456"
import sys sys.path.append('../..') from typing import Set, Dict, Tuple, Sequence, List, Any from src.py_sol import Solution sol = Solution() input_var = "III" assert (sol.romanToInt(input_var)) print("All pass")
import sys sys.path.append('../..') from typing import Set, Dict, Tuple, Sequence, List, Any from src.py_sol import Solution import time sol = Solution() arr = [3, 2, 2, 3] val = 3 assert (2 == sol.removeElement(arr, val)) arr = [0, 1, 2, 2, 3, 0, 4, 2] val = 2 assert (5 == sol.removeElement(arr, val)) print("All pass")
import sys sys.path.append('../..') from typing import Set, Dict, Tuple, Sequence, List, Any from src.py_sol import Solution sol = Solution() x = 123 assert (321 == sol.reverse(x)) x = -120 assert (-21 == sol.reverse(x)) print("All Pass")
import sys sys.path.append('../..') from typing import Set, Dict, Tuple, Sequence, List, Any from src.py_sol import Solution class ListNode: def __init__(self, x): self.val = x self.next = None sol = Solution() a = ListNode(1) b = ListNode(9) b.next = ListNode(9) ans = ListNode(0) ans.next = ListNode(0) ans.next.next = ListNode(1) x = sol.addTwoNumbers(a, b) assert(x.val == 0) assert(x.next.val == 0) assert(x.next.next.val == 1) assert(not x.next.next.next) a = ListNode(8) a.next = ListNode(9) a.next.next = ListNode(9) b = ListNode(2) ans = ListNode(0) ans.next = ListNode(0) ans.next.next = ListNode(0)
import sys sys.path.append('../..') from typing import Set, Dict, Tuple, Sequence, List, Any from src.py_sol import Solution sol = Solution() heights = [1, 8, 6, 2, 5, 4, 8, 3, 7] assert (49 == sol.maxArea(heights)) heights = [1, 1] assert (1 == sol.maxArea(heights)) heights = [1, 2, 1] assert (2 == sol.maxArea(heights)) heights = [2, 1] assert (1 == sol.maxArea(heights)) heights = [1, 2] assert (1 == sol.maxArea(heights)) print("All Pass")
import sys sys.path.append('../..') from typing import Set, Dict, Tuple, Sequence, List, Any from src.py_sol import Solution sol = Solution() input_var = [1,1,2] assert( 2 == sol.removeDuplicates(input_var) ) input_var = [0,0,1,1,1,2,2,3,3,4] assert( 5 == sol.removeDuplicates(input_var) ) input_var = [0,0] assert( 1 == sol.removeDuplicates(input_var) ) print("All pass")
import sys sys.path.append('../..') from typing import Set, Dict, Tuple, Sequence, List, Any from src.py_sol import Solution sol = Solution() a = 2 b = 2 assert (4 == sol.myPow(a, b)) print("All Pass")
import sys sys.path.append('../..') from typing import Set, Dict, Tuple, Sequence, List, Any from src.py_sol import Solution sol = Solution() input_var = 121 assert (sol.isPalindrome(input_var)) input_var = -121 assert (not sol.isPalindrome(input_var)) input_var = 10 assert (not sol.isPalindrome(input_var)) print("All pass")