├── .idea
├── .gitignore
├── codeStyles
│ └── codeStyleConfig.xml
├── dbnavigator.xml
├── misc.xml
├── modules.xml
├── uiDesigner.xml
└── vcs.xml
├── HackerHankChallenges.iml
├── README.md
├── out
└── production
│ └── HackerHankChallenges
│ └── com
│ └── br
│ └── algoritmos
│ └── basic
│ ├── ArraySum.class
│ ├── CompareTheTriples.class
│ ├── DiagonalDifference.class
│ ├── DiskSpace.class
│ ├── FindThreeLargestNumbers.class
│ ├── PlusMinus.class
│ ├── Result.class
│ ├── SolveMeFirst.class
│ └── VeryBigSum.class
└── src
└── com
└── br
└── algoritmos
└── basic
├── ArraySum.java
├── CompareTheTriples.java
├── DiagonalDifference.java
├── DiskSpace.java
├── FindThreeLargestNumbers.java
├── PlusMinus.java
├── SolveMeFirst.java
└── VeryBigSum.java
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/dbnavigator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 | -
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/HackerHankChallenges.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HackerRankChallenges
2 |
3 | ### (pt) oi pessoal bem vindo ao repositório HackerRank Challenges :tada:
4 | O objetivo é deixar aqui alguns desafios completados no hacker hanck de algoritmos e estrutura de dados, escritos em Java 8
5 | E posteriormente eu vou fazer um vídeo de como cheguei nas resoluções, enjoy!
6 |
7 | ...
8 |
9 | ### (en) hi guys welcome to the HackerRank Challenges repository :tada:
10 | The goal is to leave here some challenges completed in the hacker hanck of algorithms and data structure, written in Java 8
11 | And later I will make a video of how I got to the resolutions, enjoy!
12 |
13 |
14 | | Challenge | Resolution
15 | | ------------- |:-------------:|
16 | | [SolveMeFrist](https://www.hackerrank.com/challenges/simple-array-sum/problem) | [SolvemeFirst.java](https://github.com/anabneri/HackerHankChallenges/blob/master/src/com/br/algoritmos/basic/SolveMeFirst.java)|
17 | | [ArraySum](https://www.hackerrank.com/challenges/simple-array-sum/problem) | [ArraySum.java](https://github.com/anabneri/HackerHankChallenges/blob/master/src/com/br/algoritmos/basic/ArraySum.java)|
18 | | [Compare the Triples](https://www.hackerrank.com/challenges/compare-the-triplets/problem?h_r=next-challenge&h_v=zen)| [CompareTheTriples.java](https://github.com/anabneri/HackerHankChallenges/blob/master/src/com/br/algoritmos/basic/CompareTheTriples.java) |
19 | | [DiagonalDifference](https://www.hackerrank.com/challenges/diagonal-difference/problem) | [DiagonalDifference.java](https://github.com/anabneri/HackerHankChallenges/blob/master/src/com/br/algoritmos/basic/DiagonalDifference.java)|
20 | | [PlusMinus](https://www.hackerrank.com/challenges/plus-minus/problem) | [PlusMinus.java](https://github.com/anabneri/HackerHankChallenges/blob/master/src/com/br/algoritmos/basic/PlusMinus.java)|
21 | | [VeryBigSum](https://www.hackerrank.com/challenges/a-very-big-sum/problem) | [VeryBigSum.java](https://github.com/anabneri/HackerHankChallenges/blob/master/src/com/br/algoritmos/basic/VeryBigSum.java)|
22 |
23 |
24 |
25 | #### Let's code :smiling_imp:
26 |
27 |
28 |
--------------------------------------------------------------------------------
/out/production/HackerHankChallenges/com/br/algoritmos/basic/ArraySum.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ananeridev/hacker-rank-challenges-solved/82f4d00c1e0185e4c9d5f52afdae1a633aa02452/out/production/HackerHankChallenges/com/br/algoritmos/basic/ArraySum.class
--------------------------------------------------------------------------------
/out/production/HackerHankChallenges/com/br/algoritmos/basic/CompareTheTriples.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ananeridev/hacker-rank-challenges-solved/82f4d00c1e0185e4c9d5f52afdae1a633aa02452/out/production/HackerHankChallenges/com/br/algoritmos/basic/CompareTheTriples.class
--------------------------------------------------------------------------------
/out/production/HackerHankChallenges/com/br/algoritmos/basic/DiagonalDifference.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ananeridev/hacker-rank-challenges-solved/82f4d00c1e0185e4c9d5f52afdae1a633aa02452/out/production/HackerHankChallenges/com/br/algoritmos/basic/DiagonalDifference.class
--------------------------------------------------------------------------------
/out/production/HackerHankChallenges/com/br/algoritmos/basic/DiskSpace.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ananeridev/hacker-rank-challenges-solved/82f4d00c1e0185e4c9d5f52afdae1a633aa02452/out/production/HackerHankChallenges/com/br/algoritmos/basic/DiskSpace.class
--------------------------------------------------------------------------------
/out/production/HackerHankChallenges/com/br/algoritmos/basic/FindThreeLargestNumbers.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ananeridev/hacker-rank-challenges-solved/82f4d00c1e0185e4c9d5f52afdae1a633aa02452/out/production/HackerHankChallenges/com/br/algoritmos/basic/FindThreeLargestNumbers.class
--------------------------------------------------------------------------------
/out/production/HackerHankChallenges/com/br/algoritmos/basic/PlusMinus.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ananeridev/hacker-rank-challenges-solved/82f4d00c1e0185e4c9d5f52afdae1a633aa02452/out/production/HackerHankChallenges/com/br/algoritmos/basic/PlusMinus.class
--------------------------------------------------------------------------------
/out/production/HackerHankChallenges/com/br/algoritmos/basic/Result.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ananeridev/hacker-rank-challenges-solved/82f4d00c1e0185e4c9d5f52afdae1a633aa02452/out/production/HackerHankChallenges/com/br/algoritmos/basic/Result.class
--------------------------------------------------------------------------------
/out/production/HackerHankChallenges/com/br/algoritmos/basic/SolveMeFirst.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ananeridev/hacker-rank-challenges-solved/82f4d00c1e0185e4c9d5f52afdae1a633aa02452/out/production/HackerHankChallenges/com/br/algoritmos/basic/SolveMeFirst.class
--------------------------------------------------------------------------------
/out/production/HackerHankChallenges/com/br/algoritmos/basic/VeryBigSum.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ananeridev/hacker-rank-challenges-solved/82f4d00c1e0185e4c9d5f52afdae1a633aa02452/out/production/HackerHankChallenges/com/br/algoritmos/basic/VeryBigSum.class
--------------------------------------------------------------------------------
/src/com/br/algoritmos/basic/ArraySum.java:
--------------------------------------------------------------------------------
1 | package com.br.algoritmos.basic;
2 |
3 | import java.io.BufferedWriter;
4 | import java.io.FileWriter;
5 | import java.io.IOException;
6 | import java.util.Scanner;
7 |
8 | /**
9 | * @author Ana Beatriz Neri
10 | *
11 | */
12 | public class ArraySum {
13 |
14 | static long sum=0;
15 | // Complete the aVeryBigSum function below.
16 | static long aVeryBigSum(long[] ar) {
17 |
18 | for (int i = 0; i < ar.length; i++) {
19 | sum += ar[i];
20 | }
21 |
22 | return sum;
23 | }
24 |
25 | private static final Scanner scanner = new Scanner(System.in);
26 |
27 | public static void main(String[] args) throws IOException {
28 | BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
29 |
30 | int arCount = scanner.nextInt();
31 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
32 |
33 | long[] ar = new long[arCount];
34 |
35 | String[] arItems = scanner.nextLine().split(" ");
36 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
37 |
38 | for (int i = 0; i < arCount; i++) {
39 | long arItem = Long.parseLong(arItems[i]);
40 | ar[i] = arItem;
41 | }
42 |
43 | long result = aVeryBigSum(ar);
44 |
45 | bufferedWriter.write(String.valueOf(result));
46 | bufferedWriter.newLine();
47 |
48 | bufferedWriter.close();
49 |
50 | scanner.close();
51 | }
52 | }
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/com/br/algoritmos/basic/CompareTheTriples.java:
--------------------------------------------------------------------------------
1 | package com.br.algoritmos.basic;
2 |
3 |
4 | import java.io.*;
5 | import java.math.*;
6 | import java.security.*;
7 | import java.text.*;
8 | import java.util.*;
9 | import java.util.concurrent.*;
10 | import java.util.function.*;
11 | import java.util.regex.*;
12 | import java.util.stream.*;
13 | import static java.util.stream.Collectors.joining;
14 | import static java.util.stream.Collectors.toList;
15 |
16 | /**
17 | * @author Ana Beatriz Neri
18 | *
19 | */
20 |
21 | public class CompareTheTriples {
22 |
23 |
24 | static List compareTriplets(List a, List b) {
25 |
26 | int A = 0, B = 0;
27 | for (int i = 0; i < a.size(); i++){
28 | if (a.get(i) > b.get(i)){
29 | A++;
30 | } else if (a.get(i) < b.get(i)){
31 | B++;
32 | }
33 | }
34 | return Arrays.asList(A, B);
35 | }
36 |
37 | public static void main(String[] args) throws IOException {
38 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
39 | BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
40 |
41 | List a = Stream.of(bufferedReader.readLine().replaceAll("\\s+$", "").split(" "))
42 | .map(Integer::parseInt)
43 | .collect(toList());
44 |
45 | List b = Stream.of(bufferedReader.readLine().replaceAll("\\s+$", "").split(" "))
46 | .map(Integer::parseInt)
47 | .collect(toList());
48 |
49 | List result = compareTriplets(a, b);
50 |
51 | bufferedWriter.write(
52 | result.stream()
53 | .map(Object::toString)
54 | .collect(joining(" "))
55 | + "\n"
56 | );
57 |
58 | bufferedReader.close();
59 | bufferedWriter.close();
60 | }
61 | }
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/src/com/br/algoritmos/basic/DiagonalDifference.java:
--------------------------------------------------------------------------------
1 | package com.br.algoritmos.basic;
2 | import java.io.*;
3 | import java.math.*;
4 | import java.security.*;
5 | import java.text.*;
6 | import java.util.*;
7 | import java.util.concurrent.*;
8 | import java.util.regex.*;
9 |
10 | class Result {
11 |
12 | public static int diagonalDifference(List> arr) {
13 |
14 |
15 | int array_size = arr.size();
16 | int sum_l_to_r =0;
17 | int sum_r_to_l =0;
18 |
19 | for(int i=0; i< array_size ; i++){
20 | sum_l_to_r += arr.get(i).get(i);
21 | sum_r_to_l += arr.get(i).get(array_size-1-i);
22 | }
23 | return Math.abs(sum_l_to_r - sum_r_to_l);
24 | }
25 |
26 | }
27 |
28 | public class DiagonalDifference {
29 | public static void main(String[] args) throws IOException {
30 | BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
31 | BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
32 |
33 | int n = Integer.parseInt(bufferedReader.readLine().trim());
34 |
35 | List> arr = new ArrayList<>();
36 |
37 | for (int i = 0; i < n; i++) {
38 | String[] arrRowTempItems = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
39 |
40 | List arrRowItems = new ArrayList<>();
41 |
42 | for (int j = 0; j < n; j++) {
43 | int arrItem = Integer.parseInt(arrRowTempItems[j]);
44 | arrRowItems.add(arrItem);
45 | }
46 |
47 | arr.add(arrRowItems);
48 | }
49 |
50 | int result = Result.diagonalDifference(arr);
51 |
52 | bufferedWriter.write(String.valueOf(result));
53 | bufferedWriter.newLine();
54 |
55 | bufferedReader.close();
56 | bufferedWriter.close();
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/src/com/br/algoritmos/basic/DiskSpace.java:
--------------------------------------------------------------------------------
1 | package com.br.algoritmos.basic;
2 |
3 | import java.util.Scanner;
4 |
5 | public class DiskSpace {
6 |
7 | public static void main(String args[]) {
8 | Scanner sc = new Scanner(System.in);
9 | int x = sc.nextInt();
10 | int n = sc.nextInt();
11 | long space[] = new long[n];
12 | for (int i = 0; i < n; i++) {
13 | space[i] = sc.nextLong();
14 | }
15 | long minimal[] = new long[n - x + 1];
16 | long max = Long.MIN_VALUE;
17 | for (int i = 0; i <= n - x; i++) {
18 | minimal[i] = Long.MAX_VALUE;
19 | for (int j = i; j < i + x; j++) {
20 | if (minimal[i] > space[j])
21 | minimal[i] = space[j];
22 | }
23 | if (max < minimal[i])
24 | max = minimal[i];
25 | }
26 | System.out.println(max);
27 | sc.close();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/com/br/algoritmos/basic/FindThreeLargestNumbers.java:
--------------------------------------------------------------------------------
1 | package com.br.algoritmos.basic;
2 |
3 | public class FindThreeLargestNumbers {
4 |
5 | /*
6 | * There's the exercise: Write a function that takes an array of at least 3 integers and without sorting
7 | * the input array, returns a sorted array of the three largest input array
8 | *
9 | * */
10 |
11 | public static int[] findThreeLargestNumbers(int[] array) {
12 |
13 | int[] threeLargest = {Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE};
14 | for (int num : array) {
15 | updateLargest(threeLargest, num);
16 | }
17 |
18 | return threeLargest;
19 | }
20 |
21 | public static void updateLargest(int [] threeLargest, int num) {
22 | if(num > threeLargest[2]) {
23 | changeAndUpdate(threeLargest, num, 2);
24 | } else if (num > threeLargest[1]) {
25 | changeAndUpdate(threeLargest, num, 1);
26 | } else if (num > threeLargest[0]) {
27 | changeAndUpdate(threeLargest, num, 0);
28 | }
29 | }
30 |
31 | public static void changeAndUpdate(int[] array, int num, int idx) {
32 | for (int i = 0; i <= idx; i++) {
33 | if (i == idx) {
34 | array[i] = num;
35 | } else {
36 | array[i] = array[i + 1];
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/com/br/algoritmos/basic/PlusMinus.java:
--------------------------------------------------------------------------------
1 | package com.br.algoritmos.basic;
2 | import java.io.*;
3 | import java.math.*;
4 | import java.security.*;
5 | import java.text.*;
6 | import java.util.*;
7 | import java.util.concurrent.*;
8 | import java.util.regex.*;
9 |
10 | public class PlusMinus {
11 |
12 | // Complete the plusMinus function below.
13 | static void plusMinus(int[] arr) {
14 |
15 | int pos = 0;
16 | int neg = 0;
17 | int zer = 0;
18 |
19 | for(int a : arr){
20 | if(a > 0)
21 | pos++;
22 | if(a < 0)
23 | neg++;
24 | if(a == 0)
25 | zer++;
26 |
27 | }
28 | System.out.printf("%.6f%n",(double)pos / arr.length);
29 | System.out.printf("%.6f%n",(double)neg / arr.length);
30 | System.out.printf("%.6f%n",(double)zer / arr.length);
31 |
32 | }
33 |
34 | private static final Scanner scanner = new Scanner(System.in);
35 |
36 | public static void main(String[] args) {
37 | int n = scanner.nextInt();
38 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
39 |
40 | int[] arr = new int[n];
41 |
42 | String[] arrItems = scanner.nextLine().split(" ");
43 | scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
44 |
45 | for (int i = 0; i < n; i++) {
46 | int arrItem = Integer.parseInt(arrItems[i]);
47 | arr[i] = arrItem;
48 | }
49 |
50 | plusMinus(arr);
51 |
52 | scanner.close();
53 | }
54 | }
55 |
56 |
--------------------------------------------------------------------------------
/src/com/br/algoritmos/basic/SolveMeFirst.java:
--------------------------------------------------------------------------------
1 | package com.br.algoritmos.basic;
2 |
3 | import java.io.*;
4 | import java.util.*;
5 | import java.text.*;
6 | import java.math.*;
7 | import java.util.regex.*;
8 |
9 | /**
10 | * @author Ana Beatriz Neri
11 | *
12 | */
13 |
14 | public class SolveMeFirst {
15 |
16 | static int solveMeFirst(int a, int b) {
17 | return (a+b);
18 | }
19 |
20 | public static void main(String[] args) {
21 | Scanner in = new Scanner(System.in);
22 | int a;
23 | a = in.nextInt();
24 | int b;
25 | b = in.nextInt();
26 | int sum;
27 | sum = solveMeFirst(a, b);
28 | System.out.println(sum);
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/src/com/br/algoritmos/basic/VeryBigSum.java:
--------------------------------------------------------------------------------
1 | package com.br.algoritmos.basic;
2 | import java.io.*;
3 | import java.math.*;
4 | import java.security.*;
5 | import java.text.*;
6 | import java.util.*;
7 | import java.util.concurrent.*;
8 | import java.util.regex.*;
9 |
10 | public class VeryBigSum {
11 |
12 | // Complete the aVeryBigSum function below.
13 | static long aVeryBigSum(long[] ar) {
14 |
15 | int len=ar.length;
16 | long sum=0;
17 | for(int i=0;i