Created
January 27, 2015 07:03
-
-
Save xynophon/0e00df420d34af154b61 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| /** | |
| * Created by xynophon on 15.1.27. | |
| */ | |
| public class Unique_Binary_Search_Trees { | |
| public int solution(int n){ | |
| int dbnum = 2*n; | |
| long result = 1; | |
| int cnt = 0; | |
| while(dbnum > 0){ | |
| cnt++; | |
| if(cnt < n) | |
| result *= dbnum--; | |
| else if (cnt == n) | |
| dbnum--; | |
| else | |
| result /= dbnum--; | |
| } | |
| return (int)result; | |
| } | |
| public static void main(String args[]){ | |
| Unique_Binary_Search_Trees ubst = new Unique_Binary_Search_Trees(); | |
| Scanner sc = new Scanner(System.in); | |
| int n = sc.nextInt(); | |
| System.out.println(ubst.solution(n)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment