Statistics

Problem Statement for "KerimJavati"

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:

  1. 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.
  2. 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.
  3. 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 String text. Determine the number of keystrokes Kerim will perform while typing this text. Both letters and backspaces count as keystrokes.

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

  1. "aaa"

    Returns: 3

    Kerim will simply press the letter 'a' three times and he will be done.

  2. "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.

  3. "bad"

    Returns: 11

  4. "topcoder"

    Returns: 184

  5. "qwertyuiopasdfghjklzxcvbnm"

    Returns: 676

  6. "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

    Returns: 2550

  7. "dshyreyreqyrewqtewreuy"

    Returns: 676

  8. "cnroskiqmmtbznvadaizpxr"

    Returns: 607

  9. "k"

    Returns: 21

  10. "nhhqqlohbrlwwltkrsyghzxbekdlsmqriduhw"

    Returns: 989

  11. "gpxdyntlvjyzhzrilrsbpj"

    Returns: 664

  12. "ymixqzhtdugmpitreoafruzycciqtrpzznlyb"

    Returns: 1079

  13. "iutqvpwuzkashglnwffpgedexzslqmdioaudncl"

    Returns: 987

  14. "ib"

    Returns: 20

  15. "fxqpgzyzp"

    Returns: 317

  16. "ossawcferkubthwbmdacjbrjhtxrersyit"

    Returns: 812

  17. "cspkrbdnnljsyptecqdouzoanzsqyczzjzwpq"

    Returns: 1079

  18. "yhlzkfoa"

    Returns: 200

  19. "dvooiurvwwargvjbyirpmcxzdqwstprxzlsjny"

    Returns: 1188

  20. "gxucdqzjmkrldctxnlblsbmuziigjgovjoyokvbespaa"

    Returns: 1074

  21. "oqotijdjdfnkpnhqsqikratvmtsw"

    Returns: 736

  22. "wtotrfvwmbftftcpnbhoftmatexcrmampxoulxd"

    Returns: 1011

  23. "mdcznnrdtfvppotcmqqknxgkmcewpkuud"

    Returns: 857

  24. "pzclamtcthqugqiwy"

    Returns: 465

  25. "qtdrbjxfpwhmtpasmthu"

    Returns: 538

  26. "lzzdkcfsdhfceqfxfccesmldnjruhvlycukd"

    Returns: 792

  27. "gzr"

    Returns: 99

  28. "kckywvnqr"

    Returns: 279

  29. "yyvlzqqnuonvnxpagkbtndoysddknxbkzyfvn"

    Returns: 1093

  30. "xqpwqdhguarpkevfyjcbxtjbutvailg"

    Returns: 777

  31. "gllegotbzxjtvjndnnlypibxsxwphimbamgy"

    Returns: 936

  32. "lqclxtukoccpicfghnpzgjadtsa"

    Returns: 589

  33. "rgrlpgkmbvusnkzzr"

    Returns: 505

  34. "adajzbtgqtabrsbmyogcivu"

    Returns: 507

  35. "qlbcjtwjbtoonxxkxcinldwmmf"

    Returns: 660

  36. "aasvszgerhcannnwnsx"

    Returns: 485

  37. "eyxxxmruo"

    Returns: 329

  38. "uuecbshxsecaedqye"

    Returns: 357

  39. "jstnrxptsafzztrsuxehdejtpzupotjnyotfanzz"

    Returns: 1248

  40. "pxnklrjzjmmbtyqieomdyvdsblukvvsy"

    Returns: 930

  41. "ailftbzznp"

    Returns: 254

  42. "keiiknvdgvfthjvhowyqkeqldefshrszqykuzurgzuhblm"

    Returns: 1246

  43. "fptxxfgmzxvbpkrrcidevqxsvgitmdirldmlurhjitvwuksby"

    Returns: 1367

  44. "gjoykydesfikidjgbyituggvppcmuauysednjhny"

    Returns: 970

  45. "cguuvhrcrnjkl"

    Returns: 323

  46. "cwkogydu"

    Returns: 210

  47. "rvkysw"

    Returns: 230

  48. "zhbkjzxxvzmiysbcioqhqqpjknqhtvw"

    Returns: 917

  49. "ksugsfghybawtqtixtjgksturkqfxyklffvxpcbmow"

    Returns: 1160

  50. "jtdzuwpzuikjwgwzncitmkojfhflh"

    Returns: 793

  51. "bgwspalaujirnyqhoobc"

    Returns: 456

  52. "exmofhbmvorqdrarorpsffzyhivkgrvpqzxioikqdhyizhb"

    Returns: 1259

  53. "hwxwoxwyc"

    Returns: 327

  54. "xrxuugkudziqfilexfcfb"

    Returns: 531

  55. "qftuzrttdjbzkfcoidjgsyyptxeyehwrhtjivxozajgxanfiwp"

    Returns: 1376

  56. "oaluhmqfzfftb"

    Returns: 293

  57. "ktmujxiucjhbrp"

    Returns: 358

  58. "hajikerim"

    Returns: 159

  59. "b"

    Returns: 3

  60. "a"

    Returns: 1

  61. "jhsdjhkadakkhdyeiue"

    Returns: 331


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: