To the Top
File:  root - text - article - 2020 - 02 - plus-one.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1133 Views, 20377 Search Bots | 90 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by LinkedIn:

Given a non-empty array where each element represents a digit of a non-negative integer, add one to the integer. The most significant digit is at the front of the array and each element in the array contains only one digit. Furthermore, the integer does not have leading zeros, except in the case of the number '0'.

Example:
Input: [2,3,4]
Output: [2,3,5]

class Solution():
def plusOne(self, digits):
# Fill this in.

num = [2, 9, 9]
print(Solution().plusOne(num))
# [3, 0, 0]
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 1133 Views, 20377 Search Bots | 90 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Given two arrays, write a function to compute their intersection.
  2. Skip the readings, focus on problems. And use all the hints!
  3. First and Last Indices of an Element in a Sorted Array
  4. Find Pythagorean Triplets
  5. Algorithm Interview: Convert Roman Numerals to Decimal
  6. [Daily Problem] Remove Consecutive Nodes that Sum to 0
  7. Daily Interview Problem: Find the k-th Largest Element in a List
  8. [Daily Problem] Longest Palindromic Substring
  9. Algorithm Interview: Make the Largest Number
  10. Algorithm Interview Question: H-Index

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />