├── .gitignore ├── 2019-04-02-Output-time-on-cli-per-second.sh ├── 2019-4-26-practice-perl-converting-bits-to-bytes.pl ├── Algorithm_full_features ├── BTree-simpleImplementation │ ├── README.md │ ├── btree.cpp │ └── btree.h ├── BinarySearch.java ├── KnuthShuffer.java ├── LinkedStack.java ├── README.md ├── ResizingArrayStack.java ├── data_sets │ └── BinarySearch │ │ ├── largeT.txt │ │ ├── largeW.txt │ │ ├── tinyT.txt │ │ └── tinyW.txt ├── graph │ ├── BreadthFirstPaths.java │ ├── DepthFirstPaths.java │ ├── DepthFirstSearch.java │ ├── GraphGenerator.java │ ├── NonrecursiveDFS.java │ └── undirectedGraph.java ├── others │ └── BloomFilter.cpp ├── search │ ├── BST.java │ ├── BinarySearchST.java │ ├── DepthFirstSearch.java │ ├── RedBlackBST.java │ ├── SequentialSearchST.java │ └── frequencyCounter.java └── sort │ ├── BinaryInsertion.java │ ├── BottomUpMergeSort.java │ ├── HeapSort.java │ ├── Insertion.java │ ├── InsertionOptimized.java │ ├── Inversions.java │ ├── MergeSortOptimized.java │ ├── QuickSort.java │ ├── QuickSortOptimized.java │ ├── QuickSortThreeWaysOptimized.java │ ├── QuickSortThreeWaysPartition.java │ ├── SelectionSort.java │ ├── ShellSort.java │ └── TopDownMergeSort.java ├── Poj_Judge_solved ├── poj_1008_Maya_Calendar.cpp ├── poj_1030_Rating.cpp ├── poj_1031_Fence.cpp ├── poj_1052_Plato's_Block.cpp ├── poj_1083_Moving_Tables.cpp └── poj_1664_放苹果.cpp ├── README.md ├── SodukuSolver.cpp ├── Status.h ├── Tests └── test.cpp ├── Topcoder_solved └── topcoder_srm663_div2__ABBA.java ├── codeForces ├── CodeForces_1462C_Unique_Number.java ├── CodeForces_1B_SpreadSheet.java ├── Codeforces_0002A_Winner.java ├── Codeforces_0004B_Before_an_Exam.java ├── Codeforces_0026A_Almost_Prime.java ├── Codeforces_0034A_Reconnaissance_2.java ├── Codeforces_0037A_Towers.java ├── Codeforces_0059A_Word.java ├── Codeforces_0075A_Life_Without_Zeros.java ├── Codeforces_0102B_Sum_of_Digits.java ├── Codeforces_0118B_Present_from_Lena.java ├── Codeforces_0119A_Epic_Game.java ├── Codeforces_0139A_Petr_and_Book.java ├── Codeforces_0165A_Supercentral_Point.java ├── Codeforces_0219A_k_String.java ├── Codeforces_0224A_Parallelepiped.java ├── Codeforces_0227B_Effective_Approach.java ├── Codeforces_0228A_Is_your_horseshoe_on_the_other_hoof.java ├── Codeforces_0230B_T_primes.java ├── Codeforces_0237A_Free_Cash.java ├── Codeforces_0255A_Greg_s_Workout.java ├── Codeforces_0272A_Dima_and_Friends.java ├── Codeforces_0275A_Lights_Out.java ├── Codeforces_0276A_Lunch_Rush.java ├── Codeforces_0276B_Little_Girl_and_Game.java ├── Codeforces_0276C_Little_Girl_and_Maximum_Sum.java ├── Codeforces_0294A_Shaass_and_Oskols.java ├── Codeforces_0296A_Yaroslav_and_Permutations.java ├── Codeforces_0300A_Array.java ├── Codeforces_0330A_Cakeminator.java ├── Codeforces_0349A_Cinema_Line.java ├── Codeforces_0352A_Jeff_and_Digits.java ├── Codeforces_0378A_Playing_with_Dice.java ├── Codeforces_0404A_Valera_and_X.java ├── Codeforces_0439A_Devu_the_Singer_and_Churu_the_Joker.java ├── Codeforces_0448A_Rewards.java ├── Codeforces_0450B_Jzzhu_and_Sequences.java ├── Codeforces_0463B_Caisa_and_Pylons.java ├── Codeforces_0478A_Initial_Bet.java ├── Codeforces_0479C_Exams.java ├── Codeforces_0507B_Amr_and_Pins.java ├── Codeforces_0515C_Drazil_and_Factorial.java ├── Codeforces_0545D_Queue.java ├── Codeforces_0550C_Divisibility_by_Eight.java ├── Codeforces_0598A_Tricky_Sum.java ├── Codeforces_0599A_Patrick_and_Shopping.java ├── Codeforces_0610A_Pasha_and_Stick.java ├── Codeforces_0680B_Bear_and_Finding_Criminals.java ├── Codeforces_0698A_Vacations.java ├── Codeforces_0709A_Juicer.java ├── Codeforces_0732B_The_Best_Friend_Of_a_Man.java ├── Codeforces_0746B_Decoding.java ├── Codeforces_0766A_Mahmoud_and_Longest_Uncommon_Subsequence.java ├── Codeforces_0768A_Oath_of_the_Night_s_Watch.java ├── Codeforces_0919B_Perfect_Number.java ├── Codeforces_0939A_Love_Triangle.java ├── Codeforces_0977C_Less_or_Equal.java ├── Codeforces_0978A_Remove_Duplicates.java ├── Codeforces_0978C_Letters.java ├── Codeforces_0988A_Diverse_Team.java ├── Codeforces_1003A_Polycarp_s_Pockets.java ├── Codeforces_1005A_Tanya_and_Stairways.java ├── Codeforces_1005B_Delete_from_the_Left.java ├── Codeforces_1030A_In_Search_of_an_Easy_Problem.java ├── Codeforces_1041A_Heist.java ├── Codeforces_1077A_Frog_Jumping.java ├── Codeforces_1092B_Teams_Forming.java ├── Codeforces_1095A_Repeating_Cipher.java ├── Codeforces_1097A_Gennady_and_a_Card_Game.java ├── Codeforces_1097B_Petr_and_a_Combination_Lock.java ├── Codeforces_1102A_Integer_Sequence_Dividing.java ├── Codeforces_110A_Nearly_Lucky_Number.java ├── Codeforces_112A_Petya_and_Strings.java ├── Codeforces_1141A_Game_23.java ├── Codeforces_1154A_Restoring_Three_Numbers.java ├── Codeforces_116A_Tram.java ├── Codeforces_1180A_Alex_and_a_Rhombus.java ├── Codeforces_1182A_Filling_Shapes.java ├── Codeforces_1183A_Nearest_Interesting_Number.java ├── Codeforces_1186A_Vus_the_Cossack_and_a_Contest.java ├── Codeforces_118A_String_Task.java ├── Codeforces_1195C_Basketball_Exercise.java ├── Codeforces_1196A_Three_Piles_of_Candies.java ├── Codeforces_1206A_Choose_Two_Numbers.java ├── Codeforces_1206A_Make_Product_Equal_One.java ├── Codeforces_1213A_Chips_Moving.java ├── Codeforces_1213B_Bad_Prices.java ├── Codeforces_1220A_Cards.java ├── Codeforces_122A_Lucky_Division.java ├── Codeforces_1234A_Equalize_Prices_Again.java ├── Codeforces_1238A_Prime_Subtraction.java ├── Codeforces_124A_The_number_of_positions.java ├── Codeforces_1256A_Payment_Without_Change.java ├── Codeforces_1272C_Yet_Another_Broken_Keyboard.java ├── Codeforces_1283A_Minutes_Before_the_New_Year.java ├── Codeforces_1285A_Mezo_Playing_Zoma.java ├── Codeforces_1285C_Fadi_and_LCM.java ├── Codeforces_1294A_Collecting_Coins.java ├── Codeforces_1294C_Product_of_Three_Numbers.java ├── Codeforces_1296A_Array_with_Odd_Sum.java ├── Codeforces_1296B_Food_Buying.java ├── Codeforces_1300B_Assigning_to_Classes.java ├── Codeforces_1303A_Erasing_Zeroes.java ├── Codeforces_1304A_Two_Rabbits.java ├── Codeforces_1311A_Add_Odd_or_Subtract_Even.java ├── Codeforces_1312A_Two_Regular_Polygons.java ├── Codeforces_1312B_Bogosort.java ├── Codeforces_131A_cAPS_lOCK.java ├── Codeforces_1324A_Yet_Another_Tetris_Problem.java ├── Codeforces_1324B_Yet_Another_Palindrome_Problem.java ├── Codeforces_1325A_EhAb_AnD_gCd.java ├── Codeforces_1325B_CopyCopyCopyCopyCopy.java ├── Codeforces_1326A_Bad_Ugly_Numbers.java ├── Codeforces_1326B_Maximums.java ├── Codeforces_1327A_Sum_of_Odd_Integers.java ├── Codeforces_1328A_Divisibility_Problem.java ├── Codeforces_1328C_Ternary_XOR.java ├── Codeforces_1334B_Middle_Class.java ├── Codeforces_1335A_Candies_and_Two_Sisters.java ├── Codeforces_1335B_Construct_the_String.java ├── Codeforces_1335C_Two_Teams_Composing.java ├── Codeforces_1335D_Anti_Sudoku.java ├── Codeforces_1337A_Ichihime_and_Triangle.java ├── Codeforces_1337B_Kana_and_Dragon_Quest_game.java ├── Codeforces_1338A_Powered_Addition.java ├── Codeforces_1339A_Filling_Diamonds.java ├── Codeforces_133A_HQ9plus.java ├── Codeforces_1341A_Nastya_and_Rice.java ├── Codeforces_1342A_Road_To_Zero.java ├── Codeforces_1342B_Binary_Period.java ├── Codeforces_1343A_Candies.java ├── Codeforces_1343B_Balanced_Array.java ├── Codeforces_1343C_Alternating_Subsequence.java ├── Codeforces_1345A_Puzzle_Pieces.java ├── Codeforces_1348A_Phoenix_and_Balance.java ├── Codeforces_1348B_Phoenix_and_Beauty.java ├── Codeforces_1350A_Orac_and_Factors.java ├── Codeforces_1351A_A_plus_B.java ├── Codeforces_1352A_Sum_of_Round_Numbers.java ├── Codeforces_1352B_Same_Parity_Summands.java ├── Codeforces_1352C_K-th_Not_Divisible_by_n.java ├── Codeforces_1352D_Alice_Bob_and_Candies.java ├── Codeforces_1353A_Most_Unstable_Array.java ├── Codeforces_1353B_Two_Arrays_And_Swaps.java ├── Codeforces_1353C_Board_Moves.java ├── Codeforces_1354A_Alarm_Clock.java ├── Codeforces_1354B_Ternary_String.java ├── Codeforces_1355A_Sequence_with_Digits.java ├── Codeforces_1355B_Young_Explorers.java ├── Codeforces_1358A_Park_Lighting.java ├── Codeforces_1358B_Maria_Breaks_the_Self_isolation.java ├── Codeforces_1359A_Berland_Poker.java ├── Codeforces_1359B_New_Theatre_Square.java ├── Codeforces_1360A_Minimal_Square.java ├── Codeforces_1360B_Honest_Coach.java ├── Codeforces_1360C_Similar_Pairs.java ├── Codeforces_1360D_Buying_Shovels.java ├── Codeforces_1362A_Johnny_and_Ancient_Computer.java ├── Codeforces_1363A_Odd_Selection.java ├── Codeforces_1363B_Subsequence_Hate.java ├── Codeforces_1364A_XXXXX.java ├── Codeforces_1365A_Matrix_Game.java ├── Codeforces_1365B_Trouble_Sort.java ├── Codeforces_1366A_Shovels_and_Swords.java ├── Codeforces_1367A_Short_Substrings.java ├── Codeforces_1367B_Even_Array.java ├── Codeforces_1368A_C_plus_equal.java ├── Codeforces_1369A_FashionabLee.java ├── Codeforces_1369B_AccurateLee.java ├── Codeforces_136A_Presents.java ├── Codeforces_1370A_Maximum_GCD.java ├── Codeforces_1370B_GCD_Compression.java ├── Codeforces_1370C_Number_Game.java ├── Codeforces_1371A_Magical_Sticks.java ├── Codeforces_1372A_Omkar_and_Completio.java ├── Codeforces_1372B_Omkar_and_Last_Class_of_Math.java ├── Codeforces_1373A_Donut_Shops.java ├── Codeforces_1373B_01_Game.java ├── Codeforces_1374A_Move_Brackets.java ├── Codeforces_1374A_Required_Remainder.java ├── Codeforces_1374B_Multiply_by_2_divide_by_6.java ├── Codeforces_1380A_Three_Indices.java ├── Codeforces_1382A_Common_Subsequence.java ├── Codeforces_1385A_Three_Pairwise_Maximums.java ├── Codeforces_1385B_Restore_the_Permutation_by_Merger.java ├── Codeforces_1385C_Make_It_Good.java ├── Codeforces_1388A_Captain_Flint_and_Crew_Recruitment.java ├── Codeforces_1389A_LCM_Problem.java ├── Codeforces_1391A_Suborrays.java ├── Codeforces_1391B_Fix_You.java ├── Codeforces_1395A_Boboniu_Likes_to_Color_Balls.java ├── Codeforces_1397A_Juggling_Letters.java ├── Codeforces_1398A_Bad_Triangle.java ├── Codeforces_1398B_Substring_Removal_Game.java ├── Codeforces_1398C_Good_Subarrays.java ├── Codeforces_1399A_Remove_Smallest.java ├── Codeforces_1399B_Gifts_Fixing.java ├── Codeforces_1399C_Boats_Competition.java ├── Codeforces_1400A_String_Similarity.java ├── Codeforces_1401A_Distance_and_Axis.java ├── Codeforces_1401C_Mere_Array.java ├── Codeforces_1409A_Yet_Another_Two_Integers_Problem.java ├── Codeforces_1409B_Minimum_Product.java ├── Codeforces_1418A_Buying_Torches.java ├── Codeforces_141A_Amusing_Joke.java ├── Codeforces_1420A_Cubes_Sorting.java ├── Codeforces_1420B_Rock_and_Lever.java ├── Codeforces_1421A_XORwice.java ├── Codeforces_1426A_Floor_Number.java ├── Codeforces_1433A_Boring_Apartments.java ├── Codeforces_1433B_Yet_Another_Bookshelf.java ├── Codeforces_1433C_Dominant_Piranha.java ├── Codeforces_144A_Arrival_of_the_General.java ├── Codeforces_1451A_Subtract_or_Divide.java ├── Codeforces_1454A_Special_Permutation.java ├── Codeforces_1454B_Unique_Bid_Auction.java ├── Codeforces_1455A_Strange_Functions.java ├── Codeforces_1462A_Favorite_Sequence.java ├── Codeforces_1462B_Last_Year_s_Substring.java ├── Codeforces_1463A_Dungeon.java ├── Codeforces_1467A_Wizard_of_Orz.java ├── Codeforces_1469A_Regular_Bracket_Sequence.java ├── Codeforces_1469B_Red_and_Blue.java ├── Codeforces_1471A_Strange_Partition.java ├── Codeforces_1472A_Cards_for_Friends.java ├── Codeforces_1472B_Fair_Division.java ├── Codeforces_1472D_Even_Odd_Game.java ├── Codeforces_1473A_Replacing_Elements.java ├── Codeforces_1473B_String_LCM.java ├── Codeforces_1474B_Different_Divisors.java ├── Codeforces_1475A_Odd_Divisor.java ├── Codeforces_1475B_New_Year_s_Number.java ├── Codeforces_1476A_K_divisible_Sum.java ├── Codeforces_1478A_Nezzar_and_Colorful_Balls.java ├── Codeforces_1480A_Yet_Another_String_Game.java ├── Codeforces_1481A_Space_Navigation.java ├── Codeforces_1486A_Shifting_Stacks.java ├── Codeforces_1487A_Arena.java ├── Codeforces_148A_Insomnia_cure.java ├── Codeforces_1490A_Dense_Array.java ├── Codeforces_1490B_Balanced_Remainders.java ├── Codeforces_1490C_Sum_of_Cubes.java ├── Codeforces_1497A_Meximization.java ├── Codeforces_1497C1_k_LCM.java ├── Codeforces_149A_Business_trip.java ├── Codeforces_1506A_Strange_Table.java ├── Codeforces_1506C_Double_ended_Strings.java ├── Codeforces_1509A_Average_Height.java ├── Codeforces_1511A_Review_Site.java ├── Codeforces_1512A_Spy_Detected.java ├── Codeforces_1512B_Almost_Rectangle.java ├── Codeforces_1514A_Perfectly_Imperfect_Array.java ├── Codeforces_1515B_Phoenix_and_Puzzle.java ├── Codeforces_1516A_Tit_for_Tat.java ├── Codeforces_1517A_Sum_of_2050.java ├── Codeforces_1519A_Red_and_Blue_Beans.java ├── Codeforces_1519B_The_Cake_Is_a_Lie.java ├── Codeforces_151A_Soft_Drinking.java ├── Codeforces_1520A_Do_Not_Be_Distracted.java ├── Codeforces_1520B_Ordinary_Numbers.java ├── Codeforces_1520D_Same_Differences.java ├── Codeforces_1521A_Nastia_and_Nearly_Good_Numbers.java ├── Codeforces_1525A_Potion_making.java ├── Codeforces_1525B_Permutation_Sort.java ├── Codeforces_1526A_Mean_Inequality.java ├── Codeforces_1526B_I_Hate_1111.java ├── Codeforces_1527A_And_Then_There_Were_K.java ├── Codeforces_1527B1_Palindrome_Game_easy_version.java ├── Codeforces_1529A_Eshag_Loves_Big_Arrays.java ├── Codeforces_1535A_Fair_Playoff.java ├── Codeforces_1537A_Arithmetic_Array.java ├── Codeforces_1537B_Bad_Boy.java ├── Codeforces_1537C_Challenging_Cliffs.java ├── Codeforces_1538A_Stone_Game.java ├── Codeforces_1538B_Friends_and_Candies.java ├── Codeforces_1539B_Love_Song.java ├── Codeforces_1541A_Pretty_Permutations.java ├── Codeforces_1541B_Pleasant_Pairs.java ├── Codeforces_1542A_Odd_Set.java ├── Codeforces_1543A_Exciting_Bets.java ├── Codeforces_1547A_Shortest_Path_with_Obstacle.java ├── Codeforces_1547B_Alphabetical_Strings.java ├── Codeforces_1549A_Gregor_and_Cryptography.java ├── Codeforces_1550A_Find_The_Array.java ├── Codeforces_1550B_Maximum_Cost_Deletion.java ├── Codeforces_1551A_Polycarp_and_Coins.java ├── Codeforces_1551B1_Wonderful_Coloring_1.java ├── Codeforces_1552A_Subsequence_Permutation.java ├── Codeforces_1553A_Digits_Sum.java ├── Codeforces_1554A_Cherry.java ├── Codeforces_1555A_PizzaForces.java ├── Codeforces_1557A_Ezzat_and_Two_Subsequences.java ├── Codeforces_1559A_Mocha_and_Math.java ├── Codeforces_155A_I_love_%username%.java ├── Codeforces_1560A_Dislike_of_Threes.java ├── Codeforces_1560B_Who_s_Opposite.java ├── Codeforces_1560C_Infinity_Table.java ├── Codeforces_1562A_The_Miracle_and_the_Sleeper.java ├── Codeforces_1567A_Domino_Disaster.java ├── Codeforces_1569A_Balanced_Substring.java ├── Codeforces_1579A_Casimir_s_String_Solitaire.java ├── Codeforces_158A_Next_Round.java ├── Codeforces_158B_Taxi.java ├── Codeforces_1593A_Elections.java ├── Codeforces_1593B_Make_it_Divisible_by_25.java ├── Codeforces_1593C_Save_More_Mice.java ├── Codeforces_1593C_Stable_Groups.java ├── Codeforces_1594A_Consecutive_Sum_Riddle.java ├── Codeforces_1606A_AB_Balance.java ├── Codeforces_1607A_Linear_Keyboard.java ├── Codeforces_1607B_Odd_Grasshopper.java ├── Codeforces_1607C_Minimum_Extraction.java ├── Codeforces_160A_Twins.java ├── Codeforces_1611A_Make_Even.java ├── Codeforces_1611B_Team_Composition_Programmers_and_Mathematicians.java ├── Codeforces_1613A_Long_Comparison.java ├── Codeforces_1617B_GCD_Problem.java ├── Codeforces_1618A_Polycarp_and_Sums_of_Subsequences.java ├── Codeforces_1619A_Square_String.java ├── Codeforces_1619B_Squares_and_Cubes.java ├── Codeforces_1621A_Stable_Arrangement_of_Rooks.java ├── Codeforces_1622A_Construct_a_Rectangle.java ├── Codeforces_1624A_Plus_One_on_the_Subset.java ├── Codeforces_1624B_Make_AP.java ├── Codeforces_1626A_Equidistant_Letters.java ├── Codeforces_1627A_Not_Shading.java ├── Codeforces_1629A_Download_More_RAM.java ├── Codeforces_1629B_GCD_Arrays.java ├── Codeforces_1631A_Min_Max_Swap.java ├── Codeforces_1632A_ABC.java ├── Codeforces_1633A_Div_7.java ├── Codeforces_1633B_Minority.java ├── Codeforces_1634A_Reverse_and_Concatenate.java ├── Codeforces_1644A_Doors_and_Keys.java ├── Codeforces_1646A_Square_Counting.java ├── Codeforces_1650A_Deletions_of_Two_Adjacent_Letters.java ├── Codeforces_1650B_DIV_plus_MOD.java ├── Codeforces_1651A_Playoff.java ├── Codeforces_1657A_Integer_Moves.java ├── Codeforces_1660A_Vasya_and_Coins.java ├── Codeforces_1660B_Vlad_and_Candies.java ├── Codeforces_1665A_GCD_vs_LCM.java ├── Codeforces_1669A_Division.java ├── Codeforces_1669B_Triple.java ├── Codeforces_1669C_Odd_Even_Increments.java ├── Codeforces_1674A_Number_Transformation.java ├── Codeforces_1674B_Dictionary.java ├── Codeforces_1674C_Infinite_Replacement.java ├── Codeforces_1675A_Food_for_Animals.java ├── Codeforces_1675B_Make_It_Increasing.java ├── Codeforces_1676A_Lucky.java ├── Codeforces_1676B_Equal_Candies.java ├── Codeforces_1676C_Most_Similar_Words.java ├── Codeforces_1676E_Eating_Queries.java ├── Codeforces_1679A_AvtoBus.java ├── Codeforces_1684A_Digit_Minimization.java ├── Codeforces_1690A_Print_a_Pedestal_Codeforces_logo.java ├── Codeforces_1690B_Array_Decrements.java ├── Codeforces_1690C_Restoring_the_Duration_of_Tasks.java ├── Codeforces_1690D_Black_and_White_Stripe.java ├── Codeforces_1691A_Beat_The_Odds.java ├── Codeforces_1692A_Marathon.java ├── Codeforces_1692B_All_Distinct.java ├── Codeforces_1692C_Where_s_the_Bishop.java ├── Codeforces_1692F_3SUM.java ├── Codeforces_1696B_NIT_Destroys_the_Universe.java ├── Codeforces_1697A_Parkway_Walk.java ├── Codeforces_1697B_Promo.java ├── Codeforces_1698A_XOR_Mixup.java ├── Codeforces_1699A_The_Third_Three_Number_Problem.java ├── Codeforces_1701A_Grass_Field.java ├── Codeforces_1702A_Round_Down_the_Price.java ├── Codeforces_1702B_Polycarp_Writes_a_String_from_Memory.java ├── Codeforces_1702D_Not_a_Cheap_String.java ├── Codeforces_1703A_YES_or_YES.java ├── Codeforces_1703B_ICPC_Balloons.java ├── Codeforces_1703C_Cypher.java ├── Codeforces_1703D_Double_Strings.java ├── Codeforces_1705A_Mark_the_Photographer.java ├── Codeforces_1709A_Three_Doors.java ├── Codeforces_1711A_Perfect_Permutation.java ├── Codeforces_1712A_Wonderful_Permutation.java ├── Codeforces_1714A_Everyone_Loves_to_Sleep.java ├── Codeforces_1714B_Remove_Prefix.java ├── Codeforces_1714C_Minimum_Varied_Number.java ├── Codeforces_1716A_2_3_Moves.java ├── Codeforces_1719A_Chip_Game.java ├── Codeforces_1721A_Image.java ├── Codeforces_1722A_Spell_Check.java ├── Codeforces_1722B_Colourblindness.java ├── Codeforces_1722C_Word_Game.java ├── Codeforces_1722D_Line.java ├── Codeforces_1726A_Mainak_and_Array.java ├── Codeforces_1728A_Colored_Balls_Revisited.java ├── Codeforces_1729A_Two_Elevators.java ├── Codeforces_1729B_Decode_String.java ├── Codeforces_1741A_Compare_T-Shirt_Sizes.java ├── Codeforces_1741B_Funny_Permutation.java ├── Codeforces_1742A_Sum.java ├── Codeforces_1742B_Increasing.java ├── Codeforces_1742C_Stripes.java ├── Codeforces_1742D_Coprime.java ├── Codeforces_1742E_Scuza.java ├── Codeforces_1743A_Password.java ├── Codeforces_1744A_Number_Replacement.java ├── Codeforces_1744B_Even_Odd_Increments.java ├── Codeforces_1747A_Two_Groups.java ├── Codeforces_1748A_The_Ultimate_Square.java ├── Codeforces_1758A_SSeeeeiinngg_DDoouubbllee.java ├── Codeforces_1759A_Yes_Yes.java ├── Codeforces_1760A_Medium_Number.java ├── Codeforces_1760B_Atilla_s_Favorite_Problem.java ├── Codeforces_1760C_Advantage.java ├── Codeforces_1766A_Extremely_Round.java ├── Codeforces_1768A_Greatest_Convex.java ├── Codeforces_1770A_Koxia_and_Whiteboards.java ├── Codeforces_1772A_A_plus_B.java ├── Codeforces_1772B_Matrix_Rotation.java ├── Codeforces_1772C_Different_Differences.java ├── Codeforces_1777A_Everybody_Likes_Good_Arrays.java ├── Codeforces_1778A_Flip_Flop_Sum.java ├── Codeforces_1779B_MKnez_s_ConstructiveForces_Task.java ├── Codeforces_1783A_Make_it_Beautiful.java ├── Codeforces_1788A_One_and_Two.java ├── Codeforces_1790A_Polycarp_and_the_Day_of_Pi.java ├── Codeforces_1790B_Taisia_and_Dice.java ├── Codeforces_1791A_Codeforces_Checking.java ├── Codeforces_1791B_Following_Directions.java ├── Codeforces_1791C_Prepend_and_Append.java ├── Codeforces_1791D_Distinct_Split.java ├── Codeforces_1791E_Negatives_and_Positives.java ├── Codeforces_1791G1_Teleporters_Easy_Version.java ├── Codeforces_1792A_GamingForces.java ├── Codeforces_1794B_Not_Dividing.java ├── Codeforces_1795A_Two_Towers.java ├── Codeforces_1800A_Is_It_a_Cat.java ├── Codeforces_1800B_Count_the_Number_of_Pairs.java ├── Codeforces_1805A_We_Need_the_Zero.java ├── Codeforces_1806A_Walking_Master.java ├── Codeforces_1807A_Plus_or_Minus.java ├── Codeforces_1807B_Grab_the_Candies.java ├── Codeforces_1807C_Find_and_Replace.java ├── Codeforces_1807D_Odd_Queries.java ├── Codeforces_1809A_Garland.java ├── Codeforces_1811A_Insert_Digit.java ├── Codeforces_1814A_Coins.java ├── Codeforces_1822A_TubeTube_Feed.java ├── Codeforces_1822B_Karina_and_Array.java ├── Codeforces_1828A_Divisible_Array.java ├── Codeforces_1829A_Love_Story.java ├── Codeforces_1829B_Blank_Space.java ├── Codeforces_1829C_Mr_Perfectly_Fine.java ├── Codeforces_1829D_Gold_Rush.java ├── Codeforces_1831A_Twin_Permutations.java ├── Codeforces_1832A_New_Palindrome.java ├── Codeforces_1832C_Contrast_Value.java ├── Codeforces_1833A_Musical_Puzzle.java ├── Codeforces_1833B_Restore_the_Weather.java ├── Codeforces_1833C_Vlad_Building_Beautiful_Array.java ├── Codeforces_1834A_Unit_Array.java ├── Codeforces_1837A_Grasshopper_on_a_Line.java ├── Codeforces_1837B_Comparison_String.java ├── Codeforces_1840A_Cipher_Shifer.java ├── Codeforces_1841A_Game_with_Board.java ├── Codeforces_1843A_Sasha_and_Array_Coloring.java ├── Codeforces_1843B_Long_Long.java ├── Codeforces_1843C_Sum_in_Binary_Tree.java ├── Codeforces_1844A_Subtraction_Game.java ├── Codeforces_1845A_Forbidden_Integer.java ├── Codeforces_1846A_Rudolph_and_Cut_the_Rope.java ├── Codeforces_1846B_Rudolph_and_Tic_Tac_Toe.java ├── Codeforces_1849A_Morning_Sandwich.java ├── Codeforces_1849B_Monsters.java ├── Codeforces_1850A_To_My_Critics.java ├── Codeforces_1850B_Ten_Words_of_Wisdom.java ├── Codeforces_1850C_Word_on_the_Paper.java ├── Codeforces_1850D_Balanced_Round.java ├── Codeforces_1851A_Escalator_Conversations.java ├── Codeforces_1851B_Parity_Sort.java ├── Codeforces_1851C_Tiles_Comeback.java ├── Codeforces_1853A_Desorting.java ├── Codeforces_1855A_Dalton_the_Teacher.java ├── Codeforces_1856A_Tales_of_a_Sort.java ├── Codeforces_1856B_Good_Arrays.java ├── Codeforces_1857A_Array_Coloring.java ├── Codeforces_1857C_Assembly_via_Minimums.java ├── Codeforces_1858A_Buttons.java ├── Codeforces_1859A_United_We_Stand.java ├── Codeforces_1859B_Olya_and_Game_with_Arrays.java ├── Codeforces_1861A_Prime_Deletion.java ├── Codeforces_1862A_Gift_Carpet.java ├── Codeforces_1862B_Sequence_Game.java ├── Codeforces_1866A_Ambitious_Kid.java ├── Codeforces_1869A_Make_It_Zero.java ├── Codeforces_1872A_Two_Vessels.java ├── Codeforces_1872B_The_Corridor_or_There_and_Back_Again.java ├── Codeforces_1872C_Non_coprime_Split.java ├── Codeforces_1872D_Plus_Minus_Permutation.java ├── Codeforces_1873A_Short_Sort.java ├── Codeforces_1873B_Good_Kid.java ├── Codeforces_1873C_Target_Practice.java ├── Codeforces_1873D_1D_Eraser.java ├── Codeforces_1875A_Jellyfish_and_Undertale.java ├── Codeforces_1877A_Goals_of_Victory.java ├── Codeforces_1878A_How_Much_Does_Daytona_Cost.java ├── Codeforces_1878B_Aleksa_and_Stack.java ├── Codeforces_1878C_Vasilije_in_Cacak.java ├── Codeforces_1881A_Don_t_Try_to_Count.java ├── Codeforces_1881B_Three_Threadlets.java ├── Codeforces_1882A_Increasing_Sequence.java ├── Codeforces_1883A_Morning.java ├── Codeforces_1883B_Chemistry.java ├── Codeforces_1883C_Raspberries.java ├── Codeforces_1886A_Sum_of_Three.java ├── Codeforces_1890A_Doremy_s_Paint_3.java ├── Codeforces_1895A_Treasure_Chest.java ├── Codeforces_1896A_Jagged_Swaps.java ├── Codeforces_1899A_Game_with_Integers.java ├── Codeforces_189A_Cut_Ribbon.java ├── Codeforces_1900A_Cover_in_Water.java ├── Codeforces_1901A_Line_Trip.java ├── Codeforces_1903A_Halloumi_Boxes.java ├── Codeforces_1904A_Forked.java ├── Codeforces_1907A_Rook.java ├── Codeforces_1907B_YetnotherrokenKeoard.java ├── Codeforces_1913A_Rating_Increase.java ├── Codeforces_1913B_Swap_and_Delete.java ├── Codeforces_1914A_Problemsolving_Log.java ├── Codeforces_1914B_Preparing_for_the_Contest.java ├── Codeforces_1914C_Quests.java ├── Codeforces_1915A_Odd_One_Out.java ├── Codeforces_1915B_Not_Quite_Latin_Square.java ├── Codeforces_1915C_Can_I_Square.java ├── Codeforces_1915D_Unnatural_Language_Processing.java ├── Codeforces_1916A_2023.java ├── Codeforces_1916B_Two_Divisors.java ├── Codeforces_1917A_Least_Product.java ├── Codeforces_1918A_Brick_Wall.java ├── Codeforces_1919A_Wallet_Exchange.java ├── Codeforces_1919B_Plus_Minus_Split.java ├── Codeforces_1920A_Satisfying_Constraints.java ├── Codeforces_1921A_Square.java ├── Codeforces_1921B_Arranging_Cats.java ├── Codeforces_1921C_Sending_Messages.java ├── Codeforces_1922A_Tricky_Template.java ├── Codeforces_1923A_Moving_Chips.java ├── Codeforces_1925A_We_Got_Everything_Covered.java ├── Codeforces_1926A_Vlad_and_the_Best_of_Five.java ├── Codeforces_1926B_Vlad_and_Shapes.java ├── Codeforces_1926C_Vlad_and_a_Sum_of_Sum_of_Digits.java ├── Codeforces_1927A_Make_it_White.java ├── Codeforces_1927B_Following_the_String.java ├── Codeforces_1927C_Choose_the_Different_Ones.java ├── Codeforces_1929A_Sasha_and_the_Beautiful_Array.java ├── Codeforces_1929B_Sasha_and_the_Drawing.java ├── Codeforces_1931A_Recovering_a_Small_String.java ├── Codeforces_1931B_Make_Equal.java ├── Codeforces_1931C_Make_Equal_Again.java ├── Codeforces_1932A_Thorns_and_Coins.java ├── Codeforces_1933A_Turtle_Puzzle_Rearrange_and_Negate.java ├── Codeforces_1933B_Turtle_Math_Fast_Three_Task.java ├── Codeforces_1934A_Too_Min_Too_Max.java ├── Codeforces_1935A_Entertainment_in_MAC.java ├── Codeforces_1941A_Rudolf_and_the_Ticket.java ├── Codeforces_1941B_Rudolf_and_121.java ├── Codeforces_1941C_Rudolf_and_the_Ugly_String.java ├── Codeforces_1944A_Destroying_Bridges.java ├── Codeforces_1945A_Setting_up_Camp.java ├── Codeforces_1946A_Median_of_an_Array.java ├── Codeforces_1948A_Special_Characters.java ├── Codeforces_1950A_Stair_Peak_or_Neither.java ├── Codeforces_1950B_Upscaling.java ├── Codeforces_1950C_Clock_Conversion.java ├── Codeforces_1954A_Painting_the_Ribbon.java ├── Codeforces_1955A_Yogurt_Sale.java ├── Codeforces_1955B_Progressive_Square.java ├── Codeforces_1957A_Stickogon.java ├── Codeforces_1968A_Maximize.java ├── Codeforces_1968B_Prefiquence.java ├── Codeforces_1968C_Assembly_via_Remainders.java ├── Codeforces_1971A_My_First_Sorting_Problem.java ├── Codeforces_1971B_Different_String.java ├── Codeforces_1971C_Clock_and_Strings.java ├── Codeforces_1973A_Chess_For_Three.java ├── Codeforces_1974A_Phone_Desktop.java ├── Codeforces_1974B_Symmetric_Encoding.java ├── Codeforces_1976A_Verify_Password.java ├── Codeforces_1977A_Little_Nikita.java ├── Codeforces_1978A_Alice_and_Books.java ├── Codeforces_1979A_Guess_the_Maximum.java ├── Codeforces_1980A_Problem_Generator.java ├── Codeforces_1980B_Choosing_Cubes.java ├── Codeforces_1982A_Soccer.java ├── Codeforces_1983A_Array_Divisibility.java ├── Codeforces_1985A_Creating_Words.java ├── Codeforces_1985B_Maximum_Multiple_Sum.java ├── Codeforces_1985D_Manhattan_Circle.java ├── Codeforces_1986A_X_Axis.java ├── Codeforces_1986B_Matrix_Stabilization.java ├── Codeforces_1987A_Upload_More_RAM.java ├── Codeforces_1988A_Split_the_Multiset.java ├── Codeforces_1988B_Make_Majority.java ├── Codeforces_1989A_Catch_the_Coin.java ├── Codeforces_1990A_Submission_Bait.java ├── Codeforces_1992A_Only_Pluses.java ├── Codeforces_1992B_Angry_Monk.java ├── Codeforces_1992C_Gorilla_and_Permutation.java ├── Codeforces_1993A_Question_Marks.java ├── Codeforces_1995A_Diagonals.java ├── Codeforces_1996A_Legs.java ├── Codeforces_1996B_Scale.java ├── Codeforces_1997A_Strong_Password.java ├── Codeforces_1998A_Find_K_Distinct_Points_with_Fixed_Center.java ├── Codeforces_1999A_plus_B_Again.java ├── Codeforces_1999B_Card_Game.java ├── Codeforces_1999C_Showering.java ├── Codeforces_1999D_Slavic_s_Exam.java ├── Codeforces_2000A_Primary_Task.java ├── Codeforces_2000B_Seating_in_a_Bus.java ├── Codeforces_2001A_Make_All_Equal.java ├── Codeforces_2001B_Generate_Permutation.java ├── Codeforces_2003A_Turtle_and_Good_Strings.java ├── Codeforces_2003B_Turtle_and_Piggy_Are_Playing_a_Game_2.java ├── Codeforces_2004A_Closest_Point.java ├── Codeforces_2004B_Game_with_Doors.java ├── Codeforces_2004C_Splitting_Items.java ├── Codeforces_2008A_Sakurako_s_Exam.java ├── Codeforces_2008B_Square_or_Not.java ├── Codeforces_2008C_Longest_Good_Array.java ├── Codeforces_2009A_Minimize.java ├── Codeforces_2009B_osu_mania.java ├── Codeforces_2009C_The_Legend_of_Freya_the_Frog.java ├── Codeforces_200B_Drinks.java ├── Codeforces_2013A_Zhan_s_Blender.java ├── Codeforces_2014A_Robin_Helps.java ├── Codeforces_2014B_Robin_Hood_and_the_Major_Oak.java ├── Codeforces_2019A_Max_Plus_Size.java ├── Codeforces_2025A_Two_Screens.java ├── Codeforces_2030A_A_Gift_From_Orangutan.java ├── Codeforces_2033A_Sakurako_and_Kosuke.java ├── Codeforces_2036A_Quintomania.java ├── Codeforces_2036B_Startup.java ├── Codeforces_2037A_Twice.java ├── Codeforces_2043A_Coin_Transformation.java ├── Codeforces_2044A_Easy_Problem.java ├── Codeforces_2044B_Normal_Problem.java.java ├── Codeforces_2044C_Hard_Problem.java ├── Codeforces_2050A_Line_Breaks.java ├── Codeforces_2051A_Preparing_for_the_Olympiad.java ├── Codeforces_2051B_Journey.java ├── Codeforces_2055A_Two_Frogs.java ├── Codeforces_2056A_Shape_Perimeter.java ├── Codeforces_2057A_MEX_Table.java ├── Codeforces_2059A_Milya_and_Two_Arrays.java ├── Codeforces_2060A_Fibonacciness.java.java ├── Codeforces_2060C_Game_of_Mathletes.java ├── Codeforces_2062A_String.java ├── Codeforces_2063A_Minimal_Coprime.java ├── Codeforces_2065A_Skibidus_and_Amog_u.java ├── Codeforces_2065B_Skibidus_and_Ohio.java ├── Codeforces_2074B_The_Third_Side.java ├── Codeforces_2086A_Cloudberry_Jam.java ├── Codeforces_208A_Dubstep.java ├── Codeforces_2093A_Ideal_Generator.java ├── Codeforces_2094A_Trippi_Troppi.java ├── Codeforces_214A_System_of_Equations.java ├── Codeforces_230A_Dragons.java ├── Codeforces_231A_Team.java ├── Codeforces_233A_Perfect_Permutation.java ├── Codeforces_236A_Boy_or_Girl.java ├── Codeforces_25A_IQ_test.java ├── Codeforces_263A_Beautiful_Matrix.java ├── Codeforces_265A_Colorful_Stones_Simplified_Edition.java ├── Codeforces_266A_Stones_on_the_Table.java ├── Codeforces_266B_Queue_at_the_School.java ├── Codeforces_268A_Games.java ├── Codeforces_268B_Buttons.java ├── Codeforces_270A_Fancy_Fence.java ├── Codeforces_271A_Beautiful_Year.java ├── Codeforces_279B_Books.java ├── Codeforces_281A_Word_Capitalization.java ├── Codeforces_282A_Bit++.java ├── Codeforces_313A_Ilya_and_Bank_Account.java ├── Codeforces_313B_Ilya_and_Queries.java ├── Codeforces_318A_Even_Odds.java ├── Codeforces_320A_Magic_Numbers.java ├── Codeforces_327A_Flipping_Game.java ├── Codeforces_32B_Borze.java ├── Codeforces_337A_Puzzles.java ├── Codeforces_339A_Helpful_Maths.java ├── Codeforces_339B_Xenia_and_Ringroad.java ├── Codeforces_344A_Magnets.java ├── Codeforces_34B_Sale.java ├── Codeforces_363B_Fence.java ├── Codeforces_368B_Sereja_and_Suffixes.java ├── Codeforces_379A_New_Year_Candles.java ├── Codeforces_381A_Sereja_and_Dima.java ├── Codeforces_405A_Gravity_Flip.java ├── Codeforces_41A_Translation.java ├── Codeforces_427A_Police_Recruits.java ├── Codeforces_431A_Black_Square.java ├── Codeforces_432A_Choosing_Teams.java ├── Codeforces_433B_Kuriyama_Mirai_s_Stones.java ├── Codeforces_43A_Football.java ├── Codeforces_443A_Anton_and_Letters.java ├── Codeforces_450A_Jzzhu_and_Children.java ├── Codeforces_451A_Game_With_Sticks.java ├── Codeforces_451B_Sort_the_Array.java ├── Codeforces_455A_Boredom.java ├── Codeforces_456A_Laptops.java ├── Codeforces_459A_Pashmak_and_Garden.java ├── Codeforces_459B_Pashmak_and_Flowers.java ├── Codeforces_460A_Vasya_and_Socks.java ├── Codeforces_466A_Cheap_Travel.java ├── Codeforces_466C_Number_of_Ways.java ├── Codeforces_467A_George_and_Accommodation.java ├── Codeforces_467B_Fedor_and_New_Game.java ├── Codeforces_469A_I_Wanna_Be_the_Guy.java ├── Codeforces_472A_Design_Tutorial_Learn_from_Math.java ├── Codeforces_474A_Keyboard.java ├── Codeforces_474B_Worms.java ├── Codeforces_476A_Dreamoon_and_Stairs.java ├── Codeforces_478B_Random_Teams.java ├── Codeforces_479A_Expression.java ├── Codeforces_486A_Calculating_Function.java ├── Codeforces_489B_BerSU_Ball.java ├── Codeforces_489C_Given_Length_and_Sum_of_Digits.java ├── Codeforces_490A_Team_Olympiad.java ├── Codeforces_492A_Vanya_and_Cubes.java ├── Codeforces_492B_Vanya_and_Lanterns.java ├── Codeforces_499B_Lecture.java ├── Codeforces_4C_Registration_system.java ├── Codeforces_500A_New_Year_Transportation.java ├── Codeforces_509A_Maximum_in_Table.java ├── Codeforces_50A_Domino_piling.java ├── Codeforces_510A_Fox_And_Snake.java ├── Codeforces_514A_Chewbacca_and_Number.java ├── Codeforces_519B_A_and_B_and_Compilation_Errors.java ├── Codeforces_520A_Pangram.java ├── Codeforces_520B_Two_Buttons.java ├── Codeforces_540A_Combination_Lock.java ├── Codeforces_546A_Soldier_and_Bananas.java ├── Codeforces_550A_Two_Substrings.java ├── Codeforces_556A_Case_of_the_Zeros_and_Ones.java ├── Codeforces_567A_Lineland_Mail.java ├── Codeforces_577A_Multiplication_Table.java ├── Codeforces_579A_Raising_Bacteria.java ├── Codeforces_580A_Kefa_and_First_Steps.java ├── Codeforces_581A_Vasya_the_Hipster.java ├── Codeforces_584A_Olesya_and_Rodion.java ├── Codeforces_58A_Chat_room.java ├── Codeforces_617A_Elephant.java ├── Codeforces_61A_Ultra_Fast_Mathematician.java ├── Codeforces_630A_Again_Twenty_Five.java ├── Codeforces_677A_Vanya_and_Fence.java ├── Codeforces_686A_Free_Ice_Cream.java ├── Codeforces_688B_Lovely_Palindromes.java ├── Codeforces_69A_Young_Physicist.java ├── Codeforces_702A_Maximum_Increase.java ├── Codeforces_703A_Mishka_and_Game.java ├── Codeforces_705A_Hulk.java ├── Codeforces_706B_Interesting_drink.java ├── Codeforces_707A_Brain_s_Photos.java ├── Codeforces_711A_Bus_to_Udayland.java ├── Codeforces_71A_Way_Too_Long_Words.java ├── Codeforces_723A_The_New_Year_Meeting_Friends.java ├── Codeforces_731A_Night_at_the_Museum.java ├── Codeforces_732A_Buy_a_Shovel.java ├── Codeforces_734A_Anton_and_Danik.java ├── Codeforces_734B_Anton_and_Digit.java ├── Codeforces_742A_Arpa_s_hard_exam_and_Mehrdad_s_naive_cheat.java ├── Codeforces_749A_Bachgold_Problem.java ├── Codeforces_750A_New_Year_and_Hurry.java ├── Codeforces_758A_Holiday_Of_Equality.java ├── Codeforces_766B_Mahmoud_and_a_Triangle.java ├── Codeforces_785A_Anton_and_Polyhedrons.java ├── Codeforces_791A_Bear_and_Big_Brother.java ├── Codeforces_80A_Panoramix_s_Prediction.java ├── Codeforces_822A_I_m_bored_with_life.java ├── Codeforces_82A_Double_Cola.java ├── Codeforces_894A_QAQ.java ├── Codeforces_935A_Fafa_and_his_Company.java ├── Codeforces_959A_Mahmoud_and_Ehab_and_the_even_odd_game.java ├── Codeforces_96A_Football.java ├── Codeforces_977A_Wrong_Subtraction.java ├── Codeforces_977B_Two_gram.java ├── Codeforces_978B_File_Name.java ├── Codeforces_996A_Hit_the_Lottery.java ├── Codeforces_9A_Die_Roll.java ├── codeForces_13A_Numbers.cpp ├── codeForces_13D_D_Triangles.cpp ├── codeForces_1A_A_Theatre_Square.cpp └── codeForces_4A_A_Watermelon.cpp ├── contest ├── leetcode_biweek_17 │ ├── [refered]leetcode_5146_Distinct_Echo_Substrings.py │ ├── leetcode_5143_Decompress_Run-Length_Encoded_List.cpp │ ├── leetcode_5144_Matrix_Block_Sum.cpp │ ├── leetcode_5145_Sum_of_Nodes_with_Even-Valued_Grandparent.cpp │ └── leetcode_5146_Distinct_Echo_Substrings.cpp ├── leetcode_biweek_26 │ ├── [editing]leetcode_5398_Count_Good_Nodes_in_Binary_Tree.cpp │ ├── [editing]leetcode_5399_Form_Largest_Integer_With_Digits_That_Add_up_to_Target.cpp │ ├── leetcode_5396_Consecutive_Characters.cpp │ └── leetcode_5397_Simplified_Fractions.cpp ├── leetcode_biweek_52 │ ├── leetcode_1859_Sorting_the_Sentence.java │ ├── leetcode_1860_Incremental_Memory_Leak.java │ └── leetcode_1861_Rotating_the_Box.java ├── leetcode_biweek_57 │ ├── [editing]leetcode_1943_Describe_the_Painting.java │ ├── [editing]leetcode_1944_Number_of_Visible_People_in_a_Queue.java │ ├── leetcode_1941_Check_if_All_Characters_Have_Equal_Number_of_Occurrences.java │ └── leetcode_1942_The_Number_of_the_Smallest_Unoccupied_Chair.java ├── leetcode_biweek_58 │ ├── [editing]leetcode_1959_Minimum_Total_Space_Wasted_With_K_Resizing_Operations.java │ ├── [editing]leetcode_1960_Maximum_Product_of_the_Length_of_Two_Palindromic_Substrings.java │ ├── leetcode_1957_delete_characters_to_make_fancy_string.java │ └── leetcode_1958_Check_if_Move_is_Legal.java ├── leetcode_biweek_59 │ ├── [editing]leetcode_1976_Number_of_Ways_to_Arrive_at_Destination.java │ ├── [editing]leetcode_1977_Number_of_Ways_to_Separate_Numbers.java │ ├── leetcode_1974_Minimum_Time_to_Type_Word_Using_Special_Typewriter.java │ └── leetcode_1975_Maximum_Matrix_Sum.java ├── leetcode_biweek_60 │ ├── leetcode_1991_find_the_middle_index_in_array.java │ └── leetcode_1993_Operations_on_Tree.java ├── leetcode_week_166 │ ├── [editing]leetcode_1282_Group_the_People_Given_the_Group_Size_They_Belong_To.cpp │ ├── [editing]leetcode_1283_Find_the_Smallest_Divisor_Given_a_Threshold.cpp │ ├── [editing]leetcode_1284_Minimum_Number_of_Flips_to_Convert_Binary_Matrix_to_Zero_Matrix.cpp │ └── leetcode_1281_Subtract_the_Product_and_Sum_of_Digits_of_an_Integer.cpp ├── leetcode_week_169 │ ├── [editing]leetcode_1304_Find_N_Unique_Integers_Sum_up_to_Zero.cpp │ ├── [editing]leetcode_1305_All_Elements_in_Two_Binary_Search_Trees.cpp │ ├── [editing]leetcode_1306_Jump_Game_III.cpp │ └── [editing]leetcode_1307_Verbal_Arithmetic_Puzzle.cpp ├── leetcode_week_171 │ ├── leetcode_5307_Convert_Integer_to_the_Sum_of_Two_No-Zero_Integers.cpp │ ├── leetcode_5308_Minimum_Flips_to_Make_a_OR_b_Equal_to_c.cpp │ └── leetcode_5309_Number_of_Operations_to_Make_Network_Connected.cpp ├── leetcode_week_189 │ ├── [editing]leetcode_5414_People_Whose_List_of_Favorite_Companies_Is_Not_a_Subset_of_Another_List.cpp │ ├── [editing]leetcode_5415_Maximum_Number_of_Darts_Inside_of_a_Circular_Dartboard.cpp │ ├── leetcode_5412_Number_of_Students_Doing_Homework_at_a_Given_Time.cpp │ └── leetcode_5413_Rearrange_Words_in_a_Sentence.php ├── leetcode_week_236 │ ├── leetcode_1822_Sign_of_the_Product_of_an_Array.java │ └── leetcode_1823_Find_the_Winner_of_the_Circular_Game.java ├── leetcode_week_237 │ ├── leetcode_1832_Check_if_the_Sentence_Is_Pangram.java │ ├── leetcode_1833_Maximum_Ice_Cream_Bars.java │ ├── leetcode_1834_Single-Threaded_CPU.java │ └── leetcode_1835_Find_XOR_Sum_of_All_Pairs_Bitwise_AND.java ├── leetcode_week_249 │ ├── leetcode_1929_Concatenation_of_Array.java │ ├── leetcode_1930_Unique_Length-3_Palindromic_Subsequences.java │ └── leetcode_1932_Merge_BSTs_to_Create_Single_BST.java ├── leetcode_week_250 │ ├── leetcode_1935_Maximum_Number_of_Words_You_Can_Type.java │ └── leetcode_1936_Add_Minimum_Number_of_Rungs.java ├── leetcode_week_251 │ ├── leetcode_1945_sum_of_digits_of_string_after_convert.java │ └── leetcode_1946_Largest_Number_After_Mutating_Substring.java ├── leetcode_week_254 │ ├── leetcode_1967_Number_of_Strings_That_Appear_as_Substrings_in_Word.java │ ├── leetcode_1968_Array_With_Elements_Not_Equal_to_Average_of_Neighbors.java │ ├── leetcode_1969_Minimum_Non-Zero_Product_of_the_Array_Elements.java │ └── leetcode_1970_Last_Day_Where_You_Can_Still_Cross.java └── leetcode_week_267 │ ├── [editing]leetcode_2076_Process_Restricted_Friend_Requests.java │ ├── leetcode_2073_Time_Needed_to_Buy_Tickets.java │ ├── leetcode_2074_Reverse_Nodes_in_Even_Length_Groups.java │ └── leetcode_2075_Decode_the_Slanted_Ciphertext.java ├── fibonacci └── test.c ├── leetcode_solved ├── [todo-understand]leetcode_0043_Multiply_Strings.cpp ├── leetcode_0002_Add_Two_Numbers.java ├── leetcode_0010_Regular_Expression_Matching.cpp ├── leetcode_0011_Container_With_Most_Water.cpp ├── leetcode_0012_Integer_to_Roman.cpp ├── leetcode_0013_Roman_to_Integer.cpp ├── leetcode_0014_Longest_Common_Prefix.cpp ├── leetcode_0015_3Sum.cpp ├── leetcode_0016_3Sum_Closest.cpp ├── leetcode_0017_Letter_Combinations_of_a_Phone_Number.cpp ├── leetcode_0018_4Sum.cpp ├── leetcode_0019_Remove_Nth_Node_From_End_of_List.cpp ├── leetcode_0019_Remove_Nth_Node_From_End_of_List.java ├── leetcode_0020_Valid_Parentheses.cpp ├── leetcode_0021_Merge_Two_Sorted_Lists.cpp ├── leetcode_0022_Generate_Parentheses.cpp ├── leetcode_0023_Merge_k_Sorted_Lists.cpp ├── leetcode_0024_Swap_Nodes_in_Pairs.cpp ├── leetcode_0025_Reverse_Nodes_in_k-Group.cpp ├── leetcode_0026_Remove_Duplicates_from_Sorted_Array.cpp ├── leetcode_0027_Remove_Element.cpp ├── leetcode_0028_Implement_strStr().cpp ├── leetcode_0029_Divide_Two_Intergers.cpp ├── leetcode_0030_Substring_with_Concatenation_of_All_Words.cpp ├── leetcode_0031_Next_Permutation.cpp ├── leetcode_0032_Longest_Valid_Parentheses.cpp ├── leetcode_0033_Search_in_Rotated_Sorted_Array.cpp ├── leetcode_0034_Find_First_and_Last_Position_of_Element_in_Sorted_Array.cpp ├── leetcode_0035_Search_Insert_Position.cpp ├── leetcode_0036_Valid_Sudoku.cpp ├── leetcode_0037_Sudoku_Solver.cpp ├── leetcode_0038_Count_and_Say.cpp ├── leetcode_0039_Combination_Sum.cpp ├── leetcode_0040_Combination_Sum_II.java ├── leetcode_0041_First_Missing_Positive.java ├── leetcode_0042_Trapping_Rain_Water.java ├── leetcode_0044_Wildcard_Matching.cpp ├── leetcode_0045_Jump_Game_II.java ├── leetcode_0046_Permutations.java ├── leetcode_0047_Permutations_II.java ├── leetcode_0048_Rotate_Image.java ├── leetcode_0049_Group_Anagrams.java ├── leetcode_0050_Pow_x_n.cpp ├── leetcode_0051_N-Queens.java ├── leetcode_0052_N-Queens_II.java ├── leetcode_0053_Maximum_Subarray.cpp ├── leetcode_0054_Spiral_Matrix.java ├── leetcode_0055_Jump_Game.java ├── leetcode_0058_Length_of_Last_Word.cpp ├── leetcode_0059_Spiral_Matrix_II.cpp ├── leetcode_0060_Permutation_Sequence.java ├── leetcode_0061_Rotate_List.cpp ├── leetcode_0062_Unique_Path.cpp ├── leetcode_0063_Unique_Path_With_Obstacles.cpp ├── leetcode_0064_Minimum_Path_Sum.cpp ├── leetcode_0065_Valid_Number.java ├── leetcode_0066_Plus_One.cpp ├── leetcode_0067_Add_Binary.cpp ├── leetcode_0069_Sqrt(x).cpp ├── leetcode_0070_Climbing_Stairs.cpp ├── leetcode_0073_Set_Matrix_Zeroes.java ├── leetcode_0074_Search_a_2D_Matrix.cpp ├── leetcode_0075_Sort_Colors.java ├── leetcode_0076_Minimum_Window_Substring.java ├── leetcode_0077_Combinations.java ├── leetcode_0078_Subsets.java ├── leetcode_0079_Word_Search.java ├── leetcode_0080_Remove_Duplicates_from_Sorted_Array_II.java ├── leetcode_0081_Search_in_Rotated_Sorted_Array_II.cpp ├── leetcode_0082_Remove_Duplicates_from_Sorted_List_II.java ├── leetcode_0083_Remove_Duplicates_from_Sorted_List.java ├── leetcode_0084_Largest_Rectangle_In_Histogram.cpp ├── leetcode_0085_Maximal_Rectangle.cpp ├── leetcode_0087_Scramble_String.cpp ├── leetcode_0088_Merge_Sorted_Array.java ├── leetcode_0090_Subsets_II.java ├── leetcode_0091_Decode_Ways.cpp ├── leetcode_0092_Reverse_Linked_List_II.java ├── leetcode_0093_Restore_IP_Addresses.java ├── leetcode_0094_Binary_Tree_Inorder_Traversal.java ├── leetcode_0095_Unique_Binary_Search_Trees_II.cpp ├── leetcode_0096_Unique_Binary_Search_Trees.java ├── leetcode_0098_Validate_Binary_Search_Tree.java ├── leetcode_0099_Recover_Binary_Search_Tree.java ├── leetcode_0100_Same_Tree.java ├── leetcode_0102_Binary_Tree_Level_Order_Traversal.java ├── leetcode_0103_Binary_Tree_Zigzag_Level_Order_Traversal.java ├── leetcode_0104_Maximum_Depth_of_Binary_Tree.java ├── leetcode_0105_Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal.java ├── leetcode_0106_Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal.java ├── leetcode_0107_Binary_Tree_Level_Order_Traversal_II.java ├── leetcode_0108_Convert_Sorted_Array_to_Binary_Search_Tree.java ├── leetcode_0109_Convert_Sorted_List_to_Binary_Search_Tree.java ├── leetcode_0110_Balanced_Binary_Tree.java ├── leetcode_0111_Minimum_Depth_of_Binary_Tree.java ├── leetcode_0112_Path_Sum.java ├── leetcode_0113_Path_Sum_II.java ├── leetcode_0114_Flatten_Binary_Tree_to_Linked_List.java ├── leetcode_0115_Distinct_Subsequences.cpp ├── leetcode_0116_Populating_Next_Right_Pointers_in_Each_Node.java ├── leetcode_0117_Populating_Next_Right_Pointers_in_Each_Node_II.java ├── leetcode_0118_Pascal's_Triangle.cpp ├── leetcode_0119_Pascal's_Triangle_II.cpp ├── leetcode_0120_Triangle.cpp ├── leetcode_0121_Best_Time_To_Buy_And_Sell_Stock.cpp ├── leetcode_0122_Best_Time_to_Buy_and_Sell_Stock_II.java ├── leetcode_0123_Best_Time_to_Buy_and_Sell_Stock_III.cpp ├── leetcode_0124_Binary_Tree_Maximum_Path_Sum.java ├── leetcode_0125_Valid_Palindrome.cpp ├── leetcode_0128_Longest_Consecutive_Sequence.java ├── leetcode_0129_Sum_Root_to_Leaf_Numbers.java ├── leetcode_0131_Palindrome_Partitioning.java ├── leetcode_0134_Gas_Station.java ├── leetcode_0136_Single_Number.cpp ├── leetcode_0137_Single_Number_II.cpp ├── leetcode_0138_Copy_List_with_Random_Pointer.java ├── leetcode_0139_Word_Break.java ├── leetcode_0141_Linked_List_Cycle.java ├── leetcode_0142_Linked_List_Cycle_II.java ├── leetcode_0143_Reorder_List.java ├── leetcode_0144_Binary_Tree_Preorder_Traversal.java ├── leetcode_0145_Binary_Tree_Postorder_Traversal.java ├── leetcode_0146_LRU_Cache.java ├── leetcode_0148_Sort_List.java ├── leetcode_0150_Evaluate_Reverse_Polish_Notation.java ├── leetcode_0151_Reverse_Words_in_a_String.java ├── leetcode_0152_Maximum_Product_Subarray.java ├── leetcode_0153_Find_Minimum_in_Rotated_Sorted_Array.java ├── leetcode_0154_Find_Minimum_in_Rotated_Sorted_Array_II.java ├── leetcode_0155_Min_Stack.cpp ├── leetcode_0160_Intersection_of_Two_Linked_Lists.cpp ├── leetcode_0162_Find_Peak_Element.java ├── leetcode_0167_Two_Sum_II_-_Input_array_is_sorted.java ├── leetcode_0168_Excel_Sheet_Column_Title.java ├── leetcode_0169_Majority_Element.cpp ├── leetcode_0171_Excel_Sheet_Column_Number.java ├── leetcode_0172_Factorial_Trailing_Zeroes.java ├── leetcode_0173_Binary_Search_Tree_Iterator.java ├── leetcode_0179_Largest_Number.cpp ├── leetcode_0187_Repeated_DNA_Sequences.java ├── leetcode_0189_Rotate_Array.java ├── leetcode_0191_Number_of_1_Bits.java ├── leetcode_0198_House_Robber.java ├── leetcode_0199_Binary_Tree_Right_Side_View.java ├── leetcode_0200_Number_of_Islands.java ├── leetcode_0202_Happy_Number.cpp ├── leetcode_0203_Remove_Linked_List_Elements.cpp ├── leetcode_0204_Count_Primes.cpp ├── leetcode_0205_Isomorphic_Strings.cpp ├── leetcode_0206_Reverse_Linked_List.cpp ├── leetcode_0207_Course_Schedule.java ├── leetcode_0208_Implement_Trie_(Prefix_Tree).java ├── leetcode_0209_Minimum_Size_Subarray_Sum.java ├── leetcode_0210_Course_Schedule_II.java ├── leetcode_0213_House_Robber_II.java ├── leetcode_0214_Shortest_Palindrome.cpp ├── leetcode_0215_Kth_Largest_Element_in_an_Array.java ├── leetcode_0216_Combination_Sum_III.java ├── leetcode_0217_Contains_Duplicate.java ├── leetcode_0219_Contains_Duplicate_II.java ├── leetcode_0221_Maximal_Square.java ├── leetcode_0222_Count_Complete_Tree_Nodes.java ├── leetcode_0223_Rectangle_Area.java ├── leetcode_0225_Implement_Stack_using_Queues.java ├── leetcode_0226_Invert_Binary_Tree.cpp ├── leetcode_0226_Invert_Binary_Tree.java ├── leetcode_0228_Summary_Ranges.java ├── leetcode_0229_Majority_Element_II.java ├── leetcode_0230_Kth_Smallest_Element_in_a_BST.java ├── leetcode_0231_Power_of_Two.cpp ├── leetcode_0232_Implement_Queue_using_Stack.java ├── leetcode_0233_Number_of_Digit_One.java ├── leetcode_0234_Palindrome_Linked_List.java ├── leetcode_0235_Lowest_Common_Ancestor_of_a_Binary_Search_Tree.java ├── leetcode_0236_Lowest_Common_Ancestor_of_a_Binary_Tree.java ├── leetcode_0237_Delete_Node_in_a_Linked_List.java ├── leetcode_0238_Product_of_Array_Except_Self.java ├── leetcode_0239_Sliding_Window_Maximum.java ├── leetcode_0240_Search_a_2D_Matrix_II.java ├── leetcode_0242_Valid_Anagram.java ├── leetcode_0257_Binary_Tree_Paths.java ├── leetcode_0258_Add_Digits.java ├── leetcode_0260_Single_Number_III.java ├── leetcode_0263_Ugly_Number.cpp ├── leetcode_0264_Ugly_Number_II.cpp ├── leetcode_0268_Missing_Number.cpp ├── leetcode_0273_Integer_to_English_Words.java ├── leetcode_0278_First_Bad_Version.java ├── leetcode_0279_Perfect_Squares.java ├── leetcode_0283_Move_Zeroes.java ├── leetcode_0284_Peeking_Iterator.java ├── leetcode_0287_Find_the_Duplicate_Number.java ├── leetcode_0289_Game_of_Life.java ├── leetcode_0290_Word_Pattern.java ├── leetcode_0292_Nim_Game.java ├── leetcode_0295_Find_Median_from_Data_Stream.java ├── leetcode_0297_Serialize_and_Deserialize_Binary_Tree.java ├── leetcode_0299_Bulls_and_Cows.java ├── leetcode_0300_Longest_Increasing_Subsequence.java ├── leetcode_0303_Range_Sum_Query_-_Immutable.cpp ├── leetcode_0303_Range_Sum_Query_-_Immutable.java ├── leetcode_0318_Maximum_Product_of_Word_Lengths.java ├── leetcode_0319_Bulb_Switcher.java ├── leetcode_0322_Coin_Change.java ├── leetcode_0326_Power_of_Three.cpp ├── leetcode_0328_Odd_Even_Linked_List.java ├── leetcode_0337_House_Robber_III.java ├── leetcode_0338_Counting_Bits.java ├── leetcode_0342_Power_of_Four.cpp ├── leetcode_0343_Integer_Break.java ├── leetcode_0344_Reverse_String.java ├── leetcode_0345_Reverse_Vowels_of_a_String.java ├── leetcode_0347_Top_K_Frequent_Elements.java ├── leetcode_0349_Intersection_of_Two_Arrays.java ├── leetcode_0350_Intersection_of_Two_Arrays_II.java ├── leetcode_0355_Design_Twitter.java ├── leetcode_0357_Count_Numbers_with_Unique_Digits.java ├── leetcode_0363_Max_Sum_of_Rectangle_No_Larger_Than_K.java ├── leetcode_0367_Valid_Perfect_Square.cpp ├── leetcode_0374_Guess_Number_Higher_or_Lower.java ├── leetcode_0378_Kth_Smallest_Element_in_a_Sorted_Matrix.java ├── leetcode_0382_Linked_List_Random_Node.java ├── leetcode_0383_Ransom_Note.java ├── leetcode_0384_Shuffle_an_Array.java ├── leetcode_0386_Lexicographical_Numbers.java ├── leetcode_0387_First_Unique_Character_in_a_String.java ├── leetcode_0389_Find_the_Difference.java ├── leetcode_0392_Is_Subsequence.java ├── leetcode_0394_Decode_String.java ├── leetcode_0398_Random_Pick_Index.java ├── leetcode_0401_Binary_Watch.cpp ├── leetcode_0404_Sum_of_Left_Leaves.cpp ├── leetcode_0405_Convert_a_Number_to_Hexadecimal.java ├── leetcode_0406_Queue_Reconstruction_by_Height.java ├── leetcode_0409_Longest_Palindrome.cpp ├── leetcode_0412_Fizz_Buzz.java ├── leetcode_0413_Arithmetic_Slices.java ├── leetcode_0414_Third_Maximum_Number.java ├── leetcode_0415_Add_Strings.java ├── leetcode_0416_Partition_Equal_Subset_Sum.java ├── leetcode_0419_Battleships_in_a_Board.java ├── leetcode_0429_N-ary_Tree_Level_Order_Traversal.java ├── leetcode_0434_Number_of_Segments_in_a_String.java ├── leetcode_0438_Find_All_Anagrams_in_a_String.java ├── leetcode_0441_Arranging_Coins.java ├── leetcode_0442_Find_All_Duplicates_in_an_Array.java ├── leetcode_0445_Add_Two_Numbers_II.java ├── leetcode_0448_Find_All_Numbers_Disappeared_in_an_Array.java ├── leetcode_0451_Sort_Characters_By_Frequency.java ├── leetcode_0453_Minimum_Moves_to_Equal_Array_Elements.java ├── leetcode_0454_4Sum_II.java ├── leetcode_0455_Assign_Cookies.java ├── leetcode_0459_Repeated_Substring_Pattern.java ├── leetcode_0460_LFU_Cache.java ├── leetcode_0461_Hamming_Distance.java ├── leetcode_0462_Minimum_Moves_to_Equal_Array_Elements_II.java ├── leetcode_0463_Island_Perimeter.java ├── leetcode_0468_Validate_IP_Address.java ├── leetcode_0476_Number_Complement.java ├── leetcode_0482_License_Key_Formatting.java ├── leetcode_0485_Max_Consecutive_Ones.java ├── leetcode_0491_Increasing_Subsequences.java ├── leetcode_0492_Construct_the_Rectangle.java ├── leetcode_0495_Teemo_Attacking.java ├── leetcode_0496_Next_Greater_Element_I.java ├── leetcode_0500_Keyboard_Row.java ├── leetcode_0501_Find_Mode_in_Binary_Search_Tree.java ├── leetcode_0503_Next_Greater_Element_II.java ├── leetcode_0504_Base_7.java ├── leetcode_0506_Relative_Ranks.java ├── leetcode_0507_Perfect_Number.java ├── leetcode_0508_Most_Frequent_Subtree_Sum.java ├── leetcode_0509_Fibonacci_Number.java ├── leetcode_0513_Find_Bottom_Left_Tree_Value.java ├── leetcode_0515_Find_Largest_Value_in_Each_Tree_Row.java ├── leetcode_0520_Detect_Capital.java ├── leetcode_0521_Longest_Uncommon_Subsequence_I.java ├── leetcode_0523_Continuous_Subarray_Sum.java ├── leetcode_0525_Contiguous_Array.java ├── leetcode_0530_Minimum_Absolute_Difference_in_BST.java ├── leetcode_0532_K-diff_Pairs_in_an_Array.java ├── leetcode_0535_Encode_and_Decode_TinyURL.java ├── leetcode_0537_Complex_Number_Multiplication.java ├── leetcode_0538_Convert_BST_to_Greater_Tree.cpp ├── leetcode_0539_Minimum_Time_Difference.cpp ├── leetcode_0539_Minimum_Time_Difference.java ├── leetcode_0540_Single_Element_in_a_Sorted_Array.java ├── leetcode_0541_Reverse_String_II.cpp ├── leetcode_0541_Reverse_String_II.java ├── leetcode_0543_Diameter_of_Binary_Tree.cpp ├── leetcode_0543_Diameter_of_Binary_Tree.java ├── leetcode_0547_Friend_Circles.java ├── leetcode_0551_Student_Attendance_Record_I.java ├── leetcode_0557_Reverse_Words_in_a_String_III.java ├── leetcode_0559_Maximum_Depth_of_N-ary_Tree.java ├── leetcode_0560_Subarray_Sum_Equals_K.java ├── leetcode_0561_Array_Partition_I.java ├── leetcode_0563_Binary_Tree_Tilt.java ├── leetcode_0566_Reshape_the_Matrix.java ├── leetcode_0572_Subtree_of_Another_Tree.java ├── leetcode_0575_Distribute_Candies.java ├── leetcode_0581_Shortest_Unsorted_Continuous_Subarray.java ├── leetcode_0583_Delete_Operation_for_Two_Strings.java ├── leetcode_0586_Customer_Placing_the_Largest_Number_of_Orders.sql ├── leetcode_0589_N-ary_Tree_Preorder_Traversal.java ├── leetcode_0590_N-ary_Tree_Postorder_Traversal.java ├── leetcode_0593_Valid_Square.java ├── leetcode_0594_Longest_Harmonious_Subsequence.java ├── leetcode_0598_Range_Addition_II.java ├── leetcode_0599_Minimum_Index_Sum_of_Two_Lists.java ├── leetcode_0605_Can_Place_Flowers.java ├── leetcode_0606_Construct_String_from_Binary_Tree.java ├── leetcode_0607_Sales_Person.sql ├── leetcode_0609_Find_Duplicate_File_in_System.java ├── leetcode_0611_Valid_Triangle_Number.java ├── leetcode_0617_Merge_Two_Binary_Trees.java ├── leetcode_0621_Task_Scheduler.java ├── leetcode_0623_Add_One_Row_to_Tree.java ├── leetcode_0628_Maximum_Product_of_Three_Numbers.java ├── leetcode_0633_Sum_of_Square_Numbers.java ├── leetcode_0637_Average_of_Levels_in_Binary_Tree.java ├── leetcode_0641_Design_Circular_Deque.java ├── leetcode_0643_Maximum_Average_Subarray_I.java ├── leetcode_0645_Set_Mismatch.java ├── leetcode_0646_Maximum_Length_of_Pair_Chain.java ├── leetcode_0647_Palindromic_Substrings.java ├── leetcode_0648_Replace_Words.java ├── leetcode_0650_2_Keys_Keyboard.java ├── leetcode_0652_Find_Duplicate_Subtrees.java ├── leetcode_0653_Two_Sum_IV_-_Input_is_a_BST.java ├── leetcode_0654_Maximum_Binary_Tree.java ├── leetcode_0657_Robot_Return_to_Origin.java ├── leetcode_0661_Image_Smoother.java ├── leetcode_0662_Maximum_Width_of_Binary_Tree.java ├── leetcode_0669_Trim_a_Binary_Search_Tree.cpp ├── leetcode_0671_Second_Minimum_Node_In_a_Binary_Tree.java ├── leetcode_0672_Bulb_Switcher_II.java ├── leetcode_0674_Longest_Continuous_Increasing_Subsequence.java ├── leetcode_0677_Map_Sum_Pairs.java ├── leetcode_0680_Valid_Palindrome_II.java ├── leetcode_0682_Baseball_Game.java ├── leetcode_0690_Employee_Importance.java ├── leetcode_0692_Top_K_Frequent_Words.java ├── leetcode_0693_Binary_Number_with_Alternating_Bits.java ├── leetcode_0696_Count_Binary_Substrings.java ├── leetcode_0697_Degree_of_an_Array.java ├── leetcode_0700_Search_in_a_Binary_Search_Tree.java ├── leetcode_0701_Insert_into_a_Binary_Search_Tree.java ├── leetcode_0703_Kth_Largest_Element_in_a_Stream.java ├── leetcode_0704_Binary_Search.java ├── leetcode_0705_Design_HashSet.java ├── leetcode_0706_Design_HashMap.java ├── leetcode_0709_To_Lower_Case.java ├── leetcode_0713_Subarray_Product_Less_Than_K.cpp ├── leetcode_0717_1-bit_and_2-bit_Characters.java ├── leetcode_0718_Maximum_Length_of_Repeated_Subarray.java ├── leetcode_0720_Longest_Word_in_Dictionary.java ├── leetcode_0721_Accounts_Merge.java ├── leetcode_0724_Find_Pivot_Index.cpp ├── leetcode_0725_Split_Linked_List_in_Parts.java ├── leetcode_0728_Self_Dividing_Numbers.java ├── leetcode_0729_My_Calendar_I.java ├── leetcode_0733_Flood_Fill.java ├── leetcode_0735_Asteroid_Collision.java ├── leetcode_0739_Daily_Temperatures.java ├── leetcode_0744_Find_Smallest_Letter_Greater_Than_Target.java ├── leetcode_0746_Min_Cost_Climbing_Stairs.java ├── leetcode_0747_Largest_Number_At_Least_Twice_of_Others.java ├── leetcode_0748_Shortest_Completing_Word.java ├── leetcode_0762_Prime_Number_of_Set_Bits_in_Binary_Representation.java ├── leetcode_0763_Partition_Labels.java ├── leetcode_0766_Toeplitz_Matrix.java ├── leetcode_0768_Max_Chunks_To_Make_Sorted_II.cpp ├── leetcode_0769_Max_Chunks_To_Make_Sorted.java ├── leetcode_0771_Jewels_and_Stones.java ├── leetcode_0781_Rabbits_in_Forest.java ├── leetcode_0783_Minimum_Distance_Between_BST_Nodes.java ├── leetcode_0784_Letter_Case_Permutation.java ├── leetcode_0788_Rotated_Digits.java ├── leetcode_0791_Custom_Sort_String.java ├── leetcode_0792_Number_of_Matching_Subsequences.java ├── leetcode_0795_Number_of_Subarrays_with_Bounded_Maximum.java ├── leetcode_0796_Rotate_String.java ├── leetcode_0804_Unique_Morse_Code_Words.cpp ├── leetcode_0806_Number_of_Lines_To_Write_String.java ├── leetcode_0807_Max_Increase_to_Keep_City_Skyline.java ├── leetcode_0808_Soup_Servings.cpp ├── leetcode_0811_Subdomain_Visit_Count.java ├── leetcode_0812_Largest_Triangle_Area.java ├── leetcode_0814_Binary_Tree_Pruning.java ├── leetcode_0817_Linked_List_Components.java ├── leetcode_0819_Most_Common_Word.java ├── leetcode_0821_Shortest_Distance_to_a_Character.java ├── leetcode_0824_Goat_Latin.java ├── leetcode_0830_Positions_of_Large_Groups.java ├── leetcode_0832_Flipping_an_Image.cpp ├── leetcode_0836_Rectangle_Overlap.java ├── leetcode_0841_Keys_and_Rooms.java ├── leetcode_0844_Backspace_String_Compare.java ├── leetcode_0846_Hand_of_Straights.java ├── leetcode_0852_Peak_Index_in_a_Mountain_Array.java ├── leetcode_0856_Score_of_Parentheses.java ├── leetcode_0859_Buddy_Strings.java ├── leetcode_0860_Lemonade_Change.java ├── leetcode_0861_Score_After_Flipping_Matrix.java ├── leetcode_0867_Transpose_Matrix.java ├── leetcode_0868_Binary_Gap.java ├── leetcode_0872_Leaf-Similar_Trees.java ├── leetcode_0876_Middle_of_the_Linked_List.java ├── leetcode_0877_Stone_Game.java ├── leetcode_0883_Projection_Area_of_3D_Shapes.java ├── leetcode_0884_Uncommon_Words_from_Two_Sentences.java ├── leetcode_0888_Fair_Candy_Swap.java ├── leetcode_0890_Find_and_Replace_Pattern.java ├── leetcode_0892_Surface_Area_of_3D_Shapes.java ├── leetcode_0893_Groups_of_Special-Equivalent_Strings.java ├── leetcode_0895_Maximum_Frequency_Stack.java ├── leetcode_0896_Monotonic_Array.java ├── leetcode_0897_Increasing_Order_Search_Tree.java ├── leetcode_0899_Orderly_Queue.java ├── leetcode_0905_Sort_Array_By_Parity.java ├── leetcode_0908_Smallest_Range_I.java ├── leetcode_0912_Sort_an_Array.java ├── leetcode_0914_X_of_a_Kind_in_a_Deck_of_Cards.java ├── leetcode_0916_Word_Subsets.java ├── leetcode_0917_Reverse_Only_Letters.java ├── leetcode_0921_Minimum_Add_to_Make_Parentheses_Valid.java ├── leetcode_0922_Sort_Array_By_Parity_II.java ├── leetcode_0925_Long_Pressed_Name.java ├── leetcode_0929_Unique_Email_Addresses.java ├── leetcode_0930_Binary_Subarrays_With_Sum.java ├── leetcode_0932_Beautiful_Array.java ├── leetcode_0933_Number_of_Recent_Calls.java ├── leetcode_0937_Reorder_Data_in_Log_Files.java ├── leetcode_0938_Range_Sum_of_BST.java ├── leetcode_0941_Valid_Mountain_Array.java ├── leetcode_0942_DI_String_Match.java ├── leetcode_0944_Delete_Columns_to_Make_Sorted.java ├── leetcode_0945_Minimum_Increment_to_Make_Array_Unique.java ├── leetcode_0946_Validate_Stack_Sequences.java ├── leetcode_0950_Reveal_Cards_In_Increasing_Order.java ├── leetcode_0951_Flip_Equivalent_Binary_Trees.java ├── leetcode_0953_Verifying_an_Alien_Dictionary.java ├── leetcode_0954_Array_of_Doubled_Pairs.java ├── leetcode_0961_N-Repeated_Element_in_Size_2N_Array.java ├── leetcode_0965_Univalued_Binary_Tree.java ├── leetcode_0969_Pancake_Sorting.java ├── leetcode_0973_K_Closest_Points_to_Origin.java ├── leetcode_0974_Subarray_Sums_Divisible_by_K.java ├── leetcode_0976_Largest_Perimeter_Triangle.java ├── leetcode_0977_Squares_of_a_Sorted_Array.java ├── leetcode_0979_Distribute_Coins_in_Binary_Tree.java ├── leetcode_0981_Time_Based_Key-Value_Store.java ├── leetcode_0985_Sum_of_Even_Numbers_After_Queries.java ├── leetcode_0988_Smallest_String_Starting_From_Leaf.java ├── leetcode_0989_Add_to_Array-Form_of_Integer.java ├── leetcode_0993_Cousins_in_Binary_Tree.java ├── leetcode_0997_Find_the_Town_Judge.java ├── leetcode_0999_Available_Captures_for_Rook.java ├── leetcode_1002_Find_Common_Characters.java ├── leetcode_1003_Check_If_Word_Is_Valid_After_Substitutions.java ├── leetcode_1004_Max_Consecutive_Ones_III.java ├── leetcode_1005_Maximize_Sum_Of_Array_After_K_Negations.java ├── leetcode_1008_Construct_Binary_Search_Tree_from_Preorder_Traversal.java ├── leetcode_1009_Complement_of_Base_10_Integer.java ├── leetcode_100_Same_Tree.java ├── leetcode_1010_Pairs_of_Songs_With_Total_Durations_Divisible_by_60.java ├── leetcode_1013_Partition_Array_Into_Three_Parts_With_Equal_Sum.java ├── leetcode_1015_Smallest_Integer_Divisible_by_K.java ├── leetcode_1017_Convert_to_Base_-2.java ├── leetcode_1018_Binary_Prefix_Divisible_By_5.java ├── leetcode_1019_Next_Greater_Node_In_Linked_List.java ├── leetcode_101_Symmetric_Tree.java ├── leetcode_1020_Number_of_Enclaves.java ├── leetcode_1021_Remove_Outermost_Parentheses.java ├── leetcode_1022_Sum_of_Root_To_Leaf_Binary_Numbers.java ├── leetcode_1023_Camelcase_Matching.java ├── leetcode_1025_Divisor_Game.java ├── leetcode_1026_Maximum_Difference_Between_Node_and_Ancestor.java ├── leetcode_1030_Matrix_Cells_in_Distance_Order.java ├── leetcode_1031_Maximum_Sum_of_Two_Non-Overlapping_Subarrays.java ├── leetcode_1033_Moving_Stones_Until_Consecutive.java ├── leetcode_1037_Valid_Boomerang.java ├── leetcode_1038_Binary_Search_Tree_to_Greater_Sum_Tree.java ├── leetcode_1041_Robot_Bounded_In_Circle.java ├── leetcode_1043_Partition_Array_for_Maximum_Sum.java ├── leetcode_1046_Last_Stone_Weight.java ├── leetcode_1047_Remove_All_Adjacent_Duplicates_In_String.java ├── leetcode_1049_Last_Stone_Weight_II.cpp ├── leetcode_1050_Actors_and_Directors_Who_Cooperated_At_Least_Three_Times.sql ├── leetcode_1051_Height_Checker.java ├── leetcode_1071_Greatest_Common_Divisor_of_Strings.java ├── leetcode_1072_Flip_Columns_For_Maximum_Number_of_Equal_Rows.java ├── leetcode_1074_Number_of_Submatrices_That_Sum_to_Target.java ├── leetcode_1078_Occurrences_After_Bigram.java ├── leetcode_1079_Letter_Tile_Possibilities.java ├── leetcode_1084_Sales_Analysis_III.sql ├── leetcode_1089_Duplicate_Zeros.java ├── leetcode_1090_Largest_Values_From_Labels.java ├── leetcode_1092_Shortest_Common_Supersequence.cpp ├── leetcode_1094_Car_Pooling.java ├── leetcode_1103_Distribute_Candies_to_People.java ├── leetcode_1104_Path_In_Zigzag_Labelled_Binary_Tree.java ├── leetcode_1105_Filling_Bookcase_Shelves.cpp ├── leetcode_1122_Relative_Sort_Array.cpp ├── leetcode_1123_Lowest_Common_Ancestor_of_Deepest_Leaves.cpp ├── leetcode_1124_Longest_Well-Performing_Interval.cpp ├── leetcode_1125_Smallest_Sufficient_Team.cpp ├── leetcode_1128_Number_of_Equivalent_Domino_Pairs.cpp ├── leetcode_1129_Shortest_Path_with_Alternating_Color.cpp ├── leetcode_1130_Minimum_Cost_Tree_From_Leaf_Values.cpp ├── leetcode_1131_Maximum_of_Absolute_Value_Expression.cpp ├── leetcode_1137_Nth_Tribonacci_Number.cpp ├── leetcode_1138_Alphabet_Board_Path.cpp ├── leetcode_1139_Largest_1_Bordered_Square.cpp ├── leetcode_1140_Stone_Game_II.cpp ├── leetcode_1143_Longest_Common_Subsequence.cpp ├── leetcode_1143_Longest_Common_Subsequence.java ├── leetcode_1146_Snapshot_Array.java ├── leetcode_1148_Article_Views_I.sql ├── leetcode_1154_Day_of_the_Year.java ├── leetcode_1154_Duplicate_Zeros.java ├── leetcode_1156_Swap_For_Longest_Repeated_Character_Substring.cpp ├── leetcode_1157_Online_Majority_Element_In_Subarray.cpp ├── leetcode_1160_Find_Words_That_Can_Be_Formed_by_Characters.java ├── leetcode_1161_Maximum_Level_Sum_of_a_Binary_Tree.java ├── leetcode_1163_Last_Substring_in_Lexicographical_Order.cpp ├── leetcode_1169_Invalid_Transactions.cpp ├── leetcode_1170_Compare_Strings_by_Frequency_of_the_Smallest_Character.java ├── leetcode_1171_Remove_Zero_Sum_Consecutive_Nodes_from_Linked_List.java ├── leetcode_1177_Can_Make_Palindrome_from_Substring.cpp ├── leetcode_1178_Number_of_Valid_Words_for_Each_Puzzle.cpp ├── leetcode_1184_Distance_Between_Bus_Stops.cpp ├── leetcode_1185_Day_of_the_Week.cpp ├── leetcode_1189_Maximum_Number_of_Balloons.java ├── leetcode_1190_Reverse_Substrings_Between_Each_Pair_of_Parentheses.java ├── leetcode_1200_Minimum_Absolute_Difference.java ├── leetcode_1206_Design_Skiplist.java ├── leetcode_1207_Unique_Number_of_Occurrences.java ├── leetcode_1217_Play_with_Chips.java ├── leetcode_1221_Split_a_String_in_Balanced_Strings.cpp ├── leetcode_1221_Split_a_String_in_Balanced_Strings.java ├── leetcode_1222_Queens_That_Can_Attack_the_King.java ├── leetcode_1227_Airplane_Seat_Assignment_Probability.java ├── leetcode_1232_Check_If_It_Is_a_Straight_Line.java ├── leetcode_1233_Remove_Sub_Folders_from_the_Filesystem.java ├── leetcode_1237_Find_Positive_Integer_Solution_for_a_Given_Equation.java ├── leetcode_1239_Maximum_Length_of_a_Concatenated_String_with_Unique_Characters.java ├── leetcode_1247_Minimum_Swaps_to_Make_Strings_Equal.java ├── leetcode_1248_Count_Number_of_Nice_Subarrays.java ├── leetcode_1249_Minimum_Remove_to_Make_Valid_Parentheses.java ├── leetcode_1250_Check_If_It_Is_a_Good_Array.java ├── leetcode_1252_Cells_with_Odd_Values_in_a_Matrix.cpp ├── leetcode_1255_Maximum_Score_Words_Formed_by_Letters.java ├── leetcode_1260_Shift_2D_Grid.java ├── leetcode_1261_Find_Elements_in_a_Contaminated_Binary_Tree.java ├── leetcode_1262_Greatest_Sum_Divisible_by_Three.java ├── leetcode_1266_Minimum_Time_Visiting_All_Points.java ├── leetcode_1267_Count_Servers_that_Communicate.java ├── leetcode_1275_Find_Winner_on_a_Tic_Tac_Toe_Game.java ├── leetcode_1277_Count_Square_Submatrices_with_All_Ones.java ├── leetcode_1282_Group_the_People_Given_the_Group_Size_They_Belong_To.java ├── leetcode_1287_Element_Appearing_More_Than_25%_In_Sorted_Array.java ├── leetcode_1288_Remove_Covered_Intervals.java ├── leetcode_1290_Convert_Binary_Number_in_a_Linked_List_to_Integer.java ├── leetcode_1291_Sequential_Digits.java ├── leetcode_1295_Find_Numbers_with_Even_Number_of_Digits.java ├── leetcode_1296_Divide_Array_in_Sets_of_K_Consecutive_Numbers.java ├── leetcode_1298_Maximum_Candies_You_Can_Get_from_Boxes.java ├── leetcode_1299_Replace_Elements_with_Greatest_Element_on_Right_Side.java ├── leetcode_1302_Deepest_Leaves_Sum.java ├── leetcode_1304_Find_N_Unique_Integers_Sum_up_to_Zero.cpp ├── leetcode_1305_All_Elements_in_Two_Binary_Search_Trees.java ├── leetcode_1309_Decrypt_String_from_Alphabet_to_Integer_Mapping.cpp ├── leetcode_1310_XOR_Queries_of_a_Subarray.java ├── leetcode_1323_Maximum_69_Number.cpp ├── leetcode_1324_Print_Words_Vertically.java ├── leetcode_1325_Delete_Leaves_With_a_Given_Value.java ├── leetcode_1328_Break_a_Palindrome.java ├── leetcode_1329_Sort_the_Matrix_Diagonally.java ├── leetcode_1331_Rank_Transform_of_an_Array.cpp ├── leetcode_1332_Remove_Palindromic_Subsequences.cpp ├── leetcode_1337_The_K_Weakest_Rows_in_a_Matrix.java ├── leetcode_1338_Reduce_Array_Size_to_The_Half.java ├── leetcode_1343_Number_of_Sub-arrays_of_Size_K_and_Average_Greater_than_or_Equal_to_Threshold.java ├── leetcode_1346_Check_If_N_and_Its_Double_Exist.java ├── leetcode_1347_Minimum_Number_of_Steps_to_Make_Two_Strings_Anagram.java ├── leetcode_1351_Count_Negative_Numbers_in_a_Sorted_Matrix.cpp ├── leetcode_1356_Sort_Integers_by_The_Number_of_1_Bits.java ├── leetcode_1357_Apply_Discount_Every_n_Orders.java ├── leetcode_1358_Number_of_Substrings_Containing_All_Three_Characters.java ├── leetcode_1359_Count_All_Valid_Pickup_and_Delivery_Options.java ├── leetcode_1360_Number_of_Days_Between_Two_Dates.java ├── leetcode_1365_How_Many_Numbers_Are_Smaller_Than_the_Current_Number.java ├── leetcode_1366_Rank_Teams_by_Votes.java ├── leetcode_1370_Increasing_Decreasing_String.java ├── leetcode_1371_Find_the_Longest_Substring_Containing_Vowels_in_Even_Counts.java ├── leetcode_1374_Generate_a_String_With_Characters_That_Have_Odd_Counts.cpp ├── leetcode_1375_Bulb_Switcher_III.cpp ├── leetcode_1375_Bulb_Switcher_III.java ├── leetcode_1379_Find_a_Corresponding_Node_of_a_Binary_Tree_in_a_Clone_of_That_Tree.java ├── leetcode_1380_Lucky_Numbers_in_a_Matrix.java ├── leetcode_1381_Design_a_Stack_With_Increment_Operation.java ├── leetcode_1382_Balance_a_Binary_Search_Tree.java ├── leetcode_1387_Sort_Integers_by_The_Power_Value.java ├── leetcode_1393_Capital_Gain_Loss.sql ├── leetcode_1394_Find_Lucky_Integer_in_an_Array.java ├── leetcode_1395_Count_Number_of_Teams.java ├── leetcode_1396_Design_Underground_System.java ├── leetcode_1400_Construct_K_Palindrome_Strings.java ├── leetcode_1402_Reducing_Dishes.java ├── leetcode_1403_Minimum_Subsequence_in_Non-Increasing_Order.cpp ├── leetcode_1404_Number_of_Steps_to_Reduce_a_Number_in_Binary_Representation_to_One.java ├── leetcode_1407_Top_Travellers.sql ├── leetcode_1408_String_Matching_in_an_Array.java ├── leetcode_1409_Queries_on_a_Permutation_With_Key.java ├── leetcode_1413_Minimum_Value_to_Get_Positive_Step_by_Step_Sum.java ├── leetcode_1415_The_k-th_Lexicographical_String_of_All_Happy_Strings_of_Length_n.java ├── leetcode_1417_Reformat_The_String.java ├── leetcode_1418_Display_Table_of_Food_Orders_in_a_Restaurant.java ├── leetcode_1422_Maximum_Score_After_Splitting_a_String.java ├── leetcode_1431_Kids_With_the_Greatest_Number_of_Candies.java ├── leetcode_1433_Check_If_a_String_Can_Break_Another_String.java ├── leetcode_1437_Check_If_All_1s_Are_at_Least_Length_K_Places_Away.java ├── leetcode_1441_Build_an_Array_With_Stack_Operations.cpp ├── leetcode_1442_Count_Triplets_That_Can_Form_Two_Arrays_of_Equal_XOR.java ├── leetcode_1455_Check_If_a_Word_Occurs_As_a_Prefix_of_Any_Word_in_a_Sentence.java ├── leetcode_1457_Pseudo-Palindromic_Paths_in_a_Binary_Tree.java ├── leetcode_1460_Make_Two_Arrays_Equal_by_Reversing_Sub-arrays.java ├── leetcode_1464_Maximum_Product_of_Two_Elements_in_an_Array.cpp ├── leetcode_1472_Design_Browser_History.java ├── leetcode_1475_Final_Prices_With_a_Special_Discount_in_a_Shop.java ├── leetcode_1476_Subrectangle_Queries.java ├── leetcode_1480_Running_Sum_of_1d_Array.java ├── leetcode_1481_Least_Number_of_Unique_Integers_after_K_Removals.java ├── leetcode_1484_Group_Sold_Products_By_The_Date.sql ├── leetcode_1491_Average_Salary_Excluding_the_Minimum_and_Maximum_Salary.java ├── leetcode_1492_The_kth_Factor_of_n.java ├── leetcode_1493_Longest_Subarray_of_1's_After_Deleting_One_Element.java ├── leetcode_1496_Path_Crossing.java ├── leetcode_1502_Can_Make_Arithmetic_Progression_From_Sequence.java ├── leetcode_1507_Reformat_Date.java ├── leetcode_1509_Minimum_Difference_Between_Largest_and_Smallest_Value_in_Three_Moves.java ├── leetcode_1510_Stone_Game_IV.java ├── leetcode_1512_Number_of_Good_Pairs.java ├── leetcode_1518_Water_Bottles.java ├── leetcode_1523_Count_Odd_Numbers_in_an_Interval_Range.java ├── leetcode_1524_Number_of_Sub-arrays_With_Odd_Sum.java ├── leetcode_1525_Number_of_Good_Ways_to_Split_a_String.java ├── leetcode_1526_Minimum_Number_of_Increments_on_Subarrays_to_Form_a_Target_Array.java ├── leetcode_1529_Bulb_Switcher_IV.java ├── leetcode_1539_Kth_Missing_Positive_Number.java ├── leetcode_1544_Make_The_String_Great.java ├── leetcode_1550_Three_Consecutive_Odds.java ├── leetcode_1551_Minimum_Operations_to_Make_Array_Equal.java ├── leetcode_1556_Thousand_Separator.java ├── leetcode_1557_Minimum_Number_of_Vertices_to_Reach_All_Nodes.java ├── leetcode_1560_Most_Visited_Sector_in_a_Circular_Track.java ├── leetcode_1561_Maximum_Number_of_Coins_You_Can_Get.java ├── leetcode_1576_Replace_All_s_to_Avoid_Consecutive_Repeating_Characters.cpp ├── leetcode_1578_Minimum_Time_to_Make_Rope_Colorful.java ├── leetcode_1581_Customer_Who_Visited_but_Did_Not_Make_Any_Transactions.sql ├── leetcode_1582_Special_Positions_in_a_Binary_Matrix.java ├── leetcode_1587_Bank_Account_Summary_II.sql ├── leetcode_1588_Sum_of_All_Odd_Length_Subarrays.java ├── leetcode_1598_Crawler_Log_Folder.java ├── leetcode_1600_Throne_Inheritance.java ├── leetcode_1605_Find_Valid_Matrix_Given_Row_and_Column_Sums.java ├── leetcode_1608_Special_Array_With_X_Elements_Greater_Than_or_Equal_X.java ├── leetcode_1609_Even_Odd_Tree.java ├── leetcode_160_Intersection_of_Two_Linked_Lists.java ├── leetcode_1619_Mean_of_Array_After_Removing_Some_Elements.java ├── leetcode_1624_Largest_Substring_Between_Two_Equal_Characters.java ├── leetcode_1629_Slowest_Key.java ├── leetcode_1630_Arithmetic_Subarrays.java ├── leetcode_1636_Sort_Array_by_Increasing_Frequency.java ├── leetcode_1637_Widest_Vertical_Area_Between_Two_Points_Containing_No_Points.java ├── leetcode_1638_Count_Substrings_That_Differ_by_One_Character.java ├── leetcode_1640_Check_Array_Formation_Through_Concatenation.java ├── leetcode_1641_Count_Sorted_Vowel_Strings.java ├── leetcode_1646_Get_Maximum_in_Generated_Array.java ├── leetcode_1647_Minimum_Deletions_to_Make_Character_Frequencies_Unique.java ├── leetcode_1652_Defuse_the_Bomb.java ├── leetcode_1653_Minimum_Deletions_to_Make_String_Balanced.java ├── leetcode_1656_Design_an_Ordered_Stream.java ├── leetcode_1657_Determine_if_Two_Strings_Are_Close.java ├── leetcode_1663_Smallest_String_With_A_Given_Numeric_Value.java ├── leetcode_1664_Ways_to_Make_a_Fair_Array.java ├── leetcode_1667_Fix_Names_in_a_Table.sql ├── leetcode_1668_Maximum_Repeating_Substring.java ├── leetcode_1669_Merge_In_Between_Linked_Lists.java ├── leetcode_1683_Invalid_Tweets.sql ├── leetcode_1685_Sum_of_Absolute_Differences_in_a_Sorted_Array.java ├── leetcode_1689_Partitioning_Into_Minimum_Number_Of_Deci-Binary_Numbers.java ├── leetcode_1693_Daily_Leads_and_Partners.sql ├── leetcode_1700_Number_of_Students_Unable_to_Eat_Lunch.java ├── leetcode_1703_Determine_if_String_Halves_Are_Alike.cpp ├── leetcode_1704_Determine_if_String_Halves_Are_Alike.cpp ├── leetcode_1710_Maximum_Units_on_a_Truck.java ├── leetcode_1721_Swapping_Nodes_in_a_Linked_List.java ├── leetcode_1726_Tuple_with_Same_Product.java ├── leetcode_1729_Find_Followers_Count.sql ├── leetcode_1736_Latest_Time_by_Replacing_Hidden_Digits.java ├── leetcode_1741_Find_Total_Time_Spent_by_Each_Employee.sql ├── leetcode_1743_Restore_the_Array_From_Adjacent_Pairs.java ├── leetcode_1753_Maximum_Score_From_Removing_Stones.java ├── leetcode_1757_Recyclable_and_Low_Fat_Products.sql ├── leetcode_1759_Count_Number_of_Homogenous_Substrings.java ├── leetcode_1763_Longest_Nice_Substring.java ├── leetcode_1769_Minimum_Number_of_Operations_to_Move_All_Balls_to_Each_Box.java ├── leetcode_1780_Check_if_Number_is_a_Sum_of_Powers_of_Three.java ├── leetcode_1781_Sum_of_Beauty_of_All_Substrings.java ├── leetcode_1791_Find_Center_of_Star_Graph.java ├── leetcode_1795_Rearrange_Products_Table.sql ├── leetcode_1805_Number_of_Different_Integers_in_a_String.java ├── leetcode_1807_Evaluate_the_Bracket_Pairs_of_a_String.java ├── leetcode_1817_Finding_the_Users_Active_Minutes.java ├── leetcode_1827_Minimum_Operations_to_Make_the_Array_Increasing.java ├── leetcode_1828_Queries_on_Number_of_Points_Inside_a_Circle.java ├── leetcode_1829_Maximum_XOR_for_Each_Query.java ├── leetcode_1845_Seat_Reservation_Manager.java ├── leetcode_1863_Sum_of_All_Subset_XOR_Totals.java ├── leetcode_1873_Calculate_Special_Bonus.sql ├── leetcode_1886_Determine_Whether_Matrix_Can_Be_Obtained_By_Rotation.java ├── leetcode_1887_Reduction_Operations_to_Make_the_Array_Elements_Equal.java ├── leetcode_1890_The_Latest_Login_in_2020.sql ├── leetcode_1893_Check_if_All_the_Integers_in_a_Range_Are_Covered.java ├── leetcode_1897_Redistribute_Characters_to_Make_All_Strings_Equal.java ├── leetcode_1903_Largest_Odd_Number_in_String.java ├── leetcode_1904_The_Number_of_Full_Rounds_You_Have_Played.java ├── leetcode_1909_Remove_One_Element_to_Make_the_Array_Strictly_Increasing.java ├── leetcode_1913_Maximum_Product_Difference_Between_Two_Pairs.java ├── leetcode_1920_Build_Array_from_Permutation.java ├── leetcode_1925_Count_Square_Sum_Triples.java ├── leetcode_1929_Concatenation_of_Array.java ├── leetcode_1930_Unique_Length-3_Palindromic_Subsequences.java ├── leetcode_1932_Merge_BSTs_to_Create_Single_BST.java ├── leetcode_1935_Maximum_Number_of_Words_You_Can_Type.java ├── leetcode_1952_Three_Divisors.java ├── leetcode_1962_Remove_Stones_to_Minimize_the_Total.java ├── leetcode_1963_Minimum_Number_of_Swaps_to_Make_the_String_Balanced.java ├── leetcode_1965_Employees_With_Missing_Information.sql ├── leetcode_1967_Number_of_Strings_That_Appear_as_Substrings_in_Word.java ├── leetcode_1968_Array_With_Elements_Not_Equal_to_Average_of_Neighbors.java ├── leetcode_1969_Minimum_Non-Zero_Product_of_the_Array_Elements.java ├── leetcode_1970_Last_Day_Where_You_Can_Still_Cross.java ├── leetcode_1971_Find_if_Path_Exists_in_Graph.java ├── leetcode_1974_Minimum_Time_to_Type_Word_Using_Special_Typewriter.java ├── leetcode_1975_Maximum_Matrix_Sum.java ├── leetcode_1979_Find_Greatest_Common_Divisor_of_Array.java ├── leetcode_1980_Find_Unique_Binary_String.java ├── leetcode_1984_Minimum_Difference_Between_Highest_and_lowest_of_k_scores.java ├── leetcode_1985_Find_the_Kth_Largest_Integer_in_the_Array.java ├── leetcode_1995_Count_Special_Quadruplets.java ├── leetcode_1996_The_Number_of_Weak_Characters_in_the_Game.java ├── leetcode_2000_Reverse_Prefix_of_Word.java ├── leetcode_2006_Count_Number_of_Pairs_With_Absolute_Difference_K.java ├── leetcode_2011_Final_Value_of_Variable_After_Performing_Operations.java ├── leetcode_2012_Sum_of_Beauty_in_the_Array.java ├── leetcode_2016_Maximum_Difference_Between_Increasing_Elements.java ├── leetcode_2022_Convert_1D_Array_Into_2D_Array.java ├── leetcode_2023_Number_of_Pairs_of_Strings_With_Concatenation_Equal_to_Target.java ├── leetcode_2027_Minimum_Moves_to_Convert_String.java ├── leetcode_2032_Two_Out_of_Three.java ├── leetcode_2033_Minimum_Operations_to_Make_a_Uni-Value_Grid.java ├── leetcode_2037_Minimum_Number_of_Moves_to_Seat_Everyone.java ├── leetcode_2038_Remove_Colored_Pieces_if_Both_Neighbors_are_the_Same_Color.java ├── leetcode_2042_Check_if_Numbers_Are_Ascending_in_a_Sentence.java ├── leetcode_2043_Simple_Bank_System.java ├── leetcode_2047_Number_of_Valid_Words_in_a_Sentence.java ├── leetcode_2053_Kth_Distinct_String_in_an_Array.java ├── leetcode_2057_Smallest_Index_With_Equal_Value.java ├── leetcode_2058_Find_the_Minimum_and_Maximum_Number_of_Nodes_Between_Critical_Points.java ├── leetcode_205_Isomorphic_Strings.java ├── leetcode_2062_Count_Vowel_Substrings_of_a_String.java ├── leetcode_2068_Check_Whether_Two_Strings_are_Almost_Equivalent.java ├── leetcode_206_Reverse_Linked_List.java ├── leetcode_2078_Two_Furthest_Houses_With_Different_C.java ├── leetcode_2079_Watering_Plants.java ├── leetcode_2085_Count_Common_Words_With_One_Occurrence.java ├── leetcode_2089_Find_Target_Indices_After_Sorting_Array.java ├── leetcode_2091_Removing_Minimum_and_Maximum_From_Array.java ├── leetcode_2094_Finding_3-Digit_Even_Numbers.java ├── leetcode_2095_Delete_the_Middle_Node_of_a_Linked_List.java ├── leetcode_2099_Find_Subsequence_of_Length_K_With_the_Largest_Sum.java ├── leetcode_2103_Rings_and_Rods.java ├── leetcode_2108_Find_First_Palindromic_String_in_the_Array.java ├── leetcode_2109_Adding_Spaces_to_a_String.java ├── leetcode_2114_Maximum_Number_of_Words_Found_in_Sentences.java ├── leetcode_2116_Check_if_a_Parentheses_String_Can_Be_Valid.java ├── leetcode_2119_A_Number_After_a_Double_Reversal.java ├── leetcode_2120_Execution_of_All_Suffix_Instructions_Staying_in_a_Grid.java ├── leetcode_2124_Check_if_All_A's_Appears_Before_All_B's.java ├── leetcode_2125_Number_of_Laser_Beams_in_a_Bank.java ├── leetcode_2129_Capitalize_the_Title.java ├── leetcode_2130_Maximum_Twin_Sum_of_a_Linked_List.java ├── leetcode_2133_Check_if_Every_Row_and_Column_Contains_All_Numbers.java ├── leetcode_2138_Divide_a_String_Into_Groups_of_Size_k.java ├── leetcode_2144_Minimum_Cost_of_Buying_andies_With_Discount.java ├── leetcode_2148_Count_Elements_With_Strictly_Smaller_and_Greater_Elements.java ├── leetcode_2149_Rearrange_Array_Elements_by_Sign.java ├── leetcode_2150_Find_All_Lonely_Numbers_in_the_Array.java ├── leetcode_2154_Keep_Multiplying_Found_Values_by_Two.java ├── leetcode_2155_All_Divisions_With_the_Highest_Score_of_a_Binary_Array.java ├── leetcode_2160_Minimum_Sum_of_Four_Digit_Number_After_Splitting_Digits.java ├── leetcode_2161_Partition_Array_According_to_Given_Pivot.java ├── leetcode_2164_Sort_Even_and_Odd_Indices_Independently.java ├── leetcode_2165_Smallest_Value_of_the_Rearranged_Number.java ├── leetcode_2176_Count_Equal_and_Divisible_Pairs_in_an_Array.java ├── leetcode_2177_Find_Three_Consecutive_Integers_That_Sum_to_a_Given_Number.java ├── leetcode_2178_Maximum_Split_of_Positive_Even_Integers.java ├── leetcode_2180_Count_Integers_With_Even_Digit_Sum.java ├── leetcode_2181_Merge_Nodes_in_Between_Zeros.java ├── leetcode_2182_Construct_String_With_Repeat_Limit.java ├── leetcode_2185_Counting_Words_With_a_Given_Prefix.java ├── leetcode_2186_Minimum_Number_of_Steps_to_Make_Two_Strings_Anagram_II.java ├── leetcode_2190_Most_Frequent_umber_Following_Key_In_an_Array.java ├── leetcode_2194_Cells_in_a_Range_on_an_Excel_Sheet.java ├── leetcode_2196_Create_Binary_Tree_From_Descriptions.java ├── leetcode_2200_Find_All_K-Distant_Indices_in_an_Array.java ├── leetcode_2206_Divide_Array_Into_Equal_Pairs.java ├── leetcode_220_Contains_Duplicate_III.java ├── leetcode_2210_Count_Hills_and_Valleys_in_an_Array.java ├── leetcode_2215_Find_the_Difference_of_Two_Arrays.java ├── leetcode_2220_Minimum_Bit_Flips_to_Convert_Number.java ├── leetcode_2221_Find_Triangular_Sum_of_an_Array.java ├── leetcode_2224_Minimum_Number_of_Operations_to_Convert_Time.java ├── leetcode_2225_Find_Players_With_Zero_or_One_Losses.java ├── leetcode_2231_Largest_Number_After_Digit_Swaps_by_Parity.java ├── leetcode_2232_Minimize_Result_by_Adding_Parentheses_to_Expression.java ├── leetcode_2235_Add_Two_Integers.java ├── leetcode_2236_Root_Equals_Sum_of_Children.java ├── leetcode_2239_Find_Closest_Number_to_Zero.java ├── leetcode_2240_Number_of_Ways_to_Buy_Pens_and_Pencils.java ├── leetcode_2243_Calculate_Digit_Sum_of_a_String.java ├── leetcode_2248_Intersection_of_Multiple_Arrays.java ├── leetcode_2255_Count_Prefixes_of_a_Given_String.java ├── leetcode_2259_Remove_Digit_From_Number_to_Maximize_Result.java ├── leetcode_2264_Largest_3-Same-Digit_Number_in_String.java ├── leetcode_2265_Count_Nodes_Equal_to_Average_of_Subtree.java ├── leetcode_2269_Find_the_K-Beauty_of_a_Number.java ├── leetcode_2273_Find_Resultant_Array_After_Removing_Anagrams.java ├── leetcode_2275_Largest_Combination_With_Bitwise_AND_Greater_Than_Zero.java ├── leetcode_2278_Percentage_of_Letter_in_String.java ├── leetcode_2279_Maximum_Bags_With_Full_Capacity_of_Rocks.java ├── leetcode_2283_Check_if_Number_Has_Equal_Digit_Count_and_Digit_Value.java ├── leetcode_2287_Rearrange_Characters_to_Make_Target_String.java ├── leetcode_2293_Min_Max_Game.java ├── leetcode_2294_Partition_Array_Such_That_Maximum_Difference_Is_K.java ├── leetcode_2295_Replace_Elements_in_an_Array.java ├── leetcode_2299_Strong_Password_Checker_II.java ├── leetcode_2303_Calculate_Amount_Paid_in_Taxes.java ├── leetcode_2309_Greatest_English_Letter_in_Upper_and_Lower_Case.java ├── leetcode_2315_Count_Asterisks.java ├── leetcode_2317_Maximum_XOR_After_Operations.java ├── leetcode_2319_Check_if_Matrix_Is_X-Matrix.java ├── leetcode_2321_Maximum_Score_Of_Spliced_Array.java ├── leetcode_2325_Decode_the_Message.java ├── leetcode_2326_Spiral_Matrix_IV.java ├── leetcode_2331_Evaluate_Boolean_Binary_Tree.java ├── leetcode_2335_Minimum_Amount_of_Time_to_Fill_Cups.java ├── leetcode_2336_Smallest_Number_in_Infinite_Set.java ├── leetcode_2341_Maximum_Number_of_Pairs_in_Array.java ├── leetcode_2342_Max_Sum_of_a_Pair_With_Equal_Sum_of_Digits.java ├── leetcode_2344_Minimum_Deletions_to_Make_Array_Divisible.java ├── leetcode_2347_Best_Poker_Hand.java ├── leetcode_2348_Number_of_Zero-Filled_Subarrays.java ├── leetcode_2349_Design_a_Number_Container_System.java ├── leetcode_2351_First_Letter_to_Appear_Twice.java ├── leetcode_2352_Equal_Row_and_Column_Pairs.java ├── leetcode_2353_Design_a_Food_Rating_System.java ├── leetcode_2357_Make_Array_Zero_by_Subtracting_Equal_Amounts.java ├── leetcode_2358_Maximum_Number_of_Groups_Entering_a_Competition.java ├── leetcode_2363_Merge_Similar_Items.java ├── leetcode_2364_Count_Number_of_Bad_Pairs.java ├── leetcode_2366_Minimum_Replacements_to_Sort_the_Array.java ├── leetcode_2367_Number_of_Arithmetic_Triplets.java ├── leetcode_2373_Largest_Local_Values_in_a_Matrix.java ├── leetcode_2375_Construct_Smallest_Number_From_DI_String.java ├── leetcode_2379_Minimum_Recolors_to_Get_K_Consecutive_Black_Blocks.java ├── leetcode_2383_Minimum_Hours_of_Training_to_Win_a_Competition.java ├── leetcode_2389_Longest_Subsequence_With_Limited_Sum.java ├── leetcode_2390_Removing_Stars_From_a_String.java ├── leetcode_2391_Minimum_Amount_of_Time_to_Collect_Garbage.java ├── leetcode_2395_Find_Subarrays_With_Equal_Sum.java ├── leetcode_2396_Strictly_Palindromic_Number.java ├── leetcode_2399_Check_Distances_Between_Same_Letters.java ├── leetcode_2404_Most_Frequent_Even_Element.java ├── leetcode_2405_Optimal_Partition_of_String.java ├── leetcode_2409_Count_Days_Spent_Together.java ├── leetcode_2413_Smallest_Even_Multiple.java ├── leetcode_2414_Length_of_the_Longest_Alphabetical_Continuous_Substring.java ├── leetcode_2415_Reverse_Odd_Levels_of_Binary_Tree.java ├── leetcode_2418_Sort_the_People.java ├── leetcode_2423_Remove_Letter_To_Equalize_Frequency.java ├── leetcode_2425_Bitwise_XOR_of_All_Pairings.java ├── leetcode_2427_Number_of_Common_Factors.java ├── leetcode_2428_Maximum_Sum_of_an_Hourglass.java ├── leetcode_2432_The_Employee_That_Worked_on_the_Longest_Task.java ├── leetcode_2433_Find_The_Original_Array_of_Prefix_Xor.java ├── leetcode_2437_Number_of_Valid_Clock_Times.java ├── leetcode_2439_Minimize_Maximum_of_Array.java ├── leetcode_2441_Largest_Positive_Integer_That_Exists_With_Its_Negative.java ├── leetcode_2442_Count_Number_of_Distinct_Integers_After_Reverse_Operations.java ├── leetcode_2446_Determine_if_Two_Events_Have_Conflict.java ├── leetcode_2449_Minimum_Number_of_Operations_to_Make_Arrays_Similar.java ├── leetcode_2451_Odd_String_Difference.java ├── leetcode_2452_Words_Within_Two_Edits_of_Dictionary.java ├── leetcode_2455_Average_Value_of_Even_Numbers_That_Are_Divisible_by_Three.java ├── leetcode_2460_Apply_Operations_to_an_Array.java ├── leetcode_2465_Number_of_Distinct_Averages.java ├── leetcode_2469_Convert_the_Temperature.java ├── leetcode_2471_Minimum_Number_of_Operations_to_Sort_a_Binary_Tree_by_Level.java ├── leetcode_2475_Number_of_Unequal_Triplets_in_Array.java ├── leetcode_2481_Minimum_Cuts_to_Divide_a_Circle.java ├── leetcode_2482_Difference_Between_Ones_and_Zeros_in_Row_and_Column.java ├── leetcode_2483_Minimum_Penalty_for_a_Shop.java ├── leetcode_2485_Find_the_Pivot_Integer.java ├── leetcode_2486_Append_Characters_to_String_to_Make_Subsequence.java ├── leetcode_2487_Remove_Nodes_From_Linked_List.java ├── leetcode_2490_Circular_Sentence.java ├── leetcode_2491_Divide_Players_Into_Teams_of_Equal_Skill.java ├── leetcode_2496_Maximum_Value_of_a_String_in_an_Array.java ├── leetcode_2500_Delete_Greatest_Value_in_Each_Row.java ├── leetcode_2501_Longest_Square_Streak_in_an_Array.java ├── leetcode_2506_Count_Pairs_Of_Similar_Strings.java ├── leetcode_2511_Maximum_Enemy_Forts_That_Can_Be_Captured.java ├── leetcode_2515_Shortest_Distance_to_Target_String_in_a_Circular_Array.java ├── leetcode_2520_Count_the_Digits_That_Divide_a_Number.java ├── leetcode_2525_Categorize_Box_According_to_Criteria.java ├── leetcode_2527_Find_Xor_Beauty_of_Array.java ├── leetcode_2529_Maximum_Count_of_Positive_Integer_and_Negative_Integer.java ├── leetcode_2535_Difference_Between_Element_Sum_and_Digit_Sum_of_an_Array.java ├── leetcode_2536_Increment_Submatrices_by_One.java ├── leetcode_2537_Count_the_Number_of_Good_Subarrays.java ├── leetcode_2540_Minimum_Common_Value.java ├── leetcode_2544_Alternating_Digit_Sum.java ├── leetcode_2545_Sort_the_Students_by_Their_Kth_Score.java ├── leetcode_2549_Count_Distinct_Numbers_on_Board.java ├── leetcode_2553_Separate_the_Digits_in_an_Array.java ├── leetcode_2554_Maximum_Number_of_Integers_to_Choose_From_a_Range_I.java ├── leetcode_2558_Take_Gifts_From_the_Richest_Pile.java ├── leetcode_2559_Count_Vowel_Strings_in_Ranges.java ├── leetcode_2562_Find_the_Array_Concatenation_Value.java ├── leetcode_2566_Maximum_Difference_by_Remapping_a_Digit.java ├── leetcode_2568_Minimum_Impossible_OR.java ├── leetcode_2570_Merge_Two_2D_Arrays_by_Summing_Values.java ├── leetcode_2571_Minimum_Operations_to_Reduce_an_Integer_to_0.java ├── leetcode_2574_Left_and_Right_Sum_Differences.java ├── leetcode_2578_Split_With_Minimum_Sum.java ├── leetcode_2579_Count_Total_Number_of_Colored_Cells.java ├── leetcode_2582_Pass_the_Pillow.java ├── leetcode_2583_Kth_Largest_Sum_in_a_Binary_Tree.java ├── leetcode_2586_Count_the_Number_of_Vowel_Strings_in_Range.java ├── leetcode_2591_Distribute_Money_to_Maximum_Children.java ├── leetcode_2592_Maximize_Greatness_of_an_Array.java ├── leetcode_2595_Number_of_Even_and_Odd_Bits.java ├── leetcode_2596_Check_Knight_Tour_Configuration.java ├── leetcode_2600_K_Items_With_the_Maximum_Sum.java ├── leetcode_2605_Form_Smallest_Number_From_Two_Digit_Arrays.java ├── leetcode_2606_Find_the_Substring_With_Maximum_Cost.java ├── leetcode_2609_Find_the_Longest_Balanced_Substring_of_a_Binary_String.java ├── leetcode_2610_Convert_an_Array_Into_a_2D_Array_With_Conditions.java ├── leetcode_2614_Prime_In_Diagonal.java ├── leetcode_2639_Find_the_Width_of_Columns_of_a_Grid.java ├── leetcode_2640_Find_the_Score_of_All_Prefixes_of_an_Array.java ├── leetcode_2643_Row_With_Maximum_Ones.java ├── leetcode_2644_Find_the_Maximum_Divisibility_Score.java ├── leetcode_2651_Calculate_Delayed_Arrival_Time.java ├── leetcode_2652_Sum_Multiples.java ├── leetcode_2656_Maximum_Sum_With_Exactly_K_Elements.java ├── leetcode_2657_Find_the_Prefix_Common_Array_of_Two_Arrays.java ├── leetcode_2660_Determine_the_Winner_of_a_Bowling_Game.java ├── leetcode_2670_Find_the_Distinct_Difference_Array.java ├── leetcode_2671_Frequency_Tracker.java ├── leetcode_2678_Number_of_Senior_Citizens.java ├── leetcode_2679_Sum_in_a_Matrix.java ├── leetcode_2682_Find_the_Losers_of_the_Circular_Game.java ├── leetcode_2683_Neighboring_Bitwise_XOR.java ├── leetcode_2696_Minimum_String_Length_After_Removing_Substrings.java ├── leetcode_2697_Lexicographically_Smallest_Palindrome.java ├── leetcode_2698_Find_the_Punishment_Number_of_an_Integer.java ├── leetcode_2706_Buy_Two_Chocolates.java ├── leetcode_2710_Remove_Trailing_Zeros_From_a_String.java ├── leetcode_2711_Difference_of_Number_of_Distinct_Values_on_Diagonals.java ├── leetcode_2716_Minimize_String_Length.java ├── leetcode_2717_Semi_Ordered_Permutation.java ├── leetcode_2729_Check_if_The_Number_is_Fascinating.java ├── leetcode_2733_Neither_Minimum_nor_Maximum.java ├── leetcode_2739_Total_Distance_Traveled.java ├── leetcode_2740_Find_the_Value_of_the_Partition.java ├── leetcode_2744_Find_Maximum_Number_of_String_Pairs.java ├── leetcode_2748_Number_of_Beautiful_Pairs.java ├── leetcode_2760_Longest_Even_Odd_Subarray_With_Threshold.java ├── leetcode_2761_Prime_Pairs_With_Target_Sum.java ├── leetcode_2765_Longest_Alternating_Subarray.java ├── leetcode_2767_Partition_String_Into_Minimum_Beautiful_Substrings.java ├── leetcode_2769_Find_the_Maximum_Achievable_Number.java ├── leetcode_2778_Sum_of_Squares_of_Special_Elements.java ├── leetcode_2780_Minimum_Index_of_a_Valid_Split.java ├── leetcode_2784_Check_if_Array_is_Good.java ├── leetcode_2785_Sort_Vowels_in_a_String.java ├── leetcode_2788_Split_Strings_by_Separator.java ├── leetcode_2789_Largest_Element_in_an_Array_after_Merge_Operations.java ├── leetcode_2798_Number_of_Employees_Who_Met_the_Target.java ├── leetcode_2799_Count_Complete_Subarrays_in_an_Array.java ├── leetcode_2806_Account_Balance_After_Rounded_Purchase.java ├── leetcode_2807_Insert_Greatest_Common_Divisors_in_Linked_List.java ├── leetcode_2810_Faulty_Keyboard.java ├── leetcode_2815_Max_Pair_Sum_in_an_Array.java ├── leetcode_2816_Double_a_Number_Represented_as_a_Linked_List.java ├── leetcode_2824_Count_Pairs_Whose_Sum_is_Less_than_Target.java ├── leetcode_2828_Check_if_a_String_Is_an_Acronym_of_Words.java ├── leetcode_2829_Determine_the_Minimum_Sum_of_a_k_avoiding_Array.java ├── leetcode_2833_Furthest_Point_From_Origin.java ├── leetcode_2834_Find_the_Minimum_Possible_Sum_of_a_Beautiful_Array.java ├── leetcode_2839_Check_if_Strings_Can_be_Made_Equal_With_Operations_I.java ├── leetcode_2840_Check_if_Strings_Can_be_Made_Equal_With_Operation_II.java ├── leetcode_2843_Count_Symmetric_Integers.java ├── leetcode_2848_Points_That_Intersect_With_Cars.java ├── leetcode_2855_Minimum_Right_Shifts_to_Sort_the_Array.java ├── leetcode_2859_Sum_of_Values_at_Indices_With_K_Set_Bits.java ├── leetcode_2864_Maximum_Odd_Binary_Number.java ├── leetcode_2869_Minimum_Operations_to_Collect_Elements.java ├── leetcode_2870_Minimum_Number_of_Operations_to_Make_Array_Empty.java ├── leetcode_2873_Maximum_Value_of_an_Ordered_Triplet_I.java ├── leetcode_2877_Create_a_DataFrame_from_List.py ├── leetcode_2879_Display_the_First_Three_Rows.py ├── leetcode_2891_Method_Chaining.py ├── leetcode_2894_Divisible_and_Non_divisible_Sums_Difference.java ├── leetcode_2895_Minimum_Processing_Time.java ├── leetcode_2899_Last_Visited_Integers.java ├── leetcode_2900_Longest_Unequal_Adjacent_Groups_Subsequence_I.java ├── leetcode_2903_Find_Indices_With_Index_and_Value_Difference_I.java ├── leetcode_2905_Find_Indices_With_Index_and_Value_Difference_II.java ├── leetcode_2908_Minimum_Sum_of_Mountain_Triplets_I.java ├── leetcode_2913_Subarrays_Distinct_Element_Sum_of_Squares_I.java ├── leetcode_2914_Minimum_Number_of_Changes_to_Make_Binary_String_Beautiful.java ├── leetcode_2917_Find_the_K_or_of_an_Array.java ├── leetcode_2923_Find_Champion_I.java ├── leetcode_2928_Distribute_Candies_Among_Children_I.java ├── leetcode_2932_Maximum_Strong_Pair_XOR_I.java ├── leetcode_2937_Make_Three_Strings_Equal.java ├── leetcode_2938_Separate_Black_and_White_Balls.java ├── leetcode_2942_Find_Words_Containing_Character.java ├── leetcode_2946_Matrix_Similarity_After_Cyclic_Shifts.java ├── leetcode_2947_Count_Beautiful_Substrings_I.java ├── leetcode_2951_Find_the_Peaks.java ├── leetcode_2956_Find_Common_Elements_Between_Two_Arrays.java ├── leetcode_2957_Remove_Adjacent_Almost_Equal_Characters.java ├── leetcode_2958_Length_of_Longest_Subarray_With_at_Most_K_Frequency.java ├── leetcode_2960_Count_Tested_Devices_After_Test_Operations.java ├── leetcode_2962_Count_Subarrays_Where_Max_Element_Appears_at_Least_K_Times.java ├── leetcode_2965_Find_Missing_and_Repeated_Values.java ├── leetcode_2966_Divide_Array_Into_Arrays_With_Max_Difference.java ├── leetcode_2971_Find_Polygon_With_the_Largest_Perimeter.java ├── leetcode_2974_Minimum_Number_Game.java ├── leetcode_2980_Check_if_Bitwise_OR_Has_Trailing_Zeros.java ├── leetcode_2996_Smallest_Missing_Integer_Greater_Than_Sequential_Prefix_Sum.java ├── leetcode_2997_Minimum_Number_of_Operations_to_Make_Array_XOR_Equal_to_K.java ├── leetcode_3000_Maximum_Area_of_Longest_Diagonal_Rectangle.java ├── leetcode_3005_Count_Elements_With_Maximum_Frequency.java ├── leetcode_3010_Divide_an_Array_Into_Subarrays_With_Minimum_Cost_I.java ├── leetcode_3014_Minimum_Number_of_Pushes_to_Type_Word_I.java ├── leetcode_3016_Minimum_Number_of_Pushes_to_Type_Word_II.java ├── leetcode_3019_Number_of_Changing_Keys.java ├── leetcode_3024_Type_of_Triangle.java ├── leetcode_3028_Ant_on_the_Boundary.java ├── leetcode_3033_Modify_the_Matrix.java ├── leetcode_3038_Maximum_Number_of_Operations_With_the_Same_Score_I.java ├── leetcode_3039_Apply_Operations_to_Make_String_Empty.java ├── leetcode_3042_Count_Prefix_and_Suffix_Pairs_I.java ├── leetcode_3044_Most_Frequent_Prime.java ├── leetcode_3046_Split_the_Array.java ├── leetcode_3065_Minimum_Operations_to_Exceed_Threshold_Value_I.java ├── leetcode_3069_Distribute_Elements_Into_Two_Arrays_I.java ├── leetcode_3074_Apple_Redistribution_into_Boxes.java ├── leetcode_3079_Find_the_Sum_of_Encrypted_Integers.java ├── leetcode_3080_Mark_Elements_on_Array_by_Performing_Queries.java ├── leetcode_3083_Existence_of_a_Substring_in_a_String_and_Its_Reverse.java ├── leetcode_3084_Count_Substrings_Starting_and_Ending_with_Given_Character.java ├── leetcode_3090_Maximum_Length_Substring_With_Two_Occurrences.java ├── leetcode_3095_Shortest_Subarray_With_OR_at_Least_K_I.java ├── leetcode_3099_Harshad_Number.java ├── leetcode_3100_Water_Bottles_II.java ├── leetcode_3101_Count_Alternating_Subarrays.java ├── leetcode_3105_Longest_Strictly_Increasing_or_Strictly_Decreasing_Subarray.java ├── leetcode_3106_Lexicographically_Smallest_String_After_Operations_With_Constraint.java ├── leetcode_3110_Score_of_a_String.java ├── leetcode_3111_Minimum_Rectangles_to_Cover_Points.java ├── leetcode_3114_Latest_Time_You_Can_Obtain_After_Replacing_Characters.java ├── leetcode_3115_Maximum_Prime_Difference.java ├── leetcode_3120_Count_the_Number_of_Special_Characters_I.java ├── leetcode_3121_Count_the_Number_of_Special_Characters_II.java ├── leetcode_3127_Make_a_Square_with_the_Same_Color.java ├── leetcode_3128_Right_Triangles.java ├── leetcode_3131_Find_the_Integer_Added_to_Array_I.java ├── leetcode_3136_Valid_Word.java ├── leetcode_3137_Minimum_Number_of_Operations_to_Make_Word_K_Periodic.java ├── leetcode_3142_Check_if_Grid_Satisfies_Conditions.java ├── leetcode_3146_Permutation_Difference_between_Two_Strings.java ├── leetcode_3151_Special_Array_I.java ├── leetcode_3152_Special_Array_II.java ├── leetcode_3153_Sum_of_Digit_Differences_of_All_Pairs.java ├── leetcode_3158_Find_the_XOR_of_Numbers_Which_Appear_Twice.java ├── leetcode_3159_Find_Occurrences_of_an_Element_in_an_Array.java ├── leetcode_3160_Find_the_Number_of_Distinct_Colors_Among_the_Balls.java ├── leetcode_3162_Find_the_Number_of_Good_Pairs_I.java ├── leetcode_3163_String_Compression_III.java ├── leetcode_3168_Minimum_Number_of_Chairs_in_a_Waiting_Room.java ├── leetcode_3169_Count_Days_Without_Meetings.java ├── leetcode_3174_Clear_Digits.java ├── leetcode_3178_Find_the_Child_Who_Has_the_Ball_After_K_Seconds.java ├── leetcode_3179_Find_the_N_th_Value_After_K_Seconds.java ├── leetcode_3184_Count_Pairs_That_Form_a_Complete_Day_I.java ├── leetcode_3185_Count_Pairs_That_Form_a_Complete_Day_II.java ├── leetcode_3190_Find_Minimum_Operations_to_Make_All_Elements_Divisible_by_Three.java ├── leetcode_3191_Minimum_Operations_to_Make_Binary_Array_Elements_Equal_to_One_I.java ├── leetcode_3192_Minimum_Operations_to_Make_Binary_Array_Elements_Equal_to_One_II.java ├── leetcode_3194_Minimum_Average_of_Smallest_and_Largest_Elements.java ├── leetcode_3195_Find_the_Minimum_Area_to_Cover_All_Ones_I.java ├── leetcode_31_next_permutation.java ├── leetcode_3200_Maximum_Height_of_a_Triangle.java ├── leetcode_3206_Alternating_Groups_I.java ├── leetcode_3210_Find_the_Encrypted_String.java ├── leetcode_3211_Generate_Binary_Strings_Without_Adjacent_Zeros.java ├── leetcode_3216_Lexicographically_Smallest_String_After_a_Swap.java ├── leetcode_3217_Delete_Nodes_From_Linked_List_Present_in_Array.java ├── leetcode_3222_Find_the_Winning_Player_in_Coin_Game.java ├── leetcode_3223_Minimum_Length_of_String_After_Operations.java ├── leetcode_3226_Number_of_Bit_Changes_to_Make_Two_Integers_Equal.java ├── leetcode_3227_Vowels_Game_in_a_String.java ├── leetcode_3228_Maximum_Number_of_Operations_to_Move_Ones_to_the_End.java ├── leetcode_3232_Find_if_Digit_Game_Can_Be_Won.java ├── leetcode_3238_Find_the_Number_of_Winning_Players.java ├── leetcode_3239_Minimum_Number_of_Flips_to_Make_Binary_Grid_Palindromic_I.java ├── leetcode_3242_Design_Neighbor_Sum_Service.java ├── leetcode_3248_Snake_in_Matrix.java ├── leetcode_3249_Count_the_Number_of_Good_Nodes.java ├── leetcode_3254_Find_the_Power_of_K_Size_Subarrays_I.java ├── leetcode_3255_Find_the_Power_of_K_Size_Subarrays_II.java ├── leetcode_3256_Maximum_Value_Sum_by_Placing_Three_Rooks_I.java ├── leetcode_3257_Maximum_Value_Sum_by_Placing_Three_Rooks_II.java ├── leetcode_3258_Count_Substrings_That_Satisfy_K_Constraint_I.java ├── leetcode_3264_Final_Array_State_After_K_Multiplication_Operations_I.java ├── leetcode_3270_Find_the_Key_of_the_Numbers.java ├── leetcode_3271_Hash_Divided_String.java ├── leetcode_3274_Check_if_Two_Chessboard_Squares_Have_the_Same_Color.java ├── leetcode_3280_Convert_Date_to_Binary.java ├── leetcode_3285_Find_Indices_of_Stable_Mountains.java ├── leetcode_3289_The_Two_Sneaky_Numbers_of_Digitville.java ├── leetcode_3295_Report_Spam_Message.java ├── leetcode_3300_Minimum_Element_After_Replacement_With_Digit_Sum.java ├── leetcode_3304_Find_the_K_th_Character_in_String_Game_I.java ├── leetcode_3309_Maximum_Possible_Number_by_Binary_Concatenation.java ├── leetcode_3314_Construct_the_Minimum_Bitwise_Array_I.java ├── leetcode_3315_Construct_the_Minimum_Bitwise_Array_II.java ├── leetcode_3318_Find_X_Sum_of_All_K_Long_Subarrays_I.java ├── leetcode_3324_Find_the_Sequence_of_Strings_Appeared_on_the_Screen.java ├── leetcode_3330_Find_the_Original_Typed_String_I.java ├── leetcode_3340_Check_Balanced_String.java ├── leetcode_3345_Smallest_Divisible_Digit_Product_I.java ├── leetcode_3349_Adjacent_Increasing_Subarrays_Detection_I.java ├── leetcode_3350_Adjacent_Increasing_Subarrays_Detection_II.java ├── leetcode_3354_Make_Array_Elements_Equal_to_Zero.java ├── leetcode_3355_Zero_Array_Transformation_I.java ├── leetcode_3356_Zero_Array_Transformation_II.java ├── leetcode_3360_Stone_Removal_Game.java ├── leetcode_3361_Shift_Distance_Between_Two_Strings.java ├── leetcode_3364_Minimum_Positive_Sum_Subarray.java ├── leetcode_3370_Smallest_Number_With_All_Set_Bits.java ├── leetcode_3375_Minimum_Operations_to_Make_Array_Values_Equal_to_K.java ├── leetcode_3379_Transformed_Array.java ├── leetcode_3386_Button_with_Longest_Push_Time.java ├── leetcode_3392_Count_Subarrays_of_Length_Three_With_a_Condition.java ├── leetcode_3396_Minimum_Number_of_Operations_to_Make_Elements_in_Array_Distinct.java ├── leetcode_3402_Minimum_Operations_to_Make_Columns_Strictly_Increasing.java ├── leetcode_3411_Maximum_Subarray_With_Equal_Products.java ├── leetcode_3417_Zigzag_Grid_Traversal_With_Skip.java ├── leetcode_3423_Maximum_Difference_Between_Adjacent_Elements_in_a_Circular_Array.java ├── leetcode_3427_Sum_of_Variable_Length_Subarrays.java ├── leetcode_3432_Count_Partitions_with_Even_Sum_Difference.java ├── leetcode_3438_Find_Valid_Pair_of_Adjacent_Digits_in_String.java ├── leetcode_3442_Maximum_Difference_Between_Even_and_Odd_Frequency_I.java ├── leetcode_3452_Sum_of_Good_Numbers.java ├── leetcode_3456_Find_Special_Substring_of_Length_K.java ├── leetcode_3461_Check_If_Digits_Are_Equal_in_String_After_Operations_I.java ├── leetcode_3462_Maximum_Sum_With_at_Most_K_Elements.java ├── leetcode_3467_Transform_Array_by_Parity.java ├── leetcode_3471_Find_the_Largest_Almost_Missing_Integer.java ├── leetcode_3477_Fruits_Into_Baskets_II.java ├── leetcode_3483_Unique_3_Digit_Even_Numbers.java ├── leetcode_3484_Design_Spreadsheet.java ├── leetcode_3487_Maximum_Unique_Subarray_Sum_After_Deletion.java ├── leetcode_348_find_all_anagrams_in_a_string.java ├── leetcode_3492_Maximum_Containers_on_a_Ship.java ├── leetcode_3498_Reverse_Degree_of_a_String.java.java ├── leetcode_3502_Minimum_Cost_to_Reach_Every_Position.java ├── leetcode_3507_Minimum_Pair_Removal_to_Sort_Array_I.java ├── leetcode_3512_Minimum_Operations_to_Make_Array_Sum_Divisible_by_K.java ├── leetcode_3516_Find_Closest_Person.java ├── leetcode_3521_Find_Product_Recommendation_Pairs.sql ├── leetcode_3522_Calculate_Score_After_Performing_Instructions.java ├── leetcode_3523_Make_Array_Non_decreasing.java ├── leetcode_3527_Find_the_Most_Common_Response.java ├── leetcode_3536_Maximum_Product_of_Two_Digits.java ├── leetcode_3537_Fill_a_Special_Grid.java ├── leetcode_3541_Find_Most_Frequent_Vowel_and_Consonant.java ├── leetcode_3545_Minimum_Deletions_for_At_Most_K_Distinct_Characters.java ├── leetcode_3550_Smallest_Index_With_Digit_Sum_Equal_to_Index.java ├── leetcode_3561_Resulting_String_After_Adjacent_Removals.java ├── leetcode_404_Sum_of_Left_Leaves.java ├── leetcode_511_Game_Play_Analysis_I.sql ├── leetcode_5173_Prime_Arrangements.cpp ├── leetcode_5174_Diet_Plan_Performance.cpp ├── leetcode_538_Convert_BST_to_Greater_Tree.java ├── leetcode_584_Find_Customer_Referee.sql ├── leetcode_608_Tree_Node.sql ├── leetcode_62_Unique_Paths.java ├── leetcode_63_Unique_Paths_II.java ├── leetcode_70_Climbing_Stairs.java └── leetcode_820_Short_Encoding_of_Words.java ├── readme-1.md ├── scheduler.md ├── skills └── 20250112_判断括号字符串是否合法 │ └── ValidParenthese.java ├── 欢迎提PR或讨论 └── q /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | .DS_Store 4 | */.DS_Store 5 | 算法导论笔记/ 6 | Tests/cmake-build-debug 7 | Data_Structure_Full_features/ 8 | -------------------------------------------------------------------------------- /2019-04-02-Output-time-on-cli-per-second.sh: -------------------------------------------------------------------------------- 1 | echo ''|php -------------------------------------------------------------------------------- /Algorithm_full_features/BTree-simpleImplementation/README.md: -------------------------------------------------------------------------------- 1 | **使用方法:** 2 | (Linux 或 mac 下)使用 GCC 编译器(version >= 4.4), 执行: 3 | 4 | ```shell 5 | cd [项目目录] 6 | gcc btree.cpp -o btree.out 7 | ./btree.out 8 | ``` 9 | 10 | **B树定义:** 11 | 12 | 1.本质是一个平衡的 m 叉搜索树(m >= 2) 13 | 14 | 2.每个节点至多有 m 颗子树。 15 | 16 | 3.根节点要么为空(整颗树为空),要么至少要有两颗子树 17 | 18 | 4.非根节点的非叶子节点,至少要有 floor(m/2) 颗子树 19 | 20 | 5.每个非叶子节点中包含信息为:(n, A0, K1, A1, K2, A2, ...., Kn, An),其中 21 | 22 | 1) Ki 为关键字,关键字按升序排列 23 | 24 | 2) 指针 Ai 指向的是本节点的一颗子树的根节点 25 | 26 | 3) 关键字的个数为n, n的大小为 [floor(m / 2) - 1, m - 1] 27 | 28 | 6.所有的叶子节点是位于同一层级的,且都是空指针节点(用来被当作是查找失败的标志位) 29 | 30 | -------------------------------------------------------------------------------- /Algorithm_full_features/README.md: -------------------------------------------------------------------------------- 1 | This folder contain most of the famous algorithm. 2 | 3 | #### 算法目录: 4 | 5 | | 算法名 | 对应文件 | 6 | | --------------- | ----------------- | 7 | | 二分查找 | BinarySearch.java | 8 | | 洗牌算法(Knuth) | Shuffle.java | 9 | | | | 10 | | | | 11 | | | | 12 | | | | 13 | | | | 14 | | | | 15 | | | | 16 | 17 | -------------------------------------------------------------------------------- /Algorithm_full_features/data_sets/BinarySearch/largeT.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/Algorithm_full_features/data_sets/BinarySearch/largeT.txt -------------------------------------------------------------------------------- /Algorithm_full_features/data_sets/BinarySearch/largeW.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/Algorithm_full_features/data_sets/BinarySearch/largeW.txt -------------------------------------------------------------------------------- /Algorithm_full_features/data_sets/BinarySearch/tinyT.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/Algorithm_full_features/data_sets/BinarySearch/tinyT.txt -------------------------------------------------------------------------------- /Algorithm_full_features/data_sets/BinarySearch/tinyW.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/Algorithm_full_features/data_sets/BinarySearch/tinyW.txt -------------------------------------------------------------------------------- /Algorithm_full_features/others/BloomFilter.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 实现一个布隆过滤器功能 3 | */ 4 | -------------------------------------------------------------------------------- /Poj_Judge_solved/poj_1664_放苹果.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int solve(int m, int n) 5 | { 6 |     if (m == 1 || n == 1) return 1; 7 |     else if (m < n) return solve(m, m); 8 |     else if (m == n) return 1 + solve(m, n - 1); 9 |     else return solve(m - n, n) + solve(m, n - 1); 10 | } 11 | int main() 12 | { 13 |     int t, temp1, temp2; 14 |   //输入的组数 15 |     cin >> t; 16 |     for (int i = 1; i <= t; i++) 17 | { 18 |         cin >> temp1 >> temp2; 19 |         cout << solve(temp1, temp2) << endl; 20 |     21 | } 22 |     return 0; 23 | } 24 | -------------------------------------------------------------------------------- /Status.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/Status.h -------------------------------------------------------------------------------- /Tests/test.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by admin on 2021/2/6. 3 | // 4 | #include 5 | 6 | int main() { 7 | printf("hello world!\n"); 8 | printf("hello world!\n"); 9 | printf("hello world!\n"); 10 | 11 | printf("hello world!\n"); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /codeForces/Codeforces_0059A_Word.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 374 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_59A_Word { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | String str = sc.next(); 13 | int count = 0; 14 | for (char c : str.toCharArray()) { 15 | if (Character.isUpperCase(c)) { 16 | count++; 17 | } 18 | } 19 | 20 | System.out.println((count > str.length() / 2) ? str.toUpperCase() : str.toLowerCase()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /codeForces/Codeforces_0228A_Is_your_horseshoe_on_the_other_hoof.java: -------------------------------------------------------------------------------- 1 | // AC: 404 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Arrays; 7 | import java.util.HashSet; 8 | import java.util.Scanner; 9 | 10 | public class Codeforces_0228A_Is_your_horseshoe_on_the_other_hoof { 11 | public static void main(String[] args) { 12 | Scanner sc = new Scanner(System.in); 13 | int s1 = sc.nextInt(), s2 = sc.nextInt(), s3 = sc.nextInt(), s4 = sc.nextInt(); 14 | HashSet record = new HashSet<>(Arrays.asList(s1, s2, s3, s4)); 15 | System.out.println(4 - record.size()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_0478A_Initial_Bet.java: -------------------------------------------------------------------------------- 1 | // AC: 187 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_0478A_Initial_Bet { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int c1 = sc.nextInt(), c2 = sc.nextInt(), c3 = sc.nextInt(), c4 = sc.nextInt(), c5 = sc.nextInt(); 12 | int sum = c1 + c2 + c3 + c4 + c5; 13 | int ret = (sum > 0 && sum % 5 == 0) ? sum / 5 : -1; 14 | 15 | System.out.println(ret); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_0610A_Pasha_and_Stick.java: -------------------------------------------------------------------------------- 1 | // Time: 312 ms 2 | // Memory: 1100 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_0610A_Pasha_and_Stick { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(), ret = 0; 12 | if (n >= 6 && n % 2 == 0) { 13 | ret = n % 4 == 0 ? (n / 4 - 1) : n / 4; 14 | } 15 | 16 | System.out.println(ret); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_0766A_Mahmoud_and_Longest_Uncommon_Subsequence.java: -------------------------------------------------------------------------------- 1 | // AC: 233 ms 2 | // Memory: 0 KB 3 | // greedy. 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_0766A_Mahmoud_and_Longest_Uncommon_Subsequence { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | String a = sc.next(), b = sc.next(); 12 | 13 | System.out.println(a.equals(b) ? -1 : Math.max(a.length(), b.length())); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1030A_In_Search_of_an_Easy_Problem.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 186 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1030A_In_Search_of_an_Easy_Problem { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | sc.nextInt(); 13 | while (sc.hasNext()) { 14 | if (sc.nextInt() == 1) { 15 | System.out.println("HARD"); 16 | return; 17 | } 18 | } 19 | 20 | System.out.println("EASY"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1041A_Heist.java: -------------------------------------------------------------------------------- 1 | // AC: 233 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1041A_Heist { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(), minVal = Integer.MAX_VALUE, maxVal = 0; 12 | for (int i = 0; i < n; i++) { 13 | int a = sc.nextInt(); 14 | minVal = Math.min(minVal, a); 15 | maxVal = Math.max(maxVal, a); 16 | } 17 | System.out.println(maxVal - minVal + 1 - n); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1095A_Repeating_Cipher.java: -------------------------------------------------------------------------------- 1 | // AC: 171 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(n) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1095A_Repeating_Cipher { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(), pos = 0; 12 | String s = sc.next(); 13 | StringBuilder ret = new StringBuilder(); 14 | for (int i = 0; i < n; ) { 15 | ret.append(s.charAt(i)); 16 | i += ++pos; 17 | } 18 | System.out.println(ret); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1102A_Integer_Sequence_Dividing.java: -------------------------------------------------------------------------------- 1 | // AC: 311 ms 2 | // Memory: 1700 KB 3 | // Check sum is even, if so the answer is true. 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1102A_Integer_Sequence_Dividing { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(); 12 | long sum = (long) n * (n + 1) / 2; 13 | System.out.println(sum % 2); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /codeForces/Codeforces_112A_Petya_and_Strings.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 404 ms 2 | // Memory: 0 KB 3 | // built-in function 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Locale; 7 | import java.util.Scanner; 8 | 9 | public class Codeforces_112A_Petya_and_Strings { 10 | public static Scanner sc = new Scanner(System.in); 11 | 12 | public static void main(String[] args) { 13 | String first = sc.next(), second = sc.next(); 14 | first = first.toLowerCase(Locale.ROOT); 15 | second = second.toLowerCase(Locale.ROOT); 16 | System.out.println(first.equals(second) ? 0 : (first.compareTo(second) > 0 ? 1 : -1)); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1154A_Restoring_Three_Numbers.java: -------------------------------------------------------------------------------- 1 | // AC: 217 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Arrays; 7 | import java.util.Scanner; 8 | 9 | public class Codeforces_1154A_Restoring_Three_Numbers { 10 | public static Scanner sc = new Scanner(System.in); 11 | 12 | public static void main(String[] args) { 13 | int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt(); 14 | int[] arr = new int[]{a, b, c, d}; 15 | Arrays.sort(arr); 16 | System.out.println((arr[3] - arr[0]) + " " + (arr[3] - arr[1]) + " " + (arr[3] - arr[2])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_116A_Tram.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 498 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_116A_Tram { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), maxCount = 0, curCount = 0; 13 | while (sc.hasNext()) { 14 | int ai = sc.nextInt(), bi = sc.nextInt(); 15 | curCount += bi - ai; 16 | maxCount = Math.max(maxCount, curCount); 17 | } 18 | 19 | System.out.println(maxCount); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1180A_Alex_and_a_Rhombus.java: -------------------------------------------------------------------------------- 1 | // AC: 217 ms 2 | // Memory: 0 KB 3 | // Math: 等差数列. 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1180A_Alex_and_a_Rhombus { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(); 12 | System.out.println(1 + 4 * n * (n - 1) / 2); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1182A_Filling_Shapes.java: -------------------------------------------------------------------------------- 1 | // AC: 187 ms 2 | // Memory: 0 KB 3 | // Math: n must be even, and answer is 2^(n/2) 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1182A_Filling_Shapes { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(), ret = 0; 12 | if (n % 2 == 0) { 13 | ret = (int) Math.pow(2, (n / 2)); 14 | } 15 | 16 | System.out.println(ret); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1186A_Vus_the_Cossack_and_a_Contest.java: -------------------------------------------------------------------------------- 1 | // AC: 171 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1186A_Vus_the_Cossack_and_a_Contest { 9 | private final static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt(); 13 | System.out.println(Math.min(m, k) >= n ? "Yes" : "NO"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1196A_Three_Piles_of_Candies.java: -------------------------------------------------------------------------------- 1 | // AC: 218 ms 2 | // Memory: 0 KB 3 | // We can always split the three parts into two parts equally. 4 | // T:O(q), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1196A_Three_Piles_of_Candies { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int q = sc.nextInt(); 12 | for (int i = 0; i < q; i++) { 13 | long a = sc.nextLong(), b = sc.nextLong(), c = sc.nextLong(); 14 | 15 | System.out.println((a + b + c) / 2); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1213A_Chips_Moving.java: -------------------------------------------------------------------------------- 1 | // AC: 296 ms 2 | // Memory: 600 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1213A_Chips_Moving { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(), oddCount = 0; 12 | for (int i = 0; i < n; i++) { 13 | int x = sc.nextInt(); 14 | if (x % 2 == 1) { 15 | oddCount++; 16 | } 17 | } 18 | System.out.println(Math.min(oddCount, n - oddCount)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1238A_Prime_Subtraction.java: -------------------------------------------------------------------------------- 1 | // AC: 343 ms 2 | // Memory: 1000 KB 3 | // Math. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1238A_Prime_Subtraction { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | long x = sc.nextLong(), y = sc.nextLong(); 14 | 15 | System.out.println(x - y >= 2 ? "YES" : "NO"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_124A_The_number_of_positions.java: -------------------------------------------------------------------------------- 1 | // Time: 374 ms 2 | // Memory: 0 KB 3 | // brute-force 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_124A_The_number_of_positions { 9 | private final static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), ret = 0; 13 | for (int i = 1; i <= n; i++) { 14 | if (n - i >= a && i - 1 <= b) { 15 | ret++; 16 | } 17 | } 18 | 19 | System.out.println(ret); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1283A_Minutes_Before_the_New_Year.java: -------------------------------------------------------------------------------- 1 | // AC: 218 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1283A_Minutes_Before_the_New_Year { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int h = sc.nextInt(), m = sc.nextInt(), diff = (24 - h) * 60 - m; 15 | System.out.println(diff); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1304A_Two_Rabbits.java: -------------------------------------------------------------------------------- 1 | // AC: 233 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1304A_Two_Rabbits { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int x = sc.nextInt(), y = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(); 14 | 15 | System.out.println((y - x) % (a + b) == 0 ? (y - x) / (a + b) : -1); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1312A_Two_Regular_Polygons.java: -------------------------------------------------------------------------------- 1 | // AC: 249 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1312A_Two_Regular_Polygons { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), m = sc.nextInt(); 14 | 15 | System.out.println(n % m == 0 ? "YES" : "NO"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1325A_EhAb_AnD_gCd.java: -------------------------------------------------------------------------------- 1 | // AC: 202 ms 2 | // Memory: 0 KB 3 | // Greedy: just find 1 and x - 1 are ok. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1325A_EhAb_AnD_gCd { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int x = sc.nextInt(); 14 | System.out.println("1 " + (x - 1)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1328A_Divisibility_Problem.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 295 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1328A_Divisibility_Problem { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), a, b; 13 | for (int i = 0; i < n; i++) { 14 | a = sc.nextInt(); 15 | b = sc.nextInt(); 16 | int remain = a % b; 17 | System.out.println(remain == 0 ? 0 : (b - remain)); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1335A_Candies_and_Two_Sisters.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 264 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1335A_Candies_and_Two_Sisters { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(); 13 | for (int i = 0; i < n; i++) { 14 | int t = sc.nextInt(); 15 | System.out.println(t < 3 ? 0 : t - t / 2 - 1); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1335D_Anti_Sudoku.java: -------------------------------------------------------------------------------- 1 | // AC: 1247 ms 2 | // Memory: 0 KB 3 | // Many answers. Just replace one char to another in [1,9] is ok. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1335D_Anti_Sudoku { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | for (int j = 0; j < 9; j++) { 14 | String row = sc.next(); 15 | System.out.println(row.replace('1', '2')); 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1337A_Ichihime_and_Triangle.java: -------------------------------------------------------------------------------- 1 | // AC: 265 ms 2 | // Memory: 100 KB 3 | // just use (b, c, c) can make up a triangle 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1337A_Ichihime_and_Triangle { 9 | private final static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt(); 15 | System.out.println(b + " " + c + " " + c); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1339A_Filling_Diamonds.java: -------------------------------------------------------------------------------- 1 | // AC: 327 ms 2 | // Memory: 0 KB 3 | // dp: see the regularity we can know dp[n] = dp[n-1]+1. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1339A_Filling_Diamonds { 9 | private final static Scanner SC = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = SC.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int n = SC.nextInt(); 15 | System.out.println(n); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_133A_HQ9plus.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 374 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_133A_HQ9plus { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | String str = sc.next(); 13 | for (char c : str.toCharArray()) { 14 | if (c == 'H' || c == 'Q' || c == '9') { 15 | System.out.println("YES"); 16 | return; 17 | } 18 | } 19 | 20 | System.out.println("NO"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1345A_Puzzle_Pieces.java: -------------------------------------------------------------------------------- 1 | // AC: 233 ms 2 | // Memory: 0 KB 3 | // see the shape, you can not make 2 * n(n>2), or any edge > 2. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1345A_Puzzle_Pieces { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), m = sc.nextInt(); 14 | boolean ret = (n == 1 || m == 1) || (n == 2 && m == 2); 15 | System.out.println(ret ? "YES" : "NO"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1351A_A_plus_B.java: -------------------------------------------------------------------------------- 1 | // AC: 280 ms 2 | // Memory: 1200 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1351A_A_plus_B { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int a = sc.nextInt(), b = sc.nextInt(); 14 | System.out.println(a + b); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1358A_Park_Lighting.java: -------------------------------------------------------------------------------- 1 | // AC: 280 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1358A_Park_Lighting { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int n = sc.nextInt(), m = sc.nextInt(), area = n * m; 15 | System.out.println(area % 2 == 0 ? area / 2 : area / 2 + 1); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1360A_Minimal_Square.java: -------------------------------------------------------------------------------- 1 | // AC: 311 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1360A_Minimal_Square { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int a = sc.nextInt(), b = sc.nextInt(), minVal = Math.min(a, b), maxVal = Math.max(a, b), squareSize = Math.max(2 * minVal, maxVal); 15 | System.out.println(squareSize * squareSize); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1369A_FashionabLee.java: -------------------------------------------------------------------------------- 1 | // AC: 295 ms 2 | // Memory: 0 KB 3 | // number of edges must be 4 * k. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1369A_FashionabLee { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int n = sc.nextInt(); 15 | System.out.println(n % 4 == 0 ? "YES" : "NO"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1370A_Maximum_GCD.java: -------------------------------------------------------------------------------- 1 | // AC: 186 ms 2 | // Memory: 0KB 3 | // number theory: in this case max(i, j) is gcd(j/2, j%2==0?j:j-1)=j/2 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1370A_Maximum_GCD { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int n = sc.nextInt(); 15 | System.out.println(n / 2); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1371A_Magical_Sticks.java: -------------------------------------------------------------------------------- 1 | // AC: 202 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1371A_Magical_Sticks { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int n = sc.nextInt(); 15 | System.out.println((n + 1) / 2); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1374A_Required_Remainder.java: -------------------------------------------------------------------------------- 1 | // AC: 717 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1374A_Required_Remainder { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int x = sc.nextInt(), y = sc.nextInt(), n = sc.nextInt(); 15 | int m = (n / x) * x; 16 | System.out.println(m == 0 ? y : (m + y > n ? m - x + y : m + y)); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1400A_String_Similarity.java: -------------------------------------------------------------------------------- 1 | // AC: 217 ms 2 | // Memory: 0 KB 3 | // Repeat the n-th character will be an answer to the requirement. 4 | // T:O(sum(ni)), S:O(max(ni)) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1400A_String_Similarity { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | String s = sc.next(); 15 | 16 | System.out.println(String.valueOf(s.charAt(n - 1)).repeat(n)); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1409A_Yet_Another_Two_Integers_Problem.java: -------------------------------------------------------------------------------- 1 | // AC: 390 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1409A_Yet_Another_Two_Integers_Problem { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int a = sc.nextInt(), b = sc.nextInt(); 15 | System.out.println((int) Math.ceil(Math.abs(a - b) * 1.0 / 10)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1421A_XORwice.java: -------------------------------------------------------------------------------- 1 | // AC: 312 ms 2 | // Memory: 0 KB 3 | // smallest result is a^b 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1421A_XORwice { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int a = sc.nextInt(), b = sc.nextInt(); 14 | System.out.println(a ^ b); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1455A_Strange_Functions.java: -------------------------------------------------------------------------------- 1 | // AC: 186 ms 2 | // Memory: 0 KB 3 | // The answer depends on how many digits the number has. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1455A_Strange_Functions { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | String n = sc.next(); 14 | System.out.println(n.length()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1475B_New_Year_s_Number.java: -------------------------------------------------------------------------------- 1 | // AC: 312 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1475B_New_Year_s_Number { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int n = sc.nextInt(), count1 = n / 2020, count2 = n - count1 * 2020; 15 | System.out.println(count2 <= count1 ? "YES" : "NO"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1519B_The_Cake_Is_a_Lie.java: -------------------------------------------------------------------------------- 1 | // AC: 342 ms 2 | // Memory: 0 KB 3 | // Any path cost is n * m - 1. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1519B_The_Cake_Is_a_Lie { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 1; i <= t; i++) { 13 | int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt(); 14 | System.out.println(n * m - 1 == k ? "YES" : "NO"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_151A_Soft_Drinking.java: -------------------------------------------------------------------------------- 1 | // AC: 374 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_151A_Soft_Drinking { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), k = sc.nextInt(), l = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt(), p = sc.nextInt(), 13 | nl = sc.nextInt(), np = sc.nextInt(); 14 | System.out.println(Math.min(k * l / nl, Math.min(c * d, p / np)) / n); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1537B_Bad_Boy.java: -------------------------------------------------------------------------------- 1 | // AC: 530 ms 2 | // Memory: 0 KB 3 | // Just choose two diagonal points 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1537B_Bad_Boy { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), m = sc.nextInt(), r = sc.nextInt(), s = sc.nextInt(); 14 | 15 | System.out.println(n + " 1 1 " + m); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1549A_Gregor_and_Cryptography.java: -------------------------------------------------------------------------------- 1 | // AC: 249 ms 2 | // Memory: 0 KB 3 | // simple choose 2 and P-1 can meets the requirement. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1549A_Gregor_and_Cryptography { 9 | private static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int p = sc.nextInt(); 15 | System.out.println("2 " + (p - 1)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1551A_Polycarp_and_Coins.java: -------------------------------------------------------------------------------- 1 | // AC: 311 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1551A_Polycarp_and_Coins { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int n = sc.nextInt(), pair = n / 3, left = n - pair * 3; 15 | int c1 = pair + (left == 1 ? 1 : 0), c2 = pair + (left == 2 ? 1 : 0); 16 | System.out.println(c1 + " " + c2); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1553A_Digits_Sum.java: -------------------------------------------------------------------------------- 1 | // AC: 326 ms 2 | // Memory: 0 KB 3 | // Find the number x that x <= n, and x % 10 == 9 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1553A_Digits_Sum { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 1; i <= t; i++) { 13 | int n = sc.nextInt(); 14 | int ret = n / 10; 15 | if (n % 10 == 9) { 16 | ret++; 17 | } 18 | 19 | System.out.println(ret); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1594A_Consecutive_Sum_Riddle.java: -------------------------------------------------------------------------------- 1 | // AC: 389 ms 2 | // Memory: 700 KB 3 | // Tricky: use (1-n), (2-n), ...., n-1, n, such sequence sum is just n. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1594A_Consecutive_Sum_Riddle { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | long n = sc.nextLong(), l = 1 - n, r = n; 14 | 15 | System.out.println(l + " " + r); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1646A_Square_Counting.java: -------------------------------------------------------------------------------- 1 | // AC: 405 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1646A_Square_Counting { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | long s = sc.nextLong(), nSquare = (long) n * n; 15 | 16 | System.out.println(s / nSquare); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1651A_Playoff.java: -------------------------------------------------------------------------------- 1 | // AC: 171 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(sum(logn)), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1651A_Playoff { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | 15 | System.out.println((int) Math.pow(2, n) - 1); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1665A_GCD_vs_LCM.java: -------------------------------------------------------------------------------- 1 | // Time: 296 ms 2 | // Memory: 600 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1665A_GCD_vs_LCM { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | System.out.println("1 " + (n - 3) + " 1 1"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1701A_Grass_Field.java: -------------------------------------------------------------------------------- 1 | // AC: 186 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1701A_Grass_Field { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n1 = sc.nextInt(), n2 = sc.nextInt(), n3 = sc.nextInt(), n4 = sc.nextInt(); 14 | int countOne = n1 + n2 + n3 + n4; 15 | 16 | System.out.println(countOne == 0 ? 0 : (countOne == 4 ? 2 : 1)); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1703A_YES_or_YES.java: -------------------------------------------------------------------------------- 1 | // AC: 217 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1703A_YES_or_YES { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | String str = sc.next(); 15 | if ("YES".equalsIgnoreCase(str)) { 16 | System.out.println("YES"); 17 | } else { 18 | System.out.println("NO"); 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1716A_2_3_Moves.java: -------------------------------------------------------------------------------- 1 | // AC: 280 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1716A_2_3_Moves { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int n = sc.nextInt(); 15 | System.out.println(n == 1 ? 2 : (int) Math.ceil(n * 1.0 / 3)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1748A_The_Ultimate_Square.java: -------------------------------------------------------------------------------- 1 | // AC: 342 ms 2 | // Memory: 500 KB 3 | // It can be proved that when n is odd, the sum is always a square number, so the maximum side length is Math.ceil(n / 2). 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1748A_The_Ultimate_Square { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | System.out.println(n % 2 == 0 ? n / 2 : (n / 2 + 1)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1768A_Greatest_Convex.java: -------------------------------------------------------------------------------- 1 | // AC: 467 ms 2 | // Memory: 0 KB 3 | // thought: x! + (x-1)! = (x + 1) * (x-1)!, so just make x = k-1 is ok. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1768A_Greatest_Convex { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int k = sc.nextInt(); 14 | System.out.println(k - 1); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1772A_A_plus_B.java: -------------------------------------------------------------------------------- 1 | // AC: 202 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1772A_A_plus_B { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 1; i <= t; i++) { 13 | String expression = sc.next(); 14 | String[] arr = expression.split("\\+"); 15 | System.out.println(Integer.parseInt(arr[0]) + Integer.parseInt(arr[1])); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1807A_Plus_or_Minus.java: -------------------------------------------------------------------------------- 1 | // AC: 186 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1807A_Plus_or_Minus { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(); 14 | System.out.println(a + b == c ? "+" : "-"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1814A_Coins.java: -------------------------------------------------------------------------------- 1 | // AC: 358 ms 2 | // Memory: 600 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1814A_Coins { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | long n = sc.nextLong(), k = sc.nextLong(); 14 | boolean flag = n % 2 != 1 || k % 2 != 0; 15 | 16 | System.out.println(flag ? "YES" : "NO"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1841A_Game_with_Board.java: -------------------------------------------------------------------------------- 1 | // AC: 218 ms 2 | // Memory: 600 KB 3 | // Game: If n > 4, the first player just take n - 2 and put (n - 2), 4 | // then the second player have to take the two 1s. And the first win. 5 | // T:O(t), S:O(1) 6 | // 7 | import java.util.Scanner; 8 | 9 | public class Codeforces_1841A_Game_with_Board { 10 | public static void main(String[] args) { 11 | Scanner sc = new Scanner(System.in); 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int n = sc.nextInt(); 15 | 16 | System.out.println(n <= 4 ? "Bob" : "Alice"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1843C_Sum_in_Binary_Tree.java: -------------------------------------------------------------------------------- 1 | // AC: 280 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(sum(logni)), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1843C_Sum_in_Binary_Tree { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | long n = sc.nextLong(), ret = 0; 14 | while (n > 0) { 15 | ret += n; 16 | n /= 2; 17 | } 18 | 19 | System.out.println(ret); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1844A_Subtraction_Game.java: -------------------------------------------------------------------------------- 1 | // AC: 264 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1844A_Subtraction_Game { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int a = sc.nextInt(), b = sc.nextInt(); 14 | System.out.println(a + b); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1849A_Morning_Sandwich.java: -------------------------------------------------------------------------------- 1 | // AC: 202 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1849A_Morning_Sandwich { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(), ret = 0; 12 | for (int i = 0; i < t; i++) { 13 | int b = sc.nextInt(), c = sc.nextInt(), h = sc.nextInt(); 14 | ret = c + h >= b - 1 ? (b + b - 1) : (2 * (c + h) + 1); 15 | 16 | System.out.println(ret); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1850A_To_My_Critics.java: -------------------------------------------------------------------------------- 1 | // AC: 265 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1850A_To_My_Critics { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(); 14 | boolean ret = a + b >= 10 || a + c >= 10 || b + c >= 10; 15 | 16 | System.out.println(ret ? "YES" : "NO"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1857A_Array_Coloring.java: -------------------------------------------------------------------------------- 1 | // AC: 234 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(sum(ni)), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1857A_Array_Coloring { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), sum = 0; 14 | for (int j = 0; j < n; j++) { 15 | sum += sc.nextInt(); 16 | } 17 | 18 | System.out.println(sum % 2 == 0 ? "YES" : "NO"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1858A_Buttons.java: -------------------------------------------------------------------------------- 1 | // AC: 343 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1858A_Buttons { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(); 14 | int firstChooseC = c % 2 == 1 ? c / 2 + 1 : c / 2; 15 | 16 | System.out.println((firstChooseC + a > c / 2 + b) ? "First" : "Second"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1861A_Prime_Deletion.java: -------------------------------------------------------------------------------- 1 | // AC: 358 ms 2 | // Memory: 700 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1861A_Prime_Deletion { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | String sequence = sc.next(); 14 | int pos1 = sequence.indexOf('1'), pos2 = sequence.indexOf('3'); 15 | System.out.println(pos1 < pos2 ? 13 : 31); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1866A_Ambitious_Kid.java: -------------------------------------------------------------------------------- 1 | // Time: 453 ms 2 | // Memory: 2000 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1866A_Ambitious_Kid { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(), minVal = Integer.MAX_VALUE; 12 | for (int i = 0; i < n; i++) { 13 | int a = sc.nextInt(); 14 | minVal = Math.min(minVal, Math.abs(a)); 15 | } 16 | System.out.println(minVal); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1873A_Short_Sort.java: -------------------------------------------------------------------------------- 1 | // AC: 186 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1873A_Short_Sort { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | String s = sc.next(); 14 | System.out.println(s.equals("bca") || s.equals("cab") ? "NO" : "YES"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1877A_Goals_of_Victory.java: -------------------------------------------------------------------------------- 1 | // AC: 311 ms 2 | // Memory: 800 KB 3 | // . 4 | // T:O(sum(ni)), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1877A_Goals_of_Victory { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), sum = 0; 14 | for (int j = 0; j < n - 1; j++) { 15 | sum += sc.nextInt(); 16 | } 17 | System.out.println(-sum); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1895A_Treasure_Chest.java: -------------------------------------------------------------------------------- 1 | // AC: 327 ms 2 | // Memory: 800 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1895A_Treasure_Chest { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(); 12 | for (int i = 0; i < n; i++) { 13 | int x = sc.nextInt(), y = sc.nextInt(), k = sc.nextInt(), ret = x; 14 | if (y > x) { 15 | ret = y + (k >= (y - x) ? 0 : (y - x - k)); 16 | } 17 | System.out.println(ret); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1899A_Game_with_Integers.java: -------------------------------------------------------------------------------- 1 | // AC: 186 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1899A_Game_with_Integers { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | System.out.println(((n + 1) % 3 == 0 || (n - 1) % 3 == 0) ? "First" : "Second"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1915A_Odd_One_Out.java: -------------------------------------------------------------------------------- 1 | // AC: 186 ms 2 | // Memory: 24700 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1915A_Odd_One_Out { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), ret = a; 14 | if (b != c) { 15 | ret = a == c ? b : c; 16 | } 17 | System.out.println(ret); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1918A_Brick_Wall.java: -------------------------------------------------------------------------------- 1 | // AC: 342 ms 2 | // Memory: 400 KB 3 | // All bricks place horizontally, if m % 2, let (m / 2 - 1) be 1✖️2,the last be 1✖️3. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1918A_Brick_Wall { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), m = sc.nextInt(); 14 | System.out.println(n * (m / 2)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1919A_Wallet_Exchange.java: -------------------------------------------------------------------------------- 1 | // AC: 124 ms 2 | // Memory: 0 KB 3 | // In the optimal way, one can always convert to non-zero side, so just check the sum is odd or even. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1919A_Wallet_Exchange { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int a = sc.nextInt(), b = sc.nextInt(); 14 | System.out.println((a + b) % 2 == 0 ? "Bob" : "Alice"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1944A_Destroying_Bridges.java: -------------------------------------------------------------------------------- 1 | // Time: 249 ms 2 | // Memory: 1000 KB 3 | // Graph. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1944A_Destroying_Bridges { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), k = sc.nextInt(), ret = 1; 14 | if (k < n - 1) { 15 | ret = n; 16 | } 17 | 18 | System.out.println(ret); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1968A_Maximize.java: -------------------------------------------------------------------------------- 1 | // AC: 281 ms 2 | // Memory: 900 KB 3 | // Math: since 1 <= y < x, we can prove that gcd(x, y) + y <= x. Notice when y = x - 1, 4 | // the value of gcd(x, y) + y == x, so this is one of the answer. 5 | // T:O(t), S:O(1) 6 | // 7 | import java.util.Scanner; 8 | 9 | public class Codeforces_1968A_Maximize { 10 | public static void main(String[] args) { 11 | Scanner sc = new Scanner(System.in); 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int x = sc.nextInt(); 15 | 16 | System.out.println(x - 1); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1971A_My_First_Sorting_Problem.java: -------------------------------------------------------------------------------- 1 | // AC: 327 ms 2 | // Memory: 600 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1971A_My_First_Sorting_Problem { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int x = sc.nextInt(), y = sc.nextInt(), min = Math.min(x, y), max = Math.max(x, y); 14 | System.out.println(min + " " + max); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1977A_Little_Nikita.java: -------------------------------------------------------------------------------- 1 | // AC: 234 ms 2 | // Memory: 800 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1977A_Little_Nikita { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), m = sc.nextInt(); 14 | boolean ret = m <= n && ((n - m) % 2 == 0); 15 | 16 | System.out.println(ret ? "Yes" : "No"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1985A_Creating_Words.java: -------------------------------------------------------------------------------- 1 | // AC: 249 ms 2 | // Memory: 1200 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1985A_Creating_Words { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | String a = sc.next(), b = sc.next(); 14 | 15 | System.out.println(b.charAt(0) + a.substring(1, 3) + " " + a.charAt(0) + b.substring(1, 3)); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1987A_Upload_More_RAM.java: -------------------------------------------------------------------------------- 1 | // AC: 327 ms 2 | // Memory: 800 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1987A_Upload_More_RAM { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), k = sc.nextInt(); 14 | int ret = (n - 1) * k + 1; 15 | 16 | System.out.println(ret); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1989A_Catch_the_Coin.java: -------------------------------------------------------------------------------- 1 | // AC: 358 ms 2 | // Memory: 300 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1989A_Catch_the_Coin { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(); 12 | for (int i = 0; i < n; i++) { 13 | int x = sc.nextInt(), y = sc.nextInt(); 14 | 15 | System.out.println(y >= -1 ? "YES" : "NO"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1996A_Legs.java: -------------------------------------------------------------------------------- 1 | // AC: 233 ms 2 | // Memory: 1200 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1996A_Legs { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | System.out.println(n % 4 == 0 ? (n / 4) : (n / 4 + 1)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_1999A_plus_B_Again.java: -------------------------------------------------------------------------------- 1 | // AC: 249 ms 2 | // Memory: 1100 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_1999A_plus_B_Again { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | System.out.println(n / 10 + n % 10); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_2003A_Turtle_and_Good_Strings.java: -------------------------------------------------------------------------------- 1 | // AC: 328 ms 2 | // Memory: 700 KB 3 | // Greedy. Only check head and tail. 4 | // T:O(sum(ni)), S:O(max(ni)) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_2003A_Turtle_and_Good_Strings { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | String s = sc.next(); 15 | 16 | System.out.println(s.charAt(0) != s.charAt(n - 1) ? "YES" : "NO"); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_2009A_Minimize.java: -------------------------------------------------------------------------------- 1 | // AC: 280 ms 2 | // Memory: 400 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_2009A_Minimize { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int a = sc.nextInt(), b = sc.nextInt(); 14 | System.out.println(b - a); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_200B_Drinks.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 466 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_200B_Drinks { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int sum = 0, n = sc.nextInt(); 13 | while (sc.hasNext()) { 14 | sum += sc.nextInt(); 15 | } 16 | float ret = sum * 1.0f / n; 17 | System.out.printf("%.4f%n", ret); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_2013A_Zhan_s_Blender.java: -------------------------------------------------------------------------------- 1 | // AC: 264 ms 2 | // Memory: 400 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_2013A_Zhan_s_Blender { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt(); 14 | int x1 = (int) Math.ceil(n * 1.0 / x), y1 = (int) Math.ceil(n * 1.0 / y); 15 | 16 | System.out.println(Math.max(x1, y1)); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_2033A_Sakurako_and_Kosuke.java: -------------------------------------------------------------------------------- 1 | // Time: 249 ms 2 | // Memory: 600 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_2033A_Sakurako_and_Kosuke { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | System.out.println(n % 2 == 0 ? "Sakurako" : "Kosuke"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_2044A_Easy_Problem.java: -------------------------------------------------------------------------------- 1 | // AC: 234 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_2044A_Easy_Problem { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | System.out.println(n - 1); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_2055A_Two_Frogs.java: -------------------------------------------------------------------------------- 1 | // Time: 265 ms 2 | // Memory: 100 KB 3 | // Game: 偶数距离,先手必赢。只需先将距离缩小,后跟着对手的方向走即可。 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_2055A_Two_Frogs { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(); 14 | System.out.println((a - b) % 2 == 0 ? "YES" : "NO"); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_2057A_MEX_Table.java: -------------------------------------------------------------------------------- 1 | // AC: 280 ms 2 | // Memory: 1000 KB 3 | // Greedy. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_2057A_MEX_Table { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(), m = sc.nextInt(), ret = Math.max(n, m) + 1; 14 | System.out.println(ret); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_2065A_Skibidus_and_Amog_u.java: -------------------------------------------------------------------------------- 1 | // Time: 249 ms 2 | // Memory: 600 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_2065A_Skibidus_and_Amog_u { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | String s = sc.next(), ret = s.substring(0, s.length() - 2) + "i"; 14 | 15 | System.out.println(ret); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_2086A_Cloudberry_Jam.java: -------------------------------------------------------------------------------- 1 | // Time: 359 ms 2 | // Memory: 1200 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_2086A_Cloudberry_Jam { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int n = sc.nextInt(); 14 | 15 | System.out.println(2 * n); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_2093A_Ideal_Generator.java: -------------------------------------------------------------------------------- 1 | // Time: 218 ms 2 | // Memory: 300 KB 3 | // Math & constructive. 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_2093A_Ideal_Generator { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int t = sc.nextInt(); 12 | for (int i = 0; i < t; i++) { 13 | int k = sc.nextInt(); 14 | 15 | System.out.println(k % 2 == 0 ? "NO" : "YES"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_236A_Boy_or_Girl.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 404 ms 2 | // Memory: 0 KB 3 | // count unique chars. 4 | // T:O(n), S:(1) 5 | // 6 | import java.util.HashSet; 7 | import java.util.Scanner; 8 | 9 | public class Codeforces_236A_Boy_or_Girl { 10 | public static Scanner sc = new Scanner(System.in); 11 | 12 | public static void main(String[] args) { 13 | String str = sc.next(); 14 | HashSet record = new HashSet<>(); 15 | for (char c : str.toCharArray()) { 16 | record.add(c); 17 | } 18 | System.out.println(record.size() % 2 == 0 ? "CHAT WITH HER!" : "IGNORE HIM!"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_265A_Colorful_Stones_Simplified_Edition.java: -------------------------------------------------------------------------------- 1 | // AC: 374 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(n) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_265A_Colorful_Stones_Simplified_Edition { 9 | private static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | String s = sc.next(), t = sc.next(); 13 | int pos = 0; 14 | for (int i = 0; i < t.length(); i++) { 15 | if (s.charAt(pos) == t.charAt(i)) { 16 | pos++; 17 | } 18 | } 19 | System.out.println(pos + 1); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_266A_Stones_on_the_Table.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 374 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_266A_Stones_on_the_Table { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int len = sc.nextInt(), ret = 0; 13 | String str = sc.next(); 14 | for (int i = 1; i < len; i++) { 15 | if (str.charAt(i - 1) == str.charAt(i)) { 16 | ret++; 17 | } 18 | } 19 | 20 | System.out.println(ret); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /codeForces/Codeforces_268B_Buttons.java: -------------------------------------------------------------------------------- 1 | // AC: 404 ms 2 | // Memory: 0 KB 3 | // Math: In the worst case, from i = 1 to n-1 you need to check (n - i) times to exclude the wrong option. 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_268B_Buttons { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(), ret = n; 12 | for (int i = 1; i <= n - 1; i++) { 13 | ret += i * (n - i); 14 | } 15 | 16 | System.out.println(ret); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_270A_Fancy_Fence.java: -------------------------------------------------------------------------------- 1 | // AC: 342 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(t), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_270A_Fancy_Fence { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int t = sc.nextInt(); 13 | for (int i = 0; i < t; i++) { 14 | int angle = sc.nextInt(); 15 | System.out.println(360 % (180 - angle) == 0 ? "YES" : "NO"); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_281A_Word_Capitalization.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 434 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_281A_Word_Capitalization { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | String str = sc.next(); 13 | System.out.println(Character.toUpperCase(str.charAt(0)) + str.substring(1)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /codeForces/Codeforces_318A_Even_Odds.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 374 ms 2 | // Memory: 0 KB 3 | // 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_318A_Even_Odds { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | long n = sc.nextLong(), k = sc.nextLong(), ret = 0; 13 | if (n % 2 == 0) { 14 | ret = (k <= n / 2) ? 2 * k - 1 : (k - n / 2) * 2; 15 | } else { 16 | ret = (k <= n / 2 + 1) ? 2 * k - 1 : (k - n / 2 - 1) * 2; 17 | } 18 | System.out.println(ret); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_339B_Xenia_and_Ringroad.java: -------------------------------------------------------------------------------- 1 | // AC: 560 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_339B_Xenia_and_Ringroad { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), m = sc.nextInt(), cur = 1; 13 | long ret = 0; 14 | for (int i = 0; i < m; i++) { 15 | int a = sc.nextInt(); 16 | ret += a >= cur ? (a - cur) : (n + a - cur); 17 | cur = a; 18 | } 19 | System.out.println(ret); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_344A_Magnets.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 590 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_344A_Magnets { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), ret = 1; 13 | String prev = sc.next(); 14 | while (sc.hasNext()) { 15 | String str = sc.next(); 16 | if (!str.equals(prev)) { 17 | ret++; 18 | } 19 | prev = str; 20 | } 21 | 22 | System.out.println(ret); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /codeForces/Codeforces_41A_Translation.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 404 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(n) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_41A_Translation { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | String s = sc.next(), t = sc.next(); 13 | System.out.println(new StringBuilder(s).reverse().toString().equals(t) ? "YES" : "NO"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /codeForces/Codeforces_432A_Choosing_Teams.java: -------------------------------------------------------------------------------- 1 | // AC: 202 ms 2 | // Memory: 24700 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_432A_Choosing_Teams { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), k = sc.nextInt(), ret = 0; 13 | for (int i = 0; i < n; i++) { 14 | if (sc.nextInt() + k <= 5) { 15 | ret++; 16 | } 17 | } 18 | System.out.println(ret / 3); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_451A_Game_With_Sticks.java: -------------------------------------------------------------------------------- 1 | // AC: 218 ms 2 | // Memory: 0 KB 3 | // choose the smaller edge size, if edge is odd, then A win, otherwise M. 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_451A_Game_With_Sticks { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), m = sc.nextInt(), minEdge = Math.min(n, m); 13 | System.out.println(minEdge % 2 == 1 ? "Akshat" : "Malvika"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /codeForces/Codeforces_460A_Vasya_and_Socks.java: -------------------------------------------------------------------------------- 1 | // AC: 171 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(logm(n)), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_460A_Vasya_and_Socks { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), m = sc.nextInt(), remain = 0, newGet = 0, ret = n; 13 | while (n > 0) { 14 | newGet = (n + remain) / m; 15 | remain = (n + remain) % m; 16 | ret += newGet; 17 | n = newGet; 18 | } 19 | System.out.println(ret); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_466A_Cheap_Travel.java: -------------------------------------------------------------------------------- 1 | // AC: 202 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_466A_Cheap_Travel { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), m = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(); 13 | if (m * a <= b) { 14 | System.out.println(n * a); 15 | } else { 16 | System.out.println((n / m) * b + Math.min((n - n / m * m) * a, b)); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_467A_George_and_Accommodation.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 202 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_467A_George_and_Accommodation { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), count = 0; 13 | while (sc.hasNext()) { 14 | int p = sc.nextInt(), q = sc.nextInt(); 15 | if (q - p >= 2) { 16 | count++; 17 | } 18 | } 19 | System.out.println(count); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_486A_Calculating_Function.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 186 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_486A_Calculating_Function { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | long n = sc.nextLong(); 13 | System.out.println((n % 2 == 0) ? n / 2 : (-n - 1) / 2); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /codeForces/Codeforces_492A_Vanya_and_Cubes.java: -------------------------------------------------------------------------------- 1 | // AC: 186 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(sqrt(-3, n)), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_492A_Vanya_and_Cubes { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), level = 1, sum = 0; 13 | while (sum <= n) { 14 | sum += (level * (level + 1)) / 2; 15 | level++; 16 | } 17 | System.out.println(level - 2); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_50A_Domino_piling.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 374 ms 2 | // Memory: 0 KB 3 | // every even param can fill completely. when both odd, we can fill until one single square left. 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_50A_Domino_piling { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int m = sc.nextInt(), n = sc.nextInt(); 13 | System.out.println(m * n / 2); 14 | } 15 | } -------------------------------------------------------------------------------- /codeForces/Codeforces_546A_Soldier_and_Bananas.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 171 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_546A_Soldier_and_Bananas { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int k = sc.nextInt(), n = sc.nextInt(), w = sc.nextInt(); 13 | int total = w * (w + 1) / 2 * k; 14 | System.out.println(total > n ? total - n : 0); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /codeForces/Codeforces_579A_Raising_Bacteria.java: -------------------------------------------------------------------------------- 1 | // AC: 187 ms 2 | // Memory: 0 KB 3 | // bitmask 4 | // T:O(logn), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_579A_Raising_Bacteria { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int x = sc.nextInt(), ret = 0; 13 | while (x > 0) { 14 | if (x % 2 == 1) { 15 | ret++; 16 | } 17 | x = x >> 1; 18 | } 19 | System.out.println(ret); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_581A_Vasya_the_Hipster.java: -------------------------------------------------------------------------------- 1 | // AC: 187 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_581A_Vasya_the_Hipster { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int a = sc.nextInt(), b = sc.nextInt(); 13 | 14 | System.out.println(Math.min(a, b) + " " + (Math.max(a, b) - Math.min(a, b)) / 2); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /codeForces/Codeforces_617A_Elephant.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 187 ms 2 | // Memory: 0 KB 3 | // Math.ceil() 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_617A_Elephant { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(); 13 | System.out.println((int) Math.ceil(n * 1.0 / 5)); 14 | } 15 | } -------------------------------------------------------------------------------- /codeForces/Codeforces_630A_Again_Twenty_Five.java: -------------------------------------------------------------------------------- 1 | // AC: 171 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_630A_Again_Twenty_Five { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | long n = sc.nextLong(); 13 | System.out.println(n == 1 ? 5 : 25); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /codeForces/Codeforces_688B_Lovely_Palindromes.java: -------------------------------------------------------------------------------- 1 | // AC: 202 ms 2 | // Memory: 0 KB 3 | // See some regularity, 1-th is 11, 10-th is 1001, 100-th is 100001, 1000-th is 10000001. 4 | // T:O(1), S:O(n) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_688B_Lovely_Palindromes { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | String n = sc.next(); 12 | StringBuilder ret = new StringBuilder(), nStr = new StringBuilder(n); 13 | ret.append(n); 14 | ret.append(nStr.reverse()); 15 | 16 | System.out.println(ret.toString()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /codeForces/Codeforces_723A_The_New_Year_Meeting_Friends.java: -------------------------------------------------------------------------------- 1 | // AC: 187 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_723A_The_New_Year_Meeting_Friends { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(); 13 | int max = Math.max(a, Math.max(b, c)), min = Math.min(a, Math.min(b, c)); 14 | System.out.println(max - min); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /codeForces/Codeforces_732A_Buy_a_Shovel.java: -------------------------------------------------------------------------------- 1 | // AC: 218 ms 2 | // Memory: 0 KB 3 | // brute-force 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_732A_Buy_a_Shovel { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int k = sc.nextInt(), r = sc.nextInt(), step = (k % 2 == 1 && r % 2 == 0) ? 2 : 1; 13 | for (int i = 0; ; i += step) { 14 | if ((i != 0 && (k * i) % 10 == 0) || (k * i - r) % 10 == 0) { 15 | System.out.println(i); 16 | return; 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_734B_Anton_and_Digit.java: -------------------------------------------------------------------------------- 1 | // AC: 218 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_734B_Anton_and_Digit { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int k2 = sc.nextInt(), k3 = sc.nextInt(), k5 = sc.nextInt(), k6 = sc.nextInt(), ret = 0; 12 | int count256 = Math.min(k2, Math.min(k5, k6)); 13 | ret = count256 * 256 + Math.min(k2 - count256, k3) * 32; 14 | 15 | System.out.println(ret); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /codeForces/Codeforces_750A_New_Year_and_Hurry.java: -------------------------------------------------------------------------------- 1 | // AC: 202 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_750A_New_Year_and_Hurry { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), k = sc.nextInt(); 13 | int sqrtN = (int) Math.sqrt((240 - k) * 2.0 / 5); 14 | if (sqrtN * (sqrtN + 1) / 2 * 5 > 240 - k) { 15 | sqrtN--; 16 | } 17 | System.out.println(Math.min(n, sqrtN)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /codeForces/Codeforces_758A_Holiday_Of_Equality.java: -------------------------------------------------------------------------------- 1 | // AC: 202 ms 2 | // Memory: 24600 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_758A_Holiday_Of_Equality { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), sum = 0, maxN = -1; 13 | for (int i = 0; i < n; i++) { 14 | int t = sc.nextInt(); 15 | maxN = Math.max(maxN, t); 16 | sum += t; 17 | } 18 | System.out.println(maxN * n - sum); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /codeForces/Codeforces_791A_Bear_and_Big_Brother.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 187 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(log(b / a)), S:(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_791A_Bear_and_Big_Brother { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int a = sc.nextInt(), b = sc.nextInt(), ret = 0; 13 | while (a <= b) { 14 | a *= 3; 15 | b *= 2; 16 | ret++; 17 | } 18 | 19 | System.out.println(ret); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_822A_I_m_bored_with_life.java: -------------------------------------------------------------------------------- 1 | // AC: 187 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_822A_I_m_bored_with_life { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(), m = sc.nextInt(); 12 | System.out.println(getFactorial(Math.min(n, m))); 13 | } 14 | 15 | private static long getFactorial(int n) { 16 | long ret = 1; 17 | for (int i = 2; i <= n; i++) { 18 | ret *= i; 19 | } 20 | return ret; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /codeForces/Codeforces_935A_Fafa_and_his_Company.java: -------------------------------------------------------------------------------- 1 | // AC: 187 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_935A_Fafa_and_his_Company { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), ret = 0; 13 | for (int i = 1; i <= n / 2; i++) { 14 | if (n % i == 0) { 15 | ret++; 16 | } 17 | } 18 | 19 | System.out.println(ret); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /codeForces/Codeforces_959A_Mahmoud_and_Ehab_and_the_even_odd_game.java: -------------------------------------------------------------------------------- 1 | // AC: 187 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_959A_Mahmoud_and_Ehab_and_the_even_odd_game { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(); 13 | System.out.println(n % 2 == 0 ? "Mahmoud" : "Ehab"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /codeForces/Codeforces_977A_Wrong_Subtraction.java: -------------------------------------------------------------------------------- 1 | // AC: Time: 187 ms 2 | // Memory: 0 KB 3 | // . 4 | // T:O(k), S:O(1) 5 | // 6 | import java.util.Scanner; 7 | 8 | public class Codeforces_977A_Wrong_Subtraction { 9 | public static Scanner sc = new Scanner(System.in); 10 | 11 | public static void main(String[] args) { 12 | int n = sc.nextInt(), k = sc.nextInt(); 13 | for (int i = 0; i < k; i++) { 14 | if (n % 10 == 0) { 15 | n /= 10; 16 | } else { 17 | n--; 18 | } 19 | } 20 | 21 | System.out.println(n); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /codeForces/codeForces_1A_A_Theatre_Square.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 思路:矩形用小正方形填充,只需行和列取整就行了。 3 | * 注意陷阱,不要用 int32,否则结果打印不了最大 10^18 这样的大数 4 | * AC: 5 | * Time:15 ms Memory:0 KB 6 | * 7 | */ 8 | #include 9 | #include 10 | 11 | int main() 12 | { 13 | int n, m, a; 14 | long long ans = 0; 15 | scanf("%d%d%d", &n, &m, &a); 16 | ans = ceil((double)n / a) * ceil((double)m / a); // floor() 和 ceil() 的入参都是 double型 17 | printf("%lld", ans); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /codeForces/codeForces_4A_A_Watermelon.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * codeforces入门第一题。 3 | * 题目也没说 0 也是偶数且 0 不算,所以 2 认为是 NO,注意这里就行了。 4 | * 5 | * AC: 6 | * Accepted 62 ms 0 KB 7 | */ 8 | 9 | #include 10 | 11 | int main() { 12 | int a = 0; 13 | scanf("%d", &a); 14 | if(a < 4) { 15 | printf("NO"); 16 | } else if(a % 2 == 0) 17 | printf("YES"); 18 | else 19 | printf("NO"); 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /contest/leetcode_biweek_17/leetcode_5143_Decompress_Run-Length_Encoded_List.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * AC: 3 | * 思路:较易,略 4 | */ 5 | class Solution { 6 | public: 7 | vector decompressRLElist(vector& nums) { 8 | vector ret; 9 | for(int i = 0; i < nums.size() / 2; i++) 10 | for(int j = 0; j < nums[2 * i]; j++) 11 | ret.push_back(nums[2 * i + 1]); 12 | 13 | return ret; 14 | } 15 | }; -------------------------------------------------------------------------------- /contest/leetcode_biweek_26/[editing]leetcode_5398_Count_Good_Nodes_in_Binary_Tree.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for a binary tree node. 3 | * struct TreeNode { 4 | * int val; 5 | * TreeNode *left; 6 | * TreeNode *right; 7 | * TreeNode() : val(0), left(nullptr), right(nullptr) {} 8 | * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} 9 | * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} 10 | * }; 11 | */ 12 | class Solution { 13 | public: 14 | int goodNodes(TreeNode* root) { 15 | 16 | } 17 | }; -------------------------------------------------------------------------------- /contest/leetcode_biweek_26/[editing]leetcode_5399_Form_Largest_Integer_With_Digits_That_Add_up_to_Target.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | string largestNumber(vector& cost, int target) { 4 | 5 | } 6 | }; -------------------------------------------------------------------------------- /contest/leetcode_biweek_26/leetcode_5396_Consecutive_Characters.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * AC 3 | * 4 | */ 5 | class Solution { 6 | public: 7 | int maxPower(string s) { 8 | int ret = 1; 9 | int nowLength = 1; 10 | int size = s.length(); 11 | char nowChar = s[0]; 12 | 13 | for (int i = 1; i < size; i++) { 14 | if (s[i] == nowChar) { 15 | nowLength++; 16 | if (nowLength > ret) { 17 | ret = nowLength; 18 | } 19 | } 20 | else { 21 | nowLength = 1; 22 | nowChar = s[i]; 23 | } 24 | } 25 | 26 | return ret; 27 | 28 | } 29 | }; -------------------------------------------------------------------------------- /contest/leetcode_biweek_57/[editing]leetcode_1943_Describe_the_Painting.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/contest/leetcode_biweek_57/[editing]leetcode_1943_Describe_the_Painting.java -------------------------------------------------------------------------------- /contest/leetcode_biweek_58/[editing]leetcode_1959_Minimum_Total_Space_Wasted_With_K_Resizing_Operations.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/contest/leetcode_biweek_58/[editing]leetcode_1959_Minimum_Total_Space_Wasted_With_K_Resizing_Operations.java -------------------------------------------------------------------------------- /contest/leetcode_biweek_58/[editing]leetcode_1960_Maximum_Product_of_the_Length_of_Two_Palindromic_Substrings.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/contest/leetcode_biweek_58/[editing]leetcode_1960_Maximum_Product_of_the_Length_of_Two_Palindromic_Substrings.java -------------------------------------------------------------------------------- /contest/leetcode_biweek_59/[editing]leetcode_1976_Number_of_Ways_to_Arrive_at_Destination.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int countPaths(int n, int[][] roads) { 3 | 4 | } 5 | } -------------------------------------------------------------------------------- /contest/leetcode_biweek_59/[editing]leetcode_1977_Number_of_Ways_to_Separate_Numbers.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int numberOfCombinations(String num) { 3 | 4 | } 5 | } -------------------------------------------------------------------------------- /contest/leetcode_week_166/[editing]leetcode_1282_Group_the_People_Given_the_Group_Size_They_Belong_To.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector> groupThePeople(vector& groupSizes) { 4 | 5 | } 6 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_166/[editing]leetcode_1283_Find_the_Smallest_Divisor_Given_a_Threshold.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int smallestDivisor(vector& nums, int threshold) { 4 | 5 | } 6 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_166/[editing]leetcode_1284_Minimum_Number_of_Flips_to_Convert_Binary_Matrix_to_Zero_Matrix.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minFlips(vector>& mat) { 4 | 5 | } 6 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_166/leetcode_1281_Subtract_the_Product_and_Sum_of_Digits_of_an_Integer.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 给定一个正数,求各位之积减去各位之和。 3 | * 4 | * AC: Runtime: 0 ms | Memory Usage: 8.3 MB 5 | */ 6 | class Solution { 7 | public: 8 | int subtractProductAndSum(int n) { 9 | if(n == 0) 10 | return 0; 11 | int product = 1, sum = 0; 12 | while(n != 0) { 13 | product *= n % 10; 14 | sum += n % 10; 15 | n /= 10; 16 | } 17 | 18 | return product - sum; 19 | } 20 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_169/[editing]leetcode_1304_Find_N_Unique_Integers_Sum_up_to_Zero.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector sumZero(int n) { 4 | 5 | } 6 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_169/[editing]leetcode_1305_All_Elements_in_Two_Binary_Search_Trees.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for a binary tree node. 3 | * struct TreeNode { 4 | * int val; 5 | * TreeNode *left; 6 | * TreeNode *right; 7 | * TreeNode(int x) : val(x), left(NULL), right(NULL) {} 8 | * }; 9 | */ 10 | class Solution { 11 | public: 12 | vector getAllElements(TreeNode* root1, TreeNode* root2) { 13 | 14 | } 15 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_169/[editing]leetcode_1306_Jump_Game_III.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool canReach(vector& arr, int start) { 4 | 5 | } 6 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_169/[editing]leetcode_1307_Verbal_Arithmetic_Puzzle.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isSolvable(vector& words, string result) { 4 | 5 | } 6 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_171/leetcode_5309_Number_of_Operations_to_Make_Network_Connected.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int makeConnected(int n, vector>& connections) { 4 | int cablesCount = connections.size(); 5 | if(n - 1 > cablesCount) // 线不够 6 | return -1; 7 | 8 | } 9 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_189/[editing]leetcode_5415_Maximum_Number_of_Darts_Inside_of_a_Circular_Dartboard.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int numPoints(vector>& points, int r) { 4 | 5 | } 6 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_189/leetcode_5412_Number_of_Students_Doing_Homework_at_a_Given_Time.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * AC 3 | */ 4 | class Solution { 5 | public: 6 | int busyStudent(vector& startTime, vector& endTime, int queryTime) { 7 | int ret = 0; 8 | for (int i = 0; i < startTime.size(); i++) { 9 | if (queryTime >= startTime[i] && queryTime <= endTime[i]) { 10 | ret++; 11 | } 12 | } 13 | 14 | return ret; 15 | } 16 | }; -------------------------------------------------------------------------------- /contest/leetcode_week_236/leetcode_1822_Sign_of_the_Product_of_an_Array.java: -------------------------------------------------------------------------------- 1 | // AC 2 | class Solution { 3 | public int arraySign(int[] nums) { 4 | int negativeCount = 0; 5 | for(int i = 0; i < nums.length; i++) { 6 | if (nums[i] == 0) { 7 | return 0; 8 | } 9 | if (nums[i] < 0) { 10 | negativeCount++; 11 | } 12 | } 13 | 14 | return negativeCount % 2 == 0 ? 1 : -1; 15 | } 16 | } -------------------------------------------------------------------------------- /contest/leetcode_week_249/leetcode_1929_Concatenation_of_Array.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 2 ms, faster than 100.00% of Java online submissions for Concatenation of Array. 2 | // Memory Usage: 47.7 MB, less than 100.00% of Java online submissions for Concatenation of Array. 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int[] getConcatenation(int[] nums) { 8 | int size = nums.length; 9 | int[] ret = new int[2 * size]; 10 | for (int i = 0; i < 2 * size; i++) { 11 | ret[i] = nums[i % size]; 12 | } 13 | 14 | return ret; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /contest/leetcode_week_249/leetcode_1932_Merge_BSTs_to_Create_Single_BST.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/contest/leetcode_week_249/leetcode_1932_Merge_BSTs_to_Create_Single_BST.java -------------------------------------------------------------------------------- /contest/leetcode_week_267/[editing]leetcode_2076_Process_Restricted_Friend_Requests.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/contest/leetcode_week_267/[editing]leetcode_2076_Process_Restricted_Friend_Requests.java -------------------------------------------------------------------------------- /contest/leetcode_week_267/leetcode_2073_Time_Needed_to_Buy_Tickets.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int timeRequiredToBuy(int[] tickets, int k) { 3 | int size = tickets.length, ret = 0; 4 | 5 | while (tickets[k] > 0) { 6 | for (int i = 0; i < size; i++) { 7 | if (tickets[i] > 0) { 8 | tickets[i]--; 9 | ret++; 10 | if (tickets[k] == 0) { 11 | return ret; 12 | } 13 | } 14 | } 15 | } 16 | 17 | return ret; 18 | } 19 | } -------------------------------------------------------------------------------- /fibonacci/test.c: -------------------------------------------------------------------------------- 1 | // test data structure:sequence_list 2 | #include 3 | #include 4 | 5 | int fibonacci(int i) { 6 | if (i <= 0) { 7 | return 0; 8 | } 9 | if (i == 1 || i == 2) { 10 | return 1; 11 | } 12 | return fibonacci(i - 1) + fibonacci(i - 2); 13 | } 14 | 15 | 16 | int main() { 17 | printf("__________________"); 18 | int num_100 = fibonacci(45); 19 | printf("%d\n", num_100); 20 | printf("__________________"); 21 | system("pause"); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0011_Container_With_Most_Water.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxArea(vector& height) { 4 | int water = 0; 5 | int i = 0; 6 | int j = height.size() - 1; 7 | 8 | while(i < j) { 9 | int h = min(height[i], height[j]); 10 | water = max(water, (j - i) * h); 11 | while(height[i] <= h && i < j) 12 | i++; 13 | while(height[j] <= h && i < j) 14 | j--; 15 | } 16 | 17 | return water; 18 | } 19 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0013_Roman_to_Integer.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int romanToInt(string s) { 4 | unordered_map T = {{'I', 1}, 5 | {'V', 5}, 6 | {'X', 10}, 7 | {'L', 50}, 8 | {'C', 100}, 9 | {'D', 500}, 10 | {'M', 1000}, 11 | }; 12 | int sum = T[s.back()]; 13 | 14 | for(int i = s.length() - 2; i >= 0; --i) { 15 | if(T[s[i]] < T[s[i + 1]]) 16 | sum -= T[s[i]]; 17 | else 18 | sum += T[s[i]]; 19 | 20 | } 21 | return sum; 22 | } 23 | }; 24 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0014_Longest_Common_Prefix.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | string longestCommonPrefix(vector& strs) { 4 | string prefix = ""; 5 | int n = strs.size(); 6 | 7 | for(int t = 0; n > 0; prefix += strs[0][t], t++) { 8 | for(int i = 0; i < n; i++) { 9 | if(t >= strs[i].size() || (i > 0 && strs[i][t] != strs[i - 1][t])) 10 | return prefix; 11 | } 12 | } 13 | 14 | return prefix; 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0024_Swap_Nodes_in_Pairs.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 思路:写一个交换的处理即可。 3 | * 4 | */ 5 | /** 6 | * Definition for singly-linked list. 7 | * struct ListNode { 8 | * int val; 9 | * ListNode *next; 10 | * ListNode(int x) : val(x), next(NULL) {} 11 | * }; 12 | */ 13 | class Solution { 14 | public: 15 | ListNode* swapPairs(ListNode* head) { 16 | ListNode **pp = &head, *a, *b; 17 | while((a = *pp) && (b = a->next)) { 18 | a->next = b->next; 19 | b->next = a; 20 | *pp = b; 21 | pp = &(a->next); 22 | } 23 | 24 | return head; 25 | } 26 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0029_Divide_Two_Intergers.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | /** 4 | * AC: 5 | * Runtime: 4 ms, faster than 80.61% of C++ online submissions for Divide Two Integers. 6 | * Memory Usage: 8.2 MB, less than 77.72% of C++ online submissions for Divide Two Integers. 7 | * 8 | */ 9 | int divide(int dividend, int divisor) { 10 | if(dividend == -2147483648 && divisor == -1) 11 | return 2147483647; 12 | return dividend/divisor; 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0032_Longest_Valid_Parentheses.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/leetcode_solved/leetcode_0032_Longest_Valid_Parentheses.cpp -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0035_Search_Insert_Position.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Runtime: 12 ms, faster than 60.71% of C++ online submissions for Search Insert Position. 3 | * Memory Usage: 9.7 MB, less than 73.95% of C++ online submissions for Search Insert Position. 4 | * 5 | */ 6 | class Solution { 7 | public: 8 | int searchInsert(vector& nums, int target) { 9 | for (int i = 0; i < nums.size(); i++) { 10 | if (nums[i] >= target) { 11 | return i; 12 | } else if (i + 1 < nums.size() && nums[i + 1] >= target) { 13 | return i + 1; 14 | } 15 | } 16 | 17 | return nums.size(); 18 | } 19 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0055_Jump_Game.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 2 ms, faster than 77.50% of Java online submissions for Jump Game. 2 | // Memory Usage: 39.6 MB, less than 87.08% of Java online submissions for Jump Game. 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean canJump(int[] nums) { 8 | int size = nums.length; 9 | if (size == 1) { 10 | return true; 11 | } 12 | int reach = 0, i = 0; 13 | for (; i < size && i <= reach; i++) { 14 | reach = Math.max(reach, i + nums[i]); 15 | } 16 | 17 | return i == size; 18 | } 19 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0062_Unique_Path.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int uniquePaths(int m, int n) { 4 | int t = m + n - 2; 5 | int s = n - 1; 6 | long result = 1; 7 | for (int i = m, j = 1; i <= t; i++, j++) { 8 | result = result * i / j; 9 | } 10 | return result; 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0063_Unique_Path_With_Obstacles.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int uniquePathsWithObstacles(vector>& obstacleGrid) { 4 | int m = obstacleGrid.size(), n = obstacleGrid[0].size(); 5 | vector> dp(m + 1, vector(n + 1, 0)); 6 | dp[0][1] = 1; 7 | for (int i = 1; i <= m; ++i) 8 | for (int j = 1; j <= n; ++j) 9 | if (!obstacleGrid[i - 1][j - 1]) 10 | dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; 11 | return dp[m][n]; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0069_Sqrt(x).cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * AC: 3 | * Runtime: 4 ms, faster than 74.90% of C++ online submissions for Sqrt(x). 4 | * Memory Usage: 8 MB, less than 100.00% of C++ online submissions for Sqrt(x). 5 | * 思路:牛顿法,开方求平方根近似值的常用手法。 6 | * 7 | */ 8 | class Solution { 9 | public: 10 | int mySqrt(int x) { 11 | if(x == 0) 12 | return 0; 13 | long raw = x; 14 | while(raw * raw > x) { 15 | raw = (raw + x / raw) / 2; 16 | } 17 | 18 | return raw; 19 | } 20 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0070_Climbing_Stairs.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int climbStairs(int n) { 4 | vectordp(n+1, 0); 5 | dp[0] = 1; 6 | dp[1] = 1; 7 | for(int i = 2; i <= n; i++) 8 | dp[i] = dp[i - 1] + dp[i - 2]; 9 | return dp[n]; 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0074_Search_a_2D_Matrix.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/leetcode_solved/leetcode_0074_Search_a_2D_Matrix.cpp -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0094_Binary_Tree_Inorder_Traversal.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/leetcode_solved/leetcode_0094_Binary_Tree_Inorder_Traversal.java -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0096_Unique_Binary_Search_Trees.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Unique Binary Search Trees. 2 | // Memory Usage: 37.5 MB, less than 18.78% of Java online submissions for Unique Binary Search Trees. 3 | // DP. 4 | // T:O(n ^ 2), S:O(n) 5 | // 6 | class Solution { 7 | public int numTrees(int n) { 8 | int[] dp = new int[n + 1]; 9 | dp[0] = 1; 10 | for (int i = 1; i <= n; i++) { 11 | for (int j = 1; j <= i; j++) { 12 | dp[i] += dp[j - 1] * dp[i - j]; 13 | } 14 | } 15 | 16 | return dp[n]; 17 | } 18 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0100_Same_Tree.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% of users with Java 2 | // Memory 36.22 MB Beats 100.00% of users with Java 3 | // Recursion. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean isSameTree(TreeNode p, TreeNode q) { 8 | if (p == null && q == null) { 9 | return true; 10 | } 11 | if ((p != null && q == null) || (p == null && q != null)) { 12 | return false; 13 | } 14 | if (p.val != q.val) { 15 | return false; 16 | } 17 | return isSameTree(p.left, q.left) && isSameTree(p.right, q.right); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0120_Triangle.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minimumTotal(vector>& triangle) { 4 | int n = triangle.size(); 5 | vectorrecord(triangle.back()); 6 | for(int i = n - 2; i >= 0; i--) { 7 | for(int j = 0; j <= i; j++) { 8 | record[j] = min(record[j], record[j + 1]) + triangle[i][j]; 9 | } 10 | } 11 | 12 | return record[0]; 13 | } 14 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0121_Best_Time_To_Buy_And_Sell_Stock.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxProfit(vector& prices) { 4 | int n = prices.size(); 5 | int maxCur = 0, maxSoFar = 0; 6 | for(int i = 1; i < n; i++) { 7 | maxCur = max(0, maxCur += prices[i] - prices[i-1]); 8 | maxSoFar = max(maxCur, maxSoFar); 9 | } 10 | return maxSoFar; 11 | } 12 | }; 13 | 14 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0136_Single_Number.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Runtime: 16 ms, faster than 67.11% of C++ online submissions for Single Number. 3 | * Memory Usage: 9.7 MB, less than 93.83% of C++ online submissions for Single Number. 4 | * 5 | * 思路:用异或运算 ^= , 0 ^ A = A, A ^ A = 0, 有配对就会抵消一次运算造成的影响。 6 | * 传统的思路,既不能排序,也不能用至少 O(n) 的额外空间,是办不到的。 7 | */ 8 | class Solution { 9 | public: 10 | int singleNumber(vector& nums) { 11 | int ret = 0; 12 | for(int i = 0; i < nums.size(); i++) { 13 | ret ^= nums[i]; 14 | } 15 | return ret; 16 | } 17 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0137_Single_Number_II.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * AC: 3 | * Runtime: 16 ms, faster than 20.60% of C++ online submissions for Single Number II. 4 | * Memory Usage: 9.6 MB, less than 87.50% of C++ online submissions for Single Number II. 5 | * 6 | * 思路:归结为数组的单元素查找问题。 7 | * 8 | */ 9 | class Solution { 10 | public: 11 | int singleNumber(vector& nums) { 12 | int x1 = 0, x2 = 0, mask = 0; 13 | for(int i : nums) { 14 | x2 ^= x1 & i; 15 | x1 ^= i; 16 | mask = ~(x1 & x2); 17 | x2 &= mask; 18 | x1 &= mask; 19 | } 20 | return x1; 21 | } 22 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0171_Excel_Sheet_Column_Number.java: -------------------------------------------------------------------------------- 1 | // Runtime: 1 ms, faster than 100.00% of Java online submissions for Excel Sheet Column Number. 2 | // Memory Usage: 38.7 MB, less than 89.08% of Java online submissions for Excel Sheet Column Number. 3 | // 4 | class Solution { 5 | public int titleToNumber(String columnTitle) { 6 | int ret = 0, size = columnTitle.length(), temp; 7 | for (int i = 0; i < size; i++) { 8 | temp = (columnTitle.charAt(i) - 'A') + 1; 9 | ret += temp * (int)Math.pow(26, (size - 1 - i)); 10 | } 11 | return ret; 12 | } 13 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0179_Largest_Number.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 思路:按字典序来排序拼接出来的字符串,得到的最大的就是可以拼出的最大数字 3 | * 4 | */ 5 | class Solution { 6 | public: 7 | string largestNumber(vector &num) { 8 | vector arr; 9 | for(auto i:num) 10 | arr.push_back(to_string(i)); 11 | sort(begin(arr), end(arr), [](string &s1, string &s2){ return s1+s2>s2+s1; }); 12 | string res; 13 | for(auto s:arr) 14 | res+=s; 15 | while(res[0]=='0' && res.length()>1) 16 | res.erase(0,1); 17 | return res; 18 | } 19 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0203_Remove_Linked_List_Elements.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for singly-linked list. 3 | * struct ListNode { 4 | * int val; 5 | * ListNode *next; 6 | * ListNode(int x) : val(x), next(NULL) {} 7 | * }; 8 | */ 9 | class Solution { 10 | public: 11 | ListNode* removeElements(ListNode* head, int val) { 12 | ListNode** list = &head; 13 | 14 | while(*list != nullptr) { 15 | if((*list)->val == val) 16 | *list = (*list)->next; 17 | else 18 | list = &((*list)->next); // 跳到下一个指针 19 | } 20 | 21 | return head; 22 | } 23 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0205_Isomorphic_Strings.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isIsomorphic(string s, string t) { 4 | int m1[128] = {0}, m2[128] = {0}; 5 | int size_s = s.size(); 6 | for(int i = 0; i < size_s; i++) { 7 | if(m1[s[i]] != m2[t[i]]) 8 | return false; 9 | m1[s[i]] = i + 1; 10 | m2[t[i]] = i + 1; 11 | } 12 | 13 | return true; 14 | } 15 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0217_Contains_Duplicate.java: -------------------------------------------------------------------------------- 1 | // AC:T:O(n), S:O(n) 2 | class Solution { 3 | public boolean containsDuplicate(int[] nums) { 4 | HashSet record = new HashSet<>(); 5 | int size = nums.length; 6 | for(int i = 0; i < size; i++) { 7 | if (record.contains(nums[i])) { 8 | return true; 9 | } 10 | record.add(nums[i]); 11 | } 12 | return false; 13 | } 14 | } 15 | 16 | // 法二:先排序,再判断连续两个元素是否相等。 17 | // T:O(n logn), S:O(logn) (调用栈深度) 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0231_Power_of_Two.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * AC: 3 | * Runtime: 4 ms, faster than 56.88% of C++ online submissions for Power of Two. 4 | * Memory Usage: 8 MB, less than 100.00% of C++ online submissions for Power of Two. 5 | * 6 | * 思路:用位运算。如果是 2^n (n>=0),那么 n&(n - 1) = 0,反之则 n&(n - 1)=1 7 | */ 8 | class Solution { 9 | public: 10 | bool isPowerOfTwo(int n) { 11 | return n > 0 && !(n & (n - 1)); 12 | } 13 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0268_Missing_Number.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * AC: 3 | * Runtime: 24 ms, faster than 80.31% of C++ online submissions for Missing Number. 4 | * Memory Usage: 9.7 MB, less than 98.04% of C++ online submissions for Missing Number. 5 | * 6 | * 思路:求和,按 1-n 和减去实际 sum 就是丢掉的数 7 | */ 8 | class Solution { 9 | public: 10 | int missingNumber(vector& nums) { 11 | if(nums.empty()) 12 | return 0; 13 | int size = nums.size(); 14 | int sum = 0; 15 | 16 | for(int i = 0; i < size; i++) { 17 | sum += nums[i]; 18 | } 19 | 20 | return size * (size + 1) / 2 - sum; 21 | } 22 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0292_Nim_Game.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Nim Game. 2 | // Memory Usage: 35.2 MB, less than 99.32% of Java online submissions for Nim Game. 3 | // 如果 n 为 4 的倍数,则后手的每次只需拿走 4 - X 个即可,X 为上一回合对手拿走的数量。后手必赢 4 | // 如果 n 不是 4 的倍数,则先手者第一次只需拿走 n % 4 个,即可造成对手为 4 的倍数,那么沿用上面的情形对手必输 5 | // T:O(1), S:O(1) 6 | // 7 | class Solution { 8 | public boolean canWinNim(int n) { 9 | if (n % 4 == 0) { 10 | return false; 11 | } 12 | return true; 13 | } 14 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0326_Power_of_Three.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * AC: 3 | * Runtime: 16 ms, faster than 67.62% of C++ online submissions for Power of Three. 4 | * Memory Usage: 8.2 MB, less than 66.67% of C++ online submissions for Power of Three. 5 | * 思路: 转换为求 log3(n) 是否是整数。 6 | * 7 | */ 8 | class Solution { 9 | public: 10 | bool isPowerOfThree(int n) { 11 | double power = log10(n) / log10(3); 12 | if(fmod(power, 1) == 0) // 指数为整数 13 | return true; 14 | 15 | return false; 16 | } 17 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0342_Power_of_Four.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * AC: 3 | * Runtime: 0 ms, faster than 100.00% of C++ online submissions for Power of Four. 4 | * Memory Usage: 8.2 MB, less than 52.38% of C++ online submissions for Power of Four. 5 | * 6 | */ 7 | class Solution { 8 | public: 9 | bool isPowerOfFour(int num) { 10 | return fmod((log10(num)/log10(4)), 1) == 0; 11 | } 12 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0344_Reverse_String.java: -------------------------------------------------------------------------------- 1 | // Runtime: 1 ms, faster than 94.60% of Java online submissions for Reverse String. 2 | // Memory Usage: 45.9 MB, less than 32.96% of Java online submissions for Reverse String. 3 | // 4 | class Solution { 5 | public void reverseString(char[] s) { 6 | char tempChar; 7 | int size = s.length; 8 | for (int i = 0; i < size / 2; i++) { 9 | tempChar = s[size - 1 - i]; 10 | s[size - 1 - i] = s[i]; 11 | s[i] = tempChar; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0367_Valid_Perfect_Square.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isPerfectSquare(int num) { 4 | return fmod(sqrt(num), 1) == 0; 5 | } 6 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0476_Number_Complement.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Number Complement. 2 | // Memory Usage: 35.1 MB, less than 99.88% of Java online submissions for Number Complement. 3 | // 略 4 | // T:O(log2(n)), S:O(1) 5 | // 6 | class Solution { 7 | public int findComplement(int num) { 8 | int ret = 0, base = 1; 9 | if (num == 0) { 10 | return 1; 11 | } 12 | while (num > 0) { 13 | ret += (num % 2 == 0 ? 1 : 0) * base; 14 | num = num >> 1; 15 | base *= 2; 16 | } 17 | return ret; 18 | } 19 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0521_Longest_Uncommon_Subsequence_I.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Longest Uncommon Subsequence I. 2 | // Memory Usage: 36.9 MB, less than 57.26% of Java online submissions for Longest Uncommon Subsequence I. 3 | // if not equal length, return max one, if same length not equal string, return length of any one 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int findLUSlength(String a, String b) { 8 | return a.length() != b.length() ? Math.max(a.length(), b.length()) : (a.equals(b) ? -1 : a.length()); 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0540_Single_Element_in_a_Sorted_Array.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Single Element in a Sorted Array. 2 | // Memory Usage: 39.1 MB, less than 52.14% of Java online submissions for Single Element in a Sorted Array. 3 | // bit manipulation, a ^ a = 0. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int singleNonDuplicate(int[] nums) { 8 | int ret = 0; 9 | for (int i: nums) { 10 | ret ^= i; 11 | } 12 | 13 | return ret; 14 | } 15 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0561_Array_Partition_I.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 10 ms, faster than 96.28% of Java online submissions for Array Partition I. 2 | // Memory Usage: 40.6 MB, less than 93.76% of Java online submissions for Array Partition I. 3 | // sort and sum every 2*i + 1 ,i is from 0 to n/2 - 1. 4 | // T:O(nlogn), S:O(logn), logn is the sort used. 5 | // 6 | class Solution { 7 | public int arrayPairSum(int[] nums) { 8 | Arrays.sort(nums); 9 | int ret = 0; 10 | for (int i = 0; i < nums.length; i += 2) { 11 | ret += nums[i]; 12 | } 13 | 14 | return ret; 15 | } 16 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0586_Customer_Placing_the_Largest_Number_of_Orders.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 498 ms, faster than 43.07% of MySQL online submissions for Customer Placing the Largest Number of Orders. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Customer Placing the Largest Number of Orders. 3 | # Write your MySQL query statement below 4 | select customer_number from Orders group by customer_number order by count(order_number) desc limit 1; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0607_Sales_Person.sql: -------------------------------------------------------------------------------- 1 | -- AC: Runtime: 1565 ms, faster than 44.34% of MySQL online submissions for Sales Person. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Sales Person. 3 | select name from SalesPerson where sales_id not in (Select a.sales_id from Orders a left join Company b on a.com_id=b.com_id where b.name="RED"); -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0709_To_Lower_Case.java: -------------------------------------------------------------------------------- 1 | // AC: 2 | // Runtime: 0 ms, faster than 100.00% of Java online submissions for To Lower Case. 3 | // Memory Usage: 37.1 MB, less than 26.24% of Java online submissions for To Lower Case. 4 | // 5 | class Solution { 6 | public String toLowerCase(String str) { 7 | return str.toLowerCase(); 8 | } 9 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0768_Max_Chunks_To_Make_Sorted_II.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxChunksToSorted(vector& arr) { 4 | long long sum1 = 0, sum2 = 0; 5 | int ans = 0; 6 | vector t = arr; 7 | sort(t.begin(), t.end()); 8 | for(int i = 0; i < arr.size(); i++) { 9 | sum1 += t[i]; 10 | sum2 += arr[i]; 11 | if(sum1 == sum2) ans++; 12 | } 13 | return ans; 14 | } 15 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0769_Max_Chunks_To_Make_Sorted.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 1 ms Beats 100% 2 | // Memory 40 MB Beats 61.65% 3 | // sort and compare 4 | // T:O(n ^ 2), S:O(n) 5 | // 6 | class Solution { 7 | public int maxChunksToSorted(int[] arr) { 8 | int len = arr.length, ret = 0; 9 | HashSet set1 = new HashSet<>(), set2 = new HashSet<>(); 10 | for (int i = 0; i < len; i++) { 11 | set1.add(i); 12 | set2.add(arr[i]); 13 | if (set1.equals(set2)) { 14 | ret++; 15 | } 16 | } 17 | 18 | return ret; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0796_Rotate_String.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Rotate String. 2 | // Memory Usage: 36.7 MB, less than 84.01% of Java online submissions for Rotate String. 3 | // check the s + s contains goal or not 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean rotateString(String s, String goal) { 8 | return s.length() == goal.length() && (s + s).contains(goal); 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0877_Stone_Game.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Stone Game. 2 | // Memory Usage: 38.9 MB, less than 57.39% of Java online submissions for Stone Game. 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public boolean stoneGame(int[] piles) { 8 | return true; 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0896_Monotonic_Array.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 2 ms, faster than 15.74% of Java online submissions for Monotonic Array. 2 | // Memory Usage: 47.9 MB, less than 9.88% of Java online submissions for Monotonic Array. 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean isMonotonic(int[] nums) { 8 | boolean asc = true, desc = true; 9 | for (int i = 1; i < nums.length; i++) { 10 | asc &= nums[i] >= nums[i - 1]; 11 | desc &= nums[i] <= nums[i - 1]; 12 | } 13 | return asc || desc; 14 | } 15 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_0912_Sort_an_Array.java: -------------------------------------------------------------------------------- 1 | // Runtime: 5 ms, faster than 98.56% of Java online submissions for Sort an Array. 2 | // Memory Usage: 47.6 MB, less than 86.37% of Java online submissions for Sort an Array. 3 | // Dual-Pivot Quicksort by Vladimir Yaroslavskiy 4 | // T:O(nlogn), S:O(logn) 5 | // 6 | class Solution { 7 | public int[] sortArray(int[] nums) { 8 | Arrays.sort(nums); 9 | return nums; 10 | } 11 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1025_Divisor_Game.java: -------------------------------------------------------------------------------- 1 | // AC: 2 | // Runtime: 0 ms, faster than 100.00% of Java online submissions for Divisor Game. 3 | // Memory Usage: 35 MB, less than 99.69% of Java online submissions for Divisor Game. 4 | // 思路:简单归纳一下即可。 5 | // 因为 n = 2 先手必赢,n = 3 先手必输。 n > 2 时: 6 | // 1. 假设现在 n 为偶数, A 知道 n - 1 为奇数的情况下先手必输,所以只取走 1,那么剩下 n - 1 为奇数,B 必输,则 A 必赢。 7 | // 2. 假设现在 n 为奇数,A 先手只能减去一个奇数因子(奇数因子不会为偶数)或1,不管减什么都会留给B偶数,偶数下 B 必赢,A 必输 8 | // 9 | class Solution { 10 | public boolean divisorGame(int n) { 11 | if (n % 2 == 0) { 12 | return true; 13 | } 14 | return false; 15 | } 16 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1050_Actors_and_Directors_Who_Cooperated_At_Least_Three_Times.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 312 ms, faster than 90.87% of MySQL online submissions for Actors and Directors Who Cooperated At Least Three Times. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Actors and Directors Who Cooperated At Least Three Times. 3 | # Write your MySQL query statement below 4 | select actor_id, director_id from ActorDirector group by actor_id, director_id having count(timestamp) >= 3; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1084_Sales_Analysis_III.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 1920 ms, faster than 15.57% of MySQL online submissions for Sales Analysis III. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Sales Analysis III. 3 | select distinct a.product_id,a.product_name from Product a left join Sales b on a.product_id=b.product_id where b.sale_date >= "2019-01-01" and b.sale_date <= "2019-03-31" and b.product_id not in (select product_id from Sales where sale_date < "2019-01-01" or sale_date > "2019-03-31"); -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1148_Article_Views_I.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 345 ms, faster than 95.47% of MySQL online submissions for Article Views I. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Article Views I. 3 | # Write your MySQL query statement below 4 | select distinct author_id as id from Views where author_id = viewer_id order by author_id; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1221_Split_a_String_in_Balanced_Strings.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int balancedStringSplit(string s) { 4 | int size = strlen(s); 5 | 6 | int countL = 0, countR = 0; 7 | while(s) { 8 | 9 | } 10 | } 11 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1227_Airplane_Seat_Assignment_Probability.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Airplane Seat Assignment Probability. 2 | // Memory Usage: 36.2 MB, less than 64.15% of Java online submissions for Airplane Seat Assignment Probability. 3 | // probability analyse. 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public double nthPersonGetsNthSeat(int n) { 8 | return n == 1 ? 1.00000 : 0.50000; 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1304_Find_N_Unique_Integers_Sum_up_to_Zero.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * AC:Runtime: 4 ms, faster than 98.01% of C++ online submissions for Find N Unique Integers Sum up to Zero. 3 | * Memory Usage: 6.4 MB, less than 100.00% of C++ online submissions for Find N Unique Integers Sum up to Zero. 4 | * 5 | * T:O(n) S:O(n) 6 | */ 7 | class Solution { 8 | public: 9 | vector sumZero(int n) { 10 | vector ret; 11 | for (int i = -(n / 2); i <= (n / 2); i++) { 12 | if (i == 0 && n % 2 == 0) continue; 13 | ret.push_back(i); 14 | } 15 | 16 | return ret; 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1323_Maximum_69_Number.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maximum69Number (int num) { 4 | string str = to_string(num); 5 | for (auto &i : str) { 6 | if (i == '6') { 7 | i = '9'; 8 | break; 9 | } 10 | } 11 | 12 | return stoi(str); 13 | } 14 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1331_Rank_Transform_of_an_Array.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector arrayRankTransform(vector& arr) { 4 | vector A(arr); 5 | sort(A.begin(), A.end()); 6 | unordered_map rank; 7 | 8 | for (int& a:A) { 9 | rank.emplace(a, rank.size() + 1); 10 | } 11 | 12 | for (int& a:arr) { 13 | a = rank[a]; 14 | } 15 | 16 | return arr; 17 | } 18 | }; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1351_Count_Negative_Numbers_in_a_Sorted_Matrix.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int countNegatives(vector>& grid) { 4 | int count = 0; 5 | for (int i = 0; i < grid.size(); i++) { 6 | // 二分查找,找到从左边起第一个负数 7 | int left = 0, right = grid[0].size() - 1; 8 | int mid = (left + right) / 2; 9 | 10 | while (left < right) { 11 | if (grid[i][mid] >= 0) { 12 | left = mid + 1; 13 | } else { 14 | right = mid - 1; 15 | } 16 | } 17 | } 18 | 19 | return count; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1374_Generate_a_String_With_Characters_That_Have_Odd_Counts.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | string generateTheString(int n) { 4 | string s = ""; 5 | if (n % 2 == 0) { 6 | s.append(n - 1, 'a'); 7 | s.append(1, 'b'); 8 | } else { 9 | s.append(n, 'a'); 10 | } 11 | 12 | return s; 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1393_Capital_Gain_Loss.sql: -------------------------------------------------------------------------------- 1 | # Runtime: 664 ms, faster than 18.85% of MySQL online submissions for Capital Gain/Loss. 2 | # Memory Usage: 0B, less than 100.00% of MySQL online submissions for Capital Gain/Loss. 3 | # Write your MySQL query statement below 4 | select stock_name, SUM(case when operation="Buy" then -price else price end) as capital_gain_loss from Stocks group by stock_name; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1407_Top_Travellers.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 668 ms, faster than 74.71% of MySQL online submissions for Top Travellers. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Top Travellers. 3 | # Write your MySQL query statement below 4 | select a.name,sum(case when b.distance is null then 0 else b.distance end) as travelled_distance from Users a left join Rides b on a.id=b.user_id group by a.name order by travelled_distance desc,a.name; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1480_Running_Sum_of_1d_Array.java: -------------------------------------------------------------------------------- 1 | // AC: 2 | // Runtime: 0 ms, faster than 100.00% of Java online submissions for Running Sum of 1d Array. 3 | // Memory Usage: 39 MB, less than 70.99% of Java online submissions for Running Sum of 1d Array. 4 | // 5 | class Solution { 6 | public int[] runningSum(int[] nums) { 7 | int sum = 0, size = nums.length; 8 | int[] ret = new int[size]; 9 | for (int i = 0; i < size; i++) { 10 | sum += nums[i]; 11 | ret[i] = sum; 12 | } 13 | return ret; 14 | } 15 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1484_Group_Sold_Products_By_The_Date.sql: -------------------------------------------------------------------------------- 1 | -- group_concat() 2 | -- Runtime: 426 ms, faster than 63.70% of MySQL online submissions for Group Sold Products By The Date. 3 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Group Sold Products By The Date. 4 | # Write your MySQL query statement below 5 | select sell_date, count(distinct product) as num_sold, group_concat(distinct product order by product SEPARATOR ',') as products 6 | from Activities group by sell_date order by sell_date; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1523_Count_Odd_Numbers_in_an_Interval_Range.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Count Odd Numbers in an Interval Range. 2 | // Memory Usage: 35.6 MB, less than 75.72% of Java online submissions for Count Odd Numbers in an Interval Range. 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int countOdds(int low, int high) { 8 | return (low % 2 == 0 && high % 2 == 0) ? (high - low) / 2 : (high - low) / 2 + 1; 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1551_Minimum_Operations_to_Make_Array_Equal.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Minimum Operations to Make Array Equal. 2 | // Memory Usage: 35.4 MB, less than 94.08% of Java online submissions for Minimum Operations to Make Array Equal. 3 | // find the regularity 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int minOperations(int n) { 8 | return n % 2 == 0 ? (n * n / 4) : ((n - 1) * (n + 1) / 4); 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1576_Replace_All_s_to_Avoid_Consecutive_Repeating_Characters.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | string modifyString(string s) { 4 | int size = strlen(s); 5 | string ret = ""; 6 | 7 | for (int i = 0; i < size; i++) { 8 | if (s[i] == '?') { 9 | 10 | } else { 11 | ret.append(s[i]); 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1581_Customer_Who_Visited_but_Did_Not_Make_Any_Transactions.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 1151 ms, faster than 59.93% of MySQL online submissions for Customer Who Visited but Did Not Make Any Transactions. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Customer Who Visited but Did Not Make Any Transactions. 3 | # Write your MySQL query statement below 4 | select customer_id,count(*) as count_no_trans from Visits a left join Transactions b on a.visit_id=b.visit_id where b.transaction_id is null group by a.customer_id; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1587_Bank_Account_Summary_II.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 522 ms, faster than 95.81% of MySQL online submissions for Bank Account Summary II. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Bank Account Summary II. 3 | # Write your MySQL query statement below 4 | select a.name, sum(b.amount) as balance from Users a left join Transactions b on a.account=b.account group by a.name having balance >10000; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1667_Fix_Names_in_a_Table.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 529 ms, faster than 91.25% of MySQL online submissions for Fix Names in a Table. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Fix Names in a Table. 3 | # Write your MySQL query statement below 4 | select user_id, concat(upper(substring(name, 1, 1)), lower(substring(name, 2, length(name) - 1))) as name from Users order by user_id; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1683_Invalid_Tweets.sql: -------------------------------------------------------------------------------- 1 | # Notice: the char length also contains spaces. 2 | # Write your MySQL query statement below 3 | select tweet_id from Tweets where length(content) > 15; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1693_Daily_Leads_and_Partners.sql: -------------------------------------------------------------------------------- 1 | # Runtime: 607 ms, faster than 30.10% of MySQL online submissions for Daily Leads and Partners. 2 | # Memory Usage: 0B, less than 100.00% of MySQL online submissions for Daily Leads and Partners. 3 | # Write your MySQL query statement below 4 | select date_id, make_name, count(distinct lead_id) as unique_leads, count(distinct partner_id) as unique_partners from DailySales group by date_id, make_name; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1729_Find_Followers_Count.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 611 ms, faster than 34.38% of MySQL online submissions for Find Followers Count. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Find Followers Count. 3 | # Write your MySQL query statement below 4 | select user_id, count(follower_id) as followers_count from Followers group by user_id order by user_id; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1741_Find_Total_Time_Spent_by_Each_Employee.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 643 ms, faster than 20.80% of MySQL online submissions for Find Total Time Spent by Each Employee. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Find Total Time Spent by Each Employee. 3 | # Write your MySQL query statement below 4 | select event_day as day, emp_id, sum(out_time - in_time) as total_time from Employees group by emp_id, event_day; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1753_Maximum_Score_From_Removing_Stones.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory: 39.1 MB Beats 96.69% 3 | // strategy. 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int maximumScore(int a, int b, int c) { 8 | int[] arr = new int[]{a, b, c}; 9 | Arrays.sort(arr); 10 | if (arr[2] >= arr[0] + arr[1]) { 11 | return arr[0] + arr[1]; 12 | } else { 13 | return (a + b + c) / 2; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1757_Recyclable_and_Low_Fat_Products.sql: -------------------------------------------------------------------------------- 1 | # Write your MySQL query statement below 2 | -- Runtime: 535 ms, faster than 49.98% of MySQL online submissions for Recyclable and Low Fat Products. 3 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Recyclable and Low Fat Products. 4 | select product_id from Products where low_fats = 'Y' and recyclable = 'Y'; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1780_Check_if_Number_is_a_Sum_of_Powers_of_Three.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% 2 | // Memory 40.24 MB Beats 93.37% 3 | // N 进制的理解:从3进制的角度去理解,如果某一位置为 2, 则3^k 必然出现2次,那么不符合题目条件所述。 4 | // T:O(logn), S:O(1) 5 | // 6 | class Solution { 7 | public boolean checkPowersOfThree(int n) { 8 | while (n > 0) { 9 | if (n % 3 == 2) { 10 | return false; 11 | } 12 | n /= 3; 13 | } 14 | 15 | return true; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1791_Find_Center_of_Star_Graph.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Find Center of Star Graph. 2 | // Memory Usage: 64.6 MB, less than 48.99% of Java online submissions for Find Center of Star Graph. 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int findCenter(int[][] edges) { 8 | for (int i = 0; i < 2; i++) { 9 | for (int j = 0; j < 2; j++) { 10 | if (edges[0][i] == edges[1][j]) { 11 | return edges[0][i]; 12 | } 13 | } 14 | } 15 | 16 | return -1; 17 | } 18 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1795_Rearrange_Products_Table.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 414 ms, faster than 95.67% of MySQL online submissions for Rearrange Products Table. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Rearrange Products Table. 3 | # trick: using union 4 | # Write your MySQL query statement below 5 | select product_id,'store1' as store, store1 as price from Products where store1 is not null 6 | union 7 | select product_id,'store2' as store, store2 as price from Products where store2 is not null 8 | union 9 | select product_id,'store3' as store, store3 as price from Products where store3 is not null; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1873_Calculate_Special_Bonus.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 509 ms, faster than 81.83% of MySQL online submissions for Calculate Special Bonus. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Calculate Special Bonus. 3 | # Write your MySQL query statement below 4 | select employee_id, if(employee_id % 2 = 1 and name not like "M%", salary, 0) as bonus from Employees; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1890_The_Latest_Login_in_2020.sql: -------------------------------------------------------------------------------- 1 | # Runtime: 693 ms, faster than 35.69% of MySQL online submissions for The Latest Login in 2020. 2 | # Memory Usage: 0B, less than 100.00% of MySQL online submissions for The Latest Login in 2020. 3 | # Write your MySQL query statement below 4 | select user_id, max(time_stamp) as last_stamp from Logins where time_stamp >= '2020-01-01 00:00:00' and time_stamp < '2021-01-01 00:00:00' group by user_id; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1920_Build_Array_from_Permutation.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 1 ms, faster than 100.00% of Java online submissions for Build Array from Permutation. 2 | // Memory Usage: 39.3 MB, less than 91.97% of Java online submissions for Build Array from Permutation. 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int[] buildArray(int[] nums) { 8 | int size = nums.length; 9 | int[] ret = new int[size]; 10 | 11 | for (int i = 0; i < size; i++) { 12 | ret[i] = nums[nums[i]]; 13 | } 14 | 15 | return ret; 16 | } 17 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1929_Concatenation_of_Array.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 2 ms, faster than 100.00% of Java online submissions for Concatenation of Array. 2 | // Memory Usage: 47.7 MB, less than 100.00% of Java online submissions for Concatenation of Array. 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int[] getConcatenation(int[] nums) { 8 | int size = nums.length; 9 | int[] ret = new int[2 * size]; 10 | for (int i = 0; i < 2 * size; i++) { 11 | ret[i] = nums[i % size]; 12 | } 13 | 14 | return ret; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1965_Employees_With_Missing_Information.sql: -------------------------------------------------------------------------------- 1 | # Runtime: 430 ms, faster than 91.26% of MySQL online submissions for Employees With Missing Information. 2 | # Memory Usage: 0B, less than 100.00% of MySQL online submissions for Employees With Missing Information. 3 | # Write your MySQL query statement below 4 | select distinct t.employee_id from (select a.employee_id from Employees a left join Salaries b on a.employee_id=b.employee_id where b.salary is null 5 | union 6 | select b.employee_id from Employees a right join Salaries b on a.employee_id=b.employee_id where a.name is null) as t order by t.employee_id; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_1967_Number_of_Strings_That_Appear_as_Substrings_in_Word.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int numOfStrings(String[] patterns, String word) { 3 | int ret = 0; 4 | for (String str: patterns) { 5 | if (word.contains(str)) { 6 | ret++; 7 | } 8 | } 9 | 10 | return ret; 11 | } 12 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2027_Minimum_Moves_to_Convert_String.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 1 ms, faster than 80.00% of Java online submissions for Minimum Moves to Convert String. 2 | // Memory Usage: 38.7 MB, less than 40.00% of Java online submissions for Minimum Moves to Convert String. 3 | // straight forward 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int minimumMoves(String s) { 8 | int ret = 0; 9 | for (int i = 0; i < s.length(); i++) { 10 | if (s.charAt(i) == 'X') { 11 | ret++; 12 | i += 2; 13 | } 14 | } 15 | 16 | return ret; 17 | } 18 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2057_Smallest_Index_With_Equal_Value.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Smallest Index With Equal Value. 2 | // Memory Usage: 39.3 MB, less than 66.67% of Java online submissions for Smallest Index With Equal Value. 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int smallestEqual(int[] nums) { 8 | for (int i = 0; i < nums.length; i++) { 9 | if (i % 10 == nums[i]) { 10 | return i; 11 | } 12 | } 13 | 14 | return -1; 15 | } 16 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2114_Maximum_Number_of_Words_Found_in_Sentences.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 2 ms, faster than 100.00% of Java online submissions for Maximum Number of Words Found in Sentences. 2 | // Memory Usage: 38.3 MB, less than 100.00% of Java online submissions for Maximum Number of Words Found in Sentences. 3 | // . 4 | // T:O(sum(len)), S:O(max(len)) 5 | // 6 | class Solution { 7 | public int mostWordsFound(String[] sentences) { 8 | int ret = 0; 9 | for (String sentence: sentences) { 10 | ret = Math.max(ret, sentence.split(" ").length); 11 | } 12 | 13 | return ret; 14 | } 15 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2119_A_Number_After_a_Double_Reversal.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for A Number After a Double Reversal. 2 | // Memory Usage: 35.8 MB, less than 33.33% of Java online submissions for A Number After a Double Reversal. 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public boolean isSameAfterReversals(int num) { 8 | return num == 0 || (num % 10 != 0); 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2185_Counting_Words_With_a_Given_Prefix.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Counting Words With a Given Prefix. 2 | // Memory Usage: 42 MB, less than 100.00% of Java online submissions for Counting Words With a Given Prefix. 3 | // . 4 | // T:O(words.length * len(pref)), S:O(1) 5 | // 6 | class Solution { 7 | public int prefixCount(String[] words, String pref) { 8 | int ret = 0; 9 | for (String word:words) { 10 | if (word.startsWith(pref)) { 11 | ret++; 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2235_Add_Two_Integers.java: -------------------------------------------------------------------------------- 1 | // . 2 | class Solution { 3 | public int sum(int num1, int num2) { 4 | return num1+num2; 5 | } 6 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2236_Root_Equals_Sum_of_Children.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Root Equals Sum of Children. 2 | // Memory Usage: 40.1 MB, less than 92.42% of Java online submissions for Root Equals Sum of Children. 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public boolean checkTree(TreeNode root) { 8 | return root.val == root.left.val + root.right.val; 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2255_Count_Prefixes_of_a_Given_String.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 1 ms, faster than 100.00% of Java online submissions for Count Prefixes of a Given String. 2 | // Memory Usage: 43.7 MB, less than 33.33% of Java online submissions for Count Prefixes of a Given String. 3 | // . 4 | // T:O(sum(min(s.length(), words[i].length))), S:O(1) 5 | // 6 | class Solution { 7 | public int countPrefixes(String[] words, String s) { 8 | int ret = 0; 9 | for (String word : words) { 10 | if (s.startsWith(word)) { 11 | ret++; 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2278_Percentage_of_Letter_in_String.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Percentage of Letter in String. 2 | // Memory Usage: 42.3 MB, less than 30.50% of Java online submissions for Percentage of Letter in String. 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int percentageLetter(String s, char letter) { 8 | int letterCount = 0; 9 | for (char c : s.toCharArray()) { 10 | if (letter == c) { 11 | letterCount++; 12 | } 13 | } 14 | return letterCount * 100 / s.length(); 15 | } 16 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2317_Maximum_XOR_After_Operations.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 1 ms, faster than 100.00% of Java online submissions for Maximum XOR After Operations . 2 | // Memory Usage: 53.1 MB, less than 100.00% of Java online submissions for Maximum XOR After Operations . 3 | // in this case, the final result is combine every binary bit that value 1, so just bitwise OR every elements. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int maximumXOR(int[] nums) { 8 | int ret = 0; 9 | for (int num : nums) { 10 | ret |= num; 11 | } 12 | return ret; 13 | } 14 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2335_Minimum_Amount_of_Time_to_Fill_Cups.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 2 ms, faster than 55.56% of Java online submissions for Minimum Amount of Time to Fill Cups. 2 | // Memory Usage: 42 MB, less than 55.56% of Java online submissions for Minimum Amount of Time to Fill Cups. 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int fillCups(int[] amount) { 8 | Arrays.sort(amount); 9 | 10 | if (amount[2] - amount[1] >= amount[0]) { 11 | return amount[2]; 12 | } else { 13 | return amount[0] + (int) Math.ceil((amount[2] + amount[1] - amount[0]) / 2.0); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2396_Strictly_Palindromic_Number.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Strictly Palindromic Number. 2 | // Memory Usage: 41.1 MB, less than 27.27% of Java online submissions for Strictly Palindromic Number. 3 | // we can proove that when n >= 4, there is no integer can meets the requirement. 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public boolean isStrictlyPalindromic(int n) { 8 | return false; 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2413_Smallest_Even_Multiple.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Smallest Even Multiple. 2 | // Memory Usage: 40.8 MB, less than 60.00% of Java online submissions for Smallest Even Multiple. 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int smallestEvenMultiple(int n) { 8 | return n % 2 == 0 ? n : 2 * n; 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2427_Number_of_Common_Factors.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 1 ms Beats 100% 2 | // Memory 41 MB Beats 75% 3 | // Travel through factors. 4 | // T:O(Math.min(a, b)), S:O(1) 5 | // 6 | class Solution { 7 | public int commonFactors(int a, int b) { 8 | int ret = 0, step = 1; 9 | if (a % 2 != 0 || b % 2 != 0) { 10 | step = 2; 11 | } 12 | for (int i = 1; i <= Math.min(a, b); i += step) { 13 | if (a % i == 0 && b % i == 0) { 14 | ret++; 15 | } 16 | } 17 | 18 | return ret; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2433_Find_The_Original_Array_of_Prefix_Xor.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 1 ms Beats 100% 2 | // Memory 54.7 MB Beats 100% 3 | // bitwise manipulation 4 | // T:O(n), S:O(n) 5 | // 6 | class Solution { 7 | public int[] findArray(int[] pref) { 8 | int len = pref.length, pos = 0; 9 | int[] ret = new int[len]; 10 | ret[pos++] = pref[0]; 11 | for (int i = 1; i < len; i++) { 12 | ret[pos++] = pref[i] ^ pref[i - 1]; 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2439_Minimize_Maximum_of_Array.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 9 ms Beats 74.55% 2 | // Memory 61.1 MB Beats 92.12% 3 | // DP. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int minimizeArrayValue(int[] nums) { 8 | int count = 0, ret = 0; 9 | long sum = 0; 10 | for (int num : nums) { 11 | sum += num; 12 | count++; 13 | ret = Math.max(ret, (int) Math.ceil(sum * 1.0 / count)); 14 | } 15 | 16 | return ret; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2446_Determine_if_Two_Events_Have_Conflict.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory 39.9 MB Beats 70% 3 | // String comparison 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public boolean haveConflict(String[] event1, String[] event2) { 8 | return (event1[0].compareTo(event2[1]) <= 0 && event1[1].compareTo(event2[0]) >= 0) || 9 | (event2[0].compareTo(event1[1]) <= 0 && event2[1].compareTo(event1[0]) >= 0); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2455_Average_Value_of_Even_Numbers_That_Are_Divisible_by_Three.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 1 ms Beats 100% 2 | // Memory 42.5 MB Beats 100% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int averageValue(int[] nums) { 8 | int sum = 0, count = 0; 9 | for (int i : nums) { 10 | if (i % 6 == 0) { 11 | sum += i; 12 | count++; 13 | } 14 | } 15 | 16 | return count == 0 ? 0 : sum / count; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2465_Number_of_Distinct_Averages.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100% 2 | // Memory 39.8 MB Beats 100% 3 | // . 4 | // T:O(n), S:O(n) 5 | // 6 | class Solution { 7 | public int distinctAverages(int[] nums) { 8 | Arrays.sort(nums); 9 | HashSet record = new HashSet<>(); 10 | for (int i = 0; i < nums.length; i++) { 11 | record.add(((float) nums[i] + nums[nums.length - 1 - i]) / 2); 12 | } 13 | 14 | return record.size(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2469_Convert_the_Temperature.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100% 2 | // Memory 42.5 MB Beats 33.33% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public double[] convertTemperature(double celsius) { 8 | double[] ret = new double[2]; 9 | ret[0] = celsius + 273.15000; 10 | ret[1] = celsius * 1.8 + 32.00000; 11 | 12 | return ret; 13 | } 14 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2481_Minimum_Cuts_to_Divide_a_Circle.java: -------------------------------------------------------------------------------- 1 | // Time: Runtime 0 ms Beats 100% 2 | // Memory: 41.5 MB Beats 25% 3 | // geometry. 4 | // T:O(logn), S:O(1) 5 | // 6 | class Solution { 7 | public int numberOfCuts(int n) { 8 | int count1 = 0, ret = 0; 9 | if (n > 1) { 10 | while (n % 2 == 0) { 11 | count1++; 12 | n /= 2; 13 | } 14 | if (count1 == 0) { 15 | ret = n; 16 | } else { 17 | ret = (int) Math.pow(2, count1 - 1) * n; 18 | } 19 | } 20 | 21 | return ret; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2520_Count_the_Digits_That_Divide_a_Number.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory 39 MB Beats 100% 3 | // . 4 | // T:O(logn), S:O(1) 5 | // 6 | class Solution { 7 | public int countDigits(int num) { 8 | int ret = 0, copy = num; 9 | while (num > 0) { 10 | int digit = num % 10; 11 | if (digit != 0 && copy % digit == 0) { 12 | ret++; 13 | } 14 | num /= 10; 15 | } 16 | 17 | return ret; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2529_Maximum_Count_of_Positive_Integer_and_Negative_Integer.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory 42.2 MB Beats 100% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int maximumCount(int[] nums) { 8 | int posiCount = 0, negaCount = 0; 9 | for (int num : nums) { 10 | if (num > 0) { 11 | posiCount++; 12 | } else if (num < 0) { 13 | negaCount++; 14 | } 15 | } 16 | 17 | return Math.max(posiCount, negaCount); 18 | } 19 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2544_Alternating_Digit_Sum.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory 38.9 MB Beats 94.38% 3 | // . 4 | // T:O(logn), S:O(1) 5 | // 6 | class Solution { 7 | public int alternateDigitSum(int n) { 8 | int sum = 0, curSign = 1, firstDigitSign = 0; 9 | while (n > 0) { 10 | int digit = n % 10; 11 | sum += curSign == 1 ? digit : -digit; 12 | firstDigitSign = curSign; 13 | curSign = curSign == 1 ? -1 : 1; 14 | n /= 10; 15 | } 16 | 17 | return firstDigitSign == 1 ? sum : -sum; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2545_Sort_the_Students_by_Their_Kth_Score.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 2 ms Beats 95.36% 2 | // Memory 52.4 MB Beats 80.65% 3 | // . 4 | // T:O(nlogn), S:O(logn) 5 | // 6 | class Solution { 7 | public int[][] sortTheStudents(int[][] score, int k) { 8 | Arrays.sort(score, (a, b) -> (b[k] - a[k])); 9 | return score; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2549_Count_Distinct_Numbers_on_Board.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory 38.9 MB Beats 82.80% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int distinctIntegers(int n) { 8 | return n == 1 ? 1 : n - 1; 9 | } 10 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2562_Find_the_Array_Concatenation_Value.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 11 ms Beats 14.29% 2 | // Memory 42.7 MB Beats 14.29% 3 | // . 4 | // T:O(sum(logni)). S:O(max(logni)) 5 | // 6 | class Solution { 7 | public long findTheArrayConcVal(int[] nums) { 8 | long ret = 0; 9 | for (int i = 0, j = nums.length - 1; j - i >= 1; i++, j--) { 10 | ret += Integer.parseInt(String.valueOf(nums[i]) + nums[j]); 11 | if (j - i == 2) { 12 | ret += nums[i + 1]; 13 | } 14 | } 15 | 16 | return ret; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2579_Count_Total_Number_of_Colored_Cells.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory 39.3 MB Beats 100% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public long coloredCells(int n) { 8 | return 2 * (long) n * (n - 1) + 1; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2582_Pass_the_Pillow.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory 39.1 MB Beats 100% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int passThePillow(int n, int time) { 8 | time = time % (2 * (n - 1)); 9 | return 1 + (time <= (n - 1) ? time : (2 * (n - 1) - time)); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2600_K_Items_With_the_Maximum_Sum.java: -------------------------------------------------------------------------------- 1 | // AC: untime 1 ms Beats 100% 2 | // Memory 40.5 MB Beats 40% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int kItemsWithMaximumSum(int numOnes, int numZeros, int numNegOnes, int k) { 8 | return k <= (numOnes + numZeros) ? Math.min(k, numOnes) : (numOnes * 2 + numZeros - k); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2651_Calculate_Delayed_Arrival_Time.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory 39.1 MB Beats 100% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int findDelayedArrivalTime(int arrivalTime, int delayedTime) { 8 | return (arrivalTime + delayedTime) % 24; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2652_Sum_Multiples.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 4 ms Beats 66.67% 2 | // Memory 39.1 MB Beats 100% 3 | // Brute-force 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int sumOfMultiples(int n) { 8 | int ret = 0; 9 | for (int i = 3; i <= n; i++) { 10 | if (i % 3 == 0 || i % 5 == 0 || i % 7 == 0) { 11 | ret += i; 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2656_Maximum_Sum_With_Exactly_K_Elements.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 2 ms Beats 100% 2 | // Memory 43.2 MB Beats 16.67% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int maximizeSum(int[] nums, int k) { 8 | int maxVal = 0; 9 | for (int num : nums) { 10 | maxVal = Math.max(maxVal, num); 11 | } 12 | int ret = (maxVal + maxVal + k - 1) * k / 2; 13 | 14 | return ret; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2678_Number_of_Senior_Citizens.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 1 ms Beats 75% 2 | // Memory 42.2 MB Beats 25% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int countSeniors(String[] details) { 8 | int ret = 0; 9 | for (String detail : details) { 10 | int age = Integer.parseInt(detail.substring(11, 13)); 11 | if (age > 60) { 12 | ret++; 13 | } 14 | } 15 | 16 | return ret; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2683_Neighboring_Bitwise_XOR.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 3 ms Beats 100% 2 | // Memory 52 MB Beats 16.67% 3 | // We can prove that when xor sum of elements are equal to 0, then the answer exists. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean doesValidArrayExist(int[] derived) { 8 | int xorSum = 0; 9 | for (int i : derived) { 10 | xorSum ^= i; 11 | } 12 | 13 | return xorSum == 0; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2696_Minimum_String_Length_After_Removing_Substrings.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 10 ms Beats 66.67% 2 | // Memory 43.7 MB Beats 16.67% 3 | // native replace method. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int minLength(String s) { 8 | while (s.contains("AB") || s.contains("CD")) { 9 | s = s.replace("AB", ""); 10 | s = s.replace("CD", ""); 11 | } 12 | 13 | return s.length(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2716_Minimize_String_Length.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 9 ms Beats 100% 2 | // Memory 44.2 MB Beats 25% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int minimizedStringLength(String s) { 8 | int len = s.length(), ret = 0; 9 | HashSet record = new HashSet<>(); 10 | for (char c : s.toCharArray()) { 11 | record.add(c); 12 | } 13 | 14 | return record.size(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2733_Neither_Minimum_nor_Maximum.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 8 ms Beats 100% 2 | // Memory 43.7 MB Beats 33.33% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int findNonMinOrMax(int[] nums) { 8 | int maxVal = Integer.MIN_VALUE, minVal = Integer.MAX_VALUE; 9 | for (int num : nums) { 10 | maxVal = Math.max(maxVal, num); 11 | minVal = Math.min(minVal, num); 12 | } 13 | for (int num : nums) { 14 | if (num != maxVal && num != minVal) { 15 | return num; 16 | } 17 | } 18 | return -1; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2740_Find_the_Value_of_the_Partition.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 22 ms Beats 100% 2 | // Memory 54.5 MB Beats 75.93% 3 | // Greedy & sort. 4 | // T:O(nlogn), S:O(1) 5 | // 6 | class Solution { 7 | public int findValueOfPartition(int[] nums) { 8 | int ret = Integer.MAX_VALUE; 9 | Arrays.sort(nums); 10 | for (int i = 0; i < nums.length - 1; i++) { 11 | ret = Math.min(ret, nums[i + 1] - nums[i]); 12 | } 13 | 14 | return ret; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2744_Find_Maximum_Number_of_String_Pairs.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 3 ms Beats 33.33% 2 | // Memory 43.4 MB Beats 33.33% 3 | // Set. 4 | // T:O(n), S:O(n) 5 | // 6 | class Solution { 7 | public int maximumNumberOfStringPairs(String[] words) { 8 | int ret = 0; 9 | Set record = new HashSet<>(); 10 | for (String word : words) { 11 | String reverse = new StringBuilder(word).reverse().toString(); 12 | if (record.contains(reverse)) { 13 | ret++; 14 | } 15 | record.add(word); 16 | } 17 | 18 | return ret; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2769_Find_the_Maximum_Achievable_Number.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 2 ms Beats 100% 2 | // Memory 40 MB Beats 94.75% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int theMaximumAchievableX(int num, int t) { 8 | return num + 2 * t; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2778_Sum_of_Squares_of_Special_Elements.java: -------------------------------------------------------------------------------- 1 | // AC: 1ms Beats 100.00%of users with Java 2 | // Memory: 43.22mb Beats 66.67%of users with Java 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int sumOfSquares(int[] nums) { 8 | int len = nums.length, ret = 0; 9 | for (int i = 1; i <= len; i++) { 10 | if (len % i == 0) { 11 | ret += nums[i - 1] * nums[i - 1]; 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2798_Number_of_Employees_Who_Met_the_Target.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory 41.2 MB Beats 100% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int numberOfEmployeesWhoMetTarget(int[] hours, int target) { 8 | int ret = 0; 9 | for (int hour : hours) { 10 | if (hour >= target) { 11 | ret++; 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2806_Account_Balance_After_Rounded_Purchase.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100% 2 | // Memory 38.9 MB Beats 100% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int accountBalanceAfterPurchase(int purchaseAmount) { 8 | return 100 - (purchaseAmount % 10 >= 5 ? (purchaseAmount / 10 + 1) * 10 : purchaseAmount / 10 * 10); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2810_Faulty_Keyboard.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 3 ms Beats 100% 2 | // Memory 43.9 MB Beats 50% 3 | // . 4 | // T:O(n), S:O(n) 5 | // 6 | class Solution { 7 | public String finalString(String s) { 8 | StringBuilder ret = new StringBuilder(); 9 | for (char c : s.toCharArray()) { 10 | if (c == 'i') { 11 | ret.reverse(); 12 | } else { 13 | ret.append(c); 14 | } 15 | } 16 | 17 | return ret.toString(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2833_Furthest_Point_From_Origin.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 1 ms Beats 100% 2 | // Memory 41.4 MB Beats 50% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int furthestDistanceFromOrigin(String moves) { 8 | int len = moves.length(), countL = 0, countR = 0; 9 | for (int i = 0; i < len; i++) { 10 | char c = moves.charAt(i); 11 | if (c == 'L') { 12 | countL++; 13 | } else if (c == 'R') { 14 | countR++; 15 | } 16 | } 17 | 18 | return len - 2 * Math.min(countL, countR); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2839_Check_if_Strings_Can_be_Made_Equal_With_Operations_I.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 1 ms Beats 100% 2 | // Memory 41.7 MB Beats 50% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean canBeEqual(String s1, String s2) { 8 | char c1 = s1.charAt(0), c2 = s1.charAt(1), c3 = s1.charAt(2), c4 = s1.charAt(3), c5 = s2.charAt(0), 9 | c6 = s2.charAt(1), c7 = s2.charAt(2), c8 = s2.charAt(3); 10 | return ((c1 == c5 && c3 == c7) || (c1 == c7 && c3 == c5)) && ((c2 == c6 && c4 == c8) || (c2 == c8 && c4 == c6)); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2877_Create_a_DataFrame_from_List.py: -------------------------------------------------------------------------------- 1 | # Runtime Details 425ms Beats 67.78%of users with Pandas 2 | # Memory Details 59.96MB Beats 35.36%of users with Pandas 3 | # 4 | import pandas as pd 5 | 6 | def createDataframe(student_data: List[List[int]]) -> pd.DataFrame: 7 | column = ['student_id', 'age'] 8 | result = pd.DataFrame(student_data, columns = column) 9 | 10 | return result -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2879_Display_the_First_Three_Rows.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | def selectFirstRows(employees: pd.DataFrame) -> pd.DataFrame: 4 | return employees.iloc[0:3] 5 | # return employees.head(3) -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2891_Method_Chaining.py: -------------------------------------------------------------------------------- 1 | # AC: Runtime 552 ms Beats 34.45% 2 | # Memory 59.9 MB Beats 86.19% 3 | 4 | import pandas as pd 5 | 6 | def findHeavyAnimals(animals: pd.DataFrame) -> pd.DataFrame: 7 | return animals[animals['weight'] > 100].sort_values(['weight'], ascending=False,)[['name']] -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2894_Divisible_and_Non_divisible_Sums_Difference.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 1 ms Beats 66.67% 2 | // Memory 39.4 MB Beats 33.33% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int differenceOfSums(int n, int m) { 8 | int sum1 = 0, sum2 = 0; 9 | for (int i = 1; i <= n; i++) { 10 | if (i % m == 0) { 11 | sum2 += i; 12 | } else { 13 | sum1 += i; 14 | } 15 | } 16 | 17 | return sum1 - sum2; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2914_Minimum_Number_of_Changes_to_Make_Binary_String_Beautiful.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime Details 3ms Beats 99.61%of users with Java 2 | // Memory Details 43.63MB Beats 53.94%of users with Java 3 | // Greedy. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int minChanges(String s) { 8 | int len = s.length(), ret = 0; 9 | for (int i = 0; i < len / 2; i++) { 10 | if (s.charAt(2 * i) != s.charAt(2 * i + 1)) { 11 | ret++; 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2942_Find_Words_Containing_Character.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 2 ms Beats 100.00% of users with Java 2 | // Memory 44.22 MB Beats 50.00% of users with Java 3 | // . 4 | // T:O(n), S:O(n) 5 | // 6 | class Solution { 7 | public List findWordsContaining(String[] words, char x) { 8 | List ret = new LinkedList<>(); 9 | for (int i = 0; i < words.length; i++) { 10 | if (words[i].contains(String.valueOf(x))) { 11 | ret.add(i); 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2951_Find_the_Peaks.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 1 ms Beats 100.00% of users with Java 2 | // Memory 44.20 MB Beats 100.00% of users with Java 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public List findPeaks(int[] mountain) { 8 | List ret = new LinkedList<>(); 9 | for (int i = 1; i < mountain.length - 1; i++) { 10 | if (mountain[i] > mountain[i - 1] && mountain[i] > mountain[i + 1]) { 11 | ret.add(i); 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2960_Count_Tested_Devices_After_Test_Operations.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 0 ms Beats 100.00% of users with Java 2 | // Memory 42.94 MB Beats 100.00% of users with Java 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int countTestedDevices(int[] batteryPercentages) { 8 | int curDecr = 0; 9 | for (int i : batteryPercentages) { 10 | if (i > curDecr) { 11 | curDecr++; 12 | } 13 | } 14 | return curDecr; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2974_Minimum_Number_Game.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 2 ms Beats 100.00% of users with Java 2 | // Memory 44.80 MB Beats 66.67% of users with Java 3 | // . 4 | // T:O(nlogn), S:O(logn) 5 | // 6 | class Solution { 7 | public int[] numberGame(int[] nums) { 8 | Arrays.sort(nums); 9 | int[] ret = new int[nums.length]; 10 | for (int i = 0; i < nums.length / 2; i++) { 11 | ret[2 * i] = nums[2 * i + 1]; 12 | ret[2 * i + 1] = nums[2 * i]; 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_2980_Check_if_Bitwise_OR_Has_Trailing_Zeros.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime 2 ms Beats 33.33% of users with Java 2 | // Memory 43.77 MB Beats 33.33% of users with Java 3 | // Find the two or more even numbers. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean hasTrailingZeros(int[] nums) { 8 | int countEven = 0; 9 | for (int num : nums) { 10 | if (num % 2 == 0) { 11 | countEven++; 12 | } 13 | } 14 | 15 | return countEven >= 2; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3024_Type_of_Triangle.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 61.30% of users with Java 2 | // Memory 41.51 MB Beats 96.36% of users with Java 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public String triangleType(int[] nums) { 8 | Arrays.sort(nums); 9 | if (nums[0] + nums[1] <= nums[2]) { 10 | return "none"; 11 | } 12 | if (nums[2] == nums[0]) { 13 | return "equilateral"; 14 | } else if (nums[2] == nums[1] || nums[1] == nums[0]) { 15 | return "isosceles"; 16 | } else { 17 | return "scalene"; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3028_Ant_on_the_Boundary.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% of users with Java 2 | // Memory 41.68 MB Beats 95.33% of users with Java 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int returnToBoundaryCount(int[] nums) { 8 | int cur = 0, ret = 0; 9 | for (int num : nums) { 10 | cur += num; 11 | if (cur == 0) { 12 | ret++; 13 | } 14 | } 15 | 16 | return ret; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3038_Maximum_Number_of_Operations_With_the_Same_Score_I.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% of users with Java 2 | // Memory 41.60 MB Beats 100.00% of users with Java 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int maxOperations(int[] nums) { 8 | int ret = 1, sum1 = nums[0] + nums[1]; 9 | for (int i = 2; i + 1 < nums.length; i += 2) { 10 | if (nums[i] + nums[i + 1] == sum1) { 11 | ret++; 12 | } else { 13 | break; 14 | } 15 | } 16 | 17 | return ret; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3065_Minimum_Operations_to_Exceed_Threshold_Value_I.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% of users with Java 2 | // Memory 42.42 MB Beats 100.00% of users with Java 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int minOperations(int[] nums, int k) { 8 | int ret = 0; 9 | for (int num : nums) { 10 | if (num < k) { 11 | ret++; 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3084_Count_Substrings_Starting_and_Ending_with_Given_Character.java: -------------------------------------------------------------------------------- 1 | // Runtime 2 ms Beats 100.00% of users with Java 2 | // Memory 44.36 MB Beats 100.00% of users with Java 3 | // Combination. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public long countSubstrings(String s, char c) { 8 | int countOccurence = 0; 9 | for (char c1 : s.toCharArray()) { 10 | if (c1 == c) { 11 | countOccurence++; 12 | } 13 | } 14 | 15 | return (long) countOccurence * (countOccurence + 1) / 2; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3099_Harshad_Number.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% of users with Java 2 | // Memory 39.98 MB Beats 66.67% of users with Java 3 | // . 4 | // T:O(logn), S:O(1) 5 | // 6 | class Solution { 7 | public int sumOfTheDigitsOfHarshadNumber(int x) { 8 | int sum = 0, x1 = x; 9 | while (x1 > 0) { 10 | sum += x1 % 10; 11 | x1 /= 10; 12 | } 13 | 14 | return x % sum == 0 ? sum : -1; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3100_Water_Bottles_II.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% of users with Java 2 | // Memory 41.04 MB Beats 23.84% of users with Java 3 | // Implementation. 4 | // T:O( n / m), S:O(1) 5 | // 6 | class Solution { 7 | public int maxBottlesDrunk(int numBottles, int numExchange) { 8 | int ret = numBottles, curEmpty = numBottles, cur = 0; 9 | while (cur + curEmpty >= numExchange) { 10 | ret++; 11 | curEmpty += cur; 12 | cur = 1; 13 | curEmpty -= numExchange; 14 | numExchange++; 15 | } 16 | 17 | return ret; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3110_Score_of_a_String.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% of users with Java 2 | // Memory 41.92 MB Beats 50.00% of users with Java 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int scoreOfString(String s) { 8 | int ret = 0; 9 | for (int i = 0; i < s.length() - 1; i++) { 10 | ret += Math.abs(s.charAt(i) - s.charAt(i + 1)); 11 | } 12 | 13 | return ret; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3131_Find_the_Integer_Added_to_Array_I.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% of users with Java 2 | // Memory 42.76 MB Beats 100.00% of users with Java 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int addedInteger(int[] nums1, int[] nums2) { 8 | int max1 = -1, max2 = -1; 9 | for (int num : nums1) { 10 | max1 = Math.max(max1, num); 11 | } 12 | for (int num : nums2) { 13 | max2 = Math.max(max2, num); 14 | } 15 | 16 | return max2 - max1; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3151_Special_Array_I.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% of users with Java 2 | // Memory 42.98 MB Beats 100.00% of users with Java 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean isArraySpecial(int[] nums) { 8 | for (int i = 1; i < nums.length; i++) { 9 | if (Math.abs(nums[i] - nums[i - 1]) % 2 == 0) { 10 | return false; 11 | } 12 | } 13 | 14 | return true; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3158_Find_the_XOR_of_Numbers_Which_Appear_Twice.java: -------------------------------------------------------------------------------- 1 | // Runtime 2 ms Beats 100.00% of users with Java 2 | // Memory 43.20 MB Beats 100.00% of users with Java 3 | // . 4 | // T:O(n), S:O(n) 5 | // 6 | class Solution { 7 | public int duplicateNumbersXOR(int[] nums) { 8 | HashSet record = new HashSet<>(); 9 | int ret = 0; 10 | for (int num : nums) { 11 | if (record.contains(num)) { 12 | ret ^= num; 13 | } else { 14 | record.add(num); 15 | } 16 | } 17 | 18 | return ret; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3168_Minimum_Number_of_Chairs_in_a_Waiting_Room.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% of users with Java 2 | // Memory 41.94 MB Beats 100.00% of users with Java 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int minimumChairs(String s) { 8 | int cur = 0, ret = 0; 9 | for (char c : s.toCharArray()) { 10 | if (c == 'E') { 11 | cur++; 12 | ret = Math.max(ret, cur); 13 | } else { 14 | cur--; 15 | } 16 | } 17 | 18 | return ret; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3178_Find_the_Child_Who_Has_the_Ball_After_K_Seconds.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% of users with Java 2 | // Memory 40.54 MB Beats 100.00% of users with Java 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int numberOfChild(int n, int k) { 8 | int remain = k % (2 * (n - 1)); 9 | if (remain <= n - 1) { 10 | return remain; 11 | } else { 12 | return 2 * (n - 1) - remain; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3184_Count_Pairs_That_Form_a_Complete_Day_I.java: -------------------------------------------------------------------------------- 1 | // Runtime 2 ms Beats 100.00% 2 | // Memory 42.29 MB Beats 50.00% 3 | // Prefix sum & hashmap. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int countCompleteDayPairs(int[] hours) { 8 | int ret = 0; 9 | HashMap record = new HashMap<>(); 10 | for (int hour : hours) { 11 | int remain = hour % 24; 12 | ret += record.getOrDefault((24 - remain) % 24, 0); 13 | record.merge(hour % 24, 1, Integer::sum); 14 | } 15 | 16 | return ret; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3185_Count_Pairs_That_Form_a_Complete_Day_II.java: -------------------------------------------------------------------------------- 1 | // Runtime 27 ms Beats 100.00% 2 | // Memory 94.30 MB Beats 100.00% 3 | // Prefix sum & hashmap. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public long countCompleteDayPairs(int[] hours) { 8 | long ret = 0; 9 | HashMap record = new HashMap<>(); 10 | for (int hour : hours) { 11 | int remain = hour % 24; 12 | ret += record.getOrDefault((24 - remain) % 24, 0); 13 | record.merge(hour % 24, 1, Integer::sum); 14 | } 15 | 16 | return ret; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3190_Find_Minimum_Operations_to_Make_All_Elements_Divisible_by_Three.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% 2 | // Memory 42.12 MB Beats 100.00% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int minimumOperations(int[] nums) { 8 | int ret = 0; 9 | for (int num : nums) { 10 | ret += num % 3 == 0 ? 0 : 1; 11 | } 12 | 13 | return ret; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3194_Minimum_Average_of_Smallest_and_Largest_Elements.java: -------------------------------------------------------------------------------- 1 | // Runtime 2 ms Beats 100.00% 2 | // Memory 43.21 MB Beats 100.00% 3 | // Sort. 4 | // T:O(nlogn), S:O(1) 5 | // 6 | class Solution { 7 | public double minimumAverage(int[] nums) { 8 | double ret = Double.MAX_VALUE; 9 | Arrays.sort(nums); 10 | for (int i = 0; i < nums.length / 2; i++) { 11 | ret = Math.min(ret, (nums[i] + nums[nums.length - 1 - i]) * 1.0 / 2); 12 | } 13 | 14 | return ret; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3206_Alternating_Groups_I.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 42.83 MB Beats 100.00% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int numberOfAlternatingGroups(int[] colors) { 8 | int len = colors.length, ret = 0; 9 | for (int i = 0; i < len; i++) { 10 | int left = i == 0 ? colors[len - 1] : colors[i - 1], right = i == len - 1 ? colors[0] : colors[i + 1]; 11 | if (colors[i] != left && colors[i] != right) { 12 | ret++; 13 | } 14 | } 15 | 16 | return ret; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3210_Find_the_Encrypted_String.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 42.42 MB Beats 100.00% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public String getEncryptedString(String s, int k) { 8 | int len = s.length(); 9 | k = k % len; 10 | return s.substring(k, len) + s.substring(0, k); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3222_Find_the_Winning_Player_in_Coin_Game.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% 2 | // Memory 41.48 MB Beats 50.00% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public String losingPlayer(int x, int y) { 8 | int round = Math.min(x, y / 4); 9 | 10 | return round % 2 == 1 ? "Alice" : "Bob"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3223_Minimum_Length_of_String_After_Operations.java: -------------------------------------------------------------------------------- 1 | // Runtime 78 ms Beats 100.00% 2 | // Memory 50.59 MB Beats 100.00% 3 | // Map. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int minimumLength(String s) { 8 | HashMap record = new HashMap<>(); 9 | int ret = 0; 10 | for (char c : s.toCharArray()) { 11 | record.merge(c, 1, Integer::sum); 12 | } 13 | for (char c : record.keySet()) { 14 | ret += record.get(c) % 2 == 1 ? 1 : 2; 15 | } 16 | 17 | return ret; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3227_Vowels_Game_in_a_String.java: -------------------------------------------------------------------------------- 1 | // Runtime 31 ms Beats 50.00% 2 | // Memory 45.14 MB Beats 100.00% 3 | // Game & Greedy: If there are any vowel, then the first player can win in every situation. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean doesAliceWin(String s) { 8 | List vowels = Arrays.asList('a', 'e', 'i', 'o', 'u'); 9 | for (char c : s.toCharArray()) { 10 | if (vowels.contains(c)) { 11 | return true; 12 | } 13 | } 14 | 15 | return false; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3232_Find_if_Digit_Game_Can_Be_Won.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% 2 | // Memory 44.17 MB Beats 45.78% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean canAliceWin(int[] nums) { 8 | int sumTotal = 0, sumSmall = 0; 9 | for (int num : nums) { 10 | if (num < 10) { 11 | sumSmall += num; 12 | } 13 | sumTotal += num; 14 | } 15 | 16 | return sumSmall * 2 != sumTotal; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3274_Check_if_Two_Chessboard_Squares_Have_the_Same_Color.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% 2 | // Memory 41.46 MB Beats 100.00% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public boolean checkTwoChessboards(String coordinate1, String coordinate2) { 8 | int c1 = coordinate1.charAt(0) - 'a', c2 = coordinate1.charAt(1) - '1', c3 = coordinate2.charAt(0) - 'a', 9 | c4 = coordinate2.charAt(1) - '1'; 10 | int diff1 = Math.abs(c1 - c3), diff2 = Math.abs(c2 - c4); 11 | return Math.abs(diff1 - diff2) % 2 == 0; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3285_Find_Indices_of_Stable_Mountains.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 44.89 MB Beats 100.00% 3 | // . 4 | // T:O(n), S:O(n) 5 | // 6 | class Solution { 7 | public List stableMountains(int[] height, int threshold) { 8 | List ret = new ArrayList<>(); 9 | for (int i = 1; i < height.length; i++) { 10 | if (height[i - 1] > threshold) { 11 | ret.add(i); 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3340_Check_Balanced_String.java: -------------------------------------------------------------------------------- 1 | // Runtime 2 ms Beats 100.00% 2 | // Memory 43.30 MB Beats 100.00% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public boolean isBalanced(String num) { 8 | int evenSum = 0, oddSum = 0; 9 | for (int i = 0; i < num.length(); i++) { 10 | int digit = Integer.parseInt(String.valueOf(num.charAt(i))); 11 | if (i % 2 == 0) { 12 | evenSum += digit; 13 | } else { 14 | oddSum += digit; 15 | } 16 | } 17 | 18 | return evenSum == oddSum; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3360_Stone_Removal_Game.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% 2 | // Memory 40.76 MB Beats 50.00% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public boolean canAliceWin(int n) { 8 | int turn = 0, cur = 10; 9 | while (n > 0) { 10 | if (n < cur) { 11 | return cur % 2 != 0; 12 | } 13 | n -= cur; 14 | cur--; 15 | } 16 | 17 | if (n == 0) { 18 | return cur % 2 != 0; 19 | } 20 | 21 | return true; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3370_Smallest_Number_With_All_Set_Bits.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% 2 | // Memory 40.82 MB Beats 100.00% 3 | // . 4 | // T:O(logn), S:O(1) 5 | // 6 | class Solution { 7 | public int smallestNumber(int n) { 8 | int ret = 0, exp = 0, base = 1; 9 | while (n > 0) { 10 | exp++; 11 | n /= 2; 12 | } 13 | for (int i = 0; i < exp; i++) { 14 | ret += base; 15 | base *= 2; 16 | } 17 | 18 | return ret; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3392_Count_Subarrays_of_Length_Three_With_a_Condition.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 45.19 MB Beats 100.00% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int countSubarrays(int[] nums) { 8 | int len = nums.length, ret = 0; 9 | for (int i = 0; i < len - 2; i++) { 10 | if ((nums[i] + nums[i + 2]) * 2 == nums[i + 1]) { 11 | ret++; 12 | } 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3423_Maximum_Difference_Between_Adjacent_Elements_in_a_Circular_Array.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 43.57 MB Beats 100.00% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int maxAdjacentDistance(int[] nums) { 8 | int len = nums.length, ret = Math.abs(nums[0] - nums[len - 1]); 9 | for (int i = 0; i < len - 1; i++) { 10 | ret = Math.max(ret, Math.abs(nums[i] - nums[i + 1])); 11 | } 12 | 13 | return ret; 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3427_Sum_of_Variable_Length_Subarrays.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 44.26 MB Beats 100.00% 3 | // prefix sum. 4 | // T:O(n), S:O(n) 5 | // 6 | class Solution { 7 | public int subarraySum(int[] nums) { 8 | int len = nums.length, ret = 0; 9 | int[] dp = new int[len + 1]; 10 | for (int i = 0; i < len; i++) { 11 | dp[i + 1] = dp[i] + nums[i]; 12 | } 13 | for (int i = 0; i < len; i++) { 14 | int start = Math.max(0, i - nums[i]); 15 | ret += dp[i + 1] - dp[start]; 16 | } 17 | 18 | return ret; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3432_Count_Partitions_with_Even_Sum_Difference.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% 2 | // Memory 41.89 MB Beats 87.69% 3 | // . 4 | // T:O(1), S:O(n) 5 | // 6 | class Solution { 7 | public int countPartitions(int[] nums) { 8 | int sum = 0, cur = 0, ret = 0; 9 | for (int i : nums) { 10 | sum += i; 11 | } 12 | for (int i = 0; i < nums.length - 1; i++) { 13 | cur += nums[i]; 14 | if ((sum - 2 * cur) % 2 == 0) { 15 | ret++; 16 | } 17 | } 18 | 19 | return ret; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3452_Sum_of_Good_Numbers.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 44.11 MB Beats 100.00% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int sumOfGoodNumbers(int[] nums, int k) { 8 | int len = nums.length, ret = 0; 9 | for (int i = 0; i < len; i++) { 10 | if ((i - k < 0 || (i - k >= 0 && nums[i] > nums[i - k])) && 11 | (i + k >= len || (i + k < len && nums[i] > nums[i + k]))) { 12 | ret += nums[i]; 13 | } 14 | } 15 | 16 | return ret; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3467_Transform_Array_by_Parity.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 44.79 MB Beats 97.81% 3 | // . 4 | // T:O(n), S:O(n) 5 | // 6 | class Solution { 7 | public int[] transformArray(int[] nums) { 8 | int len = nums.length, countOdd = 0; 9 | for (int i : nums) { 10 | if (i % 2 == 1) { 11 | countOdd++; 12 | } 13 | } 14 | int[] ret = new int[len]; 15 | for (int i = len - countOdd; i < len; i++) { 16 | ret[i] = 1; 17 | } 18 | 19 | return ret; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3492_Maximum_Containers_on_a_Ship.java: -------------------------------------------------------------------------------- 1 | // Runtime 0 ms Beats 100.00% 2 | // Memory 40.98 MB Beats 65.69% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int maxContainers(int n, int w, int maxWeight) { 8 | return Math.min(n * n, maxWeight / w); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3498_Reverse_Degree_of_a_String.java.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 42.92 MB Beats 46.96% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int reverseDegree(String s) { 8 | int ret = 0; 9 | for (int i = 0; i < s.length(); i++) { 10 | char c = s.charAt(i); 11 | ret += (26 - (int) (c - 'a')) * (i + 1); 12 | } 13 | 14 | return ret; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3502_Minimum_Cost_to_Reach_Every_Position.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 97.67% 2 | // Memory 44.78 MB Beats 95.61% 3 | // . 4 | // T:O(n), S:(n) 5 | // 6 | class Solution { 7 | public int[] minCosts(int[] cost) { 8 | int len = cost.length, minVal = cost[0]; 9 | int[] ret = new int[len]; 10 | for (int i = 0; i < len; i++) { 11 | minVal = Math.min(minVal, cost[i]); 12 | ret[i] = minVal; 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3512_Minimum_Operations_to_Make_Array_Sum_Divisible_by_K.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 44.98 MB Beats 100.00% 3 | // . 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int minOperations(int[] nums, int k) { 8 | int sum = 0; 9 | for (int num : nums) { 10 | sum += num; 11 | } 12 | 13 | return sum % k; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3516_Find_Closest_Person.java: -------------------------------------------------------------------------------- 1 | // Runtime 1 ms Beats 100.00% 2 | // Memory 41.48 MB Beats 100.00% 3 | // . 4 | // T:O(1), S:O(1) 5 | // 6 | class Solution { 7 | public int findClosest(int x, int y, int z) { 8 | int ret = 0, t0 = Math.abs(x - z), t1 = Math.abs(y - z); 9 | if (t0 < t1) { 10 | ret = 1; 11 | } else if (t0 > t1) { 12 | ret = 2; 13 | } 14 | 15 | return ret; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3523_Make_Array_Non_decreasing.java: -------------------------------------------------------------------------------- 1 | // Runtime 3 ms Beats 64.27% 2 | // Memory 72.73 MB Beats 71.33% 3 | // Greedy & Monotonic. 4 | // T:O(n), S:O(1) 5 | // 6 | class Solution { 7 | public int maximumPossibleSize(int[] nums) { 8 | int ret = 0, prev = 0; 9 | for (int num : nums) { 10 | if (num > prev) { 11 | ret++; 12 | prev = num; 13 | } else if (num == prev) { 14 | ret++; 15 | } 16 | } 17 | 18 | return ret; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_3536_Maximum_Product_of_Two_Digits.java: -------------------------------------------------------------------------------- 1 | // Runtime 2 ms Beats 100.00% 2 | // Memory 40.98 MB Beats 100.00% 3 | // . 4 | // T:O(logn), S:O(logn) 5 | // 6 | class Solution { 7 | public int maxProduct(int n) { 8 | List digits = new ArrayList<>(); 9 | while (n > 0) { 10 | digits.add(n % 10); 11 | n /= 10; 12 | } 13 | digits.sort(Collections.reverseOrder()); 14 | 15 | return digits.get(0) * digits.get(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /leetcode_solved/leetcode_511_Game_Play_Analysis_I.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 635 ms, faster than 30.75% of MySQL online submissions for Game Play Analysis I. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Game Play Analysis I. 3 | # Write your MySQL query statement below 4 | select player_id, min(event_date) as first_login from Activity group by player_id; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_584_Find_Customer_Referee.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 458 ms, faster than 66.69% of MySQL online submissions for Find Customer Referee. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Find Customer Referee. 3 | # Write your MySQL query statement below 4 | select name from Customer where referee_id is null or referee_id != 2; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_608_Tree_Node.sql: -------------------------------------------------------------------------------- 1 | -- Runtime: 375 ms, faster than 84.29% of MySQL online submissions for Tree Node. 2 | -- Memory Usage: 0B, less than 100.00% of MySQL online submissions for Tree Node. 3 | # Write your MySQL query statement below 4 | select distinct a.id, (case 5 | when a.p_id is null then 'Root' 6 | when a.p_id is not null and b.id is not null then 'Inner' 7 | when b.id is null then 'Leaf' end) as type 8 | from Tree a left join Tree b on a.id=b.p_id; -------------------------------------------------------------------------------- /leetcode_solved/leetcode_70_Climbing_Stairs.java: -------------------------------------------------------------------------------- 1 | // AC: Runtime: 0 ms, faster than 100.00% of Java online submissions for Climbing Stairs. 2 | // Memory Usage: 35.4 MB, less than 91.99% of Java online submissions for Climbing Stairs. 3 | // classical DP problem 4 | // T:O(n), S:O(n) 5 | // 6 | class Solution { 7 | public int climbStairs(int n) { 8 | int[] dp = new int[n + 1]; 9 | dp[0] = 1; 10 | dp[1] = 1; 11 | for (int i = 2; i <= n; i++) { 12 | dp[i] = dp[i - 1] + dp[i - 2]; 13 | } 14 | return dp[n]; 15 | } 16 | } -------------------------------------------------------------------------------- /readme-1.md: -------------------------------------------------------------------------------- 1 | // todo -------------------------------------------------------------------------------- /欢迎提PR或讨论: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OneCodeMonkey/Algorithm/ce8635a1340d8e68cb4f1bcb8dcc33b5943ed381/欢迎提PR或讨论 --------------------------------------------------------------------------------