Given an integer, convert it to a roman numeral.
Input is guaranteed to be within the range from 1 to 3999.
Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.
Determine whether an integer is a palindrome. Do this without extra space.
def isPalindrome(self, x):
if x < 0 or (x%10 == 0 and x != 0):
r = 0
while x > r:
r = r*10 + x%10
x = x // 10
return x == r or x == r//10
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.
Given a string s, find the longest palindromic substring in s.
You may assume that the maximum length of s is 1000.
There are two sorted arrays nums1 and nums2 of size m and n respectively.
Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).