Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
public static List wordConcatenation(String inputString, String [] wordsList) { ...

Sukumar

Aug 9, 2022

public static List wordConcatenation(String inputString, String [] wordsList) { List resultIndices = new ArrayList(); Map givenWordsMap = new HashMap(); int noOfWords = wordsList.length; int wordLength = wordsList[0].length(); int resultStringLength = wordLength * noOfWords; for(String s : wordsList) givenWordsMap.put(s, givenWordsMap.getOrDefault(s, 0) + 1); for(int i = 0; i < wordLength; i++) { Map foundWordsMap = new HashMap(); int leftWindow = i; int matchCount = 0; for(int rightWindow = leftWindow; rightWindow

0

0

Comments
Comments
S
Sukumar 3 years ago

This is my Java solution basing on the sliding window solution provided in the leetcode, however I do not see the need for while loop and excessword in the leetcode solution

On this page