一、题目描述 Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 题目解读:将罗马数字转化为对应的整数
I II III IV V VI VII VIII IX X
1 2 3 4 5 6 7 8 9 10
I 1
V 5
X 10
L 50
C 100 …
一、题目描述 Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes v and w as the lowest node in T t…
一、题目描述 Write a function that takes an unsigned integer and returns the number of ’1 bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11 has binary representation 00000000000000000000000000001011, so the function shou…
一、题目描述 Given an integer, write a function to determine if it is a power of three. Follow up: Could you do it without using any loop / recursion? 题目解读:写一个函数判断一个整数是否是3的幂数 进一步尝试不用任何循环/递归 思路:一开…