例如,要添加123和912,我们添加3 + 2,然后是2 + 1,然后是1 + 9。每当我们的加法结果超过10时,我们将1带入下一列。结果是1035。 class Solution(object): def addToArrayForm(self, A, K): A[-1] += K for i in xrange(len(A) - 1, -1, -1): carry, A[i] = divmod(A[i], 10) if i: A[i-1] += carry if carry: A = ...
leetcode 989. 数组形式的整数加法(Add to Array-Form of Integer) 目录 题目描述: 示例1: 示例2: 示例3: 示例4: 解法: 题目描述: 对于非负整数 X 而言,X 的数组形式是每位数字按从左到右的顺序形成的数组。例如,如果 X = 1231,那么其数组形式为 [1,2,3,1]。 给定非负整数 X 的数组形式 A,返回...
For a non-negative integerX, thearray-form ofXis an array of its digits in left to right order. For example, ifX = 1231, then the array form is[1,2,3,1]. Given the array-formAof a non-negative integerX, return the array-form of the integerX+K. Example 1: Input:A=[1,2,0,...
989. Add to Array-Form of Integer 参考 1. Leetcode_easy_989. Add to Array-Form of Integer; 完
The array-form of an integer num is an array representing its digits in left to right order. For example, for num = 1321, the array form is [1,3,2,1]. Given num, the array-form of an integer, and an integer k, return the array-form of the integer num + k. Example 1: Input...
CodeTestcase Test Result Test Result 258. Add Digits Easy Topics Companies Hint Given an integer num, repeatedly add all its digits until the result has only one digit, and return it.Example 1:Input: num = 38 Output: 2 Explanation:...
1. Run `vllm_inference.py` to get generation results. ```bash cd Evaluation/LeetCode # Set the model or path here MODEL="deepseek-coder-7b-instruct" python vllm_inference.py --model_name_or_path $MODEL --saved_path output/20240121-Jul.deepseek-coder-7b-instruct.jsonl ``` If you ...
上周日就想写vue.nextTick的源码分析,可是总是不知道从哪儿下手,今天有时间,先把leetcode第二题补了,感觉这道题还挺简单的 一、题目 两数相加: 给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。如果,我们将这两个数相加...
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1: Input: "2-1-1" Output: [0, 2]
Evaluation/LeetCode/data/20240121-Jul.jsonl +180 Load DiffLarge diffs are not rendered by default. Evaluation/LeetCode/evaluate_leetcode.py +86 Original file line numberDiff line numberDiff line change @@ -0,0 +1,86 @@ 1 + import re 2 + import json 3 + from pathlib imp...