zoukankan      html  css  js  c++  java
  • 258. 各位相加

    258. 各位相加

    258. 各位相加

    Table of Contents

    2 代码

    class Solution {
    
        /**
         * @param Integer $num
         * @return Integer
         */
        function addDigits($num) {
            $sum = $num;
            while ($num >= 10) {
                $sum = 0;
                while ($num > 0) {
                    $sum += ($num % 10);
                    $num = floor($num / 10);
                }
                $num = $sum;
            }
    
            return $sum;
        }
    }
    

    3 思路

    • 我还是个做个普通人吧,O(1) 复杂度的那个知道有这么个事儿就行

    ===

    作者: 吴丹阳 https://www.cnblogs.com/wudanyang

    更新时间: 2020-09-09 三 13:20

    Emacs 28.0.50 (Org mode 9.3.8)

    ===

    天行健,君子以自强不息。

    地势坤,君子以厚德载物。

    ===

  • 相关阅读:
    Should I expose synchronous wrappers for asynchronous methods?
    .NET Memory Allocation Profiling with Visual Studio 2012
    Should I expose asynchronous wrappers for synchronous methods?
    Patterns for Asynchronous MVVM Applications: Commands
    WPF/SL: lazy loading TreeView
    Reusable async validation for WPF with Prism 5
    Entity Framework Code First
    ConsoleHelper 类
    [Forward]Sweeping the IDisposable minefield
    Enums and Lookup Tables with EF Code First
  • 原文地址:https://www.cnblogs.com/wudanyang/p/13598650.html
Copyright © 2011-2022 走看看