teleren/devto huggingface dataset:
Linked List Partitioning
Tags: algorithms, java, 100daysofcode, programming
Published: 2021-12-22 20:23:14

# [Description](https://binarysearch.com/problems/Linked-List-Partitioning)

You are given a singly linked list `node` and an integer `k`. Order the linked list so that all nodes whose values are less than `k` come first, all nodes whose values are equal to `k` next, and then other nodes last.

The relative ordering of the nodes should remain the same.

Bonus: Can you do it in \mathcal{O}(n)O(*n*) time and \mathcal{O}(1)O(1) space?

**Constraints:** 

- `n ≤ 100,000` where `n` is the number of nodes in `node`

## Example 1

### Input

```
node = [3, 2, 1, 2]
k = 2
```

### Output

```
[1, 2, 2, 3]
```

---

# Intuition

build 3 pointers to store smaller, equal and bigger nodes

you need to take care about the last node, you need to set the next node to null

# Implementation

```java
import java.util.*;

/**
 * class LLNode {
 *   int val;
 *   LLNode next;
 * }
 */
class Solution {
    public LLNode solve(LLNode node, int k) {
        LLNode smallerDummy = new LLNode(), equalDummy = new LLNode(), biggerDummy = new LLNode();
        LLNode smaller = smallerDummy, equal = equalDummy, bigger = biggerDummy;
        while (node != null) {
            if (node.val < k) {
                smaller.next = node;
                smaller = smaller.next;
            } else if (node.val == k) {
                equal.next = node;
                equal = equal.next;
            } else {
                bigger.next = node;
                bigger = bigger.next;
            }
            node = node.next;
        }
        smaller.next = equalDummy.next;
        equal.next = biggerDummy.next;
        bigger.next = null;
        return smallerDummy.next;
    }
}
```

## Time Complexity

- Time: O(n)
- Space: O(1)
Important Math methods
Tags: javascript, webdev, beginners, programming
Published: 2021-12-22 20:11:27

**1. <u>Math.min</u>(value0, value1, ... , valueN)**
The Math.min( ) method is used to find the lowest value in a list of arguments. Have a look at the example below:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2yx65cleyaalgoz6ylp0.png)

**2. <u>Math.max</u>(value0, value1, /* ... ,*/ valueN)**
The Math.max( ) method is used to find the highest value in a list of arguments. Have a look at the example below:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfr6g4fxxi3l4ehdls62.png)

**3. <u>Math.round</u>(a number value)**
The Math.round(x) method returns the value of a number x rounded to its nearest integer:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ofid078nc48shz16vllu.png)

**4. <u>Math.sqrt</u>(a number value)**
The Math.sqrt(x) is used to return the square root of a number x. If the value of x is negative, Math.sqrt() returns NaN. Have a look at the example below:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5v9uyl11v1jemitrn8es.png)

**5. <u>Math.pow</u>(base, exponent)**
The Math.pow(x, y) returns the value of x to the power of y. If the base is negative and the exponent is not an integer, the result is NaN. Let’s have a look at the below example:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/asqnk16qzhhqrtpzmpr9.png)

**6. <u>Math.floor</u>(a number value)**
The Math.floor(x) returns the value of x rounded down to its nearest integer. Math.floor(null) returns 0, not a NaN.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9c5zjb8zp815qo6vtv78.png)

**7. <u>Math.random</u>( )**
The Math.random() returns a random number between 0 and 1. It’s often used to extract random elements from an array.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f73b6dwexhaq2mg86heh.png)

**8. <u>Math.ceil</u>(a number value)**
The Math.ceil(x) returns the value of x rounded up to its nearest integer:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1nje1sbh4w3b1ifddmgm.png)
Generate NuGet Package with Octopus CLI
Tags: dotnet, octopus, beginners
Published: 2021-12-22 20:01:43

### Prerequisites

* Visual studio code

### Create a simple dotnet mvc web app

* dotnet command to check latest framework version
`dotnet --version`

* cli command to create a new mvc web app along with version specification when you have multiple dotnet frameworks installed locally and you dont want to use the latest one :)-

`dotnet new mvc --language C# --framework net5.0`

### Installing the octopus cli

* If you want to install Octopus CLI make sure you install it globally using the command-

`dotnet tool install Octopus.DotNet.Cli --global`

### Build / Run / Publish

* Command to build project-

`dotnet build`

* Command to run project-

`dotnet run`

> Check app is up and running using the link generated on the console

* Command to publish the project

> first `ctrl+c` to stop running the project
> run following command to publish project to custom directory-
`dotnet publish -o <foldername>`

### Generate the Nuget Package

* Command to generate the nuget package from cli-

`dotnet-octo pack --id=CodeWithAnil -outFolder=ArtifactFolder --basePath=Publish`

>--id=projectname
>--outFolder=folder where to create the nuget package
>--basePath=folder where you published your webapp or api
Facebook upgrade 11 lite
Published: 2021-12-22 20:00:54

আমাদের সবার প্রিয় ১১ লাইট এর আপডেট  ভার্সন ডাওনলোড করে নিন..  ২০২১ এর আপডেট ১১  ফেইসবুক লাইট 

সবার সাথে সেয়ার করবেন 😚😚

কিছুমেসেঞ্জার ৩ টা সাথে আছে। 
🙉

প্রচারের উদ্দেশ্যে আপনাকে দিলাম আপনি ও দিতে পারেন আপনার ফেন্ড লিস্ট এর সবাই কে.
ধন্যবাদ 

https://www.anonbar.com/2021/10/facebook-11-lite-upgrade-apk-by.html
Dec 22: Dev Holidays Guide ⛄️
Tags: stateofdevs, bahhumbugtip, mentalhealth, tips
Published: 2021-12-22 19:56:05

Bah Humbug Tips are my own way of coping & recovering from burnout & holiday stress.

###🎄  Today's Bah Humbug Tip of the Day. 
{% twitter 1473670186670563333 %}

######🎁 Today's Options 
{% twitter 1473670188184702982 %}

You can find more tips here & on [Twitter](https://twitter.com/stateofdevs). Let me know in the comments if any of these tips helps.

> If you're struggling w/ burnout & open to sharing your story, please [take the State Of Devs survey](https://stateofdevs.com/helps/dev). 🗳 Thanks!
After 1 year working on my app, I'm giving away a free month of personal coaching for creators and founders 🎉
Tags: showdev, startup, career, management
Published: 2021-12-22 19:53:53

TL;DR: check it out [here](https://www.goalswon.com/deals/new-year-gift), use the coupon code NEWYEAR22

Hi everyone! I'm Joel, the founder of [GoalsWon](https://www.goalswon.com/), masters in Computer Science and also studied psychology.

After a year of iterating the app with real clients, we are now celebrating our full release! 🎉

To mark this milestone and as it’s the new year, we’re offering **a free month of personal coaching** to start 2022 on a high note!

To take advantage of this offer:
- Go to the our [landing page](https://www.goalswon.com/deals/new-year-gift)
- Click Redeem Your Free 30 Day Pass
- Enter the promo code NEWYEAR22

![GoalsWon logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/doi5m5o5tg8s1nuwjhwy.png)

[GoalsWon](https://www.goalswon.com/) connects you with an experienced human coach giving you personalized accountability for your projects, your health, your life.

Set your goals and habits that drive you to your long term targets. Your coach will review results and keep you accountable.

![How it works 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45hbw2f3ia5v2k6kb8ms.png)


![How it works 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1e5tzf8wuxcm8ytf91as.png)


![How it works 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xk4jowjinka9bzew6shs.png)

How it works: you’ll be assigned an accountability coach from our team who you’ll connect with in the app.

Your coach, an experienced accountability professional, will get to know you, your background and the areas you'd like to work on, agreeing short and longer term targets. Then your day-to-day support begins:    

1. Each day you'll be prompted to enter your top daily goals. 
2. At the end of the day, you mark which goals and habits you accomplished with any notes, pictures or videos. 
3. Your coach will check in to see how you did, give you feedback and help plan the next steps.

They'll also help you implement science based behaviour techniques to drive lasting change.
You can use it to keep track of your daily goals and exchange feedback, advice or support with your assigned coach.

I’d love to hear your thoughts!

[![New Year offer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pj7mhecuy44x0stlcxh3.png)](https://www.goalswon.com/)
Learn AWS for FREE from top 10 Resources
Tags: aws, cloud, free
Published: 2021-12-22 19:09:23

Let's see what are the best 10 resources for learning AWS:

1. [AWS from QWIKLABS](https://aws.qwiklabs.com/)

2. [Edx from AWS](https://www.edx.org/school/aws)

3. [AWS Training and Certification](https://www.aws.training/)

4. [AWS Homepage](https://aws.amazon.com/getting-started/hands-on)

5. [YouTube Channel](https://www.youtube.com/channel/UCd6MoB9NC6uYN2grvUNT-Zg)

6. [AWS Free Tier](https://aws.amazon.com/free) 

7. [AWS Well-Architected Framework](https://wa.aws.amazon.com/index.en.html)

8. [The Official AWS Podcast](https://aws.amazon.com/podcasts/aws-podcast) 

9. [AWS Documentation](https://docs.aws.amazon.com/index.html)

10. Twitter Handles to follow:

- [Andrew Brown](https://twitter.com/andrewbrown) : founder of ExamPro and AWS Hero, creating awesome certification guides and Twitter Spaces for everything cloud

- [Alex DeBrie](https://twitter.com/alexbdebrie): AWS Data Hero, creator of The DynamoDB Book and the oracle for everything Serverless

- [Danny](https://twitter.com/dannysteenman) :  Cloud Consultant, Technical Writer, AWS Certification Guru helping cloud starters at all places

- [Marcia Villalba 🦄](https://twitter.com/mavi888uy): Content Creator by heart with a great YouTube Channel for AWS learnings focused on Serverless.

- [Simon ☁️](https://twitter.com/simonholdorf):  Multi-Cloud Expert, Fullstack Engineer, and Technical Writer posting learnings about AWS, Azure, and GCP.

11. Bonus:
Twitter Thread:

- [AWS 1x1 - 𝗦𝟯](https://twitter.com/tpschmidt_/status/1450158394233561093)

- [𝗔𝗪𝗦 𝟭𝘅𝟭 - 𝗦𝗤𝗦](uhttps://twitter.com/tpschmidt_/status/1455928446484455431)

- [AWS 1x1](https://twitter.com/tpschmidt_/status/1442880455179657219)

- [AWS 1x1 - 𝗟𝗮𝗺𝗯𝗱𝗮 ƛ](https://twitter.com/tpschmidt_/status/1449030467911569409)

- [AWS 1x1 - 𝗗𝘆𝗻𝗮𝗺𝗼𝗗𝗕](https://twitter.com/tpschmidt_/status/1448312256165556229)

- [AWS 1x1 - 𝗘𝗖𝗦](https://twitter.com/tpschmidt_/status/1458143015705489421)

- [AWS 1x1 - 𝗖𝗹𝗼𝘂𝗱𝗙𝗿𝗼𝗻𝘁](https://twitter.com/tpschmidt_/status/1458477202396303363)

- [AWS 1x1 - 𝗥𝗼𝘂𝘁𝗲 𝟱𝟯](https://twitter.com/tpschmidt_/status/1461725349952299012)

- [AWS 1x1 - 𝗔𝗣𝗜 𝗚𝗮𝘁𝗲𝘄𝗮𝘆
](https://twitter.com/tpschmidt_/status/1466079626749526021)
JSX
Tags: beginners, javascript, react, webdev
Published: 2021-12-22 17:52:02

JSX - JavaScript XML. It is simply a syntax extension of JS. It allows us to write HTML and JavaScript code together. 

Example:

```
const name = "Fahim Shahriar";
<h1>Today our special guest is {name} </h1>
```
As simple as that! 😎

**Concept**: Suppose we want to render a HTML element - h1. We write our HTML code like: `<h1>Hello world!</h1>`. Then we see a heading in our browser. But under the hood browser takes the element in it's DOM and create element in another way. 
Example: 
```
let h1 = document.createElement("h1");
h1.innerHTML = "Hello World";
domContainer.appendChild(h1);
```
We write these code in HTML like: `<h1>Hello World</h1>`. HTML syntax made it easy for us.

React is working in the same way. It creates element KINDA same way and creates a separate DOM called virtual DOM. 

We creates HTML element with HTML syntax and React provides JSX syntax for create React elements.

For understand the JSX file, JS uses Transpiler. Ex: Babel. Behind the scene Babel transpiles this JSX syntax in vanilla javascript.    

**JSX Expression:**
JSX supports expression in pure JavaScript syntax. A JSX expression starts with an HTML-like open tag and ends with the corresponding closing tag. JSX tags support the XML self-close syntax so we can optionally leave the closing tag off. JSX expressions evaluate to ReactElements.

**Another JSX code example:**
suppose you have an array. And you want to render as a list item on your webpage. You can do it in a supercool way with jsx.

```
import React from "react";
const nameList = [ "Tom", "John", "Clerk", "Harry"]
const app = () {
    return (
      <ul>
        {
          nameList.map(name => <li>{name}</li>)
        }
      </ul>
);
```

Isn't it super cool?! 🤘
String Methods JavaScript 
Tags: javascript
Published: 2021-12-22 18:17:30

**<u>JavaScript String Length:
</u>**The **length **property returns the length of a string: 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgmxd8syonjfk56wbq1u.png)



**<u>Extracting String Parts:</u>**
There are 3 methods of extracting a part of a string:

- slice(beginIndex, endIndex)
- substring(beginIndex, endIndex)
- substr(beginIndex, length)

**<u>JavaScript String slice()
</u>**
slice() extracts a section of a string and returns it as a new string, without modifying the original string. The method takes 2 parameters: the start position, and the end position (end not included).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iwe8fyfci4l9ktivr4eo.png)

If a parameter is negative, the position is counted from the end of the string.

**<u>Converting the text to Uppercase & or Lowercase</u>**
toUpperCase() returns the passed string in upper case.
toLowerCase() returns the passed string in lower case

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6of0uecmepg9pp1bdzsh.png)

**<u>Removing whitespace from the string</u>**
trim()	removes whitespace from the strings.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fohrya4z5hk00cokctf.png)

**<u>Converting the string to an array</u>**
split()	converts the string to an array of strings.
If the separator is omitted, the returned array will contain the whole string in index [0].

If the separator is "", the returned array will be an array of single characters:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4fqphg54p9twfdz9ywe.png)

**<u>Replacing String Content
</u>**
replace() replaces a string with another string.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/diijpiek9ana0v2wpvqi.png)

**<u>Check if a string includes a world</u>**
The includes() method returns true if a string contains a specified string. Otherwise it returns false. The includes() method is case sensitive.
string.includes(searchvalue, start) Start = Optional. The position to start from. Default value is 0.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v3sduqgh0bcukz5b55it.png)
**<u>Searching the index position of a word in a string</u>**
The search() method searches a string for a value. the method returns the index (position) of a match. It returns -1 if no match is found. The search() method is case sensitive. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6jxe2dk7csltn0new7tn.png)
All About Virtual Dom and Context API
Published: 2021-12-22 17:57:39

## Virtual Dom

In React, the virtual DOM (Document Object Model) is a programming concept in which a library like ReactDOM keeps an ideal, or "virtual," version of a user interface in memory and syncs it with the "actual" DOM. This is referred to as reconciliation.
Every virtual DOM object is modified when you render a JSX element. After the virtual DOM has been changed, React compares it to a virtual DOM snapshot obtained before the modification.

React detects which virtual DOM objects have changed by comparing the new virtual DOM to a version previous to the update. This process is called "diffing."
Once React has recognized which virtual DOM objects have changed, it updates the actual DOM with only those objects. React will rebuild your single checked-off list item in our previous example while leaving the rest of your list alone.

## Context API


**What is Context API**

With React v.16.3, the new React Context API allows us to transfer data through our component trees, allowing our components to communicate and exchange data at different levels. We'll look at avoiding prop drilling using React Context in this tutorial. First, we'll define prop drilling and why we should avoid it.
React context API: How it works?

**How Context API works?**
React.createContext() all you need to know must. It will provide you with a customer and a provider. The provider is a component that supplies the state to its children, as its name indicates. It will contain the "store" and serve as the parent of any components that may require it. A component that consumes and utilizes the state is known as a consumer.
React Updates in New Release
Published: 2021-12-22 17:55:51

React is the world’s most popular JavaScript framework, but it’s not cool because it’s popular. It’s popular because it’s cool. Most React introductions jump right into showing you examples of how to use React, and skip the “why”.

That’s cool. If you want to jump in and start playing with React right away, the official documentation has lots of resources to help you get started.

This post is for people who want an answer to the questions, “why React? Why does React work the way it works? What is the purpose of the API designs?”


Just like in my previous post, you don’t need to know this to be productive in React. I didn’t know this for years. Please don’t turn this into an interview question. In fact, this post is more about JavaScript than it is about React.

This blog is for a curious reader who wants to know why React works in a certain way. Are you that person? Then let’s dig in together.

This is a long journey. Buckle up. This post doesn’t have much information about React itself, but we’ll go through some aspects of new, this, class, arrow functions, prototype, __proto__, instanceof, and how those things work together in JavaScript. Luckily, you don’t need to think about those as much when you use React. If you’re implementing React though…



Refs make it possible to access DOM nodes directly within React. This comes in handy in situations where, just as one example, you want to change the child of a component. Let’s say you want to change the value of an <input> element, but without using props or re-rendering the whole component.

That’s the sort of thing refs are good for and what we’ll be digging into in this post.
Short Note of React
Tags: react, javascript, beginners
Published: 2021-12-22 17:49:56

_**React Js**_
React is an open-source JavaScript library which is used for building user interfaces based on UI components specifically for single-page applications. 

Some advantages of React are: 
- It is easy to learn.
- A virtual DOM is used in React.
- There are reusable components.
- It operates on a one-way data flow.
- SEO friendliness.

_**JSX**_
JSX is a JavaScript Extension Syntax which is used in React to easily write HTML and JavaScript together. It allows us to write HTML elements in JavaScript and place them in the DOM without any createElement()  or appendChild() methods. 
JSX converts HTML tags into react elements. It is faster than regular JavaScript.

_**Virtual DOM**_
Virtual DOM is a light-weight abstraction of the real DOM.  A virtual DOM object has the same properties as a real DOM. Manipulating the virtual DOM is much faster than the real DOM.
In React, once the virtual DOM has been updated, it compares the current version of the virtual DOM with the previous version of the virtual DOM. This process is called “diffing” and the diff algorithm does that process in react. So, once React knows which virtual DOM objects have changed, then React updates only those objects, in the real DOM.
JSX ( JavaScript XML)

Published: 2021-12-22 17:47:11

JSX Introduction
Today I will discuss an important but optional topic before starting work on React. Optional does not mean that you can skip it. Rather, everything I wrote later depended on it. So it is important for you too. Today we will discuss the JSX syntax.
In React's project, you will always see this type of code:
<h1> Hello Word!</h1>
This is actually called JSX. JSX syntax looks a lot like HTML. But neither HTML nor JavaScript's string. Rather, it is a syntax extension of JavaScript. It has been added for the benefit of developers.
Html code Full version of JSX:
“use strict”
React.creactElement(
“h1”,
null,
“Hello World!”
);
See how complex the code looks like a normal HTML code. You can also use this complex version in your React app. But who would use such a complex syntax to have such a well-arranged syntax? And so it is wise to use JSX.
Now the main task of JSX is to create an element of React which we will start using in the next episode. Moreover, although JSX is similar to HTML, it has some very good functionality. For example, if we want, we can insert JavaScript variables inside JSX:
 
import React from "react";
import ReactDOM from "react-dom";
 const variable = "anything you want";
 ReactDOM.render(<h1>My Name is <strong class="markup--strong markup--pre-strong">{variable}</strong></h1>,document.getElementById("root"));
 
Now you don't need to know how this code works, just know how to work with variables in JSX. You can call the function in the same way
 
import React from "react";
import ReactDOM from "react-dom";
 
<strong class="markup--strong markup--pre-strong">const aFunc = () => {
</strong><strong class="markup--strong markup--pre-strong"> return "Rafiuzzaman Sajib";
</strong><strong class="markup--strong markup--pre-strong">};
 
</strong>ReactDOM.render(<h1>My Name is {<strong class="markup--strong markup--pre-strong">aFunc()</strong>}</h1>, document.getElementById("root"));
 
In fact, you can write any JavaScript expression inside JSX
 
import React from "react";
import ReactDOM from "react-dom"; 
ReactDOM.render(<h1>My Name is {true ? 'rafiuzzaman sajib' : 'rafiuzzaman sajib'}</h1>, document.getElementById("root"));
 
In JSX you can also take attributes like HTML. Attributes do a different kind of work in React that we will see gradually. However, you can also take attributes in this way
 
<h1 anyName="anyvalue">Hello World!</h1>
Now you can insert JSX inside a variable and later you can use JSX by calling this variable wherever you want.

const  jsxVar = <h1> Hello World</h1>