This file contains 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
using System; | |
using System.IO; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
using System.Windows.Forms; | |
using System.Xml.Linq; | |
namespace saveAsXml | |
{ | |
public partial class Form1 : Form |
This file contains 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 meanAndVariance = (a, m, b) => ({"Mean": (a + 4 * m + b) / 6, "Standard Deviation": (b - a) / 6, "Variance": ((b - a) / 6) ** 2}); |
This file contains 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 removeDuplicates = (S) => S.match(/(.)\1/g) ? removeDuplicates(S.replace(/(.)\1/g, '')) : S; |
This file contains 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<iostream> | |
using namespace std; | |
// @params a is first number. | |
// @params b is second number. | |
// @params c is the upper limit of numbers. | |
int fobi(int a, int b, int c) { | |
int next = a + b; | |
if (next > c) return 0; | |
cout << next << " "; |
This file contains 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<iostream> | |
using namespace std; | |
main() | |
{ | |
int numbers[5] = { 10,1,53,5,8 }; | |
int length = sizeof(numbers) / sizeof(numbers[0]); | |
for (int i = 0; i < length; ++i) |
This file contains 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<iostream> | |
using namespace std; | |
main() | |
{ | |
int numbers[5] = { 10,1,53,5,8 }; | |
int length = sizeof(numbers) / sizeof(numbers[0]); | |
for (int i = 0; i < length; ++i) { |
This file contains 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<iostream> | |
using namespace std; | |
main() | |
{ | |
int numbers[5] = { 10,1,53,5,8 }; | |
int length = sizeof(numbers) / sizeof(numbers[0]); | |
for (int i = 1; i < length; ++i) { | |
int key = numbers[i]; |
This file contains 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 solution = (isBadVersion) => (n) => { | |
let left = 1, | |
right = n; | |
while (left < right) { | |
const middle = Math.floor(left + (right - left) / 2); | |
if (isBadVersion(middle)) right = middle; | |
else left = middle + 1; | |
} | |
return left; | |
}; |
This file contains 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 numJewelsInStones = (J, S) => { | |
let c = 0; | |
for (let i = 0; i < S.length; ++i) if (J.indexOf(S[i]) > -1) ++c; | |
return c; | |
}; |
This file contains 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 canConstruct = (ransomNote, magazine) => { | |
const dicMap = new Map(); | |
for (const c of magazine) dicMap.set(c, ~~dicMap.get(c) + 1); | |
for (const c of ransomNote) { | |
if (!dicMap.get(c)) return false; | |
dicMap.set(c, ~~dicMap.get(c) - 1); | |
} | |
return true; | |
}; |
OlderNewer