Skip to content

Instantly share code, notes, and snippets.

@restart916
Created July 1, 2019 08:02
Show Gist options
  • Save restart916/2f6beef7107aab38ba44fc11dc44c02f to your computer and use it in GitHub Desktop.
Save restart916/2f6beef7107aab38ba44fc11dc44c02f to your computer and use it in GitHub Desktop.
20190630_leetcode_599_MinimumIndexSumofTwoLists
/**
* @param {string[]} list1
* @param {string[]} list2
* @return {string[]}
*/
var findRestaurant = function(list1, list2) {
let findListIndex = 2000
let result = []
for (let first in list1) {
first = parseInt(first)
let firstItem = list1[first]
let second = list2.indexOf(firstItem)
console.log(firstItem, second, findListIndex)
if (second > -1) {
if (first + second < findListIndex) {
findListIndex = first + second
result = [firstItem]
} else if (first + second == findListIndex) {
result.push(firstItem)
}
}
}
return result
};
@restart916
Copy link
Author

일단 bf 로 다 풀어보았습니다. 원래 저기 list2.indexOf(firstItem) 대신에 findListIndex 변수써서 최대 findListIndex 만큼만 while 돌게 하면
그나마.. 덜 돌지 않을까 정도 생각했습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment