Python Stackoverflow 经典问题
What does the “yield” keyword do?
What is a metaclass in Python?
How do I check whether a file exists using Python?
Does Python have a ternary conditional operator?
Calling an external command in Python
What does if __name__ == “__main__”: do?
How to make a chain of function decorators in继续阅读 »
题目链接: http://oj.leetcode.com/problems/two-sum/
题目内容:
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your return继续阅读 »
dynamite关卡和之前的不同,之前是要求跳转到其他地方执行,而这一关则是返回test函数继续执行.
test源码如下
void test()
{
unsigned long long val;
volatile unsigned long long local = 0xdeadbeef;
char* variable_length;
entry_check(3); /* Make sure entered this function properly */
val = getbuf();
if (val <= 40) {
variable_length = alloca(val);
继续阅读 »
231. Power of Two
Question
Given an integer, write a function to determine if it is a power of two.
Solution
Approach #1 (count the number of 1) [Accepted]
Algorithm
Integer is a power of two means only one bit of n is '1', for example, 100 is 2^2=4 while 110 is 2^2+2^1=6.继续阅读 »