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, { useState, Fragment } from "react" | |
| export default function Counter(params) { | |
| const [count, setCount] = useState(0); | |
| return ( | |
| <div> | |
| <p>You clicked {count} times</p> | |
| <button onClick={() => setCount(count + 1)}> | |
| Click Me |
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
| #include <stdio.h> | |
| int main() | |
| { | |
| printf("Hello world!\n"); | |
| } |
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
| #include <stdio.h> | |
| void main(void) | |
| { | |
| printf("Hello Void\n"); | |
| } |
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
| #include <stdio.h> | |
| int main() | |
| { | |
| printf("Hello world!\n"); | |
| } |
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
| #include <stdio.h> | |
| int BreakingConvention(void) | |
| { | |
| printf("I won't compile\n"); | |
| } |
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 solveWorldPeace(worldPeace) { | |
| if (!worldPeace) { | |
| worldPeace = 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
| // 1. merge takes an already sorted left half and already sorted right half of the original array. | |
| const merge = (left, right) => { | |
| let resultArr = []; | |
| let leftIndex = 0; | |
| let rightIndex = 0; | |
| // 2. merge crawls over these arrays creating a resulting array from the smallest values until either the left or right array is empty. | |
| while ((leftIndex < left.length, rightIndex < right.length)) { | |
| if (left[leftIndex] < right[rightIndex]) { | |
| resultArr.push(left[leftIndex]); |
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
| void merge(int arr[], int startIndex, int endIndex) | |
| { | |
| // 1. calculate the middle index | |
| int midIndex = startIndex + ((endIndex - startIndex) / 2); | |
| // 2. determine left array size | |
| int leftArrSize = midIndex - startIndex + 1; | |
| // 3. determine right array size | |
| int rightArrSize = endIndex - midIndex; | |
| // 4. initialize left and right arrays |
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
| void mergeSort(int arr[], int leftIndex, int rightIndex) | |
| { | |
| // 1. If the array has < 1 element do nothing. otherwise: | |
| if (leftIndex < rightIndex) | |
| { | |
| // 2. determine the middle index of the array | |
| int midIndex = leftIndex + ((rightIndex - leftIndex) / 2); | |
| // 3. mergeSort the left half of the array | |
| mergeSort(arr, leftIndex, midIndex); | |
| // 4. mergeSort the left half of the array |
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
| const initialActions = { | |
| bad: "bad", | |
| fearful: "fearful", | |
| angry: "angry", | |
| disgusted: "disgusted", | |
| sad: "sad", | |
| happy: "happy", | |
| surprised: "surprised" | |
| }; |
OlderNewer