id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "/**\n * Definition for a binary tree node.\n * struct TreeNode {\n * int val;\n * TreeNode *left;\n * TreeNode *right;\n * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n * TreeNode(int x, TreeNode *left, TreeNod... |
2,461 | <p>You are given the <code>root</code> of a binary tree with <strong>unique</strong> values, and an integer <code>start</code>. At minute <code>0</code>, an <strong>infection</strong> starts from the node with value <code>start</code>.</p>
<p>Each minute, a node becomes infected if:</p>
<ul>
<li>The node is currentl... | 3 | {
"code": "// /**\n// * Definition for a binary tree node.\n// * struct TreeNode {\n// * int val;\n// * TreeNode *left;\n// * TreeNode *right;\n// * TreeNode() : val(0), left(nullptr), right(nullptr) {}\n// * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}\n// * TreeNode(int... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int c=-1;\n for(int i=0;i<nums.size();i++){\n int n=(nums[i]*-1);\n if((find(nums.begin(),nums.end(),n)!=nums.end()) && n>c){\n c=n;\n }\n }\n return c;\n }\n};"... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int ans=-1;\n for(int i:nums)\n {\n for(int j:nums)\n {\n if(i==-j)\n {\n ans=max(ans,abs(i));\n \n }\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int ans=-1;\n for(int i:nums){\n for(int j:nums){\n if(i == -j){\n ans=max(ans,abs(i));\n }\n }\n }\n return ans;\n }\n};",
"memory": "22700"
} |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n vector<bool> arr(2001);\n int mx = -1;\n for (auto i : nums){\n if (i > 0 and arr[-i+1001]) mx = max(mx, i);\n if (i < 0 and arr[-i+1001]) mx = max(mx, -i);\n arr[i+1001] = true;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n vector<bool> arr(2001);\n int mx = -1;\n for (auto i : nums){\n if (i > 0 and arr[-i+1001]) mx = max(mx, i);\n if (i < 0 and arr[-i+1001]) mx = max(mx, -i);\n arr[i+1001] = true;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n vector<bool> arr(2001);\n int mx = -1;\n for (auto i : nums){\n if (i > 0 and arr[-i+1001]) mx = max(mx, i);\n if (i < 0 and arr[-i+1001]) mx = max(mx, -i);\n arr[i+1001] = true;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n vector<bool> arr(2001);\n int mx = -1;\n for (auto i : nums){\n if (i > 0 and arr[-i+1001]) mx = max(mx, i);\n if (i < 0 and arr[-i+1001]) mx = max(mx, -i);\n arr[i+1001] = true;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n vector<bool> arr(2001);\n int mx = -1;\n for (auto i : nums){\n if (i > 0 and arr[-i+1001]) mx = max(mx, i);\n if (i < 0 and arr[-i+1001]) mx = max(mx, -i);\n arr[i+1001] = true;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int n = nums.size(), ans = -1, idx;\n vector<int8_t> seen(1001, 0);\n\n for (int i = 0; i < n; i++) {\n idx = abs(nums[i]);\n if (!seen[idx])\n seen[idx] = nums[i] > 0? 1 : -1;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int n = nums.size(), ans = -1, idx;\n vector<int8_t> seen(1001, 0);\n\n for (int i = 0; i < n; i++) {\n idx = abs(nums[i]);\n if (!seen[idx])\n seen[idx] = nums[i] > 0? 1 : -1;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int n = nums.size(), ans = -1, idx;\n vector<int8_t> seen(1001, 0);\n\n for (int i = 0; i < n; i++) {\n idx = abs(nums[i]);\n if (!seen[idx])\n seen[idx] = nums[i] > 0? 1 : -1;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int i=0;\n int j=nums.size()-1;\n while(i<j){\n if(nums[i]+nums[j]==0) return nums[j];\n else if(nums[i]+nums[j]<0) i++;\n else j--;\n } \n return -1;... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int n = nums.size(), ans = -1, idx;\n vector<int8_t> seen(1001, 0);\n\n for (int i = 0; i < n; i++) {\n idx = abs(nums[i]);\n if (!seen[idx])\n seen[idx] = nums[i] > 0? 1 : -1;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 0 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int i=0;\n int j=nums.size()-1;\n int maxi=-1;\n while(i<=j)\n {\n if(nums[i]==-nums[j])\n {\n maxi=max(maxi,nums[j]);\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 1 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n int i = 0, j = nums.size() - 1;\n while (i <= j) {\n if (nums[i] == -nums[j]) return abs(nums[i]);\n else if (nums[i] < -nums[j]) i++;\n else j-... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 1 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& arr) {\n sort(arr.begin(),arr.end());\n int lo=0,hi=arr.size()-1;\n while(lo<hi){\n if(arr[lo]>0)return -1;\n if(abs(arr[lo])==arr[hi])return arr[hi];\n else if(abs(arr[lo])<arr[hi])hi--;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n vector<bool> map(1001,false);\n int ans = -1;\n for(int i = 0;i<nums.size();i++)\n {\n if(nums[i]<0)\n {\n map[-nums[i]] = true;\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) \n {\n int table_p[2001]={0};\n int max=0;\n for(int i=0;i<nums.size();i++)\n {\n table_p[nums[i]+1000]=1;\n if(table_p[-nums[i]+1000]==1)\n {\n if(nums[i]<0)\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) \n {\n int table_p[2001]={0};\n int max=0;\n for(int i=0;i<nums.size();i++)\n {\n table_p[nums[i]+1000]=1;\n if(table_p[-nums[i]+1000]==1)\n {\n\n if(max<-nums[i])\n... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int pos[1001] = {0};\n int neg[1001] = {0};\n int k = -1;\n for (auto num: nums) {\n if (num < 0) {\n if (pos[-num]) k = max(k, -num);\n neg[-num]++;\n } else {... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int arr[1001] = {0};\n int solution = -1;\n for (int i = 0; i < nums.size(); ++i) {\n int module_i = abs(nums[i]);\n if (arr[module_i] == nums[i])\n continue;\n arr[module... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int arr[1001] = {0};\n int solution = -1;\n for (int i = 0; i < nums.size(); ++i) {\n int module_i = abs(nums[i]);\n if (arr[module_i] == nums[i])\n continue;\n arr[module... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int arr[1001] ={0};\n int solution = -1;\n for (int i = 0; i < nums.size(); ++i) {\n int module_i = abs(nums[i]);\n if (arr[module_i] == nums[i])\n continue;\n arr[module_... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n vector<int>pos;\n vector<int>neg;\n int ans= 0;\n int b=0;\n int n = nums.size();\n for(int i =0;i<n;i++){\n if(nums[i]<0){\n neg.push_back(nums[i]);\n }\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) \n {\n int nums_buffer[1001]{};\n vector<int> considerations;\n\n for(int i = 0; i < nums.size(); i++)\n {\n int sign = nums[i] < 0 ? -1 : 1;\n int num = sign * nums[i];\n if(sign ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) \n {\n int nums_buffer[1001]{};\n vector<int> considerations;\n\n for(int i = 0; i < nums.size(); i++)\n {\n int sign = nums[i] < 0 ? -1 : 1;\n int num = sign * nums[i];\n if(sign ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) \n {\n int nums_buffer[1001]{};\n vector<int> considerations;\n\n for(int i = 0; i < nums.size(); i++)\n {\n int sign = nums[i] < 0 ? -1 : 1;\n int num = sign * nums[i];\n if(sign ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n set<int> st;\n for(auto it: nums){\n if(it<0) st.insert(it);\n }\n\n int maxi=-1;\n for(auto i:nums){\n if(i>0){\n int m = i-(2*i);\n if(st.find(m) != st.end()){\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int max = -1;\n std::set<int> negs;\n\n for (int i = 0; i < nums.size(); i++){\n if (nums[i] < 0){\n negs.insert(nums[i]);\n }\n }\n\n for (int i = 0; i < nums.size(); ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution\n{\npublic:\n int findMaxK(vector<int> &nums)\n {\n\n vector<int> save;\n int max = -1;\n\n for (int i = 0; i < nums.size() - 1; i++)\n {\n for (int j = i + 1; j < nums.size(); j++)\n {\n if ((abs(nums[i]) == abs(nums[j])... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n vector<int>neg;\n vector<int>pos;\n sort(nums.begin(),nums.end());\n int n=nums.size();\n for(int i=0;i<n;i++)\n {\n if(nums[i]<0)\n {\n neg.push_back(nums[i]);\... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n vector<int>v;\n for(int i=0;i<nums.size();i++)\n {\n for(int j=i+1;j<nums.size();j++)\n {\n if(nums[i]==(-nums[j]))\n {\n v.push_back(abs(nums[i]));... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n priority_queue<int> positives; \n priority_queue<int, vector<int>, greater<int>> negatives;\n\n for (int num : nums) {\n if (num > 0) {\n positives.push(num);\n } else if (num < 0) ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int maxValue=-1;\n unordered_set<int> st;\n for(int i=0;i<nums.size();i++) {\n if(nums[i] < 0) {\n st.insert(nums[i]);\n }\n }\n for(int i=0;i<nums.size();i++) {\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n unordered_map<int , int> counter;\n for(int i = 0 ; i < nums.size() ; i++){\n if(nums[i] < 0) counter[nums[i]]++;\n }\n int res = INT_MIN;\n for(int i = 0; i < nums.size() ; i++){\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int maxValue=-1;\n unordered_set<int> st;\n for(int i=0;i<nums.size();i++) {\n if(nums[i] < 0) {\n st.insert(nums[i]);\n }\n }\n for(int i=0;i<nums.size();i++) {\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n unordered_set<int> positiveSet;\n int maxK = -1;\n\n //first pass\n for (int num : nums){\n if (num > 0){\n positiveSet.insert(num);\n }\n }\n //second pass\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int maxValue=-1;\n unordered_set<int> st;\n for(int i=0;i<nums.size();i++) {\n if(nums[i] < 0) {\n st.insert(nums[i]);\n }\n }\n for(int i=0;i<nums.size();i++) {\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n\n // sort(nums.begin(),nums.end());\n // for(int i=nums.size()-1;i>=0;i--)\n // {\n // for(int j=i-1;j>=0;j--)\n // {\n // if(nums[i]+nums[j]==0)\n // {\n // return nums[i];\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n vector<int> myvector;\n for(int i=0;i<nums.size();i++)\n {\n for(int j=i+1;j<nums.size();j++)\n {\n if(nums[i]==-(nums[j]))\n {\n myvector.push_back... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\n public:\n int findMaxK(vector<int>& nums) {\n int ans = -1;\n unordered_set<int> seen;\n\n for (const int num : nums)\n if (seen.contains(-num))\n ans = max(ans, abs(num));\n else\n seen.insert(num);\n\n return ans;\n }\n};",
"memory": "26500"
} |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "#include<bits/stdc++.h>\nusing namespace std;\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n\t\t// keep track of maximum\n int maxi = -1;\n\t\t// set to remeber the other value \n unordered_set<int> s;\n for(auto i : nums){\n if(s.find(-i) == s.end()){\n... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "#include<bits/stdc++.h>\nusing namespace std;\nclass Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n\t\t// keep track of maximum\n int maxi = -1;\n\t\t// set to remeber the other value \n unordered_set<int> s;\n for(auto i : nums){\n if(s.find(i * -1) == s.end()... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n std::unordered_set<int> num_set(nums.begin(), nums.end());\n int largest_k=-1;\n for (int num : nums) {\n if (num_set.find(-num) !=num_set.end()) {\n largest_k = std::max(largest_k, std::abs(nu... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n set<int> s(nums.begin(), nums.end());\n int ans = -1;\n sort(nums.begin(), nums.end());\n for (int i=0; i<nums.size(); i++){\n if (nums[i]<0 && s.find(-1*nums[i])!=s.end()){\n ans = nums... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n unordered_set<int> mpp(nums.begin() , nums.end());\n sort(nums.begin() , nums.end());\n for(int i = nums.size()-1 ; i>= 0 ; i--){\n if(mpp.find(-1 * nums[i]) != mpp.end()){\n return nums[i];\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n /*sort(nums.begin(), nums.end());\n\n int l = 0, r = nums.size()-1;\n\n while (l < r)\n {\n if ((-1 * nums[l]) == nums[r])\n return nums[r];\n else if ((-1 * nums[l]) > nums[r... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n unordered_set<int> numSet;\n int maxK = -1;\n //traversing\n for (int num : nums){\n if (numSet.find(-num)!= numSet.end()){\n maxK = max(maxK,abs(num));\n }\n numSe... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 2 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int ans = -1;\n\n unordered_set<int> seen;\n\n for (int num : nums) {\n const int abs_num = abs(num);\n\n if (abs_num > ans && seen.contains(-num)) {\n ans = abs_num;\n }\... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 3 | {
"code": "class Solution {\npublic:\n int findMaxK(std::vector<int>& nums) {\n std::unordered_set<int> num_set(nums.begin(), nums.end());\n int largest_k = -1;\n\n for (int num : nums) {\n if (num_set.find(-num) != num_set.end()) {\n largest_k = std::max(largest_k, s... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 3 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n unordered_set<int> s(nums.begin(), nums.end());\n int ans = -1;\n for (int x : s) {\n if (s.count(-x)) {\n ans = max(ans, x);\n }\n }\n return ans;\n }\n};",
"memo... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 3 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n std::unordered_set<int> set(nums.cbegin(), nums.cend());\n int max = -1;\n for(const auto num : nums)\n {\n if(set.contains(num * -1))\n max = std::max(max, std::abs(num));\n }\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 3 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int maxValue=-1;\n unordered_set<int> st;\n unordered_set<int> st1;\n for(int i=0;i<nums.size();i++) {\n if(nums[i] < 0) {\n st.insert(nums[i]);\n }\n }\n for(in... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 3 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& a) {\n sort(a.begin(),a.end());\n map<int,int>mp;\n for(auto i:a)\n {\n mp[i]++;\n }\n int k=-1;\n for(int i=0;i<a.size();i++)\n {\n int value=a[i];\n if(mp.find(-value)!=mp.end())\n {\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 3 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n map<int,int>ff;\n int i,j;\n sort(nums.begin(),nums.end());\n for(i=0;i<nums.size();i++)\n {\n ff[nums[i]]++;\n }\n for(i=nums.size()-1;i>=0;i--)\n {\n if(nums[i]... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 3 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n unordered_map<int, bool> map;\n for(int num: nums){\n map[num] = true;\n }\n int max = INT_MIN;\n for(int i = 0; i < nums.size(); i++){\n if(nums[i] > max && map[nums[i] - 2*nums[i]])... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 3 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n\n vector<int>temp;\n\n for(int i=0; i<nums.size();i++){\n for(int j=0;j<nums.size();j++){\n if((nums[i] == (nums[j]*(-1))) && (i!=j)){\n int tmp =max(nums[i], nums[j]);\n ... |
2,524 | <p>Given an integer array <code>nums</code> that <strong>does not contain</strong> any zeros, find <strong>the largest positive</strong> integer <code>k</code> such that <code>-k</code> also exists in the array.</p>
<p>Return <em>the positive integer </em><code>k</code>. If there is no such integer, return <code>-1</c... | 3 | {
"code": "class Solution {\npublic:\n int findMaxK(vector<int>& nums) {\n int ans=-1;\n int n=nums.size();\n unordered_map<int,int>mp;\n for(int i=0;i<n;i++){\n mp[nums[i]]++;\n }\n for(int i=0;i<n;i++){\n if(nums[i]>0 && mp[-nums[i]])ans=max(ans,num... |
2,527 | <p>You are given an integer array <code>nums</code> and two integers <code>minK</code> and <code>maxK</code>.</p>
<p>A <strong>fixed-bound subarray</strong> of <code>nums</code> is a subarray that satisfies the following conditions:</p>
<ul>
<li>The <strong>minimum</strong> value in the subarray is equal to <code>mi... | 0 | {
"code": "class Solution {\npublic:\n long long countSubarrays(vector<int>& nums, int minK, int maxK) {\n long long i = 0, ans = 0;\n long long n = nums.size();\n while (i < n) {\n\n // Skip if that element is not in given range\n if (nums[i] < minK || nums[i] > maxK) {\... |
2,527 | <p>You are given an integer array <code>nums</code> and two integers <code>minK</code> and <code>maxK</code>.</p>
<p>A <strong>fixed-bound subarray</strong> of <code>nums</code> is a subarray that satisfies the following conditions:</p>
<ul>
<li>The <strong>minimum</strong> value in the subarray is equal to <code>mi... | 0 | {
"code": "class Solution {\npublic:\n long long countSubarrays(vector<int>& nums, int minK, int maxK) {\n long long res = 0;\n int bad_idx = -1, left_idx = -1, right_idx = -1;\n\n for (int i = 0; i < nums.size(); ++i) {\n if (!(minK <= nums[i] && nums[i] <= maxK)) {\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.