id int64 1 3.58k | problem_description stringlengths 516 21.8k | instruction int64 0 3 | solution_c dict |
|---|---|---|---|
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n\n\n\n\n\n\n const int N= 1e5+1;\n int medianOfUniquenessArray(vector<int>& arr) {\n int n=arr.size();\n long long int tot= (n*1ll*(n+1))/2;\n auto f=[&](int med)->bool{\n //find number of subarray having number\n //of distinct ele... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\nprivate:\n unordered_map<int, int> store;\npublic:\n\n long long countDistinct(vector<int> &nums, int th) {\n int s = 0, e = 0;\n long long count = 0;\n\n while(e < nums.size()) {\n store[nums[e]]++;\n if(store.size() > th) {\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n bool isValid(int m, vector<int> &arr) {\n long long cnt = 0, n = arr.size();\n long long tar = n*(n+1)/2;\n tar /= 2;\n tar++;\n\n // Count of subarray's with >= k distinct elements\n int j = 0;\n unordered_map<int, int> s;\n\n... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n int n;\n long long Calc(vector<int> &a,size_t cntlimit)\n {\n unordered_map<int,int> mc;\n int last=0;\n long long cnt=0;\n for(int i=0;i<n;++i)\n {\n mc[a[i]]+=1;\n while(mc.size()>cntlimit)\n {\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "#include <bits/stdc++.h> \n\n// #define MAIN_ACTIVE\n// #define IO_FROM_FILE\n\nusing namespace std;\n#define int64_t wadwafesfesfes21321300242142104210321\nusing int64_t = long long;\nusing pii = pair<int,int>;\nusing pil = pair<int,int64_t>;\nusing pli = pair<int64_t,int>;\nusing pll = pair<int64_t,int64... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n bool check(int x,vector<int> &nums,int n){\n unordered_map<int,int> mp;int i = 0, j = 0;long long cnt = 0;\n while(i < n){\n while(j < n && ((mp.size() < x)||(mp.size() == x && (mp.find(nums[j])!= mp.end())))){\n mp[nums[j]]++;\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n long long solve(vector<int> &nums, int k)\n {\n int n=nums.size();\n int i=0;\n int j=0;\n\n unordered_map<int,int> m;\n\n long long ans=0;\n\n while(j<n)\n {\n m[nums[j]]++;\n while(m.size()>k)\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n long long solve(vector<int> &nums, int k)\n {\n int n=nums.size();\n int i=0;\n int j=0;\n\n unordered_map<int,int> m;\n\n long long ans=0;\n\n while(j<n)\n {\n m[nums[j]]++;\n while(m.size()>k)\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& N) {\n int n = N.size(), l = 1, r = n;\n long long mcnt = ceil((long long)(n + 1) * n / 4.0);\n\n while (l < r) {\n int m = l + (r - l) / 2;\n long long cnt = 0;\n unordered_map<int... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n long long lessThanEqual(vector<int> &nums, int mid) {\n int i = 0;\n long long cnt = 0; \n unordered_map<int, int> mp;\n for (int j = 0; j < nums.size(); j++) {\n mp[nums[j]]++;\n while (mp.size() > mid) {\n mp... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n int n = nums.size();\n long long k = ((long long) n * (n + 1) / 2 + 1) / 2;\n\n auto check = [&](int upper) {\n long long cnt = 0;\n int l = 0;\n unordered_map<int, int> f... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n int n = nums.size();\n long long k = ((long long) n * (n + 1) / 2 + 1) / 2;\n\n auto check = [&](int upper) {\n long long cnt = 0;\n int l = 0;\n unordered_map<int, int> f... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n long long l = 0, r = nums.size();\n long long tar = (r * (r + 1) / 2 + 1) / 2;\n auto ck = [&](int k) -> int{\n long long res = 0;\n unordered_map<int, int> cnt;\n for(int... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n long n = nums.size(), k = (n * (n + 1) / 2 + 1) / 2;\n\n auto check = [&](int upper) {\n long cnt = 0, l = 0;\n unordered_map<int, int> freq;\n for (int r = 0; r < n; ++r) {\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n long long l = 0, r = nums.size();\n long long tar = (r * (r + 1) / 2 + 1) / 2;\n auto ck = [&](int k) -> int{\n long long res = 0;\n unordered_map<int, int> cnt;\n for(int... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n long long k;\n vector<int> nums;\n int n;\n \n bool check(int mid) {\n unordered_map<int, int> mp;\n int i = 0;\n long long ans = 0;\n for (int j = 0; j < n; j++) {\n mp[nums[j]]++;\n while (mp.size() > mid) {\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "#include <unordered_map>\n\nclass Solution {\npublic:\n long long helper(const vector<int>& nums, int window) {\n unordered_map<int, int> mp;\n long long cnt = 0;\n int l = 0;\n\n for (int r = 0; r < nums.size(); ++r) {\n mp[nums[r]]++;\n\n while (mp.siz... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n long long helper(const vector<int>& nums, int window) {\n unordered_map<int, int> mp;\n long long cnt = 0;\n int l = 0;\n\n for (int r = 0; r < nums.size(); ++r) {\n mp[nums[r]]++;\n\n while (mp.size() > window) {\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 0 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n int n = nums.size();\n int low = 1, high = n;\n long long median = (1ll*n*(n+1))/2;\n median = (median + 1)/2;\n int ans = 1;\n while(low <= high){\n int mid = (low + high)... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n int n=nums.size();\n double target=(double)n*(n+1)/4;\n // cout<<target<<endl;\n int left=1,right=n;\n int ans=1;\n while(left<=right){\n int mid=(left+right)/2;\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n long long find(long long mid , vector<int>&nums)\n {\n unordered_map<int,int>m;\n int r=0 , l=0;\n long long cnt =0;\n while(r<nums.size())\n {\n m[nums[r]]++;\n while(m.size() > mid)\n {\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n int n = nums.size();\n long long median = ((long long) n * (n + 1) / 2 + 1) / 2;\n\n auto check = [&](int t) -> bool {\n unordered_map<int, int> cnt;\n long long tot = 0;\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\ntypedef long long ll;\n // f(x)=num_of_subarrays_with_distinct_element_lessThan_equal_to_x;\n ll f(vector<int> &nums,int x){\n unordered_map<int,int> ma;\n int l=0;\n ll ans=0;\n for(int r=0;r<nums.size();r++){\n ma[nums[r]]++;\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n int n = nums.size();\n long long total = (n*1ll*(n+1))/2;\n auto f = [&](int x)->int{\n int l = 0; \n int r = 0;\n unordered_map<int, int>mp;\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n int n = nums.size();\n long long total = (n*1ll*(n+1))/2;\n auto f = [&](int x)->int{\n int l = 0; \n int r = 0;\n unordered_map<int, int>mp;\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n int n = nums.size();\n long long total = 1ll*n*(n+1)/2;\n long long middle = (total+1)/2;\n int l = 1;\n int r = n;\n int distinct_num = l;\n while(l<=r){\n int mid ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n long long k;\n vector<int> nums;\n int n;\n \n bool check(int mid) {\n unordered_map<int, int> mp;\n int i = 0;\n long long ans = 0;\n for (int j = 0; j < n; j++) {\n mp[nums[j]]++;\n while (mp.size() > mid) {\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution\n{\npublic:\n long long countdistinct(vector<int> &nums, int k, long long size)\n {\n int n = nums.size();\n int s = 0, e = 0;\n unordered_map<int, int> m;\n long long count = 0;\n while (s <= e && e < n)\n {\n m[nums[e]]++;\n\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n bool check(vector<int>& nums,long mx){\n long n=nums.size();\n long count=0;\n unordered_map<int,int> mp;\n long total=(n*(n+1))/2;\n for(long i=0,j=0;j<n;j++){\n mp[nums[j]]++;\n while(i<n and mp.size()>mx){\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n bool check(vector<int>& nums,long mx){\n long n=nums.size();\n long count=0;\n unordered_map<int,int> mp;\n long total=(n*(n+1))/2;\n for(long i=0,j=0;j<n;j++){\n mp[nums[j]]++;\n while(i<n and mp.size()>mx){\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\ntypedef long long ll;\n // f(x)=num_of_subarrays_with_distinct_element_lessThan_equal_to_x;\n ll f(vector<int> &nums,int x){\n unordered_map<int,int> ma;\n int l=0;\n ll ans=0;\n for(int r=0;r<nums.size();r++){\n ma[nums[r]]++;\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n long long k;\n bool find(vector<int>& nums, int mid){\n int r = 0, l = 0;\n long long cnt = 0;\n unordered_map<int, int> mp;\n while(r < nums.size()){\n mp[nums[r]]++;\n while(mp.size() > mid){\n mp[nums[l]]-... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n long long k;\n bool find(vector<int>& nums, int mid){\n int r = 0, l = 0;\n long long cnt = 0;\n unordered_map<int, int> mp;\n while(r < nums.size()){\n mp[nums[r]]++;\n while(mp.size() > mid){\n mp[nums[l]]-... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n long long k;\n bool find(vector<int>& nums, int mid){\n int r = 0, l = 0;\n long long cnt = 0;\n unordered_map<int, int> mp;\n while(r < nums.size()){\n mp[nums[r]]++;\n while(mp.size() > mid){\n mp[nums[l]]-... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n long long k;\n bool find(vector<int>& nums, int mid){\n int r = 0, l = 0;\n long long cnt = 0;\n unordered_map<int, int> mp;\n while(r < nums.size()){\n mp[nums[r]]++;\n while(mp.size() > mid){\n mp[nums[l]]-... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n long long k;\n bool find(vector<int>& nums, int mid){\n int r = 0, l = 0;\n long long cnt = 0;\n unordered_map<int, int> mp;\n while(r < nums.size()){\n mp[nums[r]]++;\n while(mp.size() > mid){\n mp[nums[l]]-... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n long long k;\n bool find(vector<int>& nums, int mid){\n int r = 0, l = 0;\n long long cnt = 0;\n unordered_map<int, int> mp;\n while(r < nums.size()){\n mp[nums[r]]++;\n while(mp.size() > mid){\n mp[nums[l]]-... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n long long k;\n bool find(vector<int>& nums, int mid){\n int r = 0, l = 0;\n long long cnt = 0;\n unordered_map<int, int> mp;\n while(r < nums.size()){\n mp[nums[r]]++;\n while(mp.size() > mid){\n mp[nums[l]]-... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n long long k;\n bool find(vector<int>& nums, int mid){\n int r = 0, l = 0;\n long long cnt = 0;\n unordered_map<int, int> mp;\n while(r < nums.size()){\n mp[nums[r]]++;\n while(mp.size() > mid){\n mp[nums[l]]-... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n bool isposs(vector<int>&nums,int mid,long long temp){\n long long count=0;\n unordered_map<int,int>m;\n int j=0;\n for(int i=0;i<nums.size();i++){\n while(j<nums.size() && m.size()<=mid){\n if(m.size()==mid && m.find(nums[... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n bool check(vector<int>& nums,long mx){\n long n=nums.size();\n long count=0;\n unordered_map<int,int> mp;\n for(long i=0,j=0;j<n;j++){\n mp[nums[j]]++;\n while(i<n and mp.size()>mx){\n mp[nums[i]]--;\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 1 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n unordered_map<int, int> cnt;\n for(int num : nums) {\n cnt[num]++;\n }\n int n = nums.size();\n long long total = (1LL + n) * n / 2;\n\n auto subarrAtMostK = [&] (int k) {\... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\n size_t n;\n int MOD = 1e9 + 7;\npublic:\n using LL = long long;\n int medianOfUniquenessArray(vector<int>& nums) {\n n = nums.size();\n int median = 1;\n LL total = 1LL * n * (n + 1) / 2;\n\n auto uniqueCount = [](const std::vector<int>& nums) -> i... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\npublic:\n using ll = long long;\n \n ll SubarraysWithAtmostKDistinctElements(vector<int>& nums, int K) {\n ll subarray = 0;\n //freq[100005]{};\n unordered_map<int,int> mp;\n int left=0,right=0;\n while(right<nums.size())\n {\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\npublic:\n\n\n\n\n\n\n\n int medianOfUniquenessArray(vector<int>& arr) {\n int n=arr.size();\n long long int tot= (n*1ll*(n+1))/2;\n auto f=[&](int med)->bool{\n //find number of subarray having number\n //of distinct elements less equal to med... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\npublic:\nbool helper(int val,vector<int>& nums){\n long long int total=(nums.size()*(nums.size()+1))/2;\n long long int mid=(total+1)/2;\n // cout<<mid<<endl;\n unordered_map<int,int> m1;;\n int l=0;\n int r=0;\n long long int count=0;\n while(r<nums.size()){\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\npublic:\n\n long long solve(int mid,vector<int>&nums,int n){\n \n unordered_map<int,int>m;\n\n int i = 0;\n int j =0;\n\n long long ans = 0;\n\n while(j<n){\n \n m[nums[j]]++;\n\n while(i<j && m.size()>mid){\n \n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "#define ll long long\n\nclass Solution {\npublic:\n ll cnt(vector<int>&v, int sz){\n ll count = 0, l = 0;\n unordered_map<int, int> m;\n for(ll r = 0; r < v.size(); ++r){\n m[v[r]]++;\n while(m.size() > sz){\n m[v[l]]--;\n if(!m[v[... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "#define ll long long\nll find(int target, vector <int>& nums)\n{\n ll ans = 0, j = 0;\n unordered_map <int,int> mp;\n for(int i=0; i<nums.size(); ++i)\n {\n ++mp[nums[i]];\n ans += (i-j+1);\n while(mp.size() > target)\n {\n --ans;\n --mp[nums[j]... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "#define ll long long\nll find(int target, vector <int>& nums)\n{\n ll ans = 0, j = 0;\n unordered_map <int,int> mp;\n for(int i=0; i<nums.size(); ++i)\n {\n ++mp[nums[i]];\n ans += (i-j+1);\n while(mp.size() > target)\n {\n --ans;\n --mp[nums[j]... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\npublic:\n\nlong long num;\n\n bool check( int dist, vector<int> &nums)\n {\n int l=0,r=0, n=nums.size();\n long long cnt=0;\n unordered_map<int, int> m;\n while( r<n )\n {\n m[nums[r]]++;\n while( m.size() > dist )\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(const std::vector<int>& nums) {\n // #subarryas whose uniqueness <= maxDistinct, <= maxSubarrays\n static auto satisfy = [](const std::vector<int>& nums, int maxDistinct,\n long long maxSubarrys) -> bool {\n std... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(const std::vector<int>& nums) {\n // #subarryas whose uniqueness <= maxDistinct, < maxSubarrays\n static auto satisfy = [](const std::vector<int>& nums, int maxDistinct,\n long long maxSubarrys) -> bool {\n std:... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "#define ll long long \n\nclass Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& A ) {\n int N = A.size();\n\n ll T = (1LL*N*(N+1))/2 ;\n ll k = T/2 + (T&1);\n\n // 12 -> 6 [ 1 2 3 4 5 6 ]\n // 11 -> 5 [ 1 2 3 4 5 6 ]\n\n auto ok = [&]( int m )-> bo... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "#define ll long long \n\nclass Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& A ) {\n int N = A.size();\n\n ll T = (1LL*N*(N+1))/2 ;\n ll k = T/2 + (T&1);\n\n // 12 -> 6 [ 1 2 3 4 5 6 ]\n // 11 -> 5 [ 1 2 3 4 5 6 ]\n\n auto ok = [&]( int m )-> bo... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "#define ll long long int\nclass Solution {\npublic:\n bool chk(vector<int>&nums,ll median,ll n){\n ll i=0,j=0,ans=0;\n unordered_map<int,int> mp;\n while(j<n){\n mp[nums[j]]++;\n if(mp.size()<=median){\n j++;\n }else{\n while(i<n && mp.size()>median)... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "long long check(vector<int>& nums,int m){\n int n=nums.size();\n int i=0;\n int j=1;\n unordered_map<int,long long> mp;\n mp[nums[0]]++;\n long long cnt=1;\n long long subarrs = 0;\n // if(!mp[nums[1]]){\n // cnt++;\n // mp[nums[1]]++;\n // }\n while(i<j && j<n){... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n\nclass Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) \n {\n long long n = nums.size();\n \n // Helper function to count subarrays with distinct elements <= maxDistinct\n auto countSubarraysWithDistinct... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\n\n bool check(vector<int>& nums, int mid) {\n long long n = nums.size();\n long long num_sub = (1LL*n * (1LL*n+1))/2;\n long long k = num_sub % 2 == 0 ? num_sub/2 - 1: num_sub/2;\n long long i = 0, j = 0;\n unordered_map<long long, long long>m;\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "const int N = 1e5 + 2;\nint freq[N];\nclass Solution {\npublic:\n bool can(int t, vector<int>& a){\n int n = a.size();\n long long sum = 0;\n long long total = 1ll * n * (n + 1) / 2;\n set<int> s;\n int r = 0;\n for(int l = 0; l < n; l++){\n while(r <... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\npublic:\n using ll = long long;\n \n ll atMostK(vector<int>& A, int K) {\n ll i = 0, res = 0;\n unordered_map<int, ll> count;\n for (int j = 0; j < A.size(); ++j) {\n if (!count[A[j]]++) K--;\n while (K < 0) {\n if (!--cou... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\npublic:\ntypedef long long ll;\n\n ll atmostk(vector<int>& nums, int k){\n ll n = nums.size();\n ll l=0, r=0, count=0, ans=0;\n unordered_map<ll, ll> mp;\n while(r < n){\n if(mp[nums[r]] == 0) count++;\n mp[nums[r]]++;\n whil... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 2 | {
"code": "class Solution {\npublic:\n using ll = long long;\n \n ll atMostK(vector<int>& A, int K) {\n ll i = 0, res = 0;\n unordered_map<int, ll> count;\n for (int j = 0; j < A.size(); ++j) {\n if (!count[A[j]]++) K--;\n while (K < 0) {\n if (!--cou... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 3 | {
"code": "class Solution {\npublic:\nbool chk(long long int mid,long long int median,vector<int>&arr,int n){\n unordered_map<int,long long int>mp;\n long long int cnt=0;\n int r=0;\n int l=0;\n while(r<n){\n mp[arr[r]]++;\n while(mp.size()>mid){\n mp[arr[l]]--;\n if... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 3 | {
"code": "class Solution {\npublic:\n int medianOfUniquenessArray(vector<int>& nums) {\n long long l = 1, r = nums.size();\n long long n = nums.size();\n long long ans = -1;\n long long mx = (n * (n + 1))/2;\n mx = (mx + 1)/2;\n // cout << mx << \" \";\n while(l <=... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 3 | {
"code": "class Solution {\npublic:\n long long check(vector<int> &nums, int n, int mid)\n {\n long long cnt = 0;\n unordered_map<long long, long long> m;\n int l = 0;\n int r = 0;\n while(r<n)\n {\n m[nums[r]]++;\n while(m.size()>mid)\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 3 | {
"code": "#define ll long long\nclass Solution {\npublic:\n ll findcnt(vector<int> &a,ll k)\n {\n ll i=0,j=0,n=a.size(),cnt=0;\n unordered_map<ll,ll> mp;\n while(i<n)\n {\n mp[a[i]]++;\n while(j<n&&mp.size()>k)\n {\n mp[a[j]]--;\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 3 | {
"code": "class Solution {\n long long f(vector<int>&a, long long mid)\n {\n unordered_map< long long, long long>m;\n long long i,j=0;\n long long count=0;\n for(i=0;i<a.size();i++)\n {\n m[a[i]]++;\n while(m.size()>mid)\n {\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 3 | {
"code": "class Solution {\n public:\n using ll = long long;\n // Number of subarrays with Atmost k unique/distinct elements\n ll help(vector<int>& a, ll k) {\n ll n = a.size();\n ll l = 0, ans = 0, c = 0;\n unordered_map<ll, ll> m;\n\n for (ll r = 0; r < n; r++) {\n ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 3 | {
"code": "class Solution {\npublic:\nusing ll = long long;\n // Number of subarrays with Atmost k unique/distinct elements \n ll help(vector<int> &a, ll k){\n ll n = a.size();\n ll l =0, ans =0, c= 0;\n unordered_map<ll,ll> m;\n \n for(ll r =0;r<n;r++){\n ++m[a[r]]... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 3 | {
"code": "class Solution {\npublic:\n // given k unique, find the number of subarrays that contains k unique\n long long helper1(vector<int> &nums, long long k) {\n if(k <= 0) return 0;\n unordered_map<long long, long long> hm;\n long long l = 0, count = 0;\n for(long long r = 0; r ... |
3,362 | <p>You are given an integer array <code>nums</code>. The <strong>uniqueness array</strong> of <code>nums</code> is the sorted array that contains the number of distinct elements of all the <span data-keyword="subarray-nonempty">subarrays</span> of <code>nums</code>. In other words, it is a sorted array consisting of <c... | 3 | {
"code": "class Solution {\npublic:\n // given k unique, find the number of subarrays that contains k unique\n long long helper1(vector<int> &nums, long long k) {\n if(k <= 0) return 0;\n unordered_map<long long, long long> hm;\n long long l = 0, count = 0;\n for(long long r = 0; r ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 0 | {
"code": "#include <bits/stdc++.h>\nusing namespace std;\n\n#define lli long long\n#define endl '\\n'\n#define loop(i, n) for (int i = 0; i < n; i++)\n#define pool(i, n) for (int i = n - 1; i >= 0; i--)\n#define rep(i, a, b) for (int i = a; i <= b; i++)\n#define per(i, b, a) for (int i = b; i >= a; i--)\n#define all... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 0 | {
"code": "class Solution {\n public:\n bool isValid(string word) {\n return word.length() >= 3 &&\n ranges::all_of(word, [](char c) { return isalnum(c); }) &&\n ranges::any_of(word, isVowel) && ranges::any_of(word, isConsonant);\n }\n\n private:\n static bool isVowel(char c) {\n static c... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 0 | {
"code": "class Solution {\nprivate:\n bool isVowel(char ch) {\n ch = tolower(ch); \n return (ch == 'a' || ch == 'e' || ch == 'i' \n || ch == 'o' || ch == 'u');\n }\npublic:\n bool isValid(string word) {\n if (word.length() < 3) {\n return false; \n }\n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 0 | {
"code": "class Solution {\npublic:\nbool isval(char ch) { \n return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||\n ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U';\n}\n\n bool isValid(string word) {\n int n=word.length();\n if(n<3) return false;\n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 0 | {
"code": "class Solution {\npublic:\nbool isval(char ch){\n if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'){\n return true;\n }\n return false;\n}\n bool isValid(string word) {\n int n=word.length();\n if(n<3) return false;\n boo... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 2 | {
"code": "class Solution {\npublic:\nbool isval(char ch) { \n return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||\n ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U';\n}\n\n bool isValid(string word) {\n int n=word.length();\n if(n<3) return false;\n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 2 | {
"code": "class Solution {\npublic:\nbool isval(char ch){\n if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U'){\n return true;\n }\n return false;\n}\n bool isValid(string word) {\n int n=word.length();\n if(n<3) return false;\n boo... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 2 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if (word.length() <= 2) {\n return false;\n }\n std::string vowels = \"aeiouAEIOU\";\n int vowelCount = 0;\n int consonantCount = 0;\n for (size_t i = 0; i < word.length(); ++i) {\n if (isalpha(word[i])) {\n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 2 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n bool sol = false;\n\n const char* alphabet[42] = { \"b\", \"c\", \"d\", \"f\", \"g\", \"h\", \"j\", \"k\", \"l\", \"m\", \"n\", \"p\", \"q\", \"r\", \"s\", \"t\", \"v\", \"w\", \"x\", \"y\", \"z\", \"B\", \"C\", \"D\", \"F\", \"G\",... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n string vowels=\"aeuio\";\n string consonants=\"bcdfghjklmnopqrstvwxyz\";\n string digits=\"0123456789\";\n int vowel=0,consonant=0;\n if (word.length()<3)\n return false;\n else {\n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if (word.size() < 3) {\n return false;\n }\n\n set<char> vowels = {'a', 'e', 'i', 'o', 'u'};\n\n bool vowel = false, consonant = false;\n\n for (int i = 0; i < word.size(); ++i) {\n if (!is... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n set<char> st={'a','e','i','o','u','A','E','I','O','U'};\n\n bool isValid(string word) {\n if(word.length()<3) return false;\n\n int cntC=0,cntV=0;\n\n for(char c:word){\n if(!isalnum(c)) return false;\n if(!isalpha(c)) continue;\n... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if (word.length() < 3) return false;\n bool isVowel = false, isCons = false;\n unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u'};\n for (auto& c : word) {\n if (isdigit(c)) continue;\n else i... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n const set<char> x = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};\n bool isValid(string word) {\n if (word.size() < 3) return false;\n int r = 0;\n for (auto c : word) {\n if (!isalnum(c)) return false;\n if ((r == 0 || r == 1) && x.find(c)... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if (word.size() < 3) return false;\n\n string v = \"aeiouAEIOU\";\n unordered_set<char> vowels(v.begin(), v.end());\n\n int frq_vowels = 0, frq_consonants = 0;\n for (int i = 0; i < word.size(); ++i) {\n if (!isalpha(word[i]) &... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n\n if (word.size() < 3) return false;\n\n // Define the set of vowels\n std::unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};\n \n bool hasVowel = false;\n bool hasConsonant = f... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n if (word.length() < 3) { return false; }\n\n unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};\n\n bool consonant = false;\n bool vowel = false;\n\n for (auto& c : word) {\n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n string vowels = \"aeiouAEIOU\";\n string consonants = \"qwrtypsdfghjklzxcvbnmQWRTYPSDFGHJKLZXCVBNM\";\n string numbers = \"0123456789\";\n\n string total =\"\";\n total += vowels + consonants + numbers;\n\n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n unordered_set<char> s = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};\n \n int n = word.size();\n if(n < 3) return false;\n \n bool df=false, uf=false, lf=false, vf=false, cf=false;\n \n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isvowel(char c) {\n string vowels = \"aeiouAEIOU\"; \n \n bool flg = false; \n for (auto v : vowels) {\n if (c == v)\n flg = true; \n }\n \n return flg; \n }\n \n bool isValid(string word... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n std::unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};\n bool isValid(string word) {\n bool has_vowel = false, has_cons = false;\n for (auto ch : word) {\n if (!isdigit(ch) && !isalpha(ch)) {\n return f... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "#include <unordered_map>\n#include <string>\nusing namespace std;\n\nclass Solution {\npublic:\n bool isValid(string word) {\n if (word.size() < 3) return false;\n\n unordered_map<char, int> mp1; \n unordered_map<char, int> mp2;\n unordered_map<char, int> mp3; \n unord... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n map<char, int> m = {{'a', 1}, {'e', 1}, {'i', 1}, {'o', 1}, {'u', 1},{'A', 1}, {'E', 1}, {'I', 1}, {'O', 1}, {'U', 1}};\n bool isValid(string word) {\n if(word.length()<3)return 0;\n bool v=0,c=0;\n for(int i=0;i<word.length();i++){\n if((wo... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isVowel( char c)\n {\n string s = \"aeiouAEIOU\";\n for( int i= 0; i<s.size() ; i++)\n if( c == s[i])return true;\n return false;\n }\n bool isSpecial( char c)\n {\n string s = \",.!:@#?$%&*^(~)_-+=\\\"\\'\\n\\t\\b\\a{}[]/><;\\\\`₹ \";\n ... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n int isVowel(char ch){\n string s=\"aeiouAEIOU\";\n if(s.find(ch)!=string::npos)\n return 1;\n return 0;\n }\n int isConst(char ch){\n string s=\"bcdefghjklmnpqrstuvwxyz\";\n ch=tolower(ch);\n if(s.find(ch)!=string::np... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n \n std::set<char> vowelSet = {'a','e','i','o','u'};\n std::set<char> contSet = {'q','w','r','t','y','p','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m'};\n\n bool vow = false, cons = false;\n\n if(wo... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool find(string word,char ch)\n {\n for(int i=0;i<word.size();i++)\n {\n if(word[i]==ch)\n return true;\n }\n return false;\n }\n bool isValid(string word) {\n if(word.size()<3)\n return false;\... |
3,396 | <p>A word is considered <strong>valid</strong> if:</p>
<ul>
<li>It contains a <strong>minimum</strong> of 3 characters.</li>
<li>It contains only digits (0-9), and English letters (uppercase and lowercase).</li>
<li>It includes <strong>at least</strong> one <strong>vowel</strong>.</li>
<li>It includes <strong>at l... | 3 | {
"code": "class Solution {\npublic:\n bool isValid(string word) {\n bool isnum=true;\n bool isvowel=false;\n bool iscon=false;\n \n unordered_set<char> st={'a','e','i','o','u'};\n unordered_set<char> st1={'b','c','d','f','g','h','j','k','l','m','n','q','p','r','s','t','v'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.