# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 25: Reverse Nodes in k-Grouphttps://oj.leetcode.com/problems/reverse-nodes-in-k-group/ Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If th…
#1.n! def fact(n): if n == 0: return 1 else: return n*fact(n-1)print(fact(10)) #2.斐波那契数列F(n)=F(n-1)+F(n-2)def f(n): if n == 1 or n == 2: return 1 else: return f(n-1)+f(n-2) #3汉诺塔问题 count = 0def hanoi(n,src,dst,mid): global count if n == 1: print("{}:…
题目 Given a 32-bit signed integer, reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123,return -321 Example3: x = 120, return 21 思路 问题的关键在于对溢出的判断. 思路1:用long或者long long 直接用long或者long long计算,这样就保证不会溢出,再判断反转后的数字是否溢出. 思路2:stoi()…