Giter Site home page Giter Site logo

volume's People

Contributors

zhinushannan avatar

Stargazers

 avatar

Watchers

 avatar

volume's Issues

全新版本 是兄弟就来砍我

package 二零javab;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: ice_water
 * @Date: 2022/03/18/10:10 PM
 * @Description: 要做耿沁园的男人
 */

public class G_02 {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String str = scanner.nextLine();

    Map<Character, Integer> map = new HashMap<>();
    // 初始化结果,便于后期比较
    char res = str.charAt(0);
    for (int i = 0; i < str.length(); i++) {
      Character a = str.charAt(i);
      // 若存在 则+1
      if (map.containsKey(a)) {
        map.put(a, map.get(a) + 1);
        // 若不存在 则放入map中
      } else {
        map.put(a, 1);
      }

//      如果有多个字母出现的次数相等,结果为字典序最小的那个。
      if (map.get(res) == map.get(a)) {
        if (res > a) {
          res = a;
        }
      } else {
        if (map.get(res) < map.get(a)) {
          res = a;
        }
      }
    }
    System.out.println(res);
    System.out.println(map.get(res));
  }
}

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.