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
| /* | |
| Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. | |
| The overall run time complexity should be O(log (m+n)). | |
| Example 1: | |
| Input: nums1 = [1,3], nums2 = [2] | |
| Output: 2.00000 |
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
| /* | |
| Longest Substring Without Repeating Characters | |
| Example 1: | |
| Input: s = "abcabcbb" | |
| Output: 3 | |
| Explanation: The answer is "abc", with the length of 3. | |
| Example 2: |
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
| Given an array nums of distinct integers, return all the possible permutations. | |
| You can return the answer in any order. | |
| Example 1: | |
| Input: nums = [1,2,3] | |
| Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] | |
| Example 2: | |
| Input: nums = [0,1] |
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
| var prom = function(number) { | |
| return new Promise((resolve, reject) => { | |
| console.log('request start',number) | |
| setTimeout(() => { | |
| console.log('request finish') | |
| let ran = Math.random(); | |
| if (ran < 0.1) | |
| resolve(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
| # Basic configuration: datestamp e.g. YYYYMMDD | |
| DATE=$(date +"%Y%m%d") | |
| # Location of your backups (create the directory first!) | |
| BACKUP_DIR="/backup" | |
| # MySQL login details |
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 doubleAfter2Seconds(x) { | |
| return new Promise(resolve => { | |
| setTimeout(() => { | |
| resolve(x * 2); | |
| }, 2000); | |
| }); | |
| } | |
| async function addAsync(x) { | |
| const a = await doubleAfter2Seconds(10); |
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 doubleAfter2Seconds(x) { | |
| return new Promise(resolve => { | |
| setTimeout(() => { | |
| resolve(x * 2); | |
| }, 2000); | |
| }); | |
| } | |
| function addPromise(x){ | |
| return new Promise(resolve => { |
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
| var message = ""; | |
| promise1 = new Promise((resolve, reject) => { | |
| setTimeout(() => { | |
| message += "my"; | |
| resolve(message); | |
| }, 2000) | |
| }) | |
| promise2 = new Promise((resolve, reject) => { |
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
| var request = require("request"); | |
| var userDetails; | |
| function getData(url) { | |
| // Setting URL and headers for request | |
| var options = { | |
| url: url, | |
| headers: { | |
| 'User-Agent': 'request' | |
| } |
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
| var request = require("request"); | |
| var userDetails; | |
| function initialize() { | |
| // Setting URL and headers for request | |
| var options = { | |
| url: 'https://api.github.com/users/praveenmistry', | |
| headers: { | |
| 'User-Agent': 'request' | |
| } |
NewerOlder