Skip to content

shohratd15/Top-10-URL-Value-Extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Top 10 URL Value Extractor

Problem Statement

Imagine a file in the following fixed format:

<url><white_space><long value>

Example:

http://api.tech.com/item/121345 9
http://api.tech.com/item/122345 350
http://api.tech.com/item/123345 25
http://api.tech.com/item/124345 231
http://api.tech.com/item/125345 111
...

Objective

Write a program that reads from stdin the absolute path of a file in the above format and outputs a list of the URLs associated with the 10 largest values in the right-most column.

For instance, for the above example and N=2, the output would be:

http://api.tech.com/item/122345
http://api.tech.com/item/124345

Requirements

  • Must work efficiently with extremely large files (e.g., billions of lines).
  • Should use concurrency or stream processing to handle memory constraints.
  • Output should only include the top 10 URLs based on value.

Assumptions

  • The file is newline-delimited and each line contains a URL followed by a numeric value separated by whitespace.
  • We assume valid input and no missing values.

Example CLI Usage

go run main.go /path/to/data.txt

Evaluation Criteria

  • Correctness and output accuracy.
  • Efficient memory and CPU use.
  • Concurrency usage.
  • Clean and well-documented code.

🧹 Code Quality

Please install and run a linter on your code before submission.

We recommend using golangci-lint (a popular all-in-one Go linter).

Run

   golangci-lint run ./...

Make sure your code is free of linting errors and warnings before submitting.


Good luck! 🦾

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages