Giter VIP home page Giter VIP logo

railway's Introduction

Railway

#需求

建造一个火车站系统,具有以下功能:

  • (1) 可以加入某一站点或一对相邻站点,加入相邻站点时,可以设置站点间距离
  • (2) 可以查询某两个站点之间是否可达(直接连接或通过其他站点中转)
  • (3) 可以查询两个站点之间最少的中转次数,不可达则为0xffff,自己到自己为1次中转,到相邻的下一节点为2次
  • (4) 可以查询两个站点之间的最短路径,不可达则为0xffff,自己到自己路径距离为0,其他按照站点间距离累加

#提示

  • 1.需要实现以下功能接口:
public interface RailwaySystem {
  /** 增加从srcStation到dstStation的路由;dstStation为空字符串时,仅将srcStation加入系统,并且distance填0 */
  void addRoute(String srcStation, String dstStation, int distance);
  
  /** 查询srcStation是否可以到达dstStation */
  boolean canReach(String srcStation, String dstStation);
  
  /** 查询srcStation到dstStation的最小中转数 */
  int getMinHopCount(String srcStation, String dstStation);
  
  /** 查询srcStation到dstStation的最短路径 */
  int getMinCostPath(String srcStation, String dstStation);
}

#场景

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.