Git Product home page Git Product logo

goku's Introduction

Routers

a company wants to increase the reliability of its network and is piloting hardware enhancements in one of the data centers prior to a full-scale roll out. To facilitate the routing of the incoming packets, there is a network of N routers in the data center. Every router is connected to every other router of the network either through a direct link or via some other routers.

to increase the fault tolerance of the network, the company wants to identify routers which would result in a disconnected network if they went down and add replicas of these routers to the network.

Write an algorithm to identify all such routers that need to be connected to the network all the time.

Input: the input to the function/method consists of three arguments: numRouters, an integer representing the number of routers in the data center (>=3) numLinks, an integer representing the number of links between the pair of routers. Links, a list of pairs of integers - A ,B reprensenting a link between the routers A and B. the network will be connected.

numRouters = 7
numLinks = 7
links = [[1,2],[1,3],[2,4],[3,4],[3,6],[6,7],[4,5]]

Output:

Return a list of integers representing the routers which need to be connected to the network all the time.

[3 , 4 , 6]

Stores

A company plans to open stores downtown in the city of Techlandia. Downtown Techlandia consists of city blocks, represented as a grid of M*N blocks. Each block represents either building denoted by 1 or open land area denoted by 0. Adjacent blocks with value 1 are considered clusters of buildings. Diagonal blocks with value 1 are not considered part of the same cluster. this company plans to have a store in each cluster of buildings.

Write an algorithm to find the number of stores that this company can open in downtown Techlandia.

Input: the input to the function/method consists of three arguments: rows, an integer representing the number of rows in the grid. columns, an integer representing the number of columns in the grid. grid, a two-dimensional integer array representing downtown Techlandia.

rows = 5
columns = 4
grid = [
   [ 1, 1, 0, 0 ]
   [ 0, 0, 1, 0 ]
   [ 0, 0, 0, 0 ]
   [ 1, 0, 1, 1 ]
   [ 1, 1, 1, 1 ]
]

Output: Returns an integer representing the number of stores that this company could build in downtown Techlandia.

output : 3

goku's People

Contributors

roneetkumar avatar

Watchers

 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.