weijiang2009
BAN USER#step1
#store all the combinations in a dict
#step2
#check the dict to see whether some triples satisfied the condition and print them out.
NA
- weijiang2009 February 06, 2011def fun(n):
if n == 1:
return 1
if n == 2:
return 2
return fun(n-1) * n
def main():
n = 10
resultList = list(fun(10))
zeroCounter = 0
for element in resultList:
if element == "0"
zeroCounter += 1
print "answer:",zeroCounter
NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011I like the idea that "open a handler and then forget to close it."
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011def fun(String str1,String str2):
return str1.replace("str2","")
NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011def fun(arr):
dict = default(int)
for element in arr:
dict[element] +=1
for element in dict:
if dict[element] == 1:
print element
NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011def fun(String testString):
wordList = list(testString)
#print all the combinations.
get the day, month and the year.
judge the number of days existed in Feb,
and then sum up them.
YES, indeed the security keypad, I also encountered.
- weijiang2009 February 06, 2011do the for loop for the corresponding number with the letters. Put all the combinations into the list and then print the combination list.
- weijiang2009 February 06, 2011the normal expression to the postfix expression.
use the stack to help the alg run
def fun(String testString):
wordList = list(testString)
wordList.reverse()
NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011use a dict to map the missing card.
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011#pay attention to the mapping.
- weijiang2009 February 06, 2011(1)do the initilization, print once.
(2)and then judge, do nothing and exit
NA
- weijiang2009 February 06, 2011use the stack to do the operations. Will be fine
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011NA. Maybe use a stack and a queue can sovle this problem.
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011for(;0;)
printf("\n guess");
#nothing is printed because it is false.
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011minimum edit distance is the test point I think.
- weijiang2009 February 06, 2011DP is the correct one, I think.
dp[i][j] = max(dp[i-1][j],dp[i][j-1])+a[i][j];
sub optimal problems and then keep on until the final goal.
NA
- weijiang2009 February 06, 2011QuickSort or heapsort with complexity O(nlogn)
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011#python
if arr1 == arr2:
return True
elif:
return False
NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011def fun(X):
uniquePairDict = {}
for element in arr:
rest = X - element
if rest in arr:
pairString = "(" + element + "," + rest + ")"
if pairString not in uniquePairDict:
uniquePairDict[pairString] = 0
print uniquePairDict
NA
- weijiang2009 February 06, 2011NA
- weijiang2009 February 06, 2011DFS is the correct one.
Initialize all nodes with white color.
Visit a node, color it gret, continue with its connected nodes.
while doing so if u find the visiting node grey then the its cyclic.
Repemilinarula, Dev Lead at ABC TECH SUPPORT
Hi, i've been spotting for about 4 years.Teamwork: works well as a member of a team, pitches in ...
NA
- weijiang2009 February 06, 2011