teleren/devto huggingface dataset:
Remove Element
Tags: leetcode, dsa, theabbie
Published: 2022-06-13 15:30:40

Given an integer array `nums` and an integer `val`, remove all occurrences of `val` in `nums` [**in-place**](https://en.wikipedia.org/wiki/In-place_algorithm). The relative order of the elements may be changed.

Since it is impossible to change the length of the array in some languages, you must instead have the result be placed in the **first part** of the array `nums`. More formally, if there are `k` elements after removing the duplicates, then the first `k` elements of `nums` should hold the final result. It does not matter what you leave beyond the first `k` elements.

Return `k` _after placing the final result in the first_ `k` _slots of_ `nums`.

Do **not** allocate extra space for another array. You must do this by **modifying the input array [in-place](https://en.wikipedia.org/wiki/In-place_algorithm)** with O(1) extra memory.

**Custom Judge:**

The judge will test your solution with the following code:

int\[\] nums = \[...\]; // Input array
int val = ...; // Value to remove
int\[\] expectedNums = \[...\]; // The expected answer with correct length.
                            // It is sorted with no values equaling val.

int k = removeElement(nums, val); // Calls your implementation

assert k == expectedNums.length;
sort(nums, 0, k); // Sort the first k elements of nums
for (int i = 0; i < actualLength; i++) {
    assert nums\[i\] == expectedNums\[i\];
}

If all assertions pass, then your solution will be **accepted**.

**Example 1:**

**Input:** nums = \[3,2,2,3\], val = 3
**Output:** 2, nums = \[2,2,\_,\_\]
**Explanation:** Your function should return k = 2, with the first two elements of nums being 2.
It does not matter what you leave beyond the returned k (hence they are underscores).

**Example 2:**

**Input:** nums = \[0,1,2,2,3,0,4,2\], val = 2
**Output:** 5, nums = \[0,1,4,0,3,\_,\_,\_\]
**Explanation:** Your function should return k = 5, with the first five elements of nums containing 0, 0, 1, 3, and 4.
Note that the five elements can be returned in any order.
It does not matter what you leave beyond the returned k (hence they are underscores).

**Constraints:**

*   `0 <= nums.length <= 100`
*   `0 <= nums[i] <= 50`
*   `0 <= val <= 100`

**SOLUTION:**

    class Solution:
        def removeElement(self, nums: List[int], val: int) -> int:
            i = 0
            while i < len(nums):
                if nums[i] == val:
                    nums.pop(i)
                    i -= 1
                i = max(i + 1, 0)
If You Don't Know *Nix
Tags: unix, linux, wsl, beginners
Published: 2022-06-13 15:28:08

Unix invented 1970. Unix Hater's Handbook 1991 (its viral nature exposed). Mac switches to Unix 2007, saves Mac computer. All Mobile based on Unix or Linux. 51 years later, Microsoft releases Linux subsystem. You're behind if you don't know *nix 

{% youtube _GS84sJl4Bw %}
Node.js Package Authors: Please support both CJS and ESM
Tags: node, npm, typescript, tutorial
Published: 2022-06-13 15:24:22

On this post I'll describe you how you can _easily_ add support for both CJS (CommonJS) and ESM (ECMAScript Modules) when authoring your own NPM packages.

Now that TypeScript is the go-to choice for most NPM package authors, it has never been easier to support either both CJS and ESM as "build targets".

## The problem

The standard TypeScript compiler (`tsc`) is still a bit limited when it comes to ESM output. If you use `.ts` for your source-code files, it simply can't output `.mjs` files for you. Although there are workarounds for this limitation, it often becomes too much effort, specially if you are under a monorepo with more than one NPM package to create releases from.

## The solution

Use `esbuild` to generate both `.js` and `.mjs` files, and `tsc` only for the declaration files (`.d.ts`). 

You can use the same output directory for all of them.

```
npm install --save-dev esbuild
```

Generating the CommonJS (CJS) output:

```
npx esbuild --outdir=build --platform=node --format=cjs src/*.ts
```

Generating the ES Modules (ESM) output:

```
npx esbuild --out-extension:.js=.mjs --outdir=build --platform=node --format=esm src/*.ts
```

Generating the TypeScript declaration files:

```
npx tsc
```

Alternatively, you can do these 3 steps through both `esbuild` and `typescript` APIs. [See the full example using `esbuild` and `typescript` APIs](https://gist.github.com/endel/c8e5e848102690894187ce733685291a).

--- 

Finally, for the `package.json`, you can combine all the 3 outputs:

```json
  "main": "./build/index.js",
  "module": "./build/index.mjs",
  "typings": "./build/index.d.ts",
```

Hope this helps!
DevBox Showcase: JSON Explorer
Tags: productivity, tutorial, tooling
Published: 2022-06-13 15:14:59

Hi 👋,

_This is the next post in the series showcasing tools from [DevBox](https://www.dev-box.app) 🎉, an application (desktop, browser extension or web) that contains many useful tools and cheat-sheets._

-------

Did you ever had to dive deep into a JSON file? DevBox has a tool for that: you can check a JSON object interactively using a column based UI.

Here is a short video about it:

{% vimeo 719897274 %}

Some notable features:

* Clicking on a field will open up a column on the right side with its information or it's child fields in the case of an object or array.
* It can detect non-standard fields such as colors and URLs.
* Show statistics for strings (words, lines, bytes).
* Show different formats of the color (RGBA, HSLA).
* Show parts of the URL (origin, host, path, etc...).

-------

More DevBox showcases are coming, so follow me here if you want to be notified!
I just finished reading "Microsoft 365 Fundamental Guide" and this is my review
Tags: books, review
Published: 2022-06-13 15:10:13

A few weeks ago I had the chance to read the this book.
I would like to share with you my feelings.

## The authors
I don't know the authors directly but after a quick search on LinkedIn I can safely say that they are very well prepared on this topic.
Both are Microsoft Certified Trainers and have a lot of experience on Microsoft 365 as well.
Gustavo Moraes is a CEO of a company and Douglas Romão is a Microsoft MVP since 5 years.

![Microsoft 365 Fundamental Guide Cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02tzzvw6paai53qqispt.jpg)
  
## Summary
This book is a compendium of recipes to start to work with Microsoft 365 take advantage of most of the services that are prensent on the Microsoft suite.
It's a good starting point if you are new to Microsoft 365 but even if you are a long-time user it's good because there are a lot of sections not commonly used.

This is the table of contents:
- Licensing Microsoft 365
- Organize and Finding Information with Microsoft Delve
- Workplace and Personal Productivity with Microsoft MyAnalytics
- Staying on Top of Emails and Calendars with Microsoft Outlook
- Taking and Sharing Notes with Microsoft OneNote
- Working from Anywhere with Microsoft OneDrive
- Collaboration and Ideation with Microsoft Whiteboard
- Microsoft SharePoint Online (SPO)
- Working Together with Microsoft Teams
- Managing Projects and Tasks with Microsoft Planner and To-Do
- Doing More with Microsoft Power Automate
- Power Apps
- Getting Information Using Microsoft Forms
- Visualizing Data with Microsoft Power BI
- QuickStart Excel, Word, and PowerPoint

## My evaluation
I can only recommend reading this book to a new user but to a long-time user of Microsoft 365.
It's not important to read all the sections but you can focus your attention just on what you need or what do you want to use in the future.

## Conclusion
You can find this book directly on the Pack website [here](https://www.packtpub.com/product/microsoft-365-fundamentals-guide/9781801070195) or on Amazon [here](https://www.amazon.com/Microsoft-365-Fundamental-Guide-running-ebook/dp/B09HSQGGV4/ref=sr_1_3?crid=P6M8Z8U9FFX5&keywords=microsoft+365+fundamental+guide&qid=1653144061&sprefix=microsoft+365+fundamental+gui%2Caps%2C917&sr=8-3)
Two City Scheduling
Tags: leetcode, dsa, theabbie
Published: 2022-06-13 15:00:44

A company is planning to interview `2n` people. Given the array `costs` where `costs[i] = [aCosti, bCosti]`, the cost of flying the `ith` person to city `a` is `aCosti`, and the cost of flying the `ith` person to city `b` is `bCosti`.

Return _the minimum cost to fly every person to a city_ such that exactly `n` people arrive in each city.

**Example 1:**

**Input:** costs = \[\[10,20\],\[30,200\],\[400,50\],\[30,20\]\]
**Output:** 110
**Explanation:** 
The first person goes to city A for a cost of 10.
The second person goes to city A for a cost of 30.
The third person goes to city B for a cost of 50.
The fourth person goes to city B for a cost of 20.

The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interviewing in each city.

**Example 2:**

**Input:** costs = \[\[259,770\],\[448,54\],\[926,667\],\[184,139\],\[840,118\],\[577,469\]\]
**Output:** 1859

**Example 3:**

**Input:** costs = \[\[515,563\],\[451,713\],\[537,709\],\[343,819\],\[855,779\],\[457,60\],\[650,359\],\[631,42\]\]
**Output:** 3086

**Constraints:**

*   `2 * n == costs.length`
*   `2 <= costs.length <= 100`
*   `costs.length` is even.
*   `1 <= aCosti, bCosti <= 1000`

**SOLUTION:**

    from functools import cmp_to_key
    
    class Solution:
        def compare(self, cost1, cost2):
            a, b = cost1
            c, d = cost2
            if a + d <= b + c:
                return -1
            return 1
        
        def twoCitySchedCost(self, costs: List[List[int]]) -> int:
            n = len(costs)
            costs.sort(key = cmp_to_key(self.compare))
            cost = 0
            for i in range(n // 2):
                cost += costs[i][0]
            for i in range(n // 2, n):
                cost += costs[i][1]
            return cost
How to use :nth-child in CSS
Tags: css, html, webdev, jetthoughts
Published: 2022-06-13 14:53:23

The `:nth-child` pseudo-class allows to select one and more elements based on their source order.
```html
<ul>
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
  <li>Four</li>
  <li>Five</li>
</ul>
```
Let’s look at simple examples for how this can be do:

## Select the first list item
```css
li:nth-child(1) {
  color: red;
}
```
Also, you can use `first-child` pseudo-class for this
```css
li:first-child {
  color: red;
}
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e9rve6b255r7off0ugz2.png)

## Select the 5th list item
```css
li:nth-child(5) {
  color: red;
}
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3pcymakl62wpodupa6ha.png)


## Select every child elements whose index is odd
```css
li:nth-child(odd) {
  color: red;
}
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/07myqk5nxrv4ift045gg.png)

## Select every child elements whose index is even
```css
li:nth-child(even) {
  color: red;
}
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/er45co5nrbwfsi71oosn.png)

## Select every 3rd list item starting with first
```css
li:nth-child(3n — 2) {
  color: red;
}
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g39qoeqmkxuh86uxnvtm.png)

## Select every 3rd list item starting with 2nd
```css
li:nth-child(3n — 1) {
  color: red;
}
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4pax0i1343r08awa8ipe.png)
  
## Select every 3rd child item
```css
li:nth-child(3n) {
  color: red;
}
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxfyxxwzs4pbfs8vdire.png)

## Select the first three items of the list
```css
li:nth-child(-n+3) {
  color: red;
}
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4d8g0treln69h6l7xwe.png)
      
## Select the last element of the list
```css
li:last-child {
  color: red;
}
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d450kwaasyex3j2z1grz.png)
React 18 and React Router 6 changes
Tags: react
Published: 2022-06-13 14:49:09

Hey guys,

I just started to learn React. It seems I am quite unfortunate that recently has been changed a lot in React so finding tutorials and googling is quite confusing.

I transformed a server-side rendered Rails app into React and it worked fine for the index page, but I am now stuck with accessing the url parameter for the show. I have the same problem as described [here](https://stackoverflow.com/questions/69967745/react-router-v6-access-a-url-parameter) that made me also wondering what is the right way to write a React app. React.Components is still used on [react.js](https://reactjs.org/) but these hacks suggested on SO make me feel it might not be the right way to develop my application. It would be nice to hear your opinion as I am quite lost. Maybe you can even suggest something to read about how to develop a React app 2022 :)
Five Ways to Save Money as a Student
Tags: beginners, github, tutorial, discuss
Published: 2022-06-13 14:38:55

<u>**Savings on Shopping**</u>
If you are a student who shops online and wants to save some money, you should consider the great Indian sale and Flipkart Big Billion Days. You can get products at a huge discount, which will help you to save some money.

- Amazon Great Indian Festival Sale.
- Flipkart Big Billion Day Sale.



<u>**Developer**</u>
Now, If you are a student who loves to code, and you are a developer or want to be a developer, this will help you.

**1. GitHub Student Developer Pack**: You can opt for the GitHub Education pack and get a ton of paid software for free. Like You can get Bootstrap Studio for free, You can get three free domains from big domain providers like Namecheap, .tech, and name.com. The GitHub education pack has around 200k$+ amount of services, and everything is free for use.

**2. AWS Educate:** Through AWS Educate, students have access to content developed to skill up for cloud careers in growing fields. AWS Educate also connects companies hiring cloud skills to qualified student jobseekers with the AWS Educate Job Board.

**3. JetBrains:** You can use the paid version of JetBrains software for free using the JetBrains Educational Licenses. 

**4. G Suite:** If you are a student, you can get free Google Workspace benefits.

**5. Microsoft:** If you’re a student or teacher, you are eligible to get the online version of Microsoft Office for free, plus 1 TB of online storage. 

**6. Adobe:** You can get exclusive discounts of up to 70% on Adobe’s website for students.


<u>**Hosting**</u>
If you are looking for hosting then, you can get free credits from these hosting services:

1. Digital Ocean: 100$ credit when you signup.
 
2. Vultr: 50$ credit for free when you signup.
 
3. Linode: 100$ free credit when you signup.

**Travel :**

Some of the airline carriers in India provide discounts/extra luggage for students. 
 
1. Spicejet - https://corporate.spicejet.com/studentdiscountlanding.aspx
 
2. Indigo - https://www.goindigo.in/add-on-services/student-discount.html 

3. Air India - https://www.airindia.in/student-concession.htm 
 
4. Vistara- https://www.airvistara.com/in/en/vistara-exclusives/vistara-student-discount

<u>**Credit Card :**</u>
If used carefully, a credit card is an amazing tool for students. Students can use it to avail a lot of discounts/reward points during shopping on various online platforms. However, be careful while using a credit card as people holding credit cards are likely to spend more!

<u>**Entertainment**</u>
**1 Amazon Prime:** Youth Entertainment Offers on Amazon Prime can help you save big bucks.

**2 Spotify:** Listen to your favorite tracks on Spotify Premium with the best student discounts ever!
C++ Problems for Loop
Tags: cpp, programming, tutorial, beginners
Published: 2022-06-13 14:38:15

### Natija:

```
1 
2 4 
3 6 9 
4 8 12 16 
5 10 15 20 25 
6 12 18 24 30 36 
7 14 21 28 35 42 49 
8 16 24 32 40 48 56 64 
9 18 27 36 45 54 63 72 81 
10 20 30 40 50 60 70 80 90 100 
```

### Kod:

```cpp
#include <iostream>
using namespace std;

int main() {

  for(int i = 1; i <= 10; i++){
    for(int j = 1; j<=i; j++){
      cout << i*j << " ";
    }
    cout << "\n";
  }
  
  return 0;
  }
```


C++ bo'yicha masalalar ishlashda davom etamiz!

[Telegram](https://t.me/davron_js) ❤️ kanalga a'zo bo'lishni unutmang!
Tip Tuesday - What is your tech tip for tuesday?
Tags: discuss, programming, browsers, techtips
Published: 2022-06-13 14:31:32

Here is a quick tip to kick of your week. What tips do you have ? 

![How to reopen closed browser tabs?](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2huos8vo8b46o4qfxssy.png)

[Source](https://www.instagram.com/p/CetjOBdJEjM/)
Set Mismatch
Tags: leetcode, dsa, theabbie
Published: 2022-06-13 14:31:02

You have a set of integers `s`, which originally contains all the numbers from `1` to `n`. Unfortunately, due to some error, one of the numbers in `s` got duplicated to another number in the set, which results in **repetition of one** number and **loss of another** number.

You are given an integer array `nums` representing the data status of this set after the error.

Find the number that occurs twice and the number that is missing and return _them in the form of an array_.

**Example 1:**

**Input:** nums = \[1,2,2,4\]
**Output:** \[2,3\]

**Example 2:**

**Input:** nums = \[1,1\]
**Output:** \[1,2\]

**Constraints:**

*   `2 <= nums.length <= 104`
*   `1 <= nums[i] <= 104`

**SOLUTION:**

    class Solution:
        def findErrorNums(self, nums: List[int]) -> List[int]:
            ctr = set()
            n = len(nums)
            for i in range(1, n + 1):
                ctr.add(i)
            for num in nums:
                if num in ctr:
                    ctr.remove(num)
                else:
                    dup = num
            return [dup, list(ctr)[0]]
I want to build a video recording app
Tags: help
Published: 2022-06-13 14:26:21

Hi guys, so I create content sometimes and I am really frustrated with the YouTube app for creating Shorts.

So I would record a Short and it will give me an error when I try to upload it every third video. 

It will continue to give me an error for 5-10 mins before I can record another Short.

I can't use TikTok and I don't like Instagram's camera. 

Please let me know if there's one similar on the market for iOS. 

If not I'd create one with React Native preferably or Swift if it comes to that.
Music Monday — What are you listening to? (June 13)
Tags: watercooler, discuss, music
Published: 2022-06-13 14:14:16

_cover image source: [colorlessmidnight](https://colorlessmidnight.tumblr.com/post/136301212198/black-white)_

In this weekly series, folks can chime in and drop links to whatever it is they've been listening to recently + browse others suggestions.

If you like talking about music, consider following the org [#music discussions](https://dev.to/music-discussions) for more conversations about music!

{% embed https://dev.to/music-discussions %}

Also noteworthy, my friend @duxtech has a Spanish speaking version of this series [here](https://dev.to/duxtech/series/17890) in case you'd like to chime in there as well. 🙌

***

So, what have y'all been listening to today? _Note: you can embed a link to your song on most platforms using the following syntax `{% embed https://... %}`._

I look forward to listening to y'all's suggestions! 👂 🎶
Countdown to js13kGames 2022
Tags: competition, js13k, countdown, javascript
Published: 2022-06-13 14:25:57

---
title: Countdown to js13kGames 2022
published: true
date: 2022-06-13 14:14:10 UTC
tags: competition,js13k,countdown,javascript
canonical_url: https://medium.com/js13kgames/countdown-to-js13kgames-2022-fe9415fac98c
cover_image: https://cdn-images-1.medium.com/max/1024/1*JRD4r4VkX8ILgmWY0oxYyQ.jpeg
---

This year’s countdown to [js13kGames](https://js13kgames.com/), the online competition for Web Game Developers running yearly since 2012, is starting exactly two months before August 13th.

Comparing that to recent years ([April 30th](https://medium.com/js13kgames/countdown-to-js13kgames-2019-1b3d989f727f) in 2019, [June 26th](https://medium.com/js13kgames/countdown-to-js13kgames-2020-1482bec61577) in 2020, and [July 13th](https://medium.com/js13kgames/countdown-to-js13kgames-2021-e616ba372d9a) in 2021), it seems this one is right in the middle.

The 2022 edition will be our **eleventh** (!) already, which I think is quite impressive on its own. We do have plenty in store for this year, as we aim to improve the overall experience every single time, but since many of the new things are not yet confirmed we’ll wait with the official announcements till they are.

#### We need your help!

This doesn’t mean you can’t help already! As every year, **we are open to welcome new experts, judges, prizes, categories, partners** , and everyone who would like to **help make the competition better** , promote it though their communities and introduce new folks to our wonderful bunch, and a lot more. If you can assist with any of the above, please [reach out](https://js13kgames.com/#contact) - thanks!

Ps. Interested in being up-to-date with everything that’s coming? Make sure to [follow us on Twitter](https://twitter.com/js13kGames) and [join our Slack channel](https://slack.js13kgames.com/).
Do you have some story when you reported an issue to the product and it was fixed?
Tags: discuss
Published: 2022-06-13 14:07:23

Hey guys! Two years ago I found an issue on GitHub with contribution graph and I wanted to report this. The answer from support team was something like "Thank you! We'll take a look" and after few days the issue was closed, but the bug wasn't fixed. One week later I even forgot that I've reported something. I was living normal life, but after about 6 month I've got a mail from GitHub Support team. They told me that they've fixed the issue and just want to let me know.

I was confused, because I've never had that experience before, when company remember about you and your report and share feedback with you. It motivated me to report more issues, when I see something.

But what's the point of this post? I want to know if you have any story like this that inspired you to report issues, or some stories when you was happy after the talk with Support teams. I'm ready to listen anything 😍