This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function maxChar(str) { | |
const arr = str.split(""); | |
// map letters to total number of occurences | |
const map = arr.reduce((acc, letter) => { | |
if (letter.trim()) { | |
acc.set(letter, (acc.get(letter) || 0) + 1) | |
} | |
return acc; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findShortestSubArray(nums) { | |
// Elements is a map of key => elementInfo | |
// with key being each of the elements in the array | |
// and elementInfo being the object with properties count, leftIndex, rightIndex for | |
// one particular element in the array | |
let degree = 0 | |
const elementsInfoHighestCount = new Map() | |
let subArray = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"outDir": "./dist/", | |
"jsx": "react", | |
"sourceMap": true, | |
"noImplicitAny": true, | |
"module": "commonjs", | |
"target": "es6", | |
"noUnusedLocals": true, | |
"noImplicitReturns": true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>React Hooks + Redux + Typescript</title></head> | |
<body> | |
<div id="root"></div> | |
<script src="./src/index.tsx"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
const App: React.FC = () => ( | |
<div>Hello World!</div> | |
); | |
export default App; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import { render } from "react-dom"; | |
import App from "./components/App"; | |
render( | |
<App />, | |
document.getElementById("root"), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"presets": [ | |
"@babel/preset-react", | |
"@babel/preset-env" | |
], | |
"plugins": [ | |
"@babel/plugin-proposal-class-properties" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { addTodo } from './helper' | |
describe('addTodo', () => { | |
it('should add todo to the list', () => { | |
const startTodos = [ | |
{ id: 1, name: 'one', isComplete: false }, | |
{ id: 2, name: 'two', isComplete: false } | |
] | |
const newTodo = { id: 3, name: 'three', isComplete: false } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* addTodo | |
* | |
* @param {Array} list | |
* @param {Object} item | |
*/ | |
export const addTodo = (list, item) => [item, ...list] | |
/** | |
* generateId |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react" | |
import styled from "styled-components" | |
import PropTypes from "prop-types" | |
import TodoItem from "./TodoItem" | |
const StyledUl = styled.ul` | |
padding: 0; | |
` | |
const TodoList = props => { |
NewerOlder