[LeetCode] 1903. Largest Odd Number in String You are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string "" if no odd integer exists. A substring is a contiguous sequence of ...
construct_k_palindrome_str.py construct_lexicographically_seq.c construct_lexicographically_seq.py construct_smallest_di_str.c construct_smallest_di_str.py construct_string_binary_tree.c construct_string_binary_tree.py construct_string_repeat_lim.c construct_string_repeat_lim.py contains_duplicate.c co...
1312-minimum-insertion-steps-to-make-a-string-palindrome 1338-reduce-array-size-to-the-half 1346-check-if-n-and-its-double-exist 1351-count-negative-numbers-in-a-sorted-matrix 1385-find-the-distance-value-between-two-arrays 1405-longest-happy-string 1431-kids-with-the-greatest-number-of-...
class Solution(object): def largestPalindrome(self, n): if n==1: return 9 if n==2: return 987 for a in xrange(2, 9*10**(n-1)): hi=(10**n)-a lo=int(str(hi)[::-1]) if a**2-4*lo < 0: continue if (a**2-4*lo)**.5 == int((a**2-4*lo)**.5): return (...
Return to Answer With all due respect to solutions offered, thesolutions offered here are naive (naive in the sense of something that someone unfamiliar with computer science algorithms would think of). Themost optimal solution will most probably be implemented using a dynamic programming approach(...
0405. Convert a Number to Hexadecimal 0409. Longest Palindrome 0410. Split Array Largest Sum 0412. Fizz Buzz 0413. Arithmetic Slices 0414. Third Maximum Number 0416. Partition Equal Subset Sum 0417. Pacific Atlantic Water Flow 0419. Battleships in a Board 0421. Maximum X O R of Two Numbers...
Note: The result may be very large, so you need to return a string instead of an integer. ===Comments by Dabay=== 把所有num都存到一个hash表中,用值来记录出现的次数。 对于,num中很多重复项来说,这样的处理可以节约时间。 定义比较的方法:当两个字符串长度不一样时,把他们互相加到末尾比较。
0230-Kth-Smallest-Element-in-a-BST 0232-Implement-Queue-using-Stacks 0234-Palindrome-Linked-List 0235-Lowest-Common-Ancestor-of-a-Binary-Search-Tree 0236-Lowest-Common-Ancestor-of-a-Binary-Tree 0237-Delete-Node-in-a-Linked-List 0238-Product-of-Array-Except-Self 0239-Sliding-Window-Max...