Problem 1081. Test if two numbers have the same digits

Given two integers x1 and x2, return true if the numbers written with no leading zeros contain the same digits. That is, the string representation of one number is a permutation of the string representation of the other.

For example

    x1 = 1234;
    x2 = 4321;
    tf = same_digits(x1,x2)

would output

    tf = true


    x1 = 1234;
    x2 = 1244;
    tf = same_digits(x1,x2)

would output

    tf = false

Solution Stats

45.26% Correct | 54.74% Incorrect
Last solution submitted on Aug 23, 2019

Problem Comments

Recent Solvers147

Suggested Problems

More from this Author57