Problem Statement
Kerim Javati is one of the most careless coders in his university. He never knows what to type, and he relies on his friends to tell him when he's wrong. Here is how he types a letter of a command into the computer:
- He types the letter 'a' and looks at his friend. If that is the right letter, the friend nods and Kerim moves on to typing the next letter.
- If the friend shook his head, meaning that 'a' was not the correct letter, Kerim presses backspace to erase the 'a' and he types 'b' instead. Then, he looks at his friend again.
- If 'b' wasn't correct either, he will press backspace to erase it and type 'c'. And so on, through the whole alphabet.
You are given the
Definition
- Class:
- KerimJavati
- Method:
- howLong
- Parameters:
- String
- Returns:
- int
- Method signature:
- int howLong(String text)
- (be sure your method is public)
Constraints
- Length of text will be between 1 and 50, inclusive.
- text will consist of lowercase English letters only ('a'-'z').
Examples
"aaa"
Returns: 3
Kerim will simply press the letter 'a' three times and he will be done.
"d"
Returns: 7
Kerim will make the following sequence of keystrokes: 'a', backspace, 'b', backspace, 'c', backspace, 'd'. The total number of keystrokes is 7.
"bad"
Returns: 11
"topcoder"
Returns: 184
"qwertyuiopasdfghjklzxcvbnm"
Returns: 676
"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
Returns: 2550
"dshyreyreqyrewqtewreuy"
Returns: 676
"cnroskiqmmtbznvadaizpxr"
Returns: 607
"k"
Returns: 21
"nhhqqlohbrlwwltkrsyghzxbekdlsmqriduhw"
Returns: 989
"gpxdyntlvjyzhzrilrsbpj"
Returns: 664
"ymixqzhtdugmpitreoafruzycciqtrpzznlyb"
Returns: 1079
"iutqvpwuzkashglnwffpgedexzslqmdioaudncl"
Returns: 987
"ib"
Returns: 20
"fxqpgzyzp"
Returns: 317
"ossawcferkubthwbmdacjbrjhtxrersyit"
Returns: 812
"cspkrbdnnljsyptecqdouzoanzsqyczzjzwpq"
Returns: 1079
"yhlzkfoa"
Returns: 200
"dvooiurvwwargvjbyirpmcxzdqwstprxzlsjny"
Returns: 1188
"gxucdqzjmkrldctxnlblsbmuziigjgovjoyokvbespaa"
Returns: 1074
"oqotijdjdfnkpnhqsqikratvmtsw"
Returns: 736
"wtotrfvwmbftftcpnbhoftmatexcrmampxoulxd"
Returns: 1011
"mdcznnrdtfvppotcmqqknxgkmcewpkuud"
Returns: 857
"pzclamtcthqugqiwy"
Returns: 465
"qtdrbjxfpwhmtpasmthu"
Returns: 538
"lzzdkcfsdhfceqfxfccesmldnjruhvlycukd"
Returns: 792
"gzr"
Returns: 99
"kckywvnqr"
Returns: 279
"yyvlzqqnuonvnxpagkbtndoysddknxbkzyfvn"
Returns: 1093
"xqpwqdhguarpkevfyjcbxtjbutvailg"
Returns: 777
"gllegotbzxjtvjndnnlypibxsxwphimbamgy"
Returns: 936
"lqclxtukoccpicfghnpzgjadtsa"
Returns: 589
"rgrlpgkmbvusnkzzr"
Returns: 505
"adajzbtgqtabrsbmyogcivu"
Returns: 507
"qlbcjtwjbtoonxxkxcinldwmmf"
Returns: 660
"aasvszgerhcannnwnsx"
Returns: 485
"eyxxxmruo"
Returns: 329
"uuecbshxsecaedqye"
Returns: 357
"jstnrxptsafzztrsuxehdejtpzupotjnyotfanzz"
Returns: 1248
"pxnklrjzjmmbtyqieomdyvdsblukvvsy"
Returns: 930
"ailftbzznp"
Returns: 254
"keiiknvdgvfthjvhowyqkeqldefshrszqykuzurgzuhblm"
Returns: 1246
"fptxxfgmzxvbpkrrcidevqxsvgitmdirldmlurhjitvwuksby"
Returns: 1367
"gjoykydesfikidjgbyituggvppcmuauysednjhny"
Returns: 970
"cguuvhrcrnjkl"
Returns: 323
"cwkogydu"
Returns: 210
"rvkysw"
Returns: 230
"zhbkjzxxvzmiysbcioqhqqpjknqhtvw"
Returns: 917
"ksugsfghybawtqtixtjgksturkqfxyklffvxpcbmow"
Returns: 1160
"jtdzuwpzuikjwgwzncitmkojfhflh"
Returns: 793
"bgwspalaujirnyqhoobc"
Returns: 456
"exmofhbmvorqdrarorpsffzyhivkgrvpqzxioikqdhyizhb"
Returns: 1259
"hwxwoxwyc"
Returns: 327
"xrxuugkudziqfilexfcfb"
Returns: 531
"qftuzrttdjbzkfcoidjgsyyptxeyehwrhtjivxozajgxanfiwp"
Returns: 1376
"oaluhmqfzfftb"
Returns: 293
"ktmujxiucjhbrp"
Returns: 358
"hajikerim"
Returns: 159
"b"
Returns: 3
"a"
Returns: 1
"jhsdjhkadakkhdyeiue"
Returns: 331