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 rotateImage(a: number[][]): number[][] { | |
swap(a) | |
reflext90(a) | |
return a | |
} | |
function swap(a:number[][]):void{ | |
let row=a.length; | |
let col=a[0].length; | |
for(let i = 0; i < row; i ++) { |
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
// / | |
// Definition for a binary tree node. | |
class TreeNode { | |
val: number | |
left: TreeNode | null | |
right: TreeNode | null | |
constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { | |
this.val = (val===undefined ? 0 : val) | |
this.left = (left===undefined ? null : left) | |
this.right = (right===undefined ? null : right) |
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 singleNumber(nums: number[]) { | |
let set= new Set<number>(); | |
for(let i of nums){ | |
if(set.has(i)){ | |
set.delete(i); | |
}else{ | |
set.add(i); | |
} | |
} |
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 singleNumber(nums: number[]):number { | |
let map=new Map<number,number>() | |
for (const num of nums) { | |
if (map.has(num)) { | |
const nextCount = map.get(num) as number + 1 | |
if (nextCount === 3) { | |
map.delete(num) | |
} else { | |
map.set(num, nextCount) | |
} |
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
/** | |
* Definition for a binary tree node. | |
* class TreeNode { | |
* val: number | |
* left: TreeNode | null | |
* right: TreeNode | null | |
* constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { | |
* this.val = (val===undefined ? 0 : val) | |
* this.left = (left===undefined ? null : left) | |
* this.right = (right===undefined ? null : right) |
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
/** | |
* Definition for singly-linked list. | |
* class ListNode { | |
* val: number | |
* next: ListNode | null | |
* constructor(val?: number, next?: ListNode | null) { | |
* this.val = (val===undefined ? 0 : val) | |
* this.next = (next===undefined ? null : next) | |
* } | |
* } |
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
/** | |
* Definition for singly-linked list. | |
* class ListNode { | |
* val: number | |
* next: ListNode | null | |
* constructor(val?: number, next?: ListNode | null) { | |
* this.val = (val===undefined ? 0 : val) | |
* this.next = (next===undefined ? null : next) | |
* } | |
* } |
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 config, { IConfig } from 'config'; | |
import mongoose, { Mongoose } from 'mongoose'; | |
import {EventEmitter} from"events" | |
const dbConfig: IConfig = config.get('App.database'); | |
import Logger from'./lib/logger' | |
class DatabaseService { | |
public static emitter: EventEmitter = new EventEmitter(); |
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 areFollowingPatterns(strings: string[], patterns: string[]): boolean { | |
for (let i: number = 0; i < strings.length; i++) { | |
if (patterns.indexOf(patterns[i]) !== strings.indexOf(strings[i])) return false; | |
} | |
return true; | |
} | |
or | |
function areFollowingPatterns(strings: string[], patterns: string[]): boolean { |
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 isOdd(l=3,r=9){ | |
let arr=[] | |
for(;l<=r;l++){ | |
if(l%2===0){ | |
continue; | |
} | |
arr.push(l) | |
} | |
return arr.map(item=>item) |