File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @param {number[] } nums
3+ * @return {boolean }
4+ * O(nlog(n)) : 정렬 O(nlog(n)) + 탐색 O(n)
5+ */
6+ var containsDuplicate = function ( nums ) {
7+ const sortedNums = nums . toSorted ( ( a , b ) => a - b )
8+ for ( let i = 0 ; i < nums . length - 1 ; i ++ ) {
9+ if ( sortedNums [ i ] === sortedNums [ i + 1 ] ) {
10+ return true
11+ }
12+ }
13+ return false
14+ } ;
Original file line number Diff line number Diff line change 1+ /**
2+ * @param {number[] } nums
3+ * @param {number } target
4+ * @return {number[] }
5+ */
6+ var twoSum = function ( nums , target ) {
7+ for ( let i = 0 ; i < nums . length ; i ++ ) {
8+ for ( let j = i + 1 ; j < nums . length ; j ++ ) {
9+ if ( nums [ i ] + nums [ j ] === target ) {
10+ return [ i , j ] ;
11+ }
12+ if ( nums [ i ] + nums [ j ] > target ) {
13+ continue ;
14+ }
15+ }
16+ }
17+ return [ ] ;
18+ } ;
You can’t perform that action at this time.
0 commit comments