New KeyBoard (Hack The Interview V : Asia-Pacific)
Contest Link import java.util.*; class Solution{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String s = sc.next(); StringBuilder res = new StringBuilder(""); boolean isPressed = false; int count = 0; boolean cursorStart = false; ArrayList<Character> c = new ArrayList<>(); for(int i=0;i<10;i++){ c.add((char)i); } for(int i=0;i<s.length();i++){ if(s.charAt(i)=='<'){ res = res.reverse(); cursorStart = true; continue; } else if(s.charAt(i)=='>'){ if(cursorStart == true){ res = res.reverse(); cursorStart = false; } continue; } else if(s.charAt(i)=='*'){ res.delete(res.length()-1, res.length()); ...
Comments
Post a Comment