Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8958751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:17:12+00:00 2026-06-15T15:17:12+00:00

In my recent interview, the interviewer asked me to write a Java program to

  • 0

In my recent interview, the interviewer asked me to
write a Java program to find the least number whose square is of form 1_2_3_4_5_6_7_8_9_0. Where "_" could be any 1 digit number.
And I’d stuck in that.

Can anybody help me with the logic to be implemented?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:17:13+00:00Added an answer on June 15, 2026 at 3:17 pm

    Well, the minimum number of that format is 1020304050607080900 which has square root 1010101010.10.... And the maximum number of that format is 1929394959697989990 which has square root approx. 1389026623.11.

    Start at the lower bound, and iterate through to the upper bound. You use regex or even rudimentary string character matching, just check that the first char is 1, the 3rd char is 2, etc.

    Also, I think a long would be sufficient for this.

    EDIT:

    I just ran this on my machine, it took around 2 minutes. I suck at regex so I did it primitive style.

    public static void main(String[] args) {
        for (long l = 1010101010; l < 1389026623; l++) {
            long squared = l * l;
            String s = Long.toString(squared);
            if (s.charAt(0) != '1') continue;
            if (s.charAt(2) != '2') continue;
            if (s.charAt(4) != '3') continue;
            if (s.charAt(6) != '4') continue;
            if (s.charAt(8) != '5') continue;
            if (s.charAt(10) != '6') continue;
            if (s.charAt(12) != '7') continue;
            if (s.charAt(14) != '8') continue;
            if (s.charAt(16) != '9') continue;
            if (s.charAt(18) != '0') continue;
            System.out.println(s);
        }
    }
    

    The result was 1929374254627488900 (this is the squared number). Therefore, the root number is 1389019170. Also note this is the only number I found matching the pattern, not just the minimum.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a recent interview, I was asked a really strange question. The interviewer asked
In a recent interview I was asked which database does java support by default
In a recent interview I was asked: Find the middle element of a sorted
In a recent interview I was asked below question. Given a set of nodes
In a recent interview, I was asked to implement a thread safe generic (i.e.template
In a recent interview I was asked what the difference between .Any() and .Length
In a recent interview one peculiar question has been asked a[]= { 1,2,3,4,5,6,7,8,9,10} When
This was a question I was asked at my recent interview and I want
EDIT: Recent happenings of me compiling a program I know could not compile lead
At a recent job interview, I was asked to implement my own string copy

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.