Skip to content

feature: Querying a problem by it's id #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dfayd0 opened this issue Jan 6, 2024 · 2 comments
Closed

feature: Querying a problem by it's id #1

dfayd0 opened this issue Jan 6, 2024 · 2 comments
Labels

Comments

@dfayd0
Copy link

dfayd0 commented Jan 6, 2024

This API is amazing thank you for this!

I was thinking that it could be really cool to get the problem by it's id number.
Maybe it's already available and I just don't know how to do it. If that's the case, my apologies.

@1101-1
Copy link
Owner

1101-1 commented Jan 29, 2024

Thanks for your response :)

You can use ID instead of name.

For example:

let problem_info = api.set_problem("1").await.unwrap().description();

It will find the first match task. And the first info of every task starts with its own ID.

Sample response:

Ok(Description { name: "Two Sum", content: "<p>Given an array of integers <code>nums</code>&nbsp;and an integer <code>target</code>, return <em>indices of the two numbers such that they add up to <code>target</code></em>.</p>\n\n<p>You may assume that each input would have <strong><em>exactly</em> one solution</strong>, and you may not use the <em>same</em> element twice.</p>\n\n<p>You can return the answer in any order.</p>\n\n<p>&nbsp;</p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [2,7,11,15], target = 9\n<strong>Output:</strong> [0,1]\n<strong>Explanation:</strong> Because nums[0] + nums[1] == 9, we return [0, 1].\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [3,2,4], target = 6\n<strong>Output:</strong> [1,2]\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> nums = [3,3], target = 6\n<strong>Output:</strong> [0,1]\n</pre>\n\n<p>&nbsp;</p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>2 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>\n\t<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>\n\t<li><code>-10<sup>9</sup> &lt;= target &lt;= 10<sup>9</sup></code></li>\n\t<li><strong>Only one valid answer exists.</strong></li>\n</ul>\n\n<p>&nbsp;</p>\n<strong>Follow-up:&nbsp;</strong>Can you come up with an algorithm that is less than <code>O(n<sup>2</sup>)</code><font face=\"monospace\">&nbsp;</font>time complexity?" })

@1101-1 1101-1 added the solved label Jan 30, 2024
@1101-1
Copy link
Owner

1101-1 commented Jan 30, 2024

Added an additional method to make it clearer.

Commit: 5c8eae8

@1101-1 1101-1 closed this as completed Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants