fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static int count = 0;
  11. public static int getPermutationsCountGreaterThanNumber(String prefix,String str,int number){
  12.  
  13. if(str.length()==0){
  14. if(Integer.parseInt(prefix) > number ){
  15. count++;
  16. }
  17. }
  18. for(int i = 0; i <str.length(); i++){
  19.  
  20. getPermutationsCountGreaterThanNumber(prefix + str.charAt(i) , str.substring(0,i) + str.substring(i+1,str.length()),number);
  21.  
  22. }
  23.  
  24. return count;
  25. }
  26. public static void main (String[] args) throws java.lang.Exception
  27. {
  28. // your code goes here
  29. String str = "132";
  30. int number = Integer.parseInt(str);
  31. int count = getPermutationsCountGreaterThanNumber("",str,number);
  32. System.out.println(count);
  33. }
  34. }
Success #stdin #stdout 0.03s 4386816KB
stdin
Standard input is empty
stdout
4