GithubHelp home page GithubHelp logo

stage1-module4-collections-task3-map's Introduction

Tasks

1. Word repetition Map

Implement the program which gets String sentence as parameter and creates a Map<String,Integer> of word repetition , where key - the word from sentence in lower case, value - the number of repetitions of this word, ignoring case.

public class WordRepetitionMapCreator {
  public Map<String, Integer> createWordRepetitionMap(String sentence) {
  }
}

Example

Input

sentense in loWER caSE, SENTENCE IN UPper CAse.

Output

sentense - 2
in - 2
lower - 1
case - 2
upper - 1

2. Swap key and values

Implement the program which gets Map<Integer, String> as parameter and returns a Map<String, Integer> where the keys and values are swapped. If in the source map Map<Integer, String> there are the same values for different keys, in the new Map<String, Integer> this value should map to a smaller key value.

public class KeyValueSwapper {
    public Map<String, Integer> swap(Map<Integer, String> sourceMap){
    }
}

Example

Input

1 - one
2 - two
3 - three
10 - one

Output

one - 1
two - 2
three - 3

3. Function value finder

Implement the program which gets List<Integer> and required value as parameter, creates Map<Integer, Integer> and determines if required value is present among Map values.

The key of Map - element from List<Integer>, value - value of function 5x+2 for element from List<Integer>

public class FunctionValueFinder {
    public boolean isFunctionValuePresent(List<Integer> sourceList, int requiredValue){
        Map<Integer, Integer> functionMap = calculateFunctionMap(sourceList);
    }

    private Map<Integer, Integer> calculateFunctionMap(List<Integer> sourceList) {
    }
}

Example

Input

sourceList = [-1, 5, 4, 8]
value = 27

Output

true

stage1-module4-collections-task3-map's People

Contributors

amirgusmanov avatar hopenadyahope avatar kristinapotapovich avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.