Update appNew update is available. Click here to update.
About
Padmabhushan Vasantraodada Patil Institute of Technology, Sangli 2026
Java - Default language
My Stats
EXP gained
yellow-spark
17062
Level
7 (Expert)
Community stats
Discussions
0
Upvotes
0
Know more
Weekend contest rating
Contest attended
Problems solved
2021 2023
Better than %
Weekend contest rating
Contest attended
Problems solved
2021 2023
Better than %
187
Total problems solved
168
Easy
19
Moderate
0
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

8 days

Longest streak:

8 days

Less

More

Achievements
1
Ronin
Topics
Arrays
Discussions
Wrong test cases
Interview problems

/*  I code  if perfectly all test  cases are right but when i submit it was wrong . WHY can anyone explain me? */

import java.util.*;

import java.io.*;

 

public class Solution {

 

    public static String numToWord(int a) {

        String[] unit = { "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven","twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };

        String[] tense = { "", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };

 

        if (a < 20) {

            return unit[a];

        }

        if (a < 100) {

            return tense[a / 10] + (a / 10 != 0 ? " " : "") + unit[a % 10];

        }

        if (a < 1000) {// 151

 

            return numToWord(a / 100) + " hundred" + (a % 100 != 0 ? " and " : "") + numToWord(a % 100);

        }

    

        if (a < 100000) {// 12345

            

            return numToWord(a / 1000) + " thousand " +numToWord((a/100)%10)+ ((a / 100) % 10 == 0 ? " " : " hundred ") + (a % 100 == 0 ? "" : "and ") + numToWord(a % 100)

                    + " ";

        }

 

        if (a < 10000000) {// 555093

            if (a % 100000 == 0) {

                return tense[a / 100000] + " lakh ";

            }

            return numToWord(a / 100000) + " lakh " + numToWord((a / 1000) % 100) + " thousand "+numToWord((a/100)%10) +((a / 100) % 10 == 0 ? "" : " hundred ") + (a % 100 == 0 ? "" : "and ") + numToWord(a % 100) + "";

        }

        

        if (a < 100000000) {

            if (a % 100000 == 0) {

                return tense[a / 100000] + " lakh ";

            }

            return numToWord(a/10000000)+" crore "+numToWord((a / 100000)%100) + " lakh " + numToWord((a / 1000) % 100) + " thousand "+numToWord((a/100)%10) +((a / 100) % 10 == 0 ? "" : " hundred ") + (a % 100 == 0 ? "" : "and ") + numToWord(a % 100) + "";

        }

        

 

        return null;

 

    }

 

    public static String handleAll(long n) {

 

        int num = (int) n;

        

        return numToWord(num);

 

        

 

    }

}

profile
Niranjan Kulkarni
Published On 16-Nov-2023
27 views
2 replies
0 upvotes
Wrong test cases
Interview problems

/*  I code  if perfectly all test  cases are right but when i submit it was wrong . WHY can anyone explain me? */

import java.util.*;

import java.io.*;

 

public class Solution {

 

    public static String numToWord(int a) {

        String[] unit = { "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven","twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };

        String[] tense = { "", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };

 

        if (a < 20) {

            return unit[a];

        }

        if (a < 100) {

            return tense[a / 10] + (a / 10 != 0 ? " " : "") + unit[a % 10];

        }

        if (a < 1000) {// 151

 

            return numToWord(a / 100) + " hundred" + (a % 100 != 0 ? " and " : "") + numToWord(a % 100);

        }

    

        if (a < 100000) {// 12345

            

            return numToWord(a / 1000) + " thousand " +numToWord((a/100)%10)+ ((a / 100) % 10 == 0 ? " " : " hundred ") + (a % 100 == 0 ? "" : "and ") + numToWord(a % 100)

                    + " ";

        }

 

        if (a < 10000000) {// 555093

            if (a % 100000 == 0) {

                return tense[a / 100000] + " lakh ";

            }

            return numToWord(a / 100000) + " lakh " + numToWord((a / 1000) % 100) + " thousand "+numToWord((a/100)%10) +((a / 100) % 10 == 0 ? "" : " hundred ") + (a % 100 == 0 ? "" : "and ") + numToWord(a % 100) + "";

        }

        

        if (a < 100000000) {

            if (a % 100000 == 0) {

                return tense[a / 100000] + " lakh ";

            }

            return numToWord(a/10000000)+" crore "+numToWord((a / 100000)%100) + " lakh " + numToWord((a / 1000) % 100) + " thousand "+numToWord((a/100)%10) +((a / 100) % 10 == 0 ? "" : " hundred ") + (a % 100 == 0 ? "" : "and ") + numToWord(a % 100) + "";

        }

        

 

        return null;

 

    }

 

    public static String handleAll(long n) {

 

        int num = (int) n;

        

        return numToWord(num);

 

        

 

    }

}

profile
Niranjan Kulkarni
Published On 16-Nov-2023
27 views
2 replies
0 upvotes