Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions HamSungJun/Solution_1518.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function restoreString (s: string, indices: number[]): string {
const strArray: string[] = new Array(s.length)
for (let i = 0; i < indices.length; i++) {
const nextIdx = indices[i]
strArray[nextIdx] = s[i]
}
return strArray.join('')
};
24 changes: 24 additions & 0 deletions HamSungJun/Solution_1603.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class ParkingSystem {
carSlots = new Array(3).fill(0)
constructor (big: number, medium: number, small: number) {
this.carSlots[0] = big
this.carSlots[1] = medium
this.carSlots[2] = small
}

addCar (carType: number): boolean {
const nextSlot = carType - 1
if (this.carSlots[nextSlot] === 0) {
return false
} else {
this.carSlots[nextSlot] -= 1
return true
}
}
}

/**
* Your ParkingSystem object will be instantiated and called as such:
* var obj = new ParkingSystem(big, medium, small)
* var param_1 = obj.addCar(carType)
*/
6 changes: 6 additions & 0 deletions HamSungJun/Solution_1913.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function maxProductDifference (nums: number[]): number {
nums.sort((a, b) => {
return Number(a > b) - Number(a < b)
})
return (nums[nums.length - 1] * nums[nums.length - 2]) - (nums[0] * nums[1])
};