Giter VIP home page Giter VIP logo

junctionbox's Introduction

Your team at Amazon has been contracted by a telecommunications company that is trying to upgrade junction boxes all over Techlandia. Some of the junction boxes have already been upgraded , and other boxes have not. Your task is to identify the oldest boxes that need to be upgraded first but leaving newer model boxes so that they will not be prioritized.

All junction boxes are identified by an alphanumeric identifier , followed by space delimited version information. The older generation uses space delimited lowercase English Strings to identify the version, but the newer generation uses space delimited positive integers to identify the version. Your task is to sort the junction boxes in the following order:

1> The older junction boxes should be returned first ,sorted by lexicographic ordering of alphabetic version.

2> If there are any ties in the older generation ties should be broken by the alphanumeric identifier.

3> The newer generation boxes must all come after the older generation in the original order they were given in the input.

INPUT :

The input to the function/method consists of one argument boxList, a list of strings representing all of the identifiers and version information.

OUTPUT:

Return a list of strings representing the correctly prioritized orders according to this system.

Constraints:

0<=number of boxes<1000

Note:

The Junction box identifier consists of only lowercase English characters and numbers . Sorting for tiebreaks should use ASCII value - as a example , the order identifier 'a1' should come before the order identifier 'aa'.

Examples

Input:

boxLst=

[ykc 82 01]

[eo first qpx]

[09z cat hamster]

[06f 12 25 6]

[az0 first qpx]

[236 cat dog rabbit snake]

output:

[236 cat dog rabbit snake]

[09z cat hamster]

[az0 first qpx]

[eo first qpx]

[ykc 82 01]

[06f 12 25 6]

Explanation The four old generation junction boxes should come first, with the '"cat dog rabbit snake" box coming before the "cat hamster type". Since the two boxes of type "first qpx" have the same version information, they should come next, using the "azp" identifier to come before the "eo" identifier. Finally the already upgraded junction boxes should come last in the origin order they were provided in the file.

Time complexity: O(nlogn) ??? Space complexity: O(n) ???

junctionbox's People

Contributors

ugonz86 avatar

Watchers

 avatar  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.