DEV Community

Cover image for [Devmates.co] Subtract Two Integers Represented as Array by 🏢Google
Alex Wawl 🐼
Alex Wawl 🐼

Posted on

1 1

[Devmates.co] Subtract Two Integers Represented as Array by 🏢Google

Hello👋,
My name is Alex and I'm maker of Devmates.co. 😊

We are resolving daily coding problems which asked by top tech companies together. We share our solutions, give some help if anyone stuck, support each other and just hangout together in the internet. 🍻☕️💬

I get this problem from our members or just searching them in the internet(leetcode forums, Glassdoor, teamblind, etc.). Sometimes this problem can be very easy, sometimes too 👷‍♂️hard, everything depends on skills but we are trying to resolve all of them and Have Fun. 🙌

Today I want to share problem which was asked by 🏢Google.

Problem:

Given a non-empty array of digits representing a non-negative integer and each element in the array contain a single digit.

Subtract two integers represented as array and return result as array.

You may assume the integer does not contain any leading zero, except the number 0 itself.

Note: Converting to the integer and back to the array is not allowed.

Example:

Input: num1 = [3, 4, 5], num2 = [2,2,1]
Output: [1, 2, 4]

Input: num1 = [1, 0], num2 = [9]
Output: [1]

🙌 Don't hesitate to share your solutions directly on devmates.co

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs