teleren/devto huggingface dataset:
Awesome Web Browsers
Tags: webdev, programming, discuss, github
Published: 2022-07-08 08:36:19

A curated list of awesome web browsers for desktop, mobile, terminal etc. [![Awesome](https://awesome.re/badge.svg)](https://awesome.re)

### Web Browsers
Name | Mobile | Desktop | Terminal | Headless | Virtual |
|---|---|---|---|---|---|
| [Brave Browser](https://brave.com/) | Yes | Yes | No | No | No |
| [Blisk](https://blisk.io/) | Unknown | Yes | Unknown | Unknown | Unknown |
| [Chromium](https://www.chromium.org/getting-involved/download-chromium) | Yes | Yes | No | No | No |
| [Dolphin Browser](http://dolphin.com/) | Yes | No | No | No | No |
| [Firefox](https://www.mozilla.org/en-US/firefox/new/) | Yes | Yes | No | No | No |
| [Firefox Reality](https://mixedreality.mozilla.org/) | No | No | No | No | Yes |
| [Google Chrome](https://www.google.com/chrome/b/) | Yes | Yes | No | No | No |
| [Kiwi Browser](https://play.google.com/store/apps/details?id=com.kiwibrowser.browser) | Yes | Unknown | No | No | No |
| [Konqueror Browser](https://kde.org/applications/internet/org.kde.konqueror) | Unknown | Yes | Unknown | Unknown | Unknown |
| [Lynx](http://lynx.browser.org/) | No | No | No | Yes | No | No |
| [Midori](https://www.midori-browser.org/) | Unknown | Yes | Unknown | Unknown | Unknown |
| [Microsoft Edge](https://www.microsoft.com/en-us/windows/microsoft-edge) | Yes | Yes | No | No | No |
| [Opera Browser](https://www.opera.com/) | Yes | Yes | No | No | No |
| [Opera GX Browser](https://www.opera.com/gx#start) | Unknown | Yes | No | No | No |
| [Palemoon](https://www.palemoon.org/) | No | Yes | No | No | No |
| [Penny Wise](https://github.com/kamranahmedse/pennywise) | No | Yes | No | No | No |
| [Puffin Browser](https://www.puffin.com/) | Yes | No | No | No | No |
| [Pupeteer](https://github.com/GoogleChrome/puppeteer) | No | No | No | Yes | No |
| [Tor](https://www.torproject.org/) | Yes | Yes | No | No | No |
| [Safari](https://www.apple.com/safari/) | Yes | Yes | No | No | No |
| [Qutebrowser](https://www.qutebrowser.org/) | Unknown | Yes | No | No | No |
| [UC Browser](https://play.google.com/store/apps/details?id=com.UCMobile.intl) | Yes | Yes | No | No | No |
| [Via](https://play.google.com/store/apps/details?id=mark.via.gp) | Yes | No | No | No | No |
| [Vimb](https://github.com/fanglingsu/vimb) | Unknown | Yes | No | No | No |
| [Vivaldi](https://vivaldi.com/) | Unknown | Yes | No | No | No |
| [Webvium Browser](https://mrepol742.github.io/webvium/) | Yes | No | No | No | No |
| [Wexond](https://github.com/wexond/wexond) | Unknown | Yes | No | No | No |
491. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:58:04

```
class Solution {
 public:
  vector<vector<int>> findSubsequences(vector<int>& nums) {
    vector<vector<int>> ans;
    dfs(nums, 0, {}, ans);
    return ans;
  }

 private:
  void dfs(const vector<int>& nums, int s, vector<int>&& path,
           vector<vector<int>>& ans) {
    if (path.size() > 1)
      ans.push_back(path);

    unordered_set<int> used;

    for (int i = s; i < nums.size(); ++i) {
      if (used.count(nums[i]))
        continue;
      if (path.empty() || nums[i] >= path.back()) {
        used.insert(nums[i]);
        path.push_back(nums[i]);
        dfs(nums, i + 1, move(path), ans);
        path.pop_back();
      }
    }
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/increasing-subsequences/
494. Leetcode Solution in Java
Tags: java
Published: 2022-07-08 08:57:07

```
public class Solution {
    public int findTargetSumWays(int[] nums, int S) {
       int[] res = new int[1];
        findTargetSum(0, 0, S, nums, res);
        return res[0];
    }

    public void findTargetSum(int index, int curSum, int target, int[] nums, int[] res) {
        if (index == nums.length) {
            if (curSum == target) {
                ++res[0];
            }
            return;
        }

        findTargetSum(index + 1, curSum + nums[index], target, nums, res);
        findTargetSum(index + 1, curSum - nums[index], target, nums, res);
    }
}
```


#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/target-sum/
386. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:53:29

```
class Solution {
 public:
  vector<int> lexicalOrder(int n) {
    vector<int> ans;
    int curr = 1;

    while (ans.size() < n) {
      ans.push_back(curr);
      if (curr * 10 <= n) {
        curr *= 10;
      } else {
        while (curr % 10 == 9 || curr == n)
          curr /= 10;
        ++curr;
      }
    }

    return ans;
  }
};

```


#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/lexicographical-numbers/
373. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:52:01

```
struct T {
  int i;
  int j;
  int sum;  // nums1[i] + nums2[j];
  T(int i, int j, int sum) : i(i), j(j), sum(sum) {}
};

class Solution {
 public:
  vector<vector<int>> kSmallestPairs(vector<int>& nums1, vector<int>& nums2,
                                     int k) {
    vector<vector<int>> ans;
    auto compare = [&](const T& a, const T& b) { return a.sum > b.sum; };
    priority_queue<T, vector<T>, decltype(compare)> minHeap(compare);

    for (int i = 0; i < k && i < nums1.size(); ++i)
      minHeap.emplace(i, 0, nums1[i] + nums2[0]);

    while (!minHeap.empty() && ans.size() < k) {
      const auto [i, j, _] = minHeap.top();
      minHeap.pop();
      ans.push_back({nums1[i], nums2[j]});
      if (j + 1 < nums2.size())
        minHeap.emplace(i, j + 1, nums1[i] + nums2[j + 1]);
    }

    return ans;
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/find-k-pairs-with-smallest-sums/
Code snippet: A performant async queue
Tags: typescript, javascript
Published: 2022-07-08 08:51:25

Here's a queue that handles async functions in order with a wait time between each callback. You can call it from anywhere, all tasks will stay in order and won't overlap each other. It can be used for rate limiting, for example.

{% gist https://gist.github.com/pyrsmk/c1ffd70d8ae8e0f7ca2a5ff8db3ce8a3 %}

There's also an NPM package that has a more complete API: [dumb-queue](https://github.com/pyrsmk/dumb-queue).
How do you use Cascading Style Sheets (CSS)?
Tags: css, webdev, beginners, tutorial
Published: 2022-07-08 08:51:00

## What is CSS?

CSS (Cascading Style Sheets) is a style sheet language that is used to style and layout web pages, such as changing the font, colour, size, and spacing of your content, splitting it into numerous columns, and adding animations and other decorative elements.

A cascading style sheet is made up of rules. A CSS rule is made up of one or more selectors and a semicolon-separated list of declarations inside brackets.

Example:

```css
p {color: teal;}
```
`p` is called the selector
The information between the curly brackets `{ }` is called the declaration
`color` is the property
`teal` is the value

## Using CSS

CSS allows you to customise the look and feel of one or more web pages. You can target one, several, or all of the given items on a single page, or even all of the site's pages, swiftly and efficiently.

CSS can be added to HTML documents in 3 ways:

**Inline** - by using the style attribute inside HTML elements
**Internal** - by using a element in the `<head>` section
**External** - by using a element to link to an external CSS file

## Inline CSS

The first is to use an inline style, where we apply directly to individual elements with the style attribute.
The text colour of the `<h1>` element is blue, and the text colour of the `<p>` element is red in the following example:

```html
<h1 style=“color:blue;”>A Blue Heading</h1>

<p style=“color:red;”>A red paragraph.</p>
```

## Internal CSS

Internal CSS is defined within a element in the `<head>` section of an HTML page.

The example below changes the text colour of ALL `<h1>` elements on that page to blue

```html
<!DOCTYPE html>
<html>
<head>
    <style>
        body {background-color: powderblue;}
        h1   {color: blue;}
    </style>
</head>
<body>
    <h1>This is a heading</h1>
    <p>This is a paragraph.</p>
</body>
</html>
```

## External CSS

Many HTML pages rely on an external style sheet to establish their look.
Add a link to an external style sheet in the section of each HTML page to use it:

```html
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h1>This is a heading</h1>
    <p>This is a paragraph.</p>
</body>
</html>
```

Any text editor can be used to create the external style sheet. The file must be saved with a.css extension and must not contain any HTML code.

This is how the `"styles.css"` file appears:

```css
body {
  background-color: powderblue;
}
h1 {
  color: blue;
}
p {
  color: red;
}
```
**External style sheets** are the most efficient way to use CSS on a website (it's easier to maintain track of and implement a site's style from a dedicated CSS file), whereas internal style sheets and inline style can be utilised on a case-by-case basis when individual style modifications are needed.
345. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:50:13

```
class Solution {
 public:
  string reverseVowels(string s) {
    const unordered_set<char> vowels{'a', 'e', 'i', 'o', 'u',
                                     'A', 'E', 'I', 'O', 'U'};
    int l = 0;
    int r = s.length() - 1;

    while (l < r) {
      while (l < r && !vowels.count(s[l]))
        ++l;
      while (l < r && !vowels.count(s[r]))
        --r;
      swap(s[l++], s[r--]);
    }

    return s;
  }
};

```


#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/reverse-vowels-of-a-string/
331. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:48:33

```
class Solution {
 public:
  bool isValidSerialization(string preorder) {
    int degree = 1;  // outDegree (children) - inDegree (parent)
    istringstream iss(preorder);

    for (string node; getline(iss, node, ',');) {
      if (--degree < 0)
        return false;
      if (node != "#")
        degree += 2;
    }

    return degree == 0;
  }
};

```

#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/
328. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:45:13

```
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
 public:
  ListNode* oddEvenList(ListNode* head) {
    ListNode oddHead(0);
    ListNode evenHead(0);
    ListNode* odd = &oddHead;
    ListNode* even = &evenHead;

    for (int isOdd = 0; head; head = head->next)
      if (isOdd ^= 1) {
        odd->next = head;
        odd = odd->next;
      } else {
        even->next = head;
        even = even->next;
      }

    odd->next = evenHead.next;
    even->next = nullptr;
    return oddHead.next;
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/odd-even-linked-list/
326. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:35:48

```
class Solution {
 public:
  bool isPowerOfThree(int n) {
    return n > 0 && static_cast<int>(pow(3, 19)) % n == 0;
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/power-of-three/
Life Cycle of a Component
Tags: react, webdev, javascript, beginners
Published: 2022-07-08 08:34:49

Life cycle of a component can be defined as the series of methods that are invoked in different stages of the component existence.
Stages are:

• Initialization
• Mounting
• Updating
• Unmounting

####Function of each Phase of Cycle

#####1. Initialization
In this phase, we have to define the props and initial state of the component. This is done in the constructor of the component.

#####2. Mounting
In this phase, Initialization of the component is completed and the component  is mounted on the DOM and rendered on the first time on web page.

• componentWillMount() Function
• componentDidMount() Function

#####3. Updating
It is the phase where the states and the props of a component are updated followed by some user events like click or press keyboard button etc.

• componentWillRecieveProps() Function
• setState() Function
• shouldComponentUpdate() Function
• componentWillUpdate() Function
• componentDidUpdate() Function

#####4. Unmounting
This is the final phase of the life cycle of the component that is the phase of unmounting the component from the DOM.
•  componentWillUnmount() Function

######Note: _React follows a default procedure in the Naming Conventions of these predefined functions where the functions containing “Will” represents before some specific phase and “Did” represents after the completion of that phase._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u9n91nq7xtj0713uhdsy.png)
395. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:33:08

```
class Solution {
 public:
  int longestSubstring(string s, int k) {
    int ans = 0;

    for (int n = 1; n <= 26; ++n)
      ans = max(ans, longestSubstringWithNUniqueCharacters(s, k, n));

    return ans;
  }

 private:
  int longestSubstringWithNUniqueCharacters(const string& s, int k, int n) {
    int ans = 0;
    int uniqueChars = 0;  // # of unique chars in window
    int noLessThanK = 0;  // # of chars >= k in window
    vector<int> count(128);

    for (int l = 0, r = 0; r < s.length(); ++r) {
      if (count[s[r]] == 0)
        ++uniqueChars;
      if (++count[s[r]] == k)
        ++noLessThanK;
      while (uniqueChars > n) {
        if (count[s[l]] == k)
          --noLessThanK;
        if (--count[s[l]] == 0)
          --uniqueChars;
        ++l;
      }
      if (noLessThanK == n)  // unique chars also == n
        ans = max(ans, r - l + 1);
    }

    return ans;
  }
};

```

#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/
matrico (in 7 sentences)
Tags: scheme, schemelang, chickenscheme, numerics
Published: 2022-07-08 08:30:37

* `matrico` version 0.2 (2022-07-07) has been released.
* `matrico` is a flonum matrix module for CHICKEN Scheme.
* `matrico` combines numerical matrix computations with Lisp-style programming.
* `matrico` is an educational project for scientific computing.
* `matrico` can be installed from the official CHICKEN Scheme egg repository: http://wiki.call-cc.org/eggref/5/matrico
* `matrico` is open source and has a git(hub) repository: https://git.io/matrico
* `matrico` was originally inspired by: http://fmnt.info/blog/20181029_scheme.html
342. Leetcode Solution in CPp
Tags: cpp
Published: 2022-07-08 08:29:16

```
class Solution {
 public:
  bool isPowerOfFour(int n) {
    // Why (4^n - 1) % 3 == 0?
    // (4^n - 1) = (2^n - 1)(2^n + 1) and 2^n - 1, 2^n, 2^n + 1 are
    // three consecutive numbers; among one of them, there must be a multiple
    // of 3, and that can't be 2^n, so it must be either 2^n - 1 or 2^n + 1.
    // Therefore, 4^n - 1 is a multiple of 3.
    return n > 0 && __builtin_popcountll(n) == 1 && (n - 1) % 3 == 0;
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/power-of-four/
371. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:27:03

```
class Solution {
 public:
  int getSum(unsigned a, unsigned b) {
    while (b) {                      // still have carry bits
      const unsigned carry = a & b;  // record carry bits
      a ^= b;                        // ^ works like + w/o handling carry bits
      b = carry << 1;
    }
    return a;
  }
};

```


#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/sum-of-two-integers/
375. Leetcode Solution in Cpp
Tags: cpp
Published: 2022-07-08 08:18:54

```
class Solution {
 public:
  int getMoneyAmount(int n) {
    // dp[i][j] := min money you need to guarantee a win of picking i..j
    dp.resize(n + 1, vector<int>(n + 1, INT_MAX));
    return getMoneyAmount(1, n);
  }

 private:
  vector<vector<int>> dp;

  int getMoneyAmount(int i, int j) {
    if (i >= j)
      return 0;
    if (dp[i][j] != INT_MAX)
      return dp[i][j];

    for (int k = i; k <= j; ++k)
      dp[i][j] =
          min(dp[i][j],
              max(getMoneyAmount(i, k - 1), getMoneyAmount(k + 1, j)) + k);

    return dp[i][j];
  }
};

```

#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/guess-number-higher-or-lower-ii/
388. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:17:45

```
struct T {
  int depth;
  size_t length;
  T(int depth, size_t length) : depth(depth), length(length) {}
};

class Solution {
 public:
  int lengthLongestPath(string input) {
    size_t ans = 0;
    stack<T> stack{{{-1, 0}}};  // placeholder
    istringstream iss(input);

    for (string token; getline(iss, token, '\n');) {
      const int depth =
          count_if(begin(token), end(token), [](char c) { return c == '\t'; });
      token.erase(remove(begin(token), end(token), '\t'), end(token));
      while (depth <= stack.top().depth)
        stack.pop();
      if (isFile(token))
        ans = max(ans, stack.top().length + token.length());
      else  // directory + '/'
        stack.emplace(depth, stack.top().length + token.length() + 1);
    }

    return ans;
  }

 private:
  bool isFile(const string& token) {
    return token.find('.') != string::npos;
  }
};

```
#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/longest-absolute-file-path/
Gruvbox resources (Mac)
Tags: gruvbox, wallpapers, terminal, editor
Published: 2022-07-08 08:16:51

I work as a front-end developer and care about my daily experience working in my terminal and my editor of choice (WebStorm / Neovim). 

I've searched far and wide for a proper consistent thematic setup of my tools, from Tokyo Night through Rosé Pine to Gruvbox, Ayu Mirage and then back to Gruvbox – I always came back to Gruvbox. 

Gruvbox is easy on the eyes, gives enough contrast to not be annoying in the long run, and it's possible to find ports to most tools. 

So I've gathered some of the resources that I use, + a small collection of wallpapers that fits nicely with the color palette, with and without a "Gruvboxy" overlay. 

Everything can be found in this repository!
[https://github.com/christofferbergj/gruvbox-rice](https://github.com/christofferbergj/gruvbox-rice)

* Gruvbox compatible wallpapers
* iTerm2 colorscheme
* Slack theme values
* Chrome theme extension
* Webstorm/Vscode theme

---

## Demo

**Webstorm**

![Webstorm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vigb39bzk5r6a2m5g0qi.png)


**Terminal**

![Terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s58tvypup4d9qu00j6fu.png)


## Wallpapers

All wallpapers can be found [here](https://github.com/christofferbergj/gruvbox-rice#gruvbox-compatible-wallpapers)

**A few wallpapers (all can be found in the repo)**

![Wallpaper one](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8wxlh8o36gy3wglddb7.jpeg)


![Wallpaper two](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iozpdrn1g2w4ian3aj86.jpeg)


![Wallpaper three](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wn5jso19urdy4shdw158.jpeg)


The remaining wallpapers can be found [here](https://github.com/christofferbergj/gruvbox-rice#gruvbox-compatible-wallpapers)
390. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:16:40

```
class Solution {
public:
    int lastRemaining(int n) {
        int start = 1, step = 1;
        while (n > 1) {
            start += step + (n-2)/2 * 2*step;
            n /= 2;
            step *= -2;
        }
        return start;
    }
};
```

#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/elimination-game/
400. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:14:57

```
class Solution {
 public:
  int findNthDigit(int n) {
    int digitSize = 1;
    int startNum = 1;
    long count = 9;

    while (digitSize * count < n) {
      n -= digitSize * count;
      ++digitSize;
      startNum *= 10;
      count *= 10;
    }

    const int targetNum = startNum + (n - 1) / digitSize;
    const int index = (n - 1) % digitSize;
    return to_string(targetNum)[index] - '0';
  }
};

```


#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/nth-digit/
A Fun Programming Joke To Start Your Day
Tags: jokes, dailydeveloperjokes
Published: 2022-07-08 08:00:01

---
title: "A Fun Programming Joke To Start Your Day"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e12592aa5db7.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
Asynchronous JavaScript is amazing.

I Promise you, await and see.
 -->
398. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:13:43

```
class Solution {
private:
    vector<int> nums;    
public:
    Solution(vector<int> nums) {
        srand(time(0));
        this->nums = nums;
    }
    
    int pick(int target) {
	// we just randomly pick a number from the array,
        // if the number is target just return the index.
        // otherwise, keep picking the number randomly.
        while(true) {
            int idx = rand() % nums.size();
            if ( target == nums[idx] ) {
                return idx;
            }
        }
    }
};
```

#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/random-pick-index/
396. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:10:55

```
class Solution {
 public:
  int maxRotateFunction(vector<int>& nums) {
    const int sum = accumulate(begin(nums), end(nums), 0);
    int f = 0;

    // calculate F(0) first
    for (int i = 0; i < nums.size(); ++i)
      f += i * nums[i];

    int ans = f;

    for (int i = nums.size() - 1; i > 0; --i) {
      f += sum - nums.size() * nums[i];
      ans = max(ans, f);
    }

    return ans;
  }
};

```

#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/rotate-function/
292. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:09:44

```
class Solution {
 public:
  bool canWinNim(int n) {
    return n % 4 != 0;
  }
};

```

#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/nim-game/
274. Leetcode Solution in CPP
Tags: cpp
Published: 2022-07-08 08:08:40

```
class Solution {
 public:
  int hIndex(vector<int>& citations) {
    const int n = citations.size();
    int accumulate = 0;
    vector<int> count(n + 1);

    for (const int citation : citations)
      ++count[min(citation, n)];

    // to find the largeset h-index, loop from back to front
    // i is the candidate h-index
    for (int i = n; i >= 0; --i) {
      accumulate += count[i];
      if (accumulate >= i)
        return i;
    }

    throw;
  }
};

```

#leetcode
#challenge
here is the link for the problem:
https://leetcode.com/problems/h-index/