●Warmup-2 ●Logic-2 ●String-2 ●List-2 Warmup-2 1.string_times Given a string and a non-negative int n, return a larger string that is n copies of the original string.string_times('Hi', 2) → 'HiHi'string_times('Hi', 3) → 'HiHiHi'string_times('Hi', 1) → 'Hi'
public int gradeTests(String[] key, String[] answers) { } Go Editor font size %:Shorter output Forget It! -- delete my code for this problem Progress graphs: Your progress graph for this problem Random user progress graph for this problem Random Epic Progress Graph ...
Codingbatsaysallanswersaretrue.Iusedsomeofquestionsininternshipapplicationreviews.Youcanusequestions,seehttp://codingbatforusagedetails.Youcanuse/modify/distributeanswersofmeorthisdocumentitunderthetermsoftheGNUGeneralPublicLicenseaspublishedbytheFreeSoftwareFoundation;eitherversion2oftheLicense,or(atyouroption)any...
1 2 3 4 public int powerN(int base, int n) { if (n == 0) return 1; return base * powerN(base, n - 1); } countX: 1 2 3 4 5 public int countX(String str) { if (str.length() == 0) return 0; if (str.charAt(0) == 'x') return 1 + countX(str.substring(1))...
1 2 3 4 5 6 7 public int scoreUp(String[] key, String[] answers) { int sum = 0; for (int i = 0; i < answers.length; i++) if (answers[i] == key[i]) sum += 4; else if (!answers[i].equals("?")) sum -= 1; return sum; } ...
of questions in internship application reviews. You can use questions, see http://codingbat.com for usage details. You can use/modify/distribute answers of me or this document it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 ...
comparing my answers of the Codingbat problems to yours and I have learnt quite a bit form your examples. However, here I have to agree with Frank. You solution on “has12” is flawed. To quote: “if there is A 1 in the array with a 2 somewhere later” specifies a single possible ...