id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-encryption > apcsaIndexOfAnagram
prev  |  next  |  chance

Given an input str and a target str, find and return the index in which an anagram of target occurs in str. Look out though: str will contain spaces and other non-letter characters, as well as capitalization. If target is not found within str, return -1 just like indexOf. Preconditions: target will contain only lowercase letters, str and target will both have length > 0.


HINT: searching through an alternate String might be easier, right?  But then, how do you keep track of the original index positions?  Also: a helper method for finding anagrams sounds fantastic.

apcsaIndexOfAnagram("I wish, I wish upon a fish", "fashion") → 17
apcsaIndexOfAnagram("I am directing you to answer!", "direct") → 5
apcsaIndexOfAnagram("Find me my credit card.", "direct") → 11

...Save, Compile, Run (ctrl-enter)

public int apcsaIndexOfAnagram(String str, String target) { }

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

Java Help

Misc Code Practice

Difficulty: 320

Copyright Nick Parlante 2017 - privacy