Skip to content

Instantly share code, notes, and snippets.

View restart916's full-sized avatar

Yongsang Lee restart916

View GitHub Profile
@restart916
restart916 / gist:aaab7d208ab739c1f37cf4354a9880cb
Created June 4, 2017 10:19
backBaekjoon_online_judge_2309
import sys
from random import shuffle
inputs = []
a = sys.stdin.readlines()
for i in range(len(a)):
b = int(str(a[i]).replace("\n", ""))
inputs.append(b)
inputs.sort()
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
<?php
function test($input)
{
$inputArr = str_split($input);
$result = [];
array_push($result, [
'char' => $inputArr[0],
'count' => 0
]);
@restart916
restart916 / problem_02.php
Last active November 29, 2017 03:21
problem_02
<?php
// your code goes here
function find($arr, $findValue)
{
$head = 0;
$tail = count($arr) - 1;
while(1) {
@restart916
restart916 / problem.js
Created June 19, 2019 21:03
20190619_leetcode_1_TwoSum
/**
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
var twoSum = function(nums, target) {
for (let i in nums) {
let first = nums[i]
let searchVal = target - first;
@restart916
restart916 / problem.js
Created June 19, 2019 21:29
20190619_leetcode_2_AddTwoNumbers
/**
* Definition for singly-linked list.
* function ListNode(val) {
* this.val = val;
* this.next = null;
* }
*/
/**
* @param {ListNode} l1
* @param {ListNode} l2
@restart916
restart916 / problem.js
Created June 19, 2019 21:38
20190619_leetcode_771_JewelsandStones
/**
* @param {string} J
* @param {string} S
* @return {number}
*/
var numJewelsInStones = function(J, S) {
let count = 0
sMap = {}
@restart916
restart916 / problem.js
Created June 19, 2019 22:09
20190619_leetcode_852_PeakIndexinaMountainArray
/**
* @param {number[]} A
* @return {number}
*/
var peakIndexInMountainArray = function(A) {
let maxIndex = 0;
let index = 0;
A.reduce((a,c) => {
index++;
if (a < c) { maxIndex = index; }
@restart916
restart916 / problem.js
Created June 20, 2019 20:43
20190619_leetcode_1005_MaximizeSumOfArrayAfterKNegations
/**
* @param {number[]} A
* @param {number} K
* @return {number}
*/
var largestSumAfterKNegations1 = function(A, K) {
A.sort((a, b) => {return a - b})
while(K) {
let val = A.shift()
@restart916
restart916 / problem.js
Created June 29, 2019 09:39
20190629_leetcode_445_AddTwoNumbersII
/**
* Definition for singly-linked list.
* function ListNode(val) {
* this.val = val;
* this.next = null;
* }
*/
/**
* @param {ListNode} l1
* @param {ListNode} l2