1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); String str = sc.nextLine(); char[] strArray = str.toCharArray(); int height = 0; for(int i = 0; i < strArray.length;i++){ if(i == 0){ height += 10; }else if(strArray[i] == '('){ if(strArray[i-1] == '('){ height += 5; }else{ height += 10; } }else if(strArray[i] == ')'){ if(strArray[i-1] == ')'){ height += 5; }else{ height += 10; } } } System.out.println(height); } } |
Labels
Programming
(16)
Algorithm
(15)
Java
(15)
ASP .NET
(4)
Enterprise Architecture
(4)
PHP and MySQL
(4)
Software Engineering
(2)
C#
(1)
Data Mining
(1)
Deep Learning
(1)
Java Script
(1)
Python
(1)
Tuesday, September 15, 2015
Computing height as stacking bowl using parenthesis, JungOl Question 2604, (http://www.jungol.co.kr/problem.php?id=2604)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment