Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c00675d

Browse filesBrowse files
committed
commit
Change-Id: Ife16b8b946583af83883888d12d19c370e020c4f
1 parent 605cff4 commit c00675d
Copy full SHA for c00675d

File tree

Expand file treeCollapse file tree

148 files changed

+459
-466
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

148 files changed

+459
-466
lines changed

‎[0000][common]/src/MaxSubArray.java

Copy file name to clipboardExpand all lines: [0000][common]/src/MaxSubArray.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @time: 2019-06-16 11:16
88
**/
99
public class MaxSubArray {
10-
public int[] solve(int[] array) {
10+
public int[] solve(int[] array) {
1111
if (array == null || array.length < 1) {
1212
return null;
1313
}

‎[0001][Two Sum]/src/Main.java

Copy file name to clipboardExpand all lines: [0001][Two Sum]/src/Main.java
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ public void test2() {
2525
int[] result = new Solution().twoSum(new int[]{3, 2, 4}, 6);
2626
System.out.println("[" + result[0] + " ," + result[1] + "]");
2727
}
28+
2829
@Test
2930
public void test3() {
30-
int[] nums = {876,879,155,291,431,296,592,965,502,173,869,504,258,342,192,478,270,341,811,794,472,625,229,829,122,858,738,481,102,946,305,399,216,752,413,352,271,193,534,508,152,989,154,456,168,510,391,28,317,409,609,532,784,160,696,105,245,231,20,17,81,781,79,816,918,838,123,602,338,997,192,947,388,515,510,441,175,539,708,980,207,336,524,610,3,427,282,84,953,855,117,737,288,371,623,484,738,874,426,202,481,132,499,500,89,786,276,221,857,398,242,639,771,149,758,775,39,836,70,903,193,959,169,851,798,815,755,498,308,70,217,765,504,498,56,547,578,977,882,909,9,874,223,39,429,982,129,712,77,996,43,613,800,810,73,993,763,978,912,255,468,937,987,701,155,347,980,147,698,41,353,178,396,241,71,482,40,593,993,959,193,544,376,752,804,194,800,837,673,261,348,963,918,217,945,271,493,538,203,54,850,753,954,312,584,399,504,62,124,790,542,239,662,410,12,362,798,726,798,780,785,737,280,931,452,643,362,190,975,520,219,330,290,451,22,756,837,787,758,661,75,697,419,485,290,84,401,447,400,311,121,216,574,724,733,496,680,831,736,43,578,201,109,197,125,66,739,339,925,148,381,513,152,305,603,516,979,133,993,430,167,826,526,290,562,559,947,448,903,289,259,221,915,71,879,639,390,588,496,430,778,722,421,821,436,621,959,728,81,117,202,17,408,829,438,970,93,738,838,902,248,128,903,800,567,829,3,407,306,773,71,323,492,305,301,28,220,455,320,478,873,483,521,260,460,342,846,577,874,530,588,965,985,606,410,443,662,81,667,27,912,602,957,822,164,489,942,414,549,991,747,680,498,831,805,89,846,467,909,7,651,250,534,984,587,348,150,329,194,20,519,250,232,224,378,539,83,177,872,130,419,387,654,917,259,447,979,184,965,51,349,422,983,682,172,177,177,484,652,930,495,65,511,318,621,297,803,476,370,826,328,150,354,393,900,340,73,781,70,260,293,862,335,395,51,326,363,78,968,446,565,683,654,767,719,324,2,617,451,56,789,464,119,53,269,369,137,612,54,217,719,823,601,663,310,594,301,636,22,333,351,126,810,812,827,634,441,534,434,967,637,795,335,965,876,778,987,217,451,264,341,566,656,612,413,682,429,161,801,167,309,846,754,541,9,711,707,848,989,580,20,431,163,252,200,54,56,666,425,592,513,230,894,20,260,282,297,129,414,326,577,184,698,620,138,131,236,848,995,879,354,107,67,92,260,531,757,640,305,848,959,416,109,513,769,131,501,197,225,358,67,663,761,742,83,648,230,59,873,231,228,470,503,615,245,258,84,832,132,156,324,27,583,766,676,130,978,306,387,733,592,763,592,487,504,493,139,897,290,432,976,946,24,586,104,648,333,2,359,166,968,990,39,353,376,839,9,75,874,203,762,489,21,14,888,570,449,539,772,919,697,883,278,18,151,113,148,330,158,772,852,93,288,213,299,338,297,862,371,708,815,108,326,115,923,541,144,521,441,99,773,950,519,948,258,328,624,936,681,935,328,70,826,110,153,236,191,222,340,653,918,976,857,184,193,397,39,190,147,763,760,95,917,559,529,680,376,389,215,705,586,205,653,324,960,33,404,888,680,95,263,860,150,683,930,588,9,690,919,745,815,331,425,879,648,398,2,997,865,429,399,264,704,699,333,126,753,565,529,35,520,94,401,552,592,543,864,23,764,763,51,631,348,198,255,73,281,996,371,23,581,84,367,469,604,716,393,942,764,239,502,501,973,438,760,398,158,853,178,348,659,1000,739,296,444,587,528,355,867,615,847,885,160,357,618,959,330,82,182,59,224,355,250,270,447,534,97,590,284,909,406,954,419,909,158,626,818,350,994,609,540,957,152,827,830,386,380,318,580,853,440,789,432,710,955,381,241,930,880,632,750,876,189,662,127,434,38,144,20,424,27,466,538,158,416,508,990,650,698,990,970,663,121,9,713,489,977,530,694,141,930,169,695,305,567,368,777,442,668,746,618,86,592,185,328,772,213,644,440,178,243,774,467,991,455,404,919,197,830,568,661,826,841,695,52,982,515,47,47,198,9,272,425,975,472,9,302,338,470,542,247,492,367,180,708,521,592,58,572,887,670,314,191,280,256,845,971,157,725,862,452,76,200,538,44,324,992,459,196,18,64,147,423,187,191,246,305,973,802,832,436,444,242,979,351,733,459,825,833,691,372,861,617,618,190,57,848,527,56,378,533,308,430,473,701,401,871,790,459,216,983,305,61,391,251,447,661,951,150,28,572,206,299,477,703,301,227,960,866,450,335,337,852,906,956,873,893,867,196,131,456,608,688,840,569,91,922,606,961,906,836,168,838,91,607,186,754,708,477,248,138,211,458,17,509,645,629,816,47,185,661,856,508,984,320,763,297,9,446,970,472,12,386,476,686,940,387,721,546,206,110,349,88,781,150,308,136,809,670,291,767,889,926,999,832,462,706,13,9,753,458,309,984,404,801,366,56,611,38,691,174,670,306,229,12,151,697,415,180,655,418,975,781,40,448,625,775,722,350,163,397,634,102,961,322,354,836,652,877,997,397,957,640,70,467,976,901,792,173,869,248,829,919,89,324,9,639,560,744,890,846,452,197,558,756,988,771,573,494,64,423,348,296,587,327,909,371,24,369,174,132,197,412,142,257,790,770,171,875,724,608,329,256,626,868,22,311,499,933,173,78,631,931,191,132,970,194,778,33,832,75,76,63,271,905,164,970,716,216,828,56,131,898,565,791,47,634,205,118,280,605,896,433,38,39,303,242,746,673,541,759,588,990,586,244,152,586,371,666,361,691,815,658,537,371,482,656,117,316,327,368,657,848,557,761,221,147,673,945,914,976,579,804,405,182,89,429,133,485,939,586,452,20,292,108,747,188,899,293,125,976,573,162,592,880,241,685,191,539,361,430,84,791,903,475,96,388,485,416,583,944,939,987,939,545,474,272,494,664,543,480,812,212,400,728,28,379,410,127,607,59,614,883,509,695,765,533,665,754,848,268,159,678,807,325,125,92,208,216,337,697,778,466,861,22,950,74,804,925,617,159,73,676,712,558,487,711,774,383,817,737,555,811,304,743,27,67,535,426,766,615,102,437,765,291,718,641,951,255,375,442,204,108,455,592,364,457,758,486,593,780,277,789,323,404,473,258,953,318,898,555,390,727,510,783,427,806,92,33,474,858,851,783,12,752,356,942,307,235,397,915,502,939};
31+
int[] nums = {876, 879, 155, 291, 431, 296, 592, 965, 502, 173, 869, 504, 258, 342, 192, 478, 270, 341, 811, 794, 472, 625, 229, 829, 122, 858, 738, 481, 102, 946, 305, 399, 216, 752, 413, 352, 271, 193, 534, 508, 152, 989, 154, 456, 168, 510, 391, 28, 317, 409, 609, 532, 784, 160, 696, 105, 245, 231, 20, 17, 81, 781, 79, 816, 918, 838, 123, 602, 338, 997, 192, 947, 388, 515, 510, 441, 175, 539, 708, 980, 207, 336, 524, 610, 3, 427, 282, 84, 953, 855, 117, 737, 288, 371, 623, 484, 738, 874, 426, 202, 481, 132, 499, 500, 89, 786, 276, 221, 857, 398, 242, 639, 771, 149, 758, 775, 39, 836, 70, 903, 193, 959, 169, 851, 798, 815, 755, 498, 308, 70, 217, 765, 504, 498, 56, 547, 578, 977, 882, 909, 9, 874, 223, 39, 429, 982, 129, 712, 77, 996, 43, 613, 800, 810, 73, 993, 763, 978, 912, 255, 468, 937, 987, 701, 155, 347, 980, 147, 698, 41, 353, 178, 396, 241, 71, 482, 40, 593, 993, 959, 193, 544, 376, 752, 804, 194, 800, 837, 673, 261, 348, 963, 918, 217, 945, 271, 493, 538, 203, 54, 850, 753, 954, 312, 584, 399, 504, 62, 124, 790, 542, 239, 662, 410, 12, 362, 798, 726, 798, 780, 785, 737, 280, 931, 452, 643, 362, 190, 975, 520, 219, 330, 290, 451, 22, 756, 837, 787, 758, 661, 75, 697, 419, 485, 290, 84, 401, 447, 400, 311, 121, 216, 574, 724, 733, 496, 680, 831, 736, 43, 578, 201, 109, 197, 125, 66, 739, 339, 925, 148, 381, 513, 152, 305, 603, 516, 979, 133, 993, 430, 167, 826, 526, 290, 562, 559, 947, 448, 903, 289, 259, 221, 915, 71, 879, 639, 390, 588, 496, 430, 778, 722, 421, 821, 436, 621, 959, 728, 81, 117, 202, 17, 408, 829, 438, 970, 93, 738, 838, 902, 248, 128, 903, 800, 567, 829, 3, 407, 306, 773, 71, 323, 492, 305, 301, 28, 220, 455, 320, 478, 873, 483, 521, 260, 460, 342, 846, 577, 874, 530, 588, 965, 985, 606, 410, 443, 662, 81, 667, 27, 912, 602, 957, 822, 164, 489, 942, 414, 549, 991, 747, 680, 498, 831, 805, 89, 846, 467, 909, 7, 651, 250, 534, 984, 587, 348, 150, 329, 194, 20, 519, 250, 232, 224, 378, 539, 83, 177, 872, 130, 419, 387, 654, 917, 259, 447, 979, 184, 965, 51, 349, 422, 983, 682, 172, 177, 177, 484, 652, 930, 495, 65, 511, 318, 621, 297, 803, 476, 370, 826, 328, 150, 354, 393, 900, 340, 73, 781, 70, 260, 293, 862, 335, 395, 51, 326, 363, 78, 968, 446, 565, 683, 654, 767, 719, 324, 2, 617, 451, 56, 789, 464, 119, 53, 269, 369, 137, 612, 54, 217, 719, 823, 601, 663, 310, 594, 301, 636, 22, 333, 351, 126, 810, 812, 827, 634, 441, 534, 434, 967, 637, 795, 335, 965, 876, 778, 987, 217, 451, 264, 341, 566, 656, 612, 413, 682, 429, 161, 801, 167, 309, 846, 754, 541, 9, 711, 707, 848, 989, 580, 20, 431, 163, 252, 200, 54, 56, 666, 425, 592, 513, 230, 894, 20, 260, 282, 297, 129, 414, 326, 577, 184, 698, 620, 138, 131, 236, 848, 995, 879, 354, 107, 67, 92, 260, 531, 757, 640, 305, 848, 959, 416, 109, 513, 769, 131, 501, 197, 225, 358, 67, 663, 761, 742, 83, 648, 230, 59, 873, 231, 228, 470, 503, 615, 245, 258, 84, 832, 132, 156, 324, 27, 583, 766, 676, 130, 978, 306, 387, 733, 592, 763, 592, 487, 504, 493, 139, 897, 290, 432, 976, 946, 24, 586, 104, 648, 333, 2, 359, 166, 968, 990, 39, 353, 376, 839, 9, 75, 874, 203, 762, 489, 21, 14, 888, 570, 449, 539, 772, 919, 697, 883, 278, 18, 151, 113, 148, 330, 158, 772, 852, 93, 288, 213, 299, 338, 297, 862, 371, 708, 815, 108, 326, 115, 923, 541, 144, 521, 441, 99, 773, 950, 519, 948, 258, 328, 624, 936, 681, 935, 328, 70, 826, 110, 153, 236, 191, 222, 340, 653, 918, 976, 857, 184, 193, 397, 39, 190, 147, 763, 760, 95, 917, 559, 529, 680, 376, 389, 215, 705, 586, 205, 653, 324, 960, 33, 404, 888, 680, 95, 263, 860, 150, 683, 930, 588, 9, 690, 919, 745, 815, 331, 425, 879, 648, 398, 2, 997, 865, 429, 399, 264, 704, 699, 333, 126, 753, 565, 529, 35, 520, 94, 401, 552, 592, 543, 864, 23, 764, 763, 51, 631, 348, 198, 255, 73, 281, 996, 371, 23, 581, 84, 367, 469, 604, 716, 393, 942, 764, 239, 502, 501, 973, 438, 760, 398, 158, 853, 178, 348, 659, 1000, 739, 296, 444, 587, 528, 355, 867, 615, 847, 885, 160, 357, 618, 959, 330, 82, 182, 59, 224, 355, 250, 270, 447, 534, 97, 590, 284, 909, 406, 954, 419, 909, 158, 626, 818, 350, 994, 609, 540, 957, 152, 827, 830, 386, 380, 318, 580, 853, 440, 789, 432, 710, 955, 381, 241, 930, 880, 632, 750, 876, 189, 662, 127, 434, 38, 144, 20, 424, 27, 466, 538, 158, 416, 508, 990, 650, 698, 990, 970, 663, 121, 9, 713, 489, 977, 530, 694, 141, 930, 169, 695, 305, 567, 368, 777, 442, 668, 746, 618, 86, 592, 185, 328, 772, 213, 644, 440, 178, 243, 774, 467, 991, 455, 404, 919, 197, 830, 568, 661, 826, 841, 695, 52, 982, 515, 47, 47, 198, 9, 272, 425, 975, 472, 9, 302, 338, 470, 542, 247, 492, 367, 180, 708, 521, 592, 58, 572, 887, 670, 314, 191, 280, 256, 845, 971, 157, 725, 862, 452, 76, 200, 538, 44, 324, 992, 459, 196, 18, 64, 147, 423, 187, 191, 246, 305, 973, 802, 832, 436, 444, 242, 979, 351, 733, 459, 825, 833, 691, 372, 861, 617, 618, 190, 57, 848, 527, 56, 378, 533, 308, 430, 473, 701, 401, 871, 790, 459, 216, 983, 305, 61, 391, 251, 447, 661, 951, 150, 28, 572, 206, 299, 477, 703, 301, 227, 960, 866, 450, 335, 337, 852, 906, 956, 873, 893, 867, 196, 131, 456, 608, 688, 840, 569, 91, 922, 606, 961, 906, 836, 168, 838, 91, 607, 186, 754, 708, 477, 248, 138, 211, 458, 17, 509, 645, 629, 816, 47, 185, 661, 856, 508, 984, 320, 763, 297, 9, 446, 970, 472, 12, 386, 476, 686, 940, 387, 721, 546, 206, 110, 349, 88, 781, 150, 308, 136, 809, 670, 291, 767, 889, 926, 999, 832, 462, 706, 13, 9, 753, 458, 309, 984, 404, 801, 366, 56, 611, 38, 691, 174, 670, 306, 229, 12, 151, 697, 415, 180, 655, 418, 975, 781, 40, 448, 625, 775, 722, 350, 163, 397, 634, 102, 961, 322, 354, 836, 652, 877, 997, 397, 957, 640, 70, 467, 976, 901, 792, 173, 869, 248, 829, 919, 89, 324, 9, 639, 560, 744, 890, 846, 452, 197, 558, 756, 988, 771, 573, 494, 64, 423, 348, 296, 587, 327, 909, 371, 24, 369, 174, 132, 197, 412, 142, 257, 790, 770, 171, 875, 724, 608, 329, 256, 626, 868, 22, 311, 499, 933, 173, 78, 631, 931, 191, 132, 970, 194, 778, 33, 832, 75, 76, 63, 271, 905, 164, 970, 716, 216, 828, 56, 131, 898, 565, 791, 47, 634, 205, 118, 280, 605, 896, 433, 38, 39, 303, 242, 746, 673, 541, 759, 588, 990, 586, 244, 152, 586, 371, 666, 361, 691, 815, 658, 537, 371, 482, 656, 117, 316, 327, 368, 657, 848, 557, 761, 221, 147, 673, 945, 914, 976, 579, 804, 405, 182, 89, 429, 133, 485, 939, 586, 452, 20, 292, 108, 747, 188, 899, 293, 125, 976, 573, 162, 592, 880, 241, 685, 191, 539, 361, 430, 84, 791, 903, 475, 96, 388, 485, 416, 583, 944, 939, 987, 939, 545, 474, 272, 494, 664, 543, 480, 812, 212, 400, 728, 28, 379, 410, 127, 607, 59, 614, 883, 509, 695, 765, 533, 665, 754, 848, 268, 159, 678, 807, 325, 125, 92, 208, 216, 337, 697, 778, 466, 861, 22, 950, 74, 804, 925, 617, 159, 73, 676, 712, 558, 487, 711, 774, 383, 817, 737, 555, 811, 304, 743, 27, 67, 535, 426, 766, 615, 102, 437, 765, 291, 718, 641, 951, 255, 375, 442, 204, 108, 455, 592, 364, 457, 758, 486, 593, 780, 277, 789, 323, 404, 473, 258, 953, 318, 898, 555, 390, 727, 510, 783, 427, 806, 92, 33, 474, 858, 851, 783, 12, 752, 356, 942, 307, 235, 397, 915, 502, 939};
3132
int target = 28;
3233
int[] result = new Solution().twoSum(nums, target);
3334
System.out.println("[" + result[0] + " ," + result[1] + "]");

‎[0001][Two Sum]/src/Solution.java

Copy file name to clipboardExpand all lines: [0001][Two Sum]/src/Solution.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public int[] twoSum(int[] nums, int target) {
6262
List<Integer> list = map.get(num);
6363
result[0] = Math.min(list.get(0), list.get(1));
6464
result[1] = Math.max(list.get(0), list.get(1));
65-
} else if (gap != num){
65+
} else if (gap != num) {
6666
result[0] = Math.min(map.get(num).get(0), map.get(gap).get(0));
6767
result[1] = Math.max(map.get(num).get(0), map.get(gap).get(0));
6868
}

‎[0010][Regular Expression Matching]/src/Solution.java

Copy file name to clipboardExpand all lines: [0010][Regular Expression Matching]/src/Solution.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public boolean isMatch(String s, String p) {
4444
match[s.length()] = true;
4545
for (int i = p.length() - 1; i >= 0; i--) {
4646
if (p.charAt(i) == '*') {
47-
for (int j = s.length() - 1; j >= 0; j--) {
47+
for (int j = s.length() - 1; j >= 0; j--) {
4848
match[j] = match[j] || match[j + 1]
4949
&& (p.charAt(i - 1) == '.' || s.charAt(j) == p.charAt(i - 1));
5050
}

‎[0013][Roman To Integer]/src/Solution.java

Copy file name to clipboardExpand all lines: [0013][Roman To Integer]/src/Solution.java
+18-9Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,31 @@ public int romanToInt(String s) {
3434
// 要减去两倍之前前值才能回到真实值
3535
result += charToInt(s.charAt(i)) - 2 * charToInt(s.charAt(i - 1));
3636
} else {
37-
result += charToInt(s.charAt(i));
37+
result += charToInt(s.charAt(i));
3838
}
3939
}
4040

4141
return result;
4242
}
43+
4344
private int charToInt(char c) {
4445
switch (c) {
45-
case 'I': return 1;
46-
case 'V': return 5;
47-
case 'X': return 10;
48-
case 'L': return 50;
49-
case 'C': return 100;
50-
case 'D': return 500;
51-
case 'M': return 1000;
52-
default: return 0;
46+
case 'I':
47+
return 1;
48+
case 'V':
49+
return 5;
50+
case 'X':
51+
return 10;
52+
case 'L':
53+
return 50;
54+
case 'C':
55+
return 100;
56+
case 'D':
57+
return 500;
58+
case 'M':
59+
return 1000;
60+
default:
61+
return 0;
5362
}
5463
}
5564
}

‎[0014][Longest Common Prefix]/src/Main.java

Copy file name to clipboardExpand all lines: [0014][Longest Common Prefix]/src/Main.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public void test1() {
1515
@Test
1616
public void test2() {
1717
Solution solution = new Solution();
18-
Assert.assertEquals("", solution.longestCommonPrefix(new String[]{"dog","racecar","car"}));
18+
Assert.assertEquals("", solution.longestCommonPrefix(new String[]{"dog", "racecar", "car"}));
1919
}
2020
}

‎[0014][Longest Common Prefix]/src/Solution.java

Copy file name to clipboardExpand all lines: [0014][Longest Common Prefix]/src/Solution.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public String longestCommonPrefix(String[] strs) {
4646
}
4747
}
4848

49-
for (String s: strs) {
49+
for (String s : strs) {
5050
for (int i = 0; i < result.length(); i++) {
5151
if (result.charAt(i) != s.charAt(i)) {
5252
result = result.substring(0, i);

‎[0015][3 Sum]/src/Main.java

Copy file name to clipboardExpand all lines: [0015][3 Sum]/src/Main.java
+1-1Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎[0015][3 Sum]/src/Solution.java

Copy file name to clipboardExpand all lines: [0015][3 Sum]/src/Solution.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public List<List<Integer>> threeSum(int[] nums) {
7373
// nums[a-1]已经被选过了,不用再选了
7474
do {
7575
++a;
76-
}while (a < nums.length - 2 && nums[a - 1] == nums[a]);
76+
} while (a < nums.length - 2 && nums[a - 1] == nums[a]);
7777
}
7878
return result;
7979
}

‎[0016][3 Sum Closest]/src/Main.java

Copy file name to clipboardExpand all lines: [0016][3 Sum Closest]/src/Main.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
public class Main {
88
public static void main(String[] args) {
99
Solution solution = new Solution();
10-
System.out.println(solution.threeSumClosest(new int[]{0, 1 , 2}, 3));
10+
System.out.println(solution.threeSumClosest(new int[]{0, 1, 2}, 3));
1111
}
1212
}

‎[0016][3 Sum Closest]/src/Solution.java

Copy file name to clipboardExpand all lines: [0016][3 Sum Closest]/src/Solution.java
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import java.util.ArrayList;
21
import java.util.Arrays;
3-
import java.util.List;
42

53
/**
64
* Author: 王俊超
@@ -47,7 +45,7 @@ public int threeSumClosest(int[] nums, int target) {
4745

4846

4947
// i表示假设取第i个数作为结果
50-
for (int i = 0; i < nums.length - 2;) {
48+
for (int i = 0; i < nums.length - 2; ) {
5149
// 第二个数可能的起始位置
5250
int j = i + 1;
5351
// 第三个数可能是结束位置
@@ -76,21 +74,21 @@ public int threeSumClosest(int[] nums, int target) {
7674

7775
// 和大于target
7876
if (sum > target) {
79-
do {
80-
k--; // 找到不同的值
81-
}while (j < k && nums[k]==nums[k + 1]);
77+
do {
78+
k--; // 找到不同的值
79+
} while (j < k && nums[k] == nums[k + 1]);
8280
}
8381
// 和小于target
8482
else {
8583
do {
8684
j++;
87-
}while (j < k && nums[j - 1] == nums[j]);
85+
} while (j < k && nums[j - 1] == nums[j]);
8886
}
8987
}
9088

9189
do {
9290
i++;
93-
}while (i < nums.length - 2 && nums[i - 1] == nums[i]);
91+
} while (i < nums.length - 2 && nums[i - 1] == nums[i]);
9492
}
9593

9694
return (int) result;

‎[0018][4 Sum]/src/Solution.java

Copy file name to clipboardExpand all lines: [0018][4 Sum]/src/Solution.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public List<List<Integer>> fourSum(int[] num, int target) {
4949
Arrays.sort(num);
5050

5151
// 第一个加数
52-
for (int i = 0; i < num.length - 3;) {
52+
for (int i = 0; i < num.length - 3; ) {
5353
// 第四个加数
5454
for (int j = num.length - 1; j > i + 2; j--) {
5555
// 第四个加数使用不重复
@@ -98,7 +98,7 @@ public List<List<Integer>> fourSum(int[] num, int target) {
9898
// 相同的数字作为处理只能使用一次
9999
do {
100100
i++;
101-
}while (i < num.length - 2 && num[i - 1] == num[i]);
101+
} while (i < num.length - 2 && num[i - 1] == num[i]);
102102
}
103103
return result;
104104
}

‎[0022][Generate Parentheses]/src/Solution.java

Copy file name to clipboardExpand all lines: [0022][Generate Parentheses]/src/Solution.java
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import java.util.ArrayList;
2-
import java.util.LinkedList;
32
import java.util.List;
43

54
/**

‎[0023][Merge K Sorted Lists]/src/Solution.java

Copy file name to clipboardExpand all lines: [0023][Merge K Sorted Lists]/src/Solution.java
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import java.util.ArrayList;
21
import java.util.Comparator;
3-
import java.util.List;
42
import java.util.PriorityQueue;
53

64
/**

‎[0032][Longest Valid Parentheses]/src/Solution.java

Copy file name to clipboardExpand all lines: [0032][Longest Valid Parentheses]/src/Solution.java
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import java.util.Deque;
2-
import java.util.LinkedList;
31
import java.util.Stack;
42

53
/**

‎[0033][Search In Rotated Sorted Array]/src/Main.java

Copy file name to clipboardExpand all lines: [0033][Search In Rotated Sorted Array]/src/Main.java
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
**/
55
public class Main {
66
public static void main(String[] args) {
7-
int[] nums = {4,5,6,7,0,1,2}
8-
;
9-
Solution2 solution = new Solution2();
7+
int[] nums = {4, 5, 6, 7, 0, 1, 2};
8+
Solution2 solution = new Solution2();
109

1110
System.out.println(solution.search(nums, 4));
1211
System.out.println(solution.search(nums, 3));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.