Post History
JavaScript (Node.js), 86 bytes X=>{Y=[];for(i in X)Y[i]=0,X.slice(i).map((a,b)=>a-X[b]?i='':Y[i]++);return Y.slice``} Attempt This Online! Using fancy notation, the time complexity is $...
Answer
#4: Post edited
- # [JavaScript (Node.js)](https://nodejs.org/), 86 bytes
- ```js
- X=>{Y=[];for(i in X)Y[i]=0,X.slice(i).map((a,b)=>a-X[b]?i='':Y[i]++);return Y.slice``}
- ```
[Attempt It Online!](https://ato.pxeger.com/run?1=fVLNboMwDJZ25ClyK1EDJaGd1lVhlz3DBIoilXYwRWIwAT1Ne5Jd0LQ91PY0Iz-UULTJkmPZ_vzZjt8_y-ox6z5y-nVqc-_m-yGm0WtCGd_lVe0KIEoQw4QJTgMU-00hjpkroP-cvrhuig6QRqkXswO_E3SxuJWJyyXc1Vl7qkuQaMB-_6ar_1zdt1nTNoACxjAivWCElSZGY47AauVFDBMU9CJ9AVorW1qYOwoZ9r6NyQVso-K9qKgRK7ru84nBakZiRSXzgJ12oSuHFq-KX_ASi5cM7BMOHBgS2fZIJ8fQqaFqMLSIsZkI6T2EVofbcVsSNoeYVU0gkzVfQsiZR84ChhXP9IjT2Vulr2cd_v2v4J-P5Y6jzkNdl7RodKzKpioyv6ie3Fz5IIT6mLpOv78)- Using fancy notation, the time complexity is
- $$\sum^n_{i=1}i$$
- ...or $O(n^2)$, which according to [this](https://www.freecodecamp.org/news/big-o-cheat-sheet-time-complexity-chart/) is horrible/worst haha.
- Definitely can be optimized, but good enough for my standards 🙂
- # [JavaScript (Node.js)](https://nodejs.org/), 86 bytes
- ```js
- X=>{Y=[];for(i in X)Y[i]=0,X.slice(i).map((a,b)=>a-X[b]?i='':Y[i]++);return Y.slice``}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=fVLNboMwDJZ25ClyK1EDJaGd1lVhlz3DBIoilXYwRWIwAT1Ne5Jd0LQ91PY0Iz-UULTJkmPZ_vzZjt8_y-ox6z5y-nVqc-_m-yGm0WtCGd_lVe0KIEoQw4QJTgMU-00hjpkroP-cvrhuig6QRqkXswO_E3SxuJWJyyXc1Vl7qkuQaMB-_6ar_1zdt1nTNoACxjAivWCElSZGY47AauVFDBMU9CJ9AVorW1qYOwoZ9r6NyQVso-K9qKgRK7ru84nBakZiRSXzgJ12oSuHFq-KX_ASi5cM7BMOHBgS2fZIJ8fQqaFqMLSIsZkI6T2EVofbcVsSNoeYVU0gkzVfQsiZR84ChhXP9IjT2Vulr2cd_v2v4J-P5Y6jzkNdl7RodKzKpioyv6ie3Fz5IIT6mLpOv78)
- Using fancy notation, the time complexity is
- $$\sum^n_{i=1}i$$
- ...or $O(n^2)$, which according to [this](https://www.freecodecamp.org/news/big-o-cheat-sheet-time-complexity-chart/) is horrible/worst haha.
- Definitely can be optimized, but good enough for my standards 🙂
#3: Post edited
- # [JavaScript (Node.js)](https://nodejs.org/), 86 bytes
- ```js
- X=>{Y=[];for(i in X)Y[i]=0,X.slice(i).map((a,b)=>a-X[b]?i='':Y[i]++);return Y.slice``}
- ```
- [Attempt It Online!](https://ato.pxeger.com/run?1=fVLNboMwDJZ25ClyK1EDJaGd1lVhlz3DBIoilXYwRWIwAT1Ne5Jd0LQ91PY0Iz-UULTJkmPZ_vzZjt8_y-ox6z5y-nVqc-_m-yGm0WtCGd_lVe0KIEoQw4QJTgMU-00hjpkroP-cvrhuig6QRqkXswO_E3SxuJWJyyXc1Vl7qkuQaMB-_6ar_1zdt1nTNoACxjAivWCElSZGY47AauVFDBMU9CJ9AVorW1qYOwoZ9r6NyQVso-K9qKgRK7ru84nBakZiRSXzgJ12oSuHFq-KX_ASi5cM7BMOHBgS2fZIJ8fQqaFqMLSIsZkI6T2EVofbcVsSNoeYVU0gkzVfQsiZR84ChhXP9IjT2Vulr2cd_v2v4J-P5Y6jzkNdl7RodKzKpioyv6ie3Fz5IIT6mLpOv78)
- Using fancy notation, the time complexity is
- $$\sum^n_{i=1}i$$
...or $O(n^2)$ (if I'm not wrong), which according to [this](https://www.freecodecamp.org/news/big-o-cheat-sheet-time-complexity-chart/) is horrible/worst haha.- Definitely can be optimized, but good enough for my standards 🙂
- # [JavaScript (Node.js)](https://nodejs.org/), 86 bytes
- ```js
- X=>{Y=[];for(i in X)Y[i]=0,X.slice(i).map((a,b)=>a-X[b]?i='':Y[i]++);return Y.slice``}
- ```
- [Attempt It Online!](https://ato.pxeger.com/run?1=fVLNboMwDJZ25ClyK1EDJaGd1lVhlz3DBIoilXYwRWIwAT1Ne5Jd0LQ91PY0Iz-UULTJkmPZ_vzZjt8_y-ox6z5y-nVqc-_m-yGm0WtCGd_lVe0KIEoQw4QJTgMU-00hjpkroP-cvrhuig6QRqkXswO_E3SxuJWJyyXc1Vl7qkuQaMB-_6ar_1zdt1nTNoACxjAivWCElSZGY47AauVFDBMU9CJ9AVorW1qYOwoZ9r6NyQVso-K9qKgRK7ru84nBakZiRSXzgJ12oSuHFq-KX_ASi5cM7BMOHBgS2fZIJ8fQqaFqMLSIsZkI6T2EVofbcVsSNoeYVU0gkzVfQsiZR84ChhXP9IjT2Vulr2cd_v2v4J-P5Y6jzkNdl7RodKzKpioyv6ie3Fz5IIT6mLpOv78)
- Using fancy notation, the time complexity is
- $$\sum^n_{i=1}i$$
- ...or $O(n^2)$, which according to [this](https://www.freecodecamp.org/news/big-o-cheat-sheet-time-complexity-chart/) is horrible/worst haha.
- Definitely can be optimized, but good enough for my standards 🙂
#2: Post edited
- # [JavaScript (Node.js)](https://nodejs.org/), 86 bytes
- ```js
- X=>{Y=[];for(i in X)Y[i]=0,X.slice(i).map((a,b)=>a-X[b]?i='':Y[i]++);return Y.slice``}
- ```
- [Attempt It Online!](https://ato.pxeger.com/run?1=fVLNboMwDJZ25ClyK1EDJaGd1lVhlz3DBIoilXYwRWIwAT1Ne5Jd0LQ91PY0Iz-UULTJkmPZ_vzZjt8_y-ox6z5y-nVqc-_m-yGm0WtCGd_lVe0KIEoQw4QJTgMU-00hjpkroP-cvrhuig6QRqkXswO_E3SxuJWJyyXc1Vl7qkuQaMB-_6ar_1zdt1nTNoACxjAivWCElSZGY47AauVFDBMU9CJ9AVorW1qYOwoZ9r6NyQVso-K9qKgRK7ru84nBakZiRSXzgJ12oSuHFq-KX_ASi5cM7BMOHBgS2fZIJ8fQqaFqMLSIsZkI6T2EVofbcVsSNoeYVU0gkzVfQsiZR84ChhXP9IjT2Vulr2cd_v2v4J-P5Y6jzkNdl7RodKzKpioyv6ie3Fz5IIT6mLpOv78)
- Using fancy notation, the time complexity is
- $$\sum^n_{i=1}i$$
...or $O(\frac12n(n+1))$ (if I'm not wrong), which according to [this](https://www.freecodecamp.org/news/big-o-cheat-sheet-time-complexity-chart/) is horrible/worst haha.- Definitely can be optimized, but good enough for my standards 🙂
- # [JavaScript (Node.js)](https://nodejs.org/), 86 bytes
- ```js
- X=>{Y=[];for(i in X)Y[i]=0,X.slice(i).map((a,b)=>a-X[b]?i='':Y[i]++);return Y.slice``}
- ```
- [Attempt It Online!](https://ato.pxeger.com/run?1=fVLNboMwDJZ25ClyK1EDJaGd1lVhlz3DBIoilXYwRWIwAT1Ne5Jd0LQ91PY0Iz-UULTJkmPZ_vzZjt8_y-ox6z5y-nVqc-_m-yGm0WtCGd_lVe0KIEoQw4QJTgMU-00hjpkroP-cvrhuig6QRqkXswO_E3SxuJWJyyXc1Vl7qkuQaMB-_6ar_1zdt1nTNoACxjAivWCElSZGY47AauVFDBMU9CJ9AVorW1qYOwoZ9r6NyQVso-K9qKgRK7ru84nBakZiRSXzgJ12oSuHFq-KX_ASi5cM7BMOHBgS2fZIJ8fQqaFqMLSIsZkI6T2EVofbcVsSNoeYVU0gkzVfQsiZR84ChhXP9IjT2Vulr2cd_v2v4J-P5Y6jzkNdl7RodKzKpioyv6ie3Fz5IIT6mLpOv78)
- Using fancy notation, the time complexity is
- $$\sum^n_{i=1}i$$
- ...or $O(n^2)$ (if I'm not wrong), which according to [this](https://www.freecodecamp.org/news/big-o-cheat-sheet-time-complexity-chart/) is horrible/worst haha.
- Definitely can be optimized, but good enough for my standards 🙂
#1: Initial revision
# [JavaScript (Node.js)](https://nodejs.org/), 86 bytes ```js X=>{Y=[];for(i in X)Y[i]=0,X.slice(i).map((a,b)=>a-X[b]?i='':Y[i]++);return Y.slice``} ``` [Attempt It Online!](https://ato.pxeger.com/run?1=fVLNboMwDJZ25ClyK1EDJaGd1lVhlz3DBIoilXYwRWIwAT1Ne5Jd0LQ91PY0Iz-UULTJkmPZ_vzZjt8_y-ox6z5y-nVqc-_m-yGm0WtCGd_lVe0KIEoQw4QJTgMU-00hjpkroP-cvrhuig6QRqkXswO_E3SxuJWJyyXc1Vl7qkuQaMB-_6ar_1zdt1nTNoACxjAivWCElSZGY47AauVFDBMU9CJ9AVorW1qYOwoZ9r6NyQVso-K9qKgRK7ru84nBakZiRSXzgJ12oSuHFq-KX_ASi5cM7BMOHBgS2fZIJ8fQqaFqMLSIsZkI6T2EVofbcVsSNoeYVU0gkzVfQsiZR84ChhXP9IjT2Vulr2cd_v2v4J-P5Y6jzkNdl7RodKzKpioyv6ie3Fz5IIT6mLpOv78) Using fancy notation, the time complexity is $$\sum^n_{i=1}i$$ ...or $O(\frac12n(n+1))$ (if I'm not wrong), which according to [this](https://www.freecodecamp.org/news/big-o-cheat-sheet-time-complexity-chart/) is horrible/worst haha. Definitely can be optimized, but good enough for my standards 🙂