FastPrepRemove Trailing Zeros
Problems/Remove Trailing Zeros

Remove Trailing Zeros

Autodesk logoAutodesk● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported as one of three short coding questions in the opening round of a three-round video interview loop for a full-time senior software engineer role at Autodesk, a role working in C++, which the candidate had applied to online. That round was mostly questions on C++ fundamentals, and the coding questions were named only by their task. This problem covers the trailing zeros one. The candidate passed and rated the interviews easy.

The report gives only the task's name, with no input type, function, limits or examples, so we made these choices. We read it in its usual form: the number arrives as a string of digits, and the function returns that string with the zeros at its end taken off, or unchanged if it does not end in 0. The number is positive and has no leading zeros, so it is never made of zeros only and its first digit always stays. It has 1 to 1,000 digits, the usual limits for this task. The examples are ours. The other two coding questions, the design round and the hiring manager round are not part of this problem.

Our version is about 80% the same as the reported question.

The string num holds the decimal digits of a positive integer. Remove its trailing zeros, which are the 0 digits after its last nonzero digit, and return the digits that remain, also as a string.

A 0 that has a nonzero digit somewhere to its right is not trailing, so it stays. If num does not end in 0, return it unchanged.

Function

removeTrailingZeros(num: String) → String

Examples

Example 1

num = "4070500"return = "40705"

The number ends in two zeros, and both go. The zeros between 4 and 7 and between 7 and 5 are inside the number, so they stay.

Example 2

num = "86"return = "86"

The last digit is 6, so there is nothing to remove and the number comes back as it was.

Example 3

num = "9000"return = "9"

Every digit after the 9 is a zero at the end, so only the 9 is left.

Constraints

  • 1 <= num.length <= 1000
  • num is made of the digits 0 to 9 only
  • num does not start with 0

More Autodesk interview questions

  • Non-Repeating CharacterONSITE INTERVIEW · Seen Nov 2026
  • Reverse Linked ListONSITE INTERVIEW · Seen Nov 2026
  • LRU Cache with TTLONSITE INTERVIEW · Seen Oct 2026
  • Deep Merge with a Conflict ResolverONSITE INTERVIEW · Seen Mar 2026
  • Diagonal Bounce TraversalOA · Seen Oct 2026
  • Interleave Array HalvesOA · Seen Oct 2026
  • Latest Arrival to Catch a BusOA · Seen Oct 2026
  • Find Top Two TeamsOA · Seen Sep 2026
  • In-Memory Database with TTLOA · Seen Mar 2026

Similar questions at other companies

  • Extract Hashtags from a TweeteBay · ONSITE INTERVIEWeBay interview questions
  • Container Ledger with TradesFlexport · ONSITE INTERVIEWFlexport interview questions
  • Christmas Tree with N TiersVerily · ONSITE INTERVIEW
  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Valid ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
  • Longest Spoken PrefixElevenLabs · ONSITE INTERVIEWElevenLabs interview questions
  • Palindrome Check Ignoring SymbolsWalmart · ONSITE INTERVIEWWalmart interview questions
  • Reverse a String Keeping Dashes in PlaceNykaa · ONSITE INTERVIEWNykaa interview questions
  • Implement tail -nConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions

Autodesk interview experiences

  • Autodesk SDE Intern OA and Interviews: 5 Experiences
All Autodesk interview questionsSee Autodesk hiring insights
Saved
class Solution {
    public String removeTrailingZeros(String num) {
        // Write your code here.
    }
}
Checking account…