File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Algorithm/BruteForce/BOJ_3040_백설공주와일곱난쟁이 Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ const fs = require ( "fs" ) ;
2
+ const filePath =
3
+ process . platform === "linux" ? "/dev/stdin" : "./Z_Test/input.txt" ;
4
+ let input = fs . readFileSync ( filePath ) . toString ( ) . trim ( ) . split ( "\n" ) ;
5
+
6
+ const arr = input . map ( ( item ) => + item ) ;
7
+
8
+ const solution = ( arr ) => {
9
+ left = 0 ;
10
+ right = 0 ;
11
+ const heightSum = arr . reduce ( ( cur , acc ) => cur + acc ) ;
12
+
13
+ while ( right < arr . length ) {
14
+ if ( right === arr . length - 1 ) {
15
+ left += 1 ;
16
+ right = left ;
17
+ }
18
+
19
+ right += 1 ;
20
+ if ( heightSum - arr [ left ] - arr [ right ] === 100 ) {
21
+ arr . map ( ( item , index ) => {
22
+ if ( index !== right && index !== left ) {
23
+ console . log ( item ) ;
24
+ }
25
+ } ) ;
26
+ break ;
27
+ }
28
+ }
29
+ } ;
30
+
31
+ solution ( arr ) ;
Original file line number Diff line number Diff line change
1
+ 8
2
+ 6
3
+ 5
4
+ 1
5
+ 37
6
+ 30
7
+ 28
8
+ 22
9
+ 36
You can’t perform that action at this time.
0 commit comments