├── .gitignore ├── README.md ├── problems ├── 0001_Two_Sum │ ├── 0001-tyrone2497-31.c │ ├── 0001_Two_Sum.c │ ├── 0001_Two_Sum.java │ ├── 0001_Two_Sum.py │ ├── 0001_Two_Sum_Easy.txt │ ├── 26逝水流.js │ ├── Allen5G.c │ ├── Bruce0001.py │ ├── Decadence.java │ ├── HowieLee.java │ ├── LeetCode1.c │ ├── LeetCode1.cpp │ ├── LeetCode1.java │ ├── MQQM.cpp │ ├── MQQM2.cpp │ ├── Test0001.java │ ├── Two_Sum.java │ ├── WhoAmI.c │ ├── annjeff.cpp │ ├── ass.cpp │ ├── bbj.cpp │ ├── bigPandaMiaoMiao.java │ ├── ch8936.java │ ├── dahai.js │ ├── dev_bin.go │ ├── h_twosum.cpp │ ├── hainingbaby.cpp │ ├── hebust-fengyu_0001_Two_Sum.c │ ├── homesong345.c │ ├── jacklynd.c │ ├── lalala.py │ ├── liangxu.c │ ├── linghuchong.java │ ├── linlijia.java │ ├── liuxiaobei.java │ ├── my_first_code.py │ ├── nicefuture.c │ ├── peanwang.cpp │ ├── persiststudy.py │ ├── pingtou.cpp │ ├── sankforever.py │ ├── seaflower.go │ ├── shouwang.c │ ├── shyshy903.cpp │ ├── solution.py │ ├── torresng.cpp │ ├── two_sum.py │ ├── twosum │ ├── washing.py │ ├── wkh_sum.py │ ├── xifenghuyang.java │ ├── youransuifeng.java │ ├── yrpang.c │ ├── yulonghe.c │ ├── zero.java │ ├── zhaoqianxilan.cpp │ ├── 抗压斑马线.cpp │ └── 活跃time.java ├── 0002_Add_Two_Numbers │ ├── 05KevinHe.java │ ├── 2_Abel.cpp │ ├── AddTwoNumbers.cpp │ ├── Allen5G.c │ ├── Ashbringer.java │ ├── Bruce0002.py │ ├── Decadence.java │ ├── HowieLee.java │ ├── Lonecloud.java │ ├── Plummy.java │ ├── add_two.py │ ├── ass.cpp │ ├── bbj.cpp │ ├── biao2.c │ ├── dahai.js │ ├── dev_bin_28.go │ ├── h_Add Two Numbers.cpp │ ├── jasonvv.java │ ├── liangxu.c │ ├── liuxiaobei.java │ ├── nicefuture.c │ ├── pg.cpp │ ├── pingtou.cpp │ ├── sankforever.py │ ├── seaflower.go │ ├── shouwang.c │ ├── shsyshy-02.cpp │ ├── torresng.cpp │ ├── vino.cpp │ ├── washing.py │ ├── xifenghuyang.java │ ├── youransuifeng.java │ ├── yulonghe.c │ ├── zero.java │ ├── zhaoqianxilan.cpp │ ├── 活跃time.java │ └── 辉.c ├── 0003_Longest_Substring_Without_Repeating_Characters │ ├── 0003-tyrone2497-31.c │ ├── 3_Abel.cpp │ ├── HowieLee.java │ ├── Lonecloud.java │ ├── LongestSubstringWithoutRepeatingCharacters.cpp │ ├── Plummy.java │ ├── Plummy_V2.java │ ├── WhoAmI.c │ ├── ass.c │ ├── dahai.js │ ├── jacklynd.cpp │ ├── lalala.c │ ├── liangxu.c │ ├── longest-substring-without-repeating-characters.py │ ├── luffy.c │ ├── nicefuture.c │ ├── nicefuture.java │ ├── pingtou.c │ ├── seaflower.go │ ├── shouwang.c │ ├── shy.cpp │ ├── torresng.cpp │ ├── wanxu_pursue_0003.java │ ├── washing.py │ ├── xifenghuyang.java │ ├── zhaoqianxilan.cpp │ └── 活跃time.java ├── 0004_Median_of_Two_Sorted_Arrays │ ├── 22_黄有才.c │ ├── 6-hebust-fengyu_0004.寻找两个有序数组的中位数.c │ ├── Elon.py │ ├── KevinHe_04.java │ ├── Lonecloud.java │ ├── Median of Two.py │ ├── MedianOfTwoSortedArray.cpp │ ├── MedianOfTwoSortedArrays.java │ ├── aSimpleSolution.cpp │ ├── findMedian.java │ ├── jacklynd.cpp │ ├── jiangxiaomi.py │ ├── nicefuture.java │ ├── sanwuqiyan.java │ ├── seaflower.go │ ├── shy.cpp │ ├── torresng.cpp │ ├── wanxu_pursue_0004.java │ └── 活跃time.java ├── 0005_Longest_Palindromic_Substring │ ├── Elon.py │ ├── HowieLee.java │ ├── LeetCode0005.cpp │ ├── alvis.py │ ├── chengyu.cpp │ ├── jasonvv.java │ ├── linghuchong.java │ ├── nicefuture.cpp │ ├── seaflower.go │ ├── shy-05.cpp │ ├── shy05.cpp │ ├── solution.py │ ├── torresng.cpp │ ├── wanxu_pursue_0005.java │ ├── washing.py │ └── zhaoqianxilan.cpp ├── 0006_ZigZag_Conversion │ ├── Howie.java │ ├── nicefuture.c │ ├── seaflower.go │ ├── shy-06.cpp │ ├── torresng.cpp │ ├── wanxu_pursue_0006.java │ └── 石成玉.cpp ├── 0007_Reverse_Integer │ ├── 0007-tyrone-31.c │ ├── 0007_Reverse.c │ ├── 0007_Reverse_Integer.py │ ├── 1007.cpp │ ├── Adam.java │ ├── Bruce0007.py │ ├── MQQM.cpp │ ├── ReverseInteger.java │ ├── RomaNumber.java │ ├── WhoAmI │ ├── aSimpleSolution.py │ ├── bbj.cpp │ ├── hainingbaby_0007_Reverse_Integer.cpp │ ├── init6-007.txt │ ├── jacklynd.c │ ├── jasonvv.java │ ├── lalala.py │ ├── nicefuture.c │ ├── peanwang.cpp │ ├── pg.cpp │ ├── reverse │ ├── reverse.java │ ├── reverse_banana.py │ ├── seaflower.go │ ├── solution.py │ ├── torresng.cpp │ ├── wanxu_pursue_0007.java │ ├── washing.py │ ├── yrpang.c │ ├── zero.java │ ├── zhaoqianxilan.cpp │ ├── zhaos.cpp │ ├── 一碗机智的糖浆.java │ ├── 活跃time.java │ ├── 离线????.txt │ └── 辉.c ├── 0008_String_to_Integer_atoi │ ├── 1008.cpp │ ├── 16_klgentle.py │ ├── Barlowwang.cpp │ ├── KevinHe_08.java │ ├── MQQM.cpp │ ├── jacklynd.c │ ├── linghuchong.java │ ├── mark.cpp │ ├── myAtoi.py │ ├── nicefuture.c │ ├── peanwang.cpp │ ├── seaflower.go │ ├── string_to_integer_Rocky.c │ ├── torresng.cpp │ ├── wanxu_pursue_0008.java │ ├── zchaos.cpp │ ├── 活跃time.java │ └── 石成玉.cpp ├── 0009_Palindrome_Number │ ├── Bruce0009.py │ ├── MQQM.cpp │ ├── PalindromeNumber.java │ ├── Sam.c │ ├── banana.py │ ├── lalala.py │ ├── nicefuture.c │ ├── seaflower.go │ ├── shouwang.c │ ├── solution.py │ ├── torresng.cpp │ ├── wanxu_pursue_0009.java │ ├── xiaxi.c │ ├── yrpang.c │ ├── zero.java │ └── 一碗机智的糖浆.java ├── 0010_Regular_Expression_Matching │ ├── LeetCode0010.cpp │ ├── seaflower.go │ ├── torresng.cpp │ └── wanxu_pursue_0010.java ├── 0011_Container_With_Most_Water │ ├── 016_klgentle.py │ ├── 05_KevinHe.java │ ├── Container_With_Most_Water.cpp │ ├── Container_With_Most_Water2.cpp │ ├── HowieLee.java │ ├── L_Solution.kt │ ├── MaxArea_st.java │ ├── danjiaoshou.py │ ├── linlijia.java │ ├── liuxinglei.java │ ├── seaflower.go │ ├── torresng.cpp │ ├── wanxu_pursue_0011.java │ └── xiaoheng_3.cpp ├── 0012_Integer_to_Roman │ ├── 0012nian.py │ ├── 012 Integer to Roman │ │ └── 012_Integer to Roman.cpp │ ├── 012_Integer to Roman.cpp │ ├── 16_klgentle.py │ ├── int2roma.java │ ├── seaflower.go │ ├── torresng.cpp │ └── wanxu_pursue_0012.java ├── 0013_Roman_to_Integer │ ├── Barlowwang.cpp │ ├── Bruce0013.py │ ├── LeetCode0013.cpp │ ├── RomanToInteger.java │ ├── Roman_to_Interger │ ├── Sam.c │ ├── jacklynd.c │ ├── lalala.py │ ├── peanwang.cpp │ ├── roman2int.java │ ├── seaflower.go │ ├── torresng.cpp │ ├── wanxu_pursue_0013.java │ ├── zero.java │ └── 恨orhate.java ├── 0014_Longest_Common_Prefix │ ├── 0014_Longest_Common_Prefix_bluesun.py │ ├── 0014nian.py │ ├── Bruce0014.py │ ├── LongestCommonPrefix.java │ ├── LongestCommonPrefix_st.java │ ├── jacklynd.c │ ├── lalala.py │ ├── seaflower.go │ ├── torresng.cpp │ ├── wanxu_pursue_0014.java │ ├── zero.java │ └── 一碗机智的糖浆.java ├── 0015_3Sum │ ├── 0015_3Sum.java │ ├── 0015_3Sum_Rocky.c │ ├── 0015_3sum.txt │ ├── 0153Sum.cpp │ ├── 3Sum.cpp │ ├── 3Sum.java │ ├── 3Sum2.cpp │ ├── Bruce0015.py │ ├── ElonPython3.py │ ├── ThreeNumberSum.java │ ├── ThreeSum_st.java │ ├── jacklynd.c │ ├── linlijia.java │ ├── seaflower.go │ ├── torresng.cpp │ └── wanxu_pursue_0015.java ├── 0016_3Sum_Closest │ ├── 0016_3Sum_Closest.txt │ ├── 3Sum_Closest.cpp │ ├── Bruce0016.py │ ├── ElonPython3.py │ ├── ThreeNumberSumClosest.java │ ├── ThreeSumClosest_st.java │ ├── jacklynd.c │ ├── linghuchong.java │ ├── linlijia.java │ ├── torresng.cpp │ └── wanxu_pursue_0016.java ├── 0017_Letter_Combinations_of_a_Phone_Number │ ├── Curry.cpp │ ├── Letter combination.py │ ├── sanwuqiyan.java │ ├── torresng.cpp │ └── wanxu_pursue_0017.java ├── 0018_4Sum │ ├── 4Sum.cpp │ ├── ElonPython3.py │ ├── FourSum.java │ ├── Sum_of_4number.c │ ├── leet18.java │ ├── recursive.py │ ├── torresng.cpp │ ├── wanxu_pursue_0018.java │ └── 周三不加班.java ├── 0019_Remove_Nth_Node_From_End_of_List │ ├── Leetcode19.java │ ├── RemoveNthFromEnd.java │ ├── Remove_Nth_Node_From_End_of_List.cpp │ ├── ass.c │ ├── bbj.cpp │ ├── pg.cpp │ ├── removeNthFromEnd.cpp │ ├── wanxu_pursue_0019.java │ └── 一碗机智的糖浆.java ├── 0020_Valid_Parentheses │ ├── Adai.java │ ├── Bruce0020.java │ ├── Bruce0020.py │ ├── IsValid_st.java │ ├── LeetCode0020.c │ ├── LeetCode0020.cpp │ ├── MQQM.cpp │ ├── MQQM2.cpp │ ├── MQQM2.py │ ├── Solution.java │ ├── aSimpleSolution.cpp │ ├── h_有效的括号.cpp │ ├── isValid.py │ ├── liuxiang.java │ ├── merwin_20.java │ ├── sankforever.py │ ├── solution.py │ ├── torresng.cpp │ ├── wanxu_pursue_0020.java │ ├── yrpang.cpp │ └── yrpang1.c ├── 0021_Merge_Two_Sorted_Lists │ ├── 0021-init6.txt │ ├── 05KevinHe.java │ ├── Bruce0021.cpp │ ├── Bruce0021.py │ ├── MQQM.cpp │ ├── MergeTwoLists_st.java │ ├── MergeTwoSortedLists.java │ ├── ass.c │ ├── bbj.cpp │ ├── biao.c │ ├── jasonvv.java │ ├── linlijia.java │ ├── mergeTwoLists.cpp │ ├── merwin_21.java │ ├── nicefuture.java │ ├── pg.cpp │ ├── solution.py │ ├── torresng.cpp │ └── wanxu_pursue_0021.java ├── 0022_Generate_Parentheses │ ├── Abel_22.cpp │ ├── Curry.cpp │ └── wanxu_pursue_0022.java ├── 0023_mergeKLists │ ├── ALOHA.cpp │ ├── jasonvv.java │ ├── mergeKLists.cpp │ └── wanxu_pursue_0023.java ├── 0024_Swap_Nodes_in_Pairs │ ├── merwin_24.java │ ├── swapPairs.cpp │ ├── wanxu_pursue_0024.java │ ├── wkh_swap-nodes-in-pairs.py │ └── 石成玉.cpp ├── 0025_Reverse_Nodes_in_k-Group │ ├── Elon.py │ ├── nil.go │ └── wanxu_pursue_0025.java ├── 0026_Remove_Duplicates_from_Sorted_Array │ ├── 26_Rocky's_solution.c │ ├── 26_remove_duplicates_from_sorted_array.c │ ├── ActivityTime.java │ ├── Barlowwang.cpp │ ├── Bruce0026.cpp │ ├── Bruce0026.py │ ├── ElonPython3.py │ ├── JasonVV.java │ ├── LeetCode0026.cpp │ ├── NO26_liuyunsheng.java │ ├── P26.py │ ├── RemoveDupLuoQuan.java │ ├── RemoveDuplicates.java │ ├── Solution_26.java │ ├── YuanCome.java │ ├── chenghui.java │ ├── fengdongdong.cpp │ ├── init6-26.txt │ ├── liangxu.c │ ├── linlijia.java │ ├── nian.py │ ├── nicefuture.c │ ├── peanwang.cpp │ ├── removeDuplicates.cpp │ ├── removeDuplicatesFromArrayByPingtou.cpp │ ├── reowst.c │ ├── solution.py │ ├── torresng.cpp │ ├── wanxu_pursue_0026.java │ ├── y.java │ ├── yang.cpp │ ├── yang.py │ └── zchaos.cpp ├── 0027_Remove_Element │ ├── 027_Remove_Element.py │ ├── 20_Painting、时光.py │ ├── ActivityTime.java │ ├── Bruce0027.cpp │ ├── ElonPython3.py │ ├── NO27_liuyunsheng.java │ ├── RemoveElement_st.java │ ├── Remove_Element.cpp │ ├── Remove_Element2.cpp │ ├── Remove_Element3.cpp │ ├── Remove_Element4.cpp │ ├── init6-27.cpp │ ├── liuxiaobei.java │ ├── nicefuture.c │ ├── nicefuture.java │ ├── peanwang.cpp │ ├── removeElements.cpp │ ├── solution.py │ ├── torresng.cpp │ ├── wanxu_pursue_0027.java │ └── 令狐冲.java ├── 0028_Implement_strStr │ ├── 0028_Implement_strStr()_bluesun.py │ ├── Bruce0028.cpp │ ├── Bruce0028.py │ ├── Implement_strStr().cpp │ ├── Implement_strStr()2.cpp │ ├── Implement_strStr()3.cpp │ ├── StrStr_st.java │ ├── jasonvv.java │ ├── merwin_28.java │ ├── nicefuture.c │ ├── solution.py │ ├── torresng.cpp │ ├── wanxu_pursue_0028.java │ └── zchaos.cpp ├── 0030_Substring_with_concatenation_of_All_Words │ ├── 30.cpp │ ├── 30.py │ └── nil.go ├── 0031_Next_Permutation │ └── hainingbaby_0031_Next_Permutation.cpp ├── 0032_Longest_Valid_Parentheses │ └── nil.go ├── 0033_Search_in_Rotated_Sorted_Array │ └── Search_in_Rotated_Sorted_Array.cpp ├── 0034_Find_First_and_Last_Position_of_Element_in_Sorted_Array │ └── torresng.cpp ├── 0035_Search_Insert_Position │ ├── Bruce0035.cpp │ ├── aSimpleSolution.cpp │ ├── jasonvv0035.php │ ├── nicefuture.c │ ├── pg.cpp │ └── torresng.cpp ├── 0036_Valid_Sudoku │ └── valid_sudoku.cpp ├── 0038_Count_and_Say │ ├── 0038_Count_and_Say_blueusn.py │ ├── 38_1nian.py │ ├── 39_2nian.py │ ├── Bruce0038.cpp │ ├── Bruce0038.py │ ├── nicefuture.c │ └── torresng.cpp ├── 0039_Combination_Sum │ └── Test.java ├── 0041_First_Missing_Positive │ ├── LeetCode0041.cpp │ └── nil.go ├── 0042_Trapping_Rain_Water │ ├── LeetCode0042.c │ ├── LeetCode0042.cpp │ └── nil.go ├── 0043_Multiply_Strings │ ├── Main.java │ └── jasonvv.java ├── 0045_Jump_Game_2 │ └── 22_黄有才.c ├── 0046_Permutations │ ├── 4_秩秩斯干.cpp │ ├── linghuchong.java │ ├── linlijia.java │ ├── merwin_46.java │ ├── nian.py │ └── 令狐冲.java ├── 0047_Permutations_II │ ├── linghuchong.java │ └── nian.py ├── 0048_Rotate_Image │ └── mark.cpp ├── 0049_Group_Anagrams │ ├── 0049_1_nian.py │ ├── 0049_2_nian.py │ ├── L_Solution.kt │ └── 石成玉.cpp ├── 0050_Pow │ ├── 4_秩秩斯干.cpp │ ├── homesong345.c │ └── sanwuqiyan.java ├── 0051_N_Queens │ └── nil.go ├── 0053_Maximum_Subarray │ ├── Maximum_Subarray.cpp │ ├── fengdongsheng.cpp │ ├── linlijia.java │ ├── nicefuture.c │ ├── shouwang_0053.c │ ├── torresng.cpp │ ├── vincent.c │ └── 石成玉.cpp ├── 0054_Spiral_Matrix │ ├── 54.py │ └── Solution.java ├── 0055_Jump_Game │ ├── 0055nian.py │ └── 22_黄有才.c ├── 0056_Merge_Intervals │ ├── Merge Intervals.py │ ├── Merge_Intervals │ ├── Merge_Intervals.cpp │ ├── Merge_Servant.java │ ├── PythonByElon.py │ ├── Tony the Cyclist.py │ └── leetcode056.py ├── 0058_Length_of_Last_Word │ ├── 0058_Length_of_Last_Word_bluesun.py │ ├── 0058nian.py │ ├── LengthOfLastWord_st.java │ ├── Solution_58.java │ ├── __Previews │ │ └── torresng.cppPreview │ ├── jasonvv.php │ ├── linghuchong.java │ ├── luffy.c │ ├── nicefuture.c │ ├── peanwang.cpp │ ├── torresng.cpp │ └── zchaos.cpp ├── 0060_Permutation_Sequence │ └── ElonPython3.py ├── 0061_Rotate_List │ ├── jasonvv.java │ └── linghuchong.java ├── 0062_Unique_Paths │ └── torresng.cpp ├── 0064_Minimum_Path_Sum │ ├── Minimum_Path_Sum.cpp │ ├── PythonByElon.py │ ├── leet64.java │ ├── linlijia.java │ └── torresng.cpp ├── 0065_Valid_Number │ └── ElonPython3.py ├── 0066_Plus_One │ ├── ElonPython3.py │ ├── PlusOne_st.java │ ├── nicefuture.c │ ├── shouwang.c │ └── torresng.cpp ├── 0067_Add_Binary │ ├── nicefuture.c │ └── torresng.cpp ├── 0068_Text_Justification │ └── Elon.py ├── 0069_Sqrtx │ ├── 0069_Sqrtx_by_persiststudy.cpp │ ├── 16_klgentle.py │ ├── Elon.py │ ├── bbj.cpp │ ├── nicefuture.c │ ├── peanwang.cpp │ ├── torresng.cpp │ └── vincent.c ├── 0070_Climbing_Stairs │ ├── 0070nian.py │ ├── MQQM.java │ ├── MQQM2.cpp │ ├── init6.cpp │ ├── linlijia.py │ ├── merwin_70.java │ ├── nicefuture.c │ └── torresng.cpp ├── 0071_Simplify_Path │ ├── Elon.py │ └── nil.go ├── 0072_Edit_Distance │ ├── Elon.py │ └── torresng.cpp ├── 0073_Set_Matrix_Zeroes │ └── merwin_73.java ├── 0073_Word_Search │ └── Solution.py ├── 0074_Search_a_2D_Matrix │ ├── Ashbringer.java │ ├── bbj.cpp │ └── peanwang.cpp ├── 0075_Sort_Colors │ ├── 0075_Sort_Colors.py │ ├── 6-hebust-fengyu_0075_Sort_Colors.c │ └── torresng.cpp ├── 0076_Minimum_Window_Substring │ ├── 15-活跃tiime.java │ ├── 18_Decadence.md │ ├── Elon.py │ └── torresng.cpp ├── 0077_Combinations │ ├── Elon.py │ └── nil.go ├── 0078_Subsets │ ├── jasonvv.java │ ├── mark.cpp │ └── xiaoheng_3.cpp ├── 0079_Word_Search │ ├── 0079_Word _Search │ │ └── Decadence.java │ ├── Elon.py │ ├── HH79.py │ ├── Word_Search.cpp │ ├── nil.go │ ├── 石成玉.cpp │ └── 阿浩.cpp ├── 0080_Remove_Duplicates_from_Sorted_Array_II │ ├── 0080nian.py │ ├── RemoveDuplicates_st.java │ ├── Remove_Duplicates_from_Sorted_Array_II.cpp │ ├── Remove_Duplicates_from_Sorted_Array_II2.cpp │ └── torresng.cpp ├── 0081_Search_in_Rotated_Sorted_Array_II │ └── nil.go ├── 0083_Remove_Duplicates_from_Sorted_List │ ├── 83_Rocky's_solution.c │ ├── 83_remove_duplicates_from_sorted_list.cpp │ ├── DeleteDuplicates.java │ ├── YuanCome.java │ ├── deleteDuplicates.c │ ├── fengdongdong.cpp │ ├── liangxu.c │ ├── linlijia.java │ ├── nicefuture.c │ ├── reowst.c │ └── torresng.cpp ├── 0084_Largest_Rectangle_in_Histogram │ └── torresng.cpp ├── 0085_Maximal_Rectangle │ ├── HH85.py │ └── torresng.cpp ├── 0086_Partition_List │ ├── linghuchong.java │ └── nil.go ├── 0088_Merge_Sorted_Array │ ├── Merge_Sorted_Array.cpp │ ├── Merge_st.java │ ├── init6-88.py │ ├── jasonvv.java │ ├── linlijia.java │ ├── merge_sorted_array_by_pingtou.cpp │ ├── nicefuture.c │ ├── solution.py │ └── torresng.cpp ├── 0089_Gray_Code │ └── 16_klgentle.py ├── 0091_Decode_Ways │ ├── 18_Decadence.md │ ├── 22_黄有才.cpp │ ├── 91.cpp │ ├── Elon.py │ ├── liuxiang.java │ └── torresng.cpp ├── 0092_Reverse_Linked_List_II │ ├── 0092_Reverse_Linked_List_II_persiststudy.cpp │ ├── ReverseBetween.java │ ├── Solution1.cpp │ ├── Solution2.cpp │ ├── liuxiang.java │ ├── mysolution.py │ └── reverse_linked_list.py ├── 0094_Binary_Tree_Inorder_Traversal │ ├── 22_黄有才.c │ ├── Ashbringer.java │ ├── linlijia.cpp │ └── nil.go ├── 0096_Unique_Binary_Search_Trees │ ├── Ashbringer.java │ └── mark.cpp ├── 0097_Interleaving_String │ └── torresng.cpp ├── 0098_Validate_Binary_Search_Tree │ ├── Ashbringer.java │ ├── nil.go │ └── solution.py ├── 0100_Same_Tree │ ├── Ashbringer.java │ ├── Elon.py │ ├── ass.c │ ├── nicefuture.c │ ├── solution.py │ ├── torresng.cpp │ ├── vino.cpp │ ├── washing.py │ ├── xiaxi.c │ ├── zhaoqianxilan.cpp │ └── 石成玉.cpp ├── 0101_Symmetric_Tree │ ├── 18_Decadence.md │ ├── 6-hebust-fengyu_0101_Symmetric_Tree.c │ ├── ALOHA.cpp │ ├── ElonPython3.py │ ├── IsSymmetric_st.java │ ├── LeetCode0101.cpp │ ├── Lionxu_Symmetric_Tree.py │ ├── MQQM.cpp │ ├── Solution_101.java │ ├── SymmetricTree_101.java │ ├── SymmetricTree_101_By_deadlyAce.java │ ├── Symmetric_Tree_By_Decadence.java │ ├── Symmetric__Tree.py │ ├── dachuan.java │ ├── dev_bin_28.go │ ├── kevinbai.py │ ├── leetcode101.py │ ├── linghuchong.java │ ├── liuxaing.java │ ├── nicefuture.c │ ├── sankforever.py │ ├── sanwuqiyan.java │ ├── sixdays.java │ ├── symmetricTree.py │ ├── torresng.cpp │ ├── yang.py │ ├── 周三不加班.java │ └── 活跃time.java ├── 0102_Binary_Tree_Level_Order_Traversal │ ├── 0102_BFS.py │ ├── 0102_DFS.py │ ├── BinaryTreeLevelOrderTraversal_102.java │ ├── Binary_Tree_Level_Order_Traversal_By_Decadence.java │ ├── ElonPython3.py │ ├── IevelOrder_st.java │ ├── MQQM.cpp │ ├── danjiaoshou.py │ ├── kevinbai.py │ ├── linghuchong.java │ ├── sanwuqiyan.java │ ├── torresng.cpp │ └── yang.py ├── 0103_Binary_Tree_Zigzag_Level_Order_Traversal │ └── MQQM.cpp ├── 0104_Maximum_Depth_of_Binary_Tree │ ├── MQQM.cpp │ ├── nicefuture.c │ ├── nil.go │ └── torresng.cpp ├── 0105_Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal │ ├── Coke-105.py │ └── MQQM.cpp ├── 0106_Construct_Binary_Tree_from_Inorder_and_Postorder_Traversal │ ├── Coke-106.py │ └── MQQM.cpp ├── 0107_Binary_Tree_Level_Order_Traversal_II │ ├── MQQM.cpp │ ├── MQQM2.cpp │ ├── nicefuture.cpp │ ├── torresng.cpp │ └── 张小胖.cpp ├── 0108_Convert_Sorted_Array_to_Binary_Search_Tree │ ├── HH108.py │ ├── MQQM.cpp │ └── torresng.cpp ├── 0109_Convert_Sorted_List_to_Binary_Search_Tree │ ├── 0109_Rocky.c │ ├── Abel_Alan.cpp │ ├── ConvertSortedListtoBinarySearchTree_109.java │ ├── Decadence.java │ ├── leetcode109.java │ ├── leetcode109.py │ ├── protea_ban.py │ ├── sanwuqiyan.java │ ├── yang_109.cpp │ └── 周三不加班.java ├── 0110_Balanced_Binary_Tree │ ├── Ashbringer.java │ └── torresng.cpp ├── 0111_Minimum_Depth_of_Binary_Tree │ └── torresng.cpp ├── 0112_Path_Sum │ ├── nicefuture.c │ └── torresng.cpp ├── 0113_Path_Sum_II │ ├── Coke-113.py │ ├── Curry.cpp │ ├── nil.go │ ├── torresng.cpp │ └── zhaoqianxilan.cpp ├── 0114_Flattern_Binary_Tree_to_Linked_List │ ├── 114_Flatten_Binary_Tree_to_Linked_List.cpp │ ├── 18_Decadence.md │ ├── 22_黄有才.c │ ├── Elon.py │ ├── dev_bin_28.go │ └── solution.py ├── 0118_Pascals_Triangle │ ├── dachuan.java │ ├── nicefuture.java │ └── torresng.cpp ├── 0119_Pascals_Triangle_II │ ├── ALOHA.cpp │ └── nicefuture.java ├── 0120_Triangle │ ├── 15 - 活跃time.java │ ├── 18_Decadence.md │ ├── 4_秩秩斯干.cpp │ ├── ALOHA.cpp │ ├── LeetCode0120.cpp │ ├── Solution.py │ ├── liuxiang.java │ └── 君.cpp ├── 0120_triangle │ └── dev_bin_28.go ├── 0121_Best_Time_to_Buy_and_Sell_Stock │ ├── 26逝水流.js │ ├── LeetCode0121.cpp │ ├── Solution.py │ ├── linlijia.c │ ├── nicefuture.java │ ├── torresng.c │ └── torresng.cpp ├── 0122_Best_Time_to_Buy_and_Sell_Stock_II │ ├── Solution_122.java │ ├── torresng.c │ └── torresng.cpp ├── 0125_Valid_Palindrome │ ├── 0125_Valid_Palindrome.py │ ├── IsPalindrome_st.java │ ├── MQQM.cpp │ ├── merwin_125.java │ ├── nicefuture.c │ └── torresng.cpp ├── 0129_Sum_Root_to_Leaf_Numbers │ └── Coke-129.py ├── 0134_Gas_Station │ └── 0134_nian.py ├── 0136_Single_Number │ ├── 0136_Single_Number.cpp │ ├── 0136_Single_number_22k.java │ ├── dachuan.java │ ├── nicefuture.c │ ├── pg.cpp │ └── torresng.cpp ├── 0137_Single_Number_II │ ├── 0137_Single_Number_II.cpp │ ├── 16_klgentle_smile.py │ └── 君.cpp ├── 0138_Copy_List_with_Random_Pointer │ ├── 0138_1_Copy_List_with_Random_Pointer.cpp │ └── 0138_Copy_List_with_Random_Pointer.cpp ├── 0139_Word_Break │ ├── 01klgentle.py │ └── torresng.cpp ├── 0141_Linked_List_Cycle │ ├── 0141_Linked_List_Cycle.cpp │ ├── 0141_Linked_List_Cycle.java │ ├── HasCycle.java │ ├── LingHuChong.java │ ├── nicefuture.c │ ├── torresng.cpp │ └── 一碗机智的糖浆.java ├── 0142_Linked_List_Cycle_II │ ├── 0142_Linked_List_Cycle_II.cpp │ ├── 0142_Linked_List_Cycle_II.java │ ├── DetectCycle.java │ └── mysolution.py ├── 0143_Reorder_List │ └── 143_Reorder_List.cpp ├── 0144_Binary_Tree_Preorder_Traversal │ └── peanwang.cpp ├── 0146_LRU_Cache │ └── nil.go ├── 0147_Insertion-Sort-List │ └── Barlowwang.cpp ├── 0148_Sort_List │ ├── Sort-List.java │ ├── jasonvv.java │ └── nil.go ├── 0151_Reverse_Words │ ├── ReverseWords_st.java │ └── linlijia.java ├── 0151_Reverse_Words_in_a_String │ ├── LingHuChong.java │ ├── nian0151.py │ └── torresng.cpp ├── 0152_Maximum_Product_Subarray │ ├── Adam.java │ ├── Elon.py │ ├── h_Maximum_Product_Subarray.cpp │ ├── mark.cpp │ └── washing.py ├── 0155_Min_Stack │ ├── MQQM.cpp │ ├── nicefuture.c │ ├── torresng.cpp │ └── 橘子.java ├── 0160_Intersection_of_Two_Linked_Lists │ ├── MQQM.cpp │ ├── nicefuture.c │ ├── peanwang.cpp │ ├── torresng.c │ ├── torresng.cpp │ └── zhaxinle.c ├── 0166_Fraction_to_Recurring_Decimal │ └── nil.go ├── 0167_Two_Sum_II_Input_array_is_sorted │ ├── 167_Two_Sum_II_Input_array_is_sorted.py │ ├── dachuan.java │ ├── nicefuture.c │ ├── torresng.c │ ├── torresng.cpp │ └── twoSum.py ├── 0168_Excel_Sheet_Column_Title │ ├── 0168nian.py │ ├── nicefuture.c │ ├── torresng.c │ └── torresng.cpp ├── 0169_Majority_Element │ ├── 22k.java │ ├── MQQM.cpp │ ├── MQQM.py │ ├── MQQM2.cpp │ ├── liuxiaobei.java │ ├── nicefuture.c │ ├── peanwang.cpp │ ├── torresng.c │ └── torresng.cpp ├── 0171_Excel_Sheet_Column_Number │ ├── 0171nian.py │ ├── dachuan.java │ ├── nicefuture.c │ ├── peanwang.cpp │ └── torresng.cpp ├── 0172_Factorial_Trailing_Zeroes │ ├── ALOHA.cpp │ ├── nicefuture.c │ └── torresng.cpp ├── 0174_Dungeon_Game │ └── torresng.cpp ├── 0175_Combine_Two_Tables │ └── torresng.sql ├── 0176_Second_Highest_Salary │ └── torresng.sql ├── 0177_Nth_Highest_Salary │ └── 蒋小米.sql ├── 0179_Largest_Number │ └── nil.go ├── 0181_Employees_Earning_More_Than_Their_Managers │ └── torresng.sql ├── 0182_Duplicate_Emails │ ├── 0182_Duplicate_Emails.sql │ └── torresng.sql ├── 0189_Rotate_Array │ ├── nicefuture.c │ └── torresng.cpp ├── 0190_Reverse_Bits │ └── peanwang.txt ├── 0191_hammingWeight │ ├── 0191_hammingWeight_by_persiststudy.cpp │ ├── hammingWeight.cpp │ └── peanwang.cpp ├── 0198_House_Robber │ ├── 0198_House Robber.cpp │ ├── nil.go │ └── torresng.cpp ├── 0200_Number_Islands │ ├── 4_秩秩斯干.cpp │ ├── Number-Of-Lslands.java │ ├── bbj.cpp │ ├── dev_bin_28.go │ ├── numIslands.py │ ├── 君.cpp │ └── 石成玉.cpp ├── 0202_Happy_Number │ ├── bbj.cpp │ └── peanwang.cpp ├── 0203_Remove_Linked_List_Elements │ ├── 203_abel.cpp │ ├── Bruce0203.py │ ├── Elon.py │ ├── RemoveElement-ByDecadence.java │ ├── RemoveElements.java │ ├── RemoveElements.py │ ├── Remove_Linked_List_Elements.cpp │ ├── Tony the Cyclist.py │ ├── bbj.cpp │ ├── dachuan.java │ ├── hainingbaby.cpp │ ├── jacklynd.c │ ├── reowst.cpp │ ├── torresng.cpp │ └── 阿浩.cpp ├── 0204_Count_Primes │ ├── alvis.c │ ├── bbj.cpp │ ├── count_primes.cpp │ ├── liangxu.c │ ├── linlijia.java │ ├── nicefuture.c │ └── torresng.cpp ├── 0205_Isomorphic_Strings │ ├── 0205nian.py │ └── isIsomorphic.py ├── 0206_Reverse_Linked_List │ ├── 0206Reverse_linked_list_BY.cpp │ ├── 0206_Reverse_Linked_List_persiststudy.cpp │ ├── 206_HH.py │ ├── 206_shouwang.c │ ├── ListNode.java │ ├── ReverseLinkNode.java │ ├── Reverse_Linked_List.cpp │ ├── Reverse_Linked_List2.cpp │ ├── Test.java │ ├── bbj.cpp │ ├── init6.cpp │ ├── jasonvv.java │ ├── nian_pointer.py │ ├── nian_recursion.py │ └── nian_stack.py ├── 0209_Minimum_Size_Subarray_Sum │ └── 0209_Minimum_Size_Subarray_Sum.cpp ├── 0213_House_Robber_II │ ├── Adam.java │ ├── mark_213.cpp │ ├── solution.py │ └── torresng.cpp ├── 0215_Kth_Largest_Element_in_an_Array │ ├── 0215_Rocky.c │ ├── Abel_Alan.cpp │ ├── FindKMaxNumber.java │ ├── FindKthElement.java │ ├── FindKthLargest_st.java │ ├── KthLargestElementinanArray_215.java │ ├── LX.kt │ ├── MQQM.cpp │ ├── MQQM2.cpp │ ├── Solution.py │ ├── Tony the Cyclist.py │ ├── heapq_solution.py │ ├── homesong345.c │ ├── leetcode215.py │ ├── protea_ban.py │ ├── sanwuqiyan.java │ └── yang_215.cpp ├── 0217_Contains_Duplicate │ ├── 217_charlie.py │ ├── MQQM.cpp │ ├── MQQM.py │ ├── MQQM2.cpp │ ├── containsDuplicate.py │ └── nicefuture.java ├── 0219_Contains_Duplicate_II │ └── nicefuture.java ├── 0221_Maximal_Square │ └── torresng.cpp ├── 0222_Count_Complete_Tree_Nodes │ ├── Count_Nodes.cpp │ └── recursive_count_nodes.py ├── 0224_Basic_Calculator │ └── aSimpleSolution.cpp ├── 0225_Implement_Queue_using_Stacks │ └── 橘子.java ├── 0226_Invert_Binary_Tree │ ├── 226Invert_Binary_Tree.ipynb │ ├── ALOHA.cpp │ └── torresng.cpp ├── 0230_Kth_Smallest_Element_in_a_BST │ └── MQQM.cpp ├── 0231_Power_of_Two │ ├── MQQM.cpp │ └── peanwang.cpp ├── 0234_Palindrome_Linked_List │ ├── 0234PalindromeLinkedList1.cpp │ ├── 0234_Palindrome_Linked_List.java │ ├── 234.cpp │ ├── 234_protea-ban.py │ ├── IsPalindrome.java │ ├── IsPalindrome_Servant.java │ ├── ListNode.java │ ├── Palindrome.java │ ├── Palindrome_Linked_List.cpp │ ├── biao.c │ ├── leetcode234.py │ ├── nian.py │ ├── paLinkedList_234.py │ ├── palindromeLinkedList_234.py │ ├── test.c │ ├── torresng.cpp │ └── xiaxi.c ├── 0235_Lowest_Common_Ancestor_of_a_Binary_Search_Tree │ └── MQQM.cpp ├── 0236_Lowest_Common_Ancestor_of_a_Binary_Tree │ ├── Ashbringer.java │ └── MQQM.cpp ├── 0237_Delete_Node_in_a_Linked_List │ ├── Adam.java │ ├── Delete_Node_in_a_Linked_List.cpp │ └── bbj.cpp ├── 0238_Product_of_Array_Except_Self │ └── MQQM.cpp ├── 0240_Search_a_2D_Matrix_II │ └── 20_Painting、时光.py ├── 0242_Valid_Anagram │ └── Valid_Anagram.cpp ├── 0257_binary_tree_paths │ ├── Ashbringer.java │ ├── binary_tree_paths_Rocky.c │ ├── fengdongdong.cpp │ └── peanwang.cpp ├── 0258_Add_Digits │ ├── 258_Add_Digits.c │ ├── 258_Add_Digits_22k.java │ ├── Solution_258.java │ ├── add_digits_banana.py │ ├── dachuan.java │ ├── peanwang.cpp │ └── torresng.cpp ├── 0262_Trips_and_Users │ └── 蒋小米.sql ├── 0263_Ugly_Number │ └── solution.py ├── 0264_ugly-number-ii │ ├── 0263_Ugly_Number │ │ ├── alvis.c │ │ ├── liangxu.c │ │ ├── linlijia.java │ │ ├── nicefuture.c │ │ ├── shouwang.c │ │ └── torresng.cpp │ ├── 0264_ugly-number-ii.cpp │ └── solution.py ├── 0268_Missing_Number │ ├── Missing_Number.cpp │ ├── Missing_Number2.cpp │ ├── Missing_Number3.cpp │ ├── Tony the Cyclist.py │ ├── liuxiaobei.java │ ├── missing_number_by_Rocky.c │ ├── nicefuture.c │ └── torresng.cpp ├── 0274_H-Index │ └── H-Index_nian.py ├── 0275_H-index_II │ └── nian0275.py ├── 0278_First_Bad_Version │ └── torresng.cpp ├── 0279_Perfect_Squares │ └── torresng.cpp ├── 0283_Move_Zeroes │ ├── Tony the Cyclist.py │ ├── nicefuture.c │ ├── torresng.c │ └── torresng.cpp ├── 0287_Find_the_Duplicate_Number │ └── 0287_Find_the_Duplicate_Number.py ├── 0290_Word_Pattern │ └── 0290nian.py ├── 0295_Find_Median_From_DataStream │ └── MedianFinder.cpp ├── 0299_bulls_and_cows │ └── 0299_nian.py ├── 0303_Range_Sum_Query │ ├── 16_klgentle_smile.py │ ├── 18_Decadence.md │ ├── 303.cpp │ ├── Elon.py │ ├── NumArray.java │ ├── liuxiang.java │ └── sanwuqiyan.java ├── 0312_Burst_Balloons │ └── torresng.cpp ├── 0322_Coin_Change │ ├── torresng.cpp │ └── 小恒_3.js ├── 0326_Power_of_Three │ └── peanwang.cpp ├── 0328_Odd_Even_Linked_List │ └── Curry.cpp ├── 0334_Increasing_Triplet_Subsequence │ ├── 0334_Increasing_Triplet_Subsequence.java │ ├── Bruce0334.py │ ├── ElonPython.py │ ├── Zeny.java │ ├── abelZW.c │ ├── lionfly.py │ ├── reowst.c │ └── xiaxi.c ├── 0342_Power_of_Four │ └── torresng.cpp ├── 0343_Integer_Break │ └── 0343_IntegerBreak.cpp ├── 0344_Reverse_String │ ├── MQQM.cpp │ ├── dachuan.java │ ├── jasonvv.java │ ├── nicefuture.c │ ├── shouwang.c │ └── torresng.cpp ├── 0345_Reverse_Vowels_of_a_String │ ├── 345nain.py │ ├── nicefuture.c │ └── nicefuture.py ├── 0347_Top_K_Frequent_Elements │ ├── 16_klgentle_smile.py │ └── MQQM.cpp ├── 0349_Intersection_of_Two_Arrays │ ├── Tony the Cyclist.py │ ├── dachuan.java │ ├── homesong345_0349.c │ ├── init6-349.txt │ └── torresng.cpp ├── 0350_Intersection_of_Two_Arrays_II │ ├── Tony the Cyclist.py │ └── homesong345_0350.c ├── 0371_Sum_Of_TwoIntegers │ └── Sum_Of_Twointegers.cpp ├── 0371_Sum_of_Two_Integers │ ├── Decadence.java │ ├── Elon.py │ ├── jacklynd.c │ └── reowst.cpp ├── 0374_Guess_Number_Higher_or_Lower │ ├── Guess_Number.cpp │ ├── guess_number.py │ ├── guess_number_by_Rocky.java │ ├── nicefuture.java │ └── torresng.cpp ├── 0375_Guess_Number_Higher_or_Lower_II │ └── torresng.cpp ├── 0378_Kth_Smallest_Element_in_a_Sorted_Matrix │ └── washing.py ├── 0378_Kth_Smallest_Element_in_a_Sorted_Matrix │ └── 0378.py ├── 0383_Ransom_Note │ ├── 0383_Ransom_Note_blueusn.py │ └── nicefuture.c ├── 0387_First_Unique_Character_in_a_String │ ├── 0387_First_Unique_Character_in_a_String_bluesun.py │ ├── FirstUniqChar_st.java │ ├── FirstUniqueChar.java │ ├── First_Unique_Character_in_a_String.cpp │ ├── First_Unique_Character_in_a_String2.cpp │ ├── First_Unique_Character_in_a_String3.cpp │ ├── linlijia.java │ ├── nian.py │ ├── nicefuture.c │ ├── peanwang.cpp │ ├── torresng.c │ └── torresng.cpp ├── 0389_Find_the_Difference │ └── torresng.cpp ├── 0392_IsSubsequence │ ├── Adam.java │ └── isSubsequence.py ├── 0400_Nth_Digit │ ├── FindNthDigit_st.java │ ├── Nth_Digit.cpp │ ├── Nth_Digit_by_Rocky.c │ ├── Solution.java │ ├── nicefuture.c │ ├── torresng.cpp │ └── wanxu_pursue.java ├── 0401_Binary_Watch │ └── wanxu_pursue_0401.java ├── 0402_Remove_K_Digits │ ├── 402_Remove_K_Digits.cpp │ └── wanxu_pursue_0402.java ├── 0405_Convert_a_Number_to_Hexadecimal │ ├── Convert_a_Number_to_Hexadecimal.cpp │ ├── ToHex_Servant.java │ ├── nicefuture.c │ ├── torresng.cpp │ └── wanxu_pursue.java ├── 0414_Third_Maximum_Number │ └── nicefuture.java ├── 0415_Add_Strings │ ├── 26逝水流.js │ ├── Adam.java │ └── nicefuture.c ├── 0434_Number_of_Segments_in_a_String │ └── nicefuture.c ├── 0440_K-th_Smallest_in_Lexicographical_Order │ └── 30_bigfish.cpp ├── 0442_Find_All_Duplicates_in_an_Array │ ├── Bruce0442.py │ └── Find_All_Duplicates_in_an_Array.cpp ├── 0443_Compress │ ├── Compress_st.java │ └── nicefuture.c ├── 0445_Add_Two_Numbers_II │ ├── Add_Two_Numbers_II.cpp │ └── add_two_numbers_by_pingtou.cpp ├── 0448_Find_All_Numbers_Disappeared_in_an_Array │ ├── 0448_Find_All_Numbers_Disappeared_in_an_Array.java │ ├── AbelAlan.c │ ├── Bruce0448.c │ ├── Bruce0448.py │ ├── ElonPython3.py │ ├── Zeny.java │ ├── dachuan.java │ ├── hainingbaby.cpp │ ├── nicefuture.java │ ├── 小恒_3.js │ └── 阿浩.cpp ├── 0451_Sort_Characters_By_Frequency │ └── LX.kt ├── 0461_Hamming_Distance │ ├── 16_klgentle.py │ ├── 461_Hamming_Distance.c │ └── torresng.cpp ├── 0476_Number_Complement │ ├── 0476_Number_Complement_Rocky.c │ ├── shouwang.c │ └── torresng.cpp ├── 0485_Max_Consecutive_Ones │ ├── jiangmimin.py │ └── nicefuture.c ├── 0485_findMaxConsecutiveOnes │ └── Sam.c ├── 0496_nextGreaterElement │ └── Sam.c ├── 0498_Diagonal_Traverse │ ├── Elon.py │ ├── jiangxiaomi.py │ ├── solution.py │ ├── washing.py │ ├── zhaoqianxilan.cpp │ └── 石成玉.cpp ├── 0500_Keyboard_Row │ ├── Keyboard_Row.cpp │ ├── dachuan.java │ └── torresng.cpp ├── 0509_Fibonacci_Number │ ├── dachuan.java │ ├── nicefuture.c │ └── nicefuture.java ├── 0515_Find_Largest_Value_in_Each_Tree_Row │ └── ass.c ├── 0520_Detect_Capital │ └── nicefuture.c ├── 0521_Longest_Uncommon_Subsequence_I │ ├── dachuan.java │ └── nicefuture.c ├── 0532_K-diff_Pairs_in_an_Array │ └── nicefuture.java ├── 0539findMinDifference │ └── findMinDifference.c ├── 0540_Single_Element_in_a_Sorted_Array │ ├── Tony the Cyclist.py │ └── shouwang.c ├── 0541_Reverse_String_II │ ├── SAM.c │ └── nicefuture.c ├── 0543_Diameter_of_Binary_Tree │ └── 0543_Diameter_of_Binary_Tree.ipynb ├── 0551_Student_Attendance_Record_I │ └── nicefuture.c ├── 0557_Reverse_Words_in_a_String_III │ ├── 05KevinHe.java │ ├── MQQM.cpp │ ├── ReverseWords_st.java │ ├── boom米花.js │ ├── dachuan.java │ ├── nicefuture.c │ ├── torresng.c │ └── torresng.cpp ├── 0559_Maximum_Depth_of_N-ary_Tree │ ├── 36朱鑫鑫.java │ └── dachuan.java ├── 0561_array-partition-i │ ├── 0561_array-partition-i.cpp │ └── dachuan.java ├── 0566_Reshape_the_Matrix │ ├── 016_klgentle.py │ ├── 0566_Reshape_the_Matrix.cpp │ ├── 15 - 活跃time.java │ ├── 20_Painting、时光.py │ ├── 21_no566.py │ ├── 22_黄有才.c │ ├── 26逝水流.js │ ├── 566.cpp │ ├── Elon.py │ ├── Reshape_the_Matrix.cpp │ ├── SunspotsInys.cpp │ ├── dachuan.java │ ├── jacklynd.c │ ├── liuxiang.java │ ├── liuxiaobei.java │ ├── reowst.cpp │ ├── solution.py │ ├── washing.py │ ├── 石成玉.cpp │ └── 阿浩.cpp ├── 0572_Subtree_of_Another_Tree │ └── 0572_Subtree_of_Another_Tree.py ├── 0581_Shortest_Unsorted_Continuous_Subarray │ └── xiaoheng_3_0581.js ├── 0589_N-ary_Tree_Preorder_Traversal │ └── dachuan.java ├── 0590_N-ary_Tree_Postorder_Traversal │ └── dachuan.java ├── 0605_Can_Place_Flowers │ └── 张小胖.cpp ├── 0606_Construct_String_from_Binary_Tree │ └── nicefuture.java ├── 0617_Merge_Two_Binary_Trees │ ├── dachuan.java │ └── torresng.cpp ├── 0633_Sum_of_Square_Numbers │ └── bbj.cpp ├── 0637_Average_of_Levels_in_Binary_tree │ └── fengdongdong.cpp ├── 0646_Maximum_Length_of_Pair_Chain │ ├── Elon.py │ └── Maximum_Length_of_Pair_Chain.cpp ├── 0650_2_Keys_Keyboard │ └── xiaoheng_3.c ├── 0657_Robot_Return_to_Origin │ └── nicefuture.c ├── 0665_Non_decreasing_Array │ └── nil.go ├── 0669_Trima_Binary_Search_Tree │ └── Ashbringer.java ├── 0680_Valid_Palindrome_II │ └── nicefuture.c ├── 0682_Baseball_Game │ └── dachuan.java ├── 0684_Redundant_Connection │ └── Redundant_Connection.cpp ├── 0695_Max_Area_of_Island │ └── LX.kt ├── 0700_Search_in_a_Binary_Search_Tree │ └── dachuan.java ├── 0704_Binary_Search │ ├── 0704_Binary_Search.js │ └── 0704_Binary_Search_by_persiststudy.c ├── 0707_Design_Linked_List │ └── 0707_Design_Linked_List.cpp ├── 0707_MyLinkedList │ └── MyLinkedList.cpp ├── 0709_To_Lower_Case │ ├── 0709_To_Lower_Case.js │ ├── 709_To_Lower_Case.java │ └── 709_To_Lower_Case │ │ └── nicefuture.c ├── 0717_1-bit and 2-bit Characters │ └── xiaoheng_3.js ├── 0728_Self_Dividing_Numbers │ └── dachuan.java ├── 0739_Daily_Temperatures │ ├── 0739_Daily_Temperatures_Rocky.c │ └── peanwang.cpp ├── 0769_Max_Chunks_To_Make_Sorted │ ├── 769_Max_Chunks_To_Make_Sorted │ │ └── washing.py │ ├── Elon.py │ ├── jiangxiaomi.py │ ├── mark.cpp │ ├── solution.py │ └── zhaoqianxilan.cpp ├── 0771_Jewels_And_Stones │ ├── 0771_22k.java │ ├── 0771_Jewels_And_Stones.js │ ├── JewelsAndStones.java │ └── 【LeetCode题解---771】Jewels and Stones.md ├── 0783_Min_Diff_In_BST │ └── solution.py ├── 0784_Letter_Case_Permutation │ ├── Elon.py │ ├── jiangxiaomi.py │ ├── solution.py │ ├── washing.py │ ├── zhaoqianxilan.cpp │ └── 石成玉.cpp ├── 0788_Rotated_Digits │ ├── 0788_Rotated-Digits_persiststudy.cpp │ ├── 0788_Rotated_DIgits_byAarynArwin.java │ ├── 0788_Rotated_DIgits_byDecadence.java │ ├── 0788_Rotated_Digits.py │ ├── 0788_Rotated_DigitsbyMagnetStone.scala │ ├── 0788_code_zero.py │ ├── 0788_yang.py │ ├── Abel_Alan.cpp │ ├── CycleNumber.java │ ├── ElonPython3.py │ ├── RotatedDigits_788.java │ ├── RotatedDigits_st.java │ ├── Rotated_Digits.cpp │ ├── Solution_788.java │ ├── dachuan.java │ ├── daguodong1234.c │ ├── homesong345.c │ ├── kevinbai.py │ ├── leetcode788.py │ ├── protea_ban.py │ ├── sanwuqiyan.java │ ├── yyh.py │ ├── zwalker.py │ └── จุ๊บ.java ├── 0804_Unique_Morse_Code_Words │ ├── 804_Unique_Morse_Code_Words.js │ └── nicefuture.java ├── 0806_Number_of_Lines_To_Write_String │ └── L_solution.java ├── 0811_Subdomain_Visit_Count │ └── dachuan.java ├── 0812_Largest_Triangle_Area │ └── xiaxi.c ├── 0817_Linked_List_Components │ ├── 817_abel.cpp │ ├── Bruce0817.c │ ├── Decadence.java │ ├── Elon.py │ └── numComponents.py ├── 0819_Most_Common_Word │ └── nicefuture.java ├── 0821_Shortest_Distance_to_a_Character │ └── dachuan.java ├── 0824_Goat_Latin │ └── nicefuture.java ├── 0852_Peak_Index_in_a_Mountain_Array │ └── 0852_Peak_Index_in_a_Mountain_Array.js ├── 0859_Buddy_Strings │ └── nicefuture.java ├── 0867_Transpose_Matrix │ ├── dachuan.java │ ├── jiangxiaomi.py │ └── liuxiaobei.java ├── 0876_Middle_of_the_Linked_List │ ├── fengdongsheng.cpp │ └── qingcaibaiyutang17.c ├── 0876_middle_of_the_linked_list │ └── 0876_middleNode.cpp ├── 0890_Find_And_Replace_Pattern │ ├── 0890_Code_Zero.py │ ├── 0890_Find_And_Replace_Pattern.py │ ├── 0890_Find_And_Replace_PatternbyDecadence (2).txt │ ├── 0890_Find_And_Replace_PatternbyDecadence.java │ ├── 0890_Find_And_Replace_PatternbyMagnetStone.scala │ ├── 0890_Find_And_Replace_Patternbymagumagua.py │ ├── 0890_yang.py │ ├── 16_klgentle.py │ ├── 890_Find_And_Replace_Pattern_Rocky.c │ ├── 890_find_And_Replace_Pattern.cpp │ ├── Abel_Alan.cpp │ ├── ElonPython3.py │ ├── FindAndReplace.java │ ├── FindAndReplacePattern_st.java │ ├── FindandReplacePattern_890.java │ ├── boom米花.py │ ├── daguodong1234.cpp │ ├── findAndReplacePattern.py │ ├── kevinbai.py │ ├── sanwuqiyan.java │ ├── yyh.py │ ├── zwalker1.py │ ├── จุ๊บ.java │ └── 流萤.c++ ├── 0893_Groups_of_Special_Equivalent_Strings │ └── nicefuture.java ├── 0905_Sort_Array_By_Parity │ ├── 0905_Sort_Array_By_Parity.java │ ├── 26逝水流.js │ ├── PythonByElon.py │ ├── Solution.java │ ├── Sort Array By Parity_prtea-ban.py │ ├── SortArray.java │ ├── SortArrayByParity.java │ ├── SortArrayByParity_Servant.java │ ├── Sort_Array_By_Parity.cpp │ ├── Sort_Array_By_Parity.java │ ├── Sort_Array_By_Parity2.cpp │ ├── Sort_Array_By_Parity_nian.py │ ├── leet905.java │ ├── leetcode905.py │ ├── new_leetcode905.py │ ├── peanwang.cpp │ ├── persiststudy.c │ └── wanxu_pursue_0905.java ├── 0908_Smallest_Range_I │ └── dachuan.java ├── 0914_X_of_a_Kind_in_a_Deck_of_Cards │ └── L_solution.java ├── 0917_Reverse_Only_Letters │ ├── nicefuture.c │ └── peanwang.cpp ├── 0925_Long_Pressed_Name │ ├── L_Solution.java │ └── nicefuture.c ├── 0929_Unique_Email_Addresses │ ├── 0929_Unique_Email_Addresses.js │ ├── Unique_Email_Addresses.cpp │ ├── dachuan.java │ └── nicefuture.java ├── 0933_Number_of_Recent_Calls │ └── dachuan.java ├── 0937_Reorder_Log_Files │ └── nicefuture.java ├── 0938_Range_Sum_of_BST │ └── dachuan.java ├── 0942_DI_String_Match │ └── dachuan.java ├── 0944_Delete_Columns_to_Make_Sorted │ └── dachuan.java ├── 0949_Largest_Time_for_Given_Digits │ └── 0949_Largest_Time_for_Given_Digits.py ├── 0961_ N-Repeated_Element_in_Size_2N_Array │ └── qingcaibaiyutang17.c ├── 0961_N-Repeated_Element_in_Size_2N_Array │ └── dachuan.java ├── 0964_Least_Operators_to_Express_Number │ └── Abel_964.cpp ├── 0965_Univalued_Binary_Tree │ └── dachuan.java ├── 0973_K_Closest_Points_to_Origin │ └── dachuan.java ├── 0977_Squares_of_a_Sorted_Array │ ├── bbj.cpp │ └── dachuan.java ├── 0978_Longest_Turbulent_Subarray │ └── xiaxi.c ├── 0985_Sum_of_Even_Numbers_After_Queries │ ├── dachuan.java │ └── qingcaibaiyutang17.c ├── 0989_Add_to_Array_Form_of_Integer │ └── 989_22k.java ├── 0994_Rotting_Oranges │ └── LX.kt ├── 0995_Sort_Array_By_Parity │ └── 21_no995.py ├── 0997_Find_the_Town_Judge │ └── ass.c ├── 0999_Available_Captures_for_Rook │ └── dachuan.java ├── 1002_Find_Common_Characters │ └── dachuan.java ├── 1005_Maximize_Sum_Of_Array_After_K_Negations │ └── 1005_Maximize_Sum_Of_Array_After_K_Negations.js ├── 1013_Partition_Array_Into_Three_Parts_With_Equal_Sum │ └── qingcaibaiyutang17.c ├── 1020_Number_of_Enclaves │ └── Elon.py ├── 1021_Remove_Outermost_Parentheses │ ├── 21_charlie.py │ └── dachuan.java └── 1025_Divisor_Game │ ├── dachuan.java │ └── nil.go └── submittors ├── 01nicefuture.txt ├── 05KevinHe.txt ├── 05_KevinHe.txt ├── 05__KevinHe.txt ├── 1-nicefuture.txt ├── 10_O-Ra2f.py ├── 10_O_Ra2f ├── 10_RA2F ├── 15 - 活跃time:101.txt ├── 15 - 活跃time:120.txt ├── 15 - 活跃time:76 ├── 16_klgentle_smile_3w.txt ├── 16_klgentle_smile_4w.txt ├── 18_Decadence.txt ├── 19_大船_0609.txt ├── 19_大船_0616.txt ├── 19大船.txt ├── 1nicefuture.txt ├── 2-lionfly.txt ├── 20_Painting、时光.txt ├── 22_黄有才_1.txt ├── 22_黄有才_第三周.txt ├── 22_黄有才_第四周.txt ├── 22k.txt ├── 23令狐冲.java ├── 23令狐冲_0616.java ├── 24-北极熊.txt ├── 27_Torres@Ng ├── 28_dev_bin.txt ├── 2_lionfly.txt ├── 30_bigfish.txt ├── 39_Abel.txt ├── 39_Abel_6月8日.txt ├── 39_Abel_Alan.txt ├── 4_秩秩斯干.txt ├── 6-hebust-fengyu_0004.寻找两个有序数组的中位数.txt ├── 6-hebust-fengyu_0075_Sort_Colors.txt ├── 6-hebust-fengyu_0101_Symmetric_Tree.txt ├── ALOHA.txt ├── dev_bin_28-3.txt ├── dev_bin_28.txt ├── jasonvv_35_0028.txt ├── jasonvv_35_0035.txt ├── jasonvv_35_0058.txt ├── liangxu.txt ├── qingcaibaiyutang17_2.txt ├── qingcaibaiyutang17_3.txt ├── qingcaibaiyutang17_4.txt ├── tyrone2497-31.txt ├── washing_add_0007 ├── 小恒_3_581题.txt ├── 小恒_3_650题.txt ├── 小恒_3_717题.txt ├── 小恒_3_78题.txt ├── 第三周_25pg_1.txt ├── 第三周_25pg_2.txt ├── 第二周_25pg.txt └── 第四周_25pg.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vscode/ 3 | output/ 4 | out/ 5 | */.idea/ 6 | *.pyc 7 | *.pyo 8 | *.pyd 9 | */build/ 10 | */node_modules/ 11 | */output/ 12 | */out/ 13 | */target/ 14 | *.class 15 | *.jar 16 | *.o 17 | *.iml 18 | .ipynb_checkpoints/ 19 | .DS_Store 20 | */.DS_Store 21 | *.out 22 | **/torresng_rust/debug 23 | .ccls 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LeetCode 2 | 一起来刷LeetCode,一起学习,一起提高!Let's LeetCode together! 3 | 4 | ### 刷题规则: 5 | 1. 请将自己的提交放在对应的题号目录下,以自己的微信昵称命名,如:liangxu.c; 6 | 7 | 2. 如果题号没有对应的目录,请自己新建一个。一定要按格式来啊,一堆乱七八糟的格式让良许操碎了心…… 8 | 格式为:0002_Add_Two_Numbers,先是题号,再跟上题目,题号与题目,以及题目单词间以下划线间隔; 9 | 10 | 3. 题目做完之后,请在submittors目录下建立一个以微信昵称命名的文件,内容是你的commitID。这个步骤一周只需做一次即可,因为一周只要求提交一次。当然自己的题解鼓励多多提交,这样既可以提高自己,也可以帮助别人。 11 | 12 | 4. 请为本项目点 star ,让更多人看到,让更多人一起参与,人越多越有氛围! 13 | 14 | 5. 想要一起加入刷题的朋友,请在公众号「**良许Linux**」内回复 **leetcode** ,获取入群方式。 15 | 16 | ![](https://i.loli.net/2019/02/24/5c720ddaa110b.jpg) 17 | -------------------------------------------------------------------------------- /problems/0001_Two_Sum/0001_Two_Sum.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Note: The returned array must be malloced, assume caller calls free(). 3 | */ 4 | int* twoSum(int* nums, int numsSize, int target) { 5 | int i = 0, j = 0; 6 | int n = numsSize; 7 | int* result = NULL; 8 | for(i = 0; i < n; i++) { 9 | for(j = i + 1; j < n; j++) { 10 | if(target == nums[i] + nums[j]) { 11 | result = (int*)malloc(sizeof(int) * 2); 12 | result[0] = i; 13 | result[1] = j; 14 | return result; 15 | } 16 | } 17 | } 18 | return result; 19 | 20 | } -------------------------------------------------------------------------------- /problems/0001_Two_Sum/0001_Two_Sum.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def twoSum(self, nums, target): 3 | dicNum={} 4 | numLen=len(nums) 5 | for i in range(numLen): 6 | num=target-nums[i] 7 | if dicNum.get(num)!=None: 8 | return [dicNum[num],i] 9 | else: 10 | dicNum[nums[i]]=i -------------------------------------------------------------------------------- /problems/0001_Two_Sum/Bruce0001.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def twoSum(self, nums, target): 3 | """ 4 | :type nums: List[int] 5 | :type target: int 6 | :rtype: List[int] 7 | """ 8 | input = {} 9 | for index, num in enumerate(nums): 10 | other = target - num 11 | if other in input: 12 | return [input[other], index] 13 | else: 14 | input[num] = index 15 | return [] 16 | 17 | -------------------------------------------------------------------------------- /problems/0001_Two_Sum/MQQM.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 题目: 3 | 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 4 | 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 5 | */ 6 | class Solution { 7 | public: 8 | vector twoSum(vector& nums, int target) { 9 | int len=nums.size(); 10 | for(int i=0; i<=len-2; i++){ 11 | for(int j=i+1; j<=len-1; j++){ 12 | if(nums[i]+nums[j] == target){ 13 | return vector{i,j}; 14 | } 15 | } 16 | } 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /problems/0001_Two_Sum/MQQM2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 题目: 3 | 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 4 | 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 5 | */ 6 | class Solution { 7 | public: 8 | vector twoSum(vector& nums, int target) { 9 | map m; 10 | for(int i=0; i::iterator it=m.find(dif); 13 | if(it != m.end()){ 14 | return vector{i,it->second}; 15 | } 16 | m.insert({nums[i],i}); 17 | } 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /problems/0001_Two_Sum/Test0001.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0001_Two_Sum/Test0001.java -------------------------------------------------------------------------------- /problems/0001_Two_Sum/WhoAmI.c: -------------------------------------------------------------------------------- 1 | int* twoSum(int* nums, int numsSize, int target) 2 | { 3 | int *a; 4 | a = (int*)malloc(sizeof(int)*2); 5 | 6 | for (int i = 0; i < numsSize - 1; i++) 7 | { 8 | for (int j = i+1; j < numsSize; j++) 9 | { 10 | if (nums[i] + nums[j] == target) 11 | { 12 | a[0] = i; 13 | a[1] = j; 14 | return a; 15 | } 16 | } 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /problems/0001_Two_Sum/dahai.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number[]} nums 3 | * @param {number} target 4 | * @return {number[]} 5 | */ 6 | var twoSum = function(nums, target) { 7 | for( let i = 0,l = nums.length; i < l; i++){ 8 | for(let j = 0; j< l; j ++){ 9 | if(target - nums[i] === nums[j]){ 10 | return [i,j]; 11 | } 12 | } 13 | } 14 | return []; 15 | }; 16 | //测试代码 17 | let nums = [2, 7, 11, 15], target = 9; 18 | console.log(twoSum(nums, target)); 19 | -------------------------------------------------------------------------------- /problems/0001_Two_Sum/dev_bin.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | nums := []int{2, 7, 11, 15} 9 | result := twoSum(nums, 9) 10 | if len(result) == 2 { 11 | fmt.Println(result) 12 | } else { 13 | fmt.Println("没有找到") 14 | } 15 | } 16 | 17 | // twosum ... 18 | func twoSum(nums []int, target int) []int { 19 | numsMap := make(map[int]int) 20 | for key, value := range nums { 21 | othter := target - value 22 | if index, ok := numsMap[othter]; ok { 23 | return []int{index, key} 24 | } 25 | numsMap[value] = key 26 | } 27 | return []int{} 28 | } 29 | -------------------------------------------------------------------------------- /problems/0001_Two_Sum/hainingbaby.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector twoSum(vector& nums, int target) { 4 | // 时间复杂度O(n^2) 5 | for(int i = 0; i twoSum(vector& nums, int target) { 7 | unordered_map hash; 8 | for(int i=0;i{i,hash[target-nums[i]]}; 14 | } 15 | } 16 | return vector(0); 17 | } 18 | }; -------------------------------------------------------------------------------- /problems/0001_Two_Sum/solution.py: -------------------------------------------------------------------------------- 1 | # 主要使用hash表的快速查找特性 2 | # 把双重循环转化成单层循环 3 | 4 | class Solution: 5 | def twoSum(self, nums, target): 6 | num_dict = {nums[i]: i for i in range(nums)} 7 | 8 | for i in range(len(nums)): 9 | component = target - nums[i] 10 | if component in num_dict and num_dict[component] != i: 11 | return [i, num_dict[component]] 12 | -------------------------------------------------------------------------------- /problems/0001_Two_Sum/two_sum.py: -------------------------------------------------------------------------------- 1 | # 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 2 | # 3 | # 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素 4 | class Solution: 5 | def twoSum(self, nums, target): 6 | d=dict() 7 | for i, num in enumerate(nums): 8 | tmp = target - num 9 | if tmp in d: 10 | return [i, d[tmp]] 11 | d[num] = i -------------------------------------------------------------------------------- /problems/0001_Two_Sum/twosum: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int[] twoSum(int[] nums, int target) { 3 | int i = 0 ; 4 | int j = 0 ; 5 | int[] = a[]; 6 | for(i = 0,i < nums.length,i++ ){ 7 | for(j = 0,j < nums.length,j++){ 8 | if(nums[i] + nums[j] == target)&&(i != j) 9 | return [i,j] 10 | } 11 | } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /problems/0001_Two_Sum/washing.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def twoSum(self, nums, target): 3 | """ 4 | :type nums: List[int] 5 | :type target: int 6 | :rtype: List[int] 7 | """ 8 | dic = {} 9 | for i in range(len(nums)): 10 | if target - nums[i] in dic.keys(): 11 | return [dic[target - nums[i]], i] 12 | dic[nums[i]] = i 13 | 14 | 15 | if __name__ == '__main__': 16 | haha = Solution() 17 | print(haha.twoSum([1, 2, 3, 4, 5, 6, 7], 11)) 18 | -------------------------------------------------------------------------------- /problems/0001_Two_Sum/xifenghuyang.java: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Created with IntelliJ IDEA. 4 | * Description: 5 | * 6 | * @author: xifenghuyang 7 | * @Date: 2018-11-11 8 | * @Time: 15:03 9 | */ 10 | 11 | class Solution { 12 | public int[] twoSum(int[] nums, int target) { 13 | for(int i=0; i map = new HashMap<>(); 4 | for(int i = 0; i < nums.length; i++){ 5 | if(map.containsKey(nums[i])){ 6 | return new int[]{map.get(nums[i]),i}; 7 | }else{ 8 | map.put(target-nums[i],i); 9 | } 10 | } 11 | return null; 12 | 13 | } 14 | } -------------------------------------------------------------------------------- /problems/0001_Two_Sum/yulonghe.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Note: The returned array must be malloced, assume caller calls free(). 3 | */ 4 | int* twoSum(int* nums, int numsSize, int target) { 5 | int i, j; 6 | int *p; 7 | 8 | p = (int *)malloc(2*sizeof(int)); 9 | for(i=0; i i; j--){ 6 | if (nums[i] + nums[j] == target){ 7 | return new int[]{i,j}; 8 | } 9 | } 10 | } 11 | return new int[]{}; 12 | } 13 | } -------------------------------------------------------------------------------- /problems/0001_Two_Sum/zhaoqianxilan.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0001_Two_Sum/zhaoqianxilan.cpp -------------------------------------------------------------------------------- /problems/0001_Two_Sum/抗压斑马线.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Runtime: 132 ms, faster than 36.84% of C++ online submissions for Two Sum. 3 | Memory Usage: 9.3 MB, less than 84.28% of C++ online submissions for Two Sum. 4 | */ 5 | class Solution { 6 | public: 7 | vector twoSum(vector& nums, int target) { 8 | for (int i = 0; i < nums.size(); i++) 9 | for(int j = i + 1; j < nums.size(); j++) 10 | if (nums[i] + nums[j] == target) 11 | return vector{i,j}; 12 | 13 | return vector{0,0}; 14 | } 15 | }; -------------------------------------------------------------------------------- /problems/0001_Two_Sum/活跃time.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int[] twoSum(int[] nums, int target) { 3 | for(int i = 0; i < nums.length; i++){ 4 | for(int j = i + 1; j < nums.length; j++){ 5 | if(nums[i] + nums[j] == target) return new int[]{i, j}; 6 | } 7 | } 8 | return null; 9 | } 10 | } -------------------------------------------------------------------------------- /problems/0002_Add_Two_Numbers/Plummy.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0002_Add_Two_Numbers/Plummy.java -------------------------------------------------------------------------------- /problems/0002_Add_Two_Numbers/dahai.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for singly-linked list. 3 | * function ListNode(val) { 4 | * this.val = val; 5 | * this.next = null; 6 | * } 7 | */ 8 | /** 9 | * @param {ListNode} l1 10 | * @param {ListNode} l2 11 | * @return {ListNode} 12 | */ 13 | var addTwoNumbers = function(l1, l2) { 14 | (Number(l1.reverse().join(''))+Number(l2.reverse().join(''))).toString().split('').reverse().join('->') 15 | }; 16 | addTwoNumbers([2,4,3],[5,6,4]); 17 | -------------------------------------------------------------------------------- /problems/0002_Add_Two_Numbers/liangxu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0002_Add_Two_Numbers/liangxu.c -------------------------------------------------------------------------------- /problems/0002_Add_Two_Numbers/nicefuture.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0002_Add_Two_Numbers/nicefuture.c -------------------------------------------------------------------------------- /problems/0002_Add_Two_Numbers/pingtou.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by pingtou on 18-11-8. 3 | // 4 | #include 5 | #include 6 | int HammingDistance(int x,int y) 7 | { 8 | int num = 0; 9 | x = x ^ y; 10 | while(x) 11 | { 12 | if(x & 1) 13 | { 14 | num++; 15 | } 16 | x = x>>1; 17 | } 18 | return num; 19 | } 20 | 21 | int main(int argc,char *argv[]){ 22 | int x=atoi(argv[1]),y=atoi(argv[2]); 23 | std::cout << HammingDistance(x,y) << std::endl; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /problems/0002_Add_Two_Numbers/辉.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0002_Add_Two_Numbers/辉.c -------------------------------------------------------------------------------- /problems/0003_Longest_Substring_Without_Repeating_Characters/jacklynd.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int lengthOfLongestSubstring(string s) { 4 | vector m(128, -1); 5 | int res = 0, left = -1; 6 | for (int i = 0; i < s.size(); ++i) { 7 | left = max(left, m[s[i]]); 8 | m[s[i]] = i; 9 | res = max(res, i - left); 10 | } 11 | return res; 12 | } 13 | }; -------------------------------------------------------------------------------- /problems/0003_Longest_Substring_Without_Repeating_Characters/liangxu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0003_Longest_Substring_Without_Repeating_Characters/liangxu.c -------------------------------------------------------------------------------- /problems/0003_Longest_Substring_Without_Repeating_Characters/nicefuture.c: -------------------------------------------------------------------------------- 1 | int lengthOfLongestSubstring(char* s) { 2 | int exist[1000], len = 0; 3 | memset(exist, 0, sizeof(exist)); 4 | char *p = s, *q = s; 5 | 6 | while (*q != '\0') { 7 | if (exist[*q]) { 8 | exist[*p] = 0; 9 | p++; 10 | } else { 11 | exist[*q] += 1; 12 | // putchar(*q); 13 | q++; 14 | len = len > (q - p) ? len : (q-p); 15 | // printf(" %d\n", len); 16 | } 17 | } 18 | return len; 19 | } 20 | -------------------------------------------------------------------------------- /problems/0003_Longest_Substring_Without_Repeating_Characters/wanxu_pursue_0003.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0003_Longest_Substring_Without_Repeating_Characters/wanxu_pursue_0003.java -------------------------------------------------------------------------------- /problems/0003_Longest_Substring_Without_Repeating_Characters/washing.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def lengthOfLongestSubstring(self, s): 3 | """ 4 | :type s: str 5 | :rtype: int 6 | """ 7 | if not s: 8 | return 0 9 | ans = 0 10 | l = s[0] 11 | for i in s: 12 | if i not in l: 13 | l += i 14 | else: 15 | ans = len(l) if ans < len(l) else ans 16 | l = l[l.find(i)+1:] + i 17 | ans = len(l) if ans < len(l) else ans 18 | return ans -------------------------------------------------------------------------------- /problems/0003_Longest_Substring_Without_Repeating_Characters/zhaoqianxilan.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0003_Longest_Substring_Without_Repeating_Characters/zhaoqianxilan.cpp -------------------------------------------------------------------------------- /problems/0003_Longest_Substring_Without_Repeating_Characters/活跃time.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0003_Longest_Substring_Without_Repeating_Characters/活跃time.java -------------------------------------------------------------------------------- /problems/0004_Median_of_Two_Sorted_Arrays/Lonecloud.java: -------------------------------------------------------------------------------- 1 | class Lonecloud { 2 | public double findMedianSortedArrays(int[] nums1, int[] nums2) { 3 | int len=nums1.length + nums2.length; 4 | int[] nums = new int[len]; 5 | System.arraycopy(nums1,0, nums, 0,nums1.length); 6 | System.arraycopy(nums2,0, nums, nums1.length, nums2.length); 7 | Arrays.sort(nums); 8 | return len%2==0?((nums[len/2]+nums[len/2-1])/2.0):nums[len/2]; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /problems/0004_Median_of_Two_Sorted_Arrays/Median of Two.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findMedianSortedArrays(self, nums1, nums2): 3 | """ 4 | :type nums1: List[int] 5 | :type nums2: List[int] 6 | :rtype: float 7 | """ 8 | nums = nums1 + nums2 9 | nums.sort() 10 | length = len(nums) 11 | medium = length//2 12 | if length%2 == 1: 13 | return nums[medium] 14 | else: 15 | return (nums[medium-1] + nums[medium])/2 16 | -------------------------------------------------------------------------------- /problems/0004_Median_of_Two_Sorted_Arrays/sanwuqiyan.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public double findMedianSortedArrays(int[] nums1, int[] nums2) { 3 | int len1 = nums1.length, len2 = nums2.length, len3 = len1+len2; 4 | int[] res = new int[len1+len2]; 5 | int j=0, index=0; 6 | for( int num : nums1 ) { 7 | while( jnums2[j] ) { 8 | res[index++] = nums2[j++]; 9 | } 10 | res[index++] = num; 11 | } 12 | for( ; jflog1||result 0: 4 | nums = str(x)[::-1] 5 | else: 6 | nums = '-' + str(-x)[::-1] 7 | if int(nums) < 2**31-1 and int(nums) > -2**31: 8 | return int(nums) 9 | else: 10 | return 0 -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/1007.cpp: -------------------------------------------------------------------------------- 1 | 2 | class Solution { 3 | public: 4 | int reverse(int x) { 5 | string s = std::to_string(x); 6 | if(s[0] == '-') 7 | std::reverse(s.begin()+1,s.end()); 8 | else 9 | std::reverse(s.begin(),s.end()); 10 | long long int temp = stoll(s); 11 | if(temp>2147483647 || temp<-2147483648) 12 | return 0; 13 | return (int)temp; 14 | } 15 | this file is added by shyshy 16 | -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/WhoAmI: -------------------------------------------------------------------------------- 1 | int reverse(int x) { 2 | int rev = 0; 3 | while (x != 0) 4 | { 5 | int pop = x % 10; 6 | x /= 10; 7 | if (rev > INT_MAX/10 || (rev == INT_MAX / 10 && pop > 7)) return 0; 8 | if (rev < INT_MIN/10 || (rev == INT_MIN / 10 && pop < -8)) return 0; 9 | rev = rev * 10 + pop; 10 | } 11 | return rev; 12 | } 13 | -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/aSimpleSolution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def reverse(self, x): 3 | """ 4 | :type x: int 5 | :rtype: int 6 | """ 7 | if x < 0: 8 | x = int(str(x)[::-1][-1] + str(x)[::-1][:-1]) 9 | else: 10 | x = int(str(x)[::-1]) 11 | x = 0 if abs(x) > 0x7FFFFFFF else x 12 | return x -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/bbj.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int reverse(int x) { 4 | int rev = 0; 5 | int MAX = 214748364; 6 | int MIN = -214748364; 7 | while (x != 0){ 8 | int pop = x % 10; 9 | x = x / 10; 10 | // avoid overflow 11 | if (rev > MAX || rev == MAX && pop > 7) 12 | return 0; 13 | if (rev < MIN || rev == MIN && pop < -8) 14 | return 0; 15 | rev = rev * 10 + pop; 16 | } 17 | return rev; 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/hainingbaby_0007_Reverse_Integer.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int reverse(int x) { 4 | int res = 0; 5 | while(x != 0){ 6 | if(res > INT_MAX/10 || res < INT_MIN/10) 7 | return 0; 8 | res = res *10 + x % 10; 9 | x /= 10; 10 | } 11 | return res; 12 | } 13 | }; -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/init6-007.txt: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int reverse(int x) 4 | { 5 | long rev = 0; 6 | while(x != 0) 7 | { 8 | rev =10 * rev + x % 10; 9 | cout << rev << endl; 10 | x /= 10; 11 | } 12 | if (rev > INT_MAX || rev < INT_MIN) 13 | return 0; 14 | else 15 | return rev; 16 | } 17 | }; -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/jacklynd.c: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int reverse(int x) { 4 | int flog1 = 0x7fffffff; 5 | int flog2 = (int)0x80000000; 6 | int rev=0; 7 | int temp; 8 | while(x!=0){ 9 | temp=x%10; 10 | x=x/10; 11 | if(rev>flog1/10||(rev==flog1/10)&& temp>7) return 0; 12 | //本题以数学方法进行屏蔽溢出情况,常见堆栈处理对于这种简单问题的适用可能耗时更长,资源耗用更多。 13 | if(rev=0; 5 | x = flag?x:-x; 6 | long long reverse_x = 0; 7 | do{ 8 | reverse_x = reverse_x*10 + x%10; 9 | x/=10; 10 | }while(x); 11 | reverse_x *= flag?1:-1; 12 | return (reverse_x<=INT_MAX && reverse_x>=INT_MIN)?reverse_x:0; 13 | } 14 | }; -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/reverse: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class reverse{ 3 | public static void main(String[] args) { 4 | // 输入一个三位数,输出它的逆序排列 5 | Scanner input=new Scanner(System.in);//创建Scanner对象 6 | System.out.println("请输入三位数:"); 7 | int score = input.nextInt();//获取用户输入成绩并保存在变量中 8 | int m = Math.abs(score); 9 | int a = m / 100; 10 | 11 | int b = (m - a * 100) / 10; 12 | int c = (m - a * 100 - b * 10); 13 | int n = c * 100 + b * 10 + a; 14 | if (score > 0) { 15 | System.out.println("输出结果为:"+n); 16 | }else { 17 | System.out .println("输出结果为:-"+n); 18 | } 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/reverse.java: -------------------------------------------------------------------------------- 1 | public class Helloworld{ 2 | public static void main(String[] args) { 3 | // 输入一个三位数,输出它的逆序排列 4 | Scanner input=new Scanner(System.in);//创建Scanner对象 5 | System.out.println("请输入三位数:"); 6 | int score = input.nextInt();//获取用户输入成绩并保存在变量中 7 | int m = Math.abs(score); 8 | int a = m / 100; 9 | 10 | int b = (m - a * 100) / 10; 11 | int c = (m - a * 100 - b * 10); 12 | int n = c * 100 + b * 10 + a; 13 | if (score > 0) { 14 | System.out.println("输出结果为:"+n); 15 | }else { 16 | System.out .println("输出结果为:-"+n); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/reverse_banana.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def reverse(self, x): 3 | x1 = int(str(abs(x))[::-1]) 4 | if x1 > 2**31: 5 | return 0 6 | else: 7 | if x < 0: 8 | return x1*-1 9 | else: 10 | return x1 -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/solution.py: -------------------------------------------------------------------------------- 1 | # 通过不断循环取余,对应的余数乘以10,然后再累加,就可以得到结果 2 | # 只不过要注意对负数的处理,同时注意数值的取值范围 3 | 4 | class Solution: 5 | def reverse(self, x): 6 | result = 0 7 | flag = -1 if x < 0 else 1 8 | x = abs(x) 9 | while x != 0: 10 | pop = x % 10 11 | x = x / 10 12 | result = result * 10 + pop 13 | result *= flag 14 | if result < - 2 ** 31 or result > 2 ** 31 -1: 15 | return 0 16 | return result 17 | -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/washing.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def reverse(self, x): 3 | """ 4 | :type x: int 5 | :rtype: int 6 | """ 7 | s = str(x) 8 | if s.startswith("-"): 9 | s = '-' + s[1:][::-1] 10 | else: 11 | s = s[::-1] 12 | 13 | ans = int(s) 14 | 15 | if -2147483648 > ans or 2147483647 < ans: 16 | ans = 0 17 | 18 | return ans -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/zero.java: -------------------------------------------------------------------------------- 1 | 2 | class Solution { 3 | public int reverse(int x) { 4 | int remainder; 5 | int result = 0; 6 | long resultCope = 0; 7 | while (x / 10 != 0){ 8 | remainder = x % 10; 9 | x = x / 10; 10 | result = result * 10 + remainder * 10; 11 | resultCope = resultCope * 10 + remainder * 10; 12 | } 13 | result += x; 14 | resultCope += x; 15 | if(resultCope != result){ 16 | return 0; 17 | } 18 | return result; 19 | } 20 | } -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/zhaoqianxilan.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0007_Reverse_Integer/zhaoqianxilan.cpp -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/zhaos.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0007_Reverse_Integer/zhaos.cpp -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/一碗机智的糖浆.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0007_Reverse_Integer/一碗机智的糖浆.java -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/活跃time.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0007_Reverse_Integer/活跃time.java -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/离线????.txt: -------------------------------------------------------------------------------- 1 | commit 38be20e5e521d51c1afd9310b1fcc8613b80d53c 2018-12-16 -------------------------------------------------------------------------------- /problems/0007_Reverse_Integer/辉.c: -------------------------------------------------------------------------------- 1 | This file is added by 2345oo5432 2 | -------------------------------------------------------------------------------- /problems/0008_String_to_Integer_atoi/1008.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0008_String_to_Integer_atoi/1008.cpp -------------------------------------------------------------------------------- /problems/0008_String_to_Integer_atoi/wanxu_pursue_0008.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0008_String_to_Integer_atoi/wanxu_pursue_0008.java -------------------------------------------------------------------------------- /problems/0008_String_to_Integer_atoi/zchaos.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0008_String_to_Integer_atoi/zchaos.cpp -------------------------------------------------------------------------------- /problems/0008_String_to_Integer_atoi/活跃time.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0008_String_to_Integer_atoi/活跃time.java -------------------------------------------------------------------------------- /problems/0009_Palindrome_Number/banana.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isPalindrome(self, x): 3 | if (x < 0 or (x % 10 == 0 and x != 0)): 4 | return False 5 | 6 | a = 0 7 | while (x > a): 8 | a = a * 10 + x % 10 9 | x = int(x / 10) 10 | return int(a / 10) == x or x == a -------------------------------------------------------------------------------- /problems/0009_Palindrome_Number/seaflower.go: -------------------------------------------------------------------------------- 1 | func isPalindrome(x int) bool { 2 | if x < 0 { 3 | return false 4 | } 5 | temp := x 6 | var x2 int 7 | for temp != 0 { 8 | pop := temp % 10 9 | temp = temp / 10 10 | x2 = x2*10 + pop 11 | } 12 | if x2 == x { 13 | return true 14 | } 15 | return false 16 | } 17 | 18 | // 先把原數字%10 在 /10 依照此步驟來反轉 -------------------------------------------------------------------------------- /problems/0009_Palindrome_Number/shouwang.c: -------------------------------------------------------------------------------- 1 | bool isPalindrome(int x) { 2 | if(x < 0) 3 | return false; 4 | /*int最大有10位*/ 5 | char bit[10] = {0}; 6 | int temp = x; 7 | int loop = 0; 8 | int pos = 0; 9 | /*将每位存储*/ 10 | for(loop = 0;0 != temp;loop++ ) 11 | { 12 | pos = temp % 10; 13 | temp = temp /10; 14 | bit[loop] = pos; 15 | } 16 | int num = loop; 17 | /*判断折半各位是否相等*/ 18 | for(loop = 0;loop < num/2;loop++) 19 | { 20 | if(bit[loop] != bit[num-loop-1]) 21 | return false; 22 | } 23 | return true; 24 | } 25 | -------------------------------------------------------------------------------- /problems/0009_Palindrome_Number/solution.py: -------------------------------------------------------------------------------- 1 | # 主要是利用python的切片操作,来实现字符串的反转 2 | 3 | class Solution: 4 | def isPalindrome(self, x): 5 | if x < 0: 6 | return False 7 | else: 8 | y = str(x)[::-1] 9 | if y == str(x): 10 | return True 11 | else: 12 | return False 13 | -------------------------------------------------------------------------------- /problems/0009_Palindrome_Number/zero.java: -------------------------------------------------------------------------------- 1 | 2 | class Solution { 3 | public int reverse(int x) { 4 | int remainder; 5 | int result = 0; 6 | long resultCope = 0; 7 | while (x / 10 != 0){ 8 | remainder = x % 10; 9 | x = x / 10; 10 | result = result * 10 + remainder * 10; 11 | resultCope = resultCope * 10 + remainder * 10; 12 | } 13 | result += x; 14 | resultCope += x; 15 | if(resultCope != result){ 16 | return 0; 17 | } 18 | return result; 19 | } 20 | } -------------------------------------------------------------------------------- /problems/0009_Palindrome_Number/一碗机智的糖浆.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0009_Palindrome_Number/一碗机智的糖浆.java -------------------------------------------------------------------------------- /problems/0010_Regular_Expression_Matching/wanxu_pursue_0010.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0010_Regular_Expression_Matching/wanxu_pursue_0010.java -------------------------------------------------------------------------------- /problems/0011_Container_With_Most_Water/MaxArea_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0011_Container_With_Most_Water/MaxArea_st.java -------------------------------------------------------------------------------- /problems/0011_Container_With_Most_Water/linlijia.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int maxArea(int[] height) { 3 | if (height == null || height.length < 2) 4 | return 0; 5 | 6 | int left = 0; 7 | int right = height.length - 1; 8 | int max = 0; 9 | 10 | while (left < right) { 11 | int t = Math.min(height[left], height[right]) * (right - left); 12 | max = max > t ? max : t; 13 | if (height[left] > height[right]) 14 | right--; 15 | else left++; 16 | } 17 | 18 | return max; 19 | } 20 | } -------------------------------------------------------------------------------- /problems/0011_Container_With_Most_Water/xiaoheng_3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | 7 | int maxArea(vector& height) { 8 | int left = 0; 9 | int right = height.size()-1; 10 | int maxarea = 0; 11 | 12 | while(left != right){ 13 | maxarea = max(min(height[left],height[right]) * (right-left) , maxarea); 14 | 15 | (height[left] < height[right]) ? ++left : --right; 16 | 17 | } 18 | return maxarea; 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /problems/0012_Integer_to_Roman/seaflower.go: -------------------------------------------------------------------------------- 1 | //IntToRoman 整數轉羅馬數字 2 | func IntToRoman(num int) string { 3 | if num <= 0 { 4 | return "" 5 | } 6 | var ans string 7 | var nums = []int{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1} 8 | var symbols = []string{"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"} 9 | for i := 0; i < len(nums); i++ { //舉例: 進來的數字 3978, 10 | for num >= nums[i] { //第一次迴圈 3978 > 1000 第二次迴圈 2978 > 1000 11 | num -= nums[i] //3978 - 1000 = 2978 2978 - 1000 = 1978 12 | ans += symbols[i] // 加一個M , 再加一個M 以此類推... 13 | } 14 | } 15 | return ans 16 | } -------------------------------------------------------------------------------- /problems/0013_Roman_to_Integer/jacklynd.c: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int romanToInt(string s) { 4 | int res = 0; 5 | unordered_map m{{'I', 1}, {'V', 5}, {'X', 10}, {'L', 50}, {'C', 100}, {'D', 500}, {'M', 1000}}; 6 | for (int i = 0; i < s.size(); ++i) { 7 | if (i == 0 || m[s[i]] <= m[s[i - 1]]) res += m[s[i]]; 8 | else res += m[s[i]] - 2 * m[s[i - 1]]; 9 | } 10 | return res; 11 | } 12 | }; -------------------------------------------------------------------------------- /problems/0013_Roman_to_Integer/lalala.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | 3 | def romanToInt(self, s): 4 | roman = {'M': 1000,'D': 500 ,'C': 100,'L': 50,'X': 10,'V': 5,'I': 1} 5 | z = 0 6 | for i in range(0, len(s) - 1): 7 | if roman[s[i]] < roman[s[i+1]]: 8 | z -= roman[s[i]] 9 | else: 10 | z += roman[s[i]] 11 | return z + roman[s[-1]] 12 | 13 | a = Solution() 14 | print(a.romanToInt("XC")) 15 | -------------------------------------------------------------------------------- /problems/0013_Roman_to_Integer/wanxu_pursue_0013.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0013_Roman_to_Integer/wanxu_pursue_0013.java -------------------------------------------------------------------------------- /problems/0014_Longest_Common_Prefix/LongestCommonPrefix.java: -------------------------------------------------------------------------------- 1 | public class Solution { 2 | public String longestCommonPrefix(String[] strs) { 3 | if (strs == null || strs.length == 0) return ""; 4 | for (int j = 0; j < strs[0].length(); ++j) { 5 | for (int i = 0; i < strs.length - 1; ++i) { 6 | if (j >= strs[i].length() || j >= strs[i + 1].length() || strs[i].charAt(j) != strs[i + 1].charAt(j)) { 7 | return strs[i].substring(0, j); 8 | } 9 | } 10 | } 11 | return strs[0]; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /problems/0014_Longest_Common_Prefix/LongestCommonPrefix_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0014_Longest_Common_Prefix/LongestCommonPrefix_st.java -------------------------------------------------------------------------------- /problems/0014_Longest_Common_Prefix/jacklynd.c: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | string longestCommonPrefix(vector& strs) { 4 | if (strs.empty()) return ""; 5 | sort(strs.begin(), strs.end()); 6 | int i = 0, len = min(strs[0].size(), strs.back().size()); 7 | while (i < len && strs[0][i] == strs.back()[i]) ++i; 8 | return strs[0].substr(0, i); 9 | } 10 | }; -------------------------------------------------------------------------------- /problems/0014_Longest_Common_Prefix/wanxu_pursue_0014.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0014_Longest_Common_Prefix/wanxu_pursue_0014.java -------------------------------------------------------------------------------- /problems/0014_Longest_Common_Prefix/一碗机智的糖浆.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0014_Longest_Common_Prefix/一碗机智的糖浆.java -------------------------------------------------------------------------------- /problems/0015_3Sum/0153Sum.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0015_3Sum/0153Sum.cpp -------------------------------------------------------------------------------- /problems/0015_3Sum/ThreeSum_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0015_3Sum/ThreeSum_st.java -------------------------------------------------------------------------------- /problems/0015_3Sum/wanxu_pursue_0015.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0015_3Sum/wanxu_pursue_0015.java -------------------------------------------------------------------------------- /problems/0016_3Sum_Closest/0016_3Sum_Closest.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0016_3Sum_Closest/0016_3Sum_Closest.txt -------------------------------------------------------------------------------- /problems/0016_3Sum_Closest/ThreeSumClosest_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0016_3Sum_Closest/ThreeSumClosest_st.java -------------------------------------------------------------------------------- /problems/0016_3Sum_Closest/wanxu_pursue_0016.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0016_3Sum_Closest/wanxu_pursue_0016.java -------------------------------------------------------------------------------- /problems/0019_Remove_Nth_Node_From_End_of_List/Leetcode19.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0019_Remove_Nth_Node_From_End_of_List/Leetcode19.java -------------------------------------------------------------------------------- /problems/0019_Remove_Nth_Node_From_End_of_List/RemoveNthFromEnd.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0019_Remove_Nth_Node_From_End_of_List/RemoveNthFromEnd.java -------------------------------------------------------------------------------- /problems/0019_Remove_Nth_Node_From_End_of_List/removeNthFromEnd.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0019_Remove_Nth_Node_From_End_of_List/removeNthFromEnd.cpp -------------------------------------------------------------------------------- /problems/0019_Remove_Nth_Node_From_End_of_List/一碗机智的糖浆.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0019_Remove_Nth_Node_From_End_of_List/一碗机智的糖浆.java -------------------------------------------------------------------------------- /problems/0020_Valid_Parentheses/Adai.java: -------------------------------------------------------------------------------- 1 | import java.util.Stack; 2 | 3 | public class ValidParentheses { 4 | public boolean isValid(String s) { 5 | Stack stack = new Stack(); 6 | for (char c : s.toCharArray()) { 7 | if (c == '(') 8 | stack.push(')'); 9 | else if (c == '{') 10 | stack.push('}'); 11 | else if (c == '[') 12 | stack.push(']'); 13 | else if (stack.isEmpty() || stack.pop() != c) 14 | return false; 15 | } 16 | return stack.isEmpty(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /problems/0020_Valid_Parentheses/Bruce0020.py: -------------------------------------------------------------------------------- 1 | # 第二十题 2 | 3 | # Solution one in python 4 | 5 | # 下述内容有问题。需要更改 6 | 7 | class Solution: 8 | def isValid(self, s): 9 | stack = [] 10 | dict = {"]":"[","{":"}",")":"("} 11 | for char in s: 12 | if char in dict.values(): 13 | stack.append(char) 14 | elif char in dict.keys(): 15 | if stack == [] or dict[char] != stack.pop(): 16 | return False 17 | else: 18 | return False 19 | return stack == [] 20 | 21 | 22 | # Solution Two in java 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /problems/0020_Valid_Parentheses/IsValid_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0020_Valid_Parentheses/IsValid_st.java -------------------------------------------------------------------------------- /problems/0020_Valid_Parentheses/h_有效的括号.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0020_Valid_Parentheses/h_有效的括号.cpp -------------------------------------------------------------------------------- /problems/0020_Valid_Parentheses/isValid.py: -------------------------------------------------------------------------------- 1 | # 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。 2 | # 3 | # 有效字符串需满足: 4 | # 5 | # 左括号必须用相同类型的右括号闭合。 6 | # 左括号必须以正确的顺序闭合。 7 | # 注意空字符串可被认为是有效字符串。 8 | 9 | class Solution: 10 | def isValid(self, s: str) -> bool: 11 | while ('()' in s or '[]' in s or '{}' in s): 12 | s = s.replace('()', '').replace('[]', '').replace('{}', '') 13 | 14 | return s == '' -------------------------------------------------------------------------------- /problems/0020_Valid_Parentheses/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isValid(self, s): 3 | if not s: 4 | return True 5 | stack = [] 6 | for c in s: 7 | if (c == '(') or (c == '{') or (c == ']'): 8 | stack.append(c) 9 | else: 10 | if not stack: 11 | return False 12 | top = stack.pop() 13 | if top == '(' and c != ')': 14 | return False 15 | if top == '{' and c != '}': 16 | return False 17 | if top == '[' and c != ']': 18 | return False 19 | return not stack 20 | -------------------------------------------------------------------------------- /problems/0020_Valid_Parentheses/wanxu_pursue_0020.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0020_Valid_Parentheses/wanxu_pursue_0020.java -------------------------------------------------------------------------------- /problems/0021_Merge_Two_Sorted_Lists/Bruce0021.py: -------------------------------------------------------------------------------- 1 | # 21题,混合2链表并排序 2 | class Solution: 3 | def mergeTwoLists(self, a, b): 4 | if not a or b and a.val > b.val: 5 | a, b = b, a 6 | if a: 7 | a.next = self.mergeTwoLists(a.next, b) 8 | return a 9 | 10 | """ 11 | # solution 2 还没看懂啊!20190313 12 | class Solution: 13 | def mergeTwoLists(self, a, b): 14 | if a and b: 15 | if a.val > b.val: 16 | a, b = b, a 17 | a.next = self.mergeTwoLists(a.next, b) 18 | return a or b 19 | 20 | """ 21 | -------------------------------------------------------------------------------- /problems/0021_Merge_Two_Sorted_Lists/MergeTwoLists_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0021_Merge_Two_Sorted_Lists/MergeTwoLists_st.java -------------------------------------------------------------------------------- /problems/0021_Merge_Two_Sorted_Lists/MergeTwoSortedLists.java: -------------------------------------------------------------------------------- 1 | public class MergeTwoSortedLists { 2 | 3 | public ListNode mergeTwoLists(ListNode l1, ListNode l2) { 4 | if (l1 == null) return l2; 5 | if (l2 == null) return l1; 6 | ListNode head = (l1.val < l2.val) ? l1 : l2; 7 | ListNode nonhead = (l1.val < l2.val) ? l2 : l1; 8 | head.next = mergeTwoLists(head.next, nonhead); 9 | return head; 10 | } 11 | } 12 | This file is added by Chenghui 13 | -------------------------------------------------------------------------------- /problems/0021_Merge_Two_Sorted_Lists/wanxu_pursue_0021.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0021_Merge_Two_Sorted_Lists/wanxu_pursue_0021.java -------------------------------------------------------------------------------- /problems/0022_Generate_Parentheses/wanxu_pursue_0022.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0022_Generate_Parentheses/wanxu_pursue_0022.java -------------------------------------------------------------------------------- /problems/0023_mergeKLists/mergeKLists.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0023_mergeKLists/mergeKLists.cpp -------------------------------------------------------------------------------- /problems/0024_Swap_Nodes_in_Pairs/swapPairs.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0024_Swap_Nodes_in_Pairs/swapPairs.cpp -------------------------------------------------------------------------------- /problems/0024_Swap_Nodes_in_Pairs/wkh_swap-nodes-in-pairs.py: -------------------------------------------------------------------------------- 1 | 2 | #24.swap-nodes-in-pairs 3 | #微信:HH 4 | class Solution: 5 | def swapPairs(self, head): 6 | """ 7 | :type head: ListNode 8 | :rtype: ListNode 9 | """ 10 | pre, pre.next = self, head 11 | while pre.next and pre.next.next: 12 | a = pre.next 13 | b = a.next 14 | pre.next, b.next, a.next = b, a, b.next 15 | pre = a 16 | return self.next 17 | 18 | -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/26_Rocky's_solution.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0026_Remove_Duplicates_from_Sorted_Array/26_Rocky's_solution.c -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/26_remove_duplicates_from_sorted_array.c: -------------------------------------------------------------------------------- 1 | /** 2 | * LeetCode The 26th problem :remove-duplicates-from-sorted-array 3 | * Auth:Barlowwang 4 | * Date:2018-10-08 5 | **/ 6 | int removeDuplicates(int *nums, int numsSize) 7 | { 8 | if (numsSize == 0) 9 | return 0; 10 | int current = 0; 11 | for (int i = 0; i < numsSize; ++i) 12 | { 13 | if (nums[i] != nums[current]) 14 | { 15 | nums[++current] = nums[i]; 16 | } 17 | } 18 | return current + 1; 19 | } -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/ActivityTime.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int removeDuplicates(int[] nums) { 3 | 4 | if(nums.length == 0) return 0; 5 | if(nums.length == 1) return 1; 6 | 7 | int point = 1; 8 | 9 | for(int i = 1; i < nums.length; i++){ 10 | if(nums[i] != nums[i-1]){ 11 | nums[point++] = nums[i]; 12 | } 13 | } 14 | 15 | return point; 16 | } 17 | } -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/Bruce0026.cpp: -------------------------------------------------------------------------------- 1 | 2 | //第26题。 3 | //用的快慢指针的方法来完成的。 4 | 5 | 6 | class Solution { 7 | public: 8 | int removeDuplicates(vector& nums) { 9 | if (nums.empty()) return 0; 10 | int pre = 0, cur = 0, n = nums.size(); 11 | while (cur < n) { 12 | if (nums[pre] == nums[cur]) ++cur; 13 | else nums[++pre] = nums[cur++]; 14 | } 15 | } 16 | return pre + 1; 17 | }; 18 | -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/ElonPython3.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def removeDuplicates(self, nums): 3 | """ 4 | :type nums: List[int] 5 | :rtype: int 6 | """ 7 | if len(nums)<2: 8 | return len(nums) 9 | diff = 1 10 | for index in range(1,len(nums)): 11 | if nums[index] !=nums[index-1]: 12 | nums[diff] = nums[index] 13 | diff = diff + 1 14 | return diff 15 | -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/P26.py: -------------------------------------------------------------------------------- 1 | #python3 emmmleetcode这个东西就只要实现的类的方法,其他的并没有构建,额,懒一点就这样写了 2 | class Solution: 3 | def removeDuplicates(self, nums): 4 | """ 5 | :type nums: List[int] 6 | :rtype: int 7 | """ 8 | length = len(nums) 9 | if length < 2: 10 | return length 11 | cur = 0 12 | for i in range(1, length): 13 | if nums[i] != nums[cur]: 14 | cur += 1 15 | nums[cur] = nums[i] 16 | return cur + 1 17 | -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/RemoveDuplicates.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0026_Remove_Duplicates_from_Sorted_Array/RemoveDuplicates.java -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/Solution_26.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int removeDuplicates(int[] nums) { 3 | //如果数组长度为0,直接返回 4 | if(nums.length==0)return 0; 5 | int i=0; 6 | for(int n:nums){ 7 | //因为数组已经排序过了,所以判断是否大于前一个即可 8 | if(i==0||n>nums[i-1]) 9 | nums[i++]=n; 10 | } 11 | return i; 12 | } 13 | } -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/chenghui.java: -------------------------------------------------------------------------------- 1 | public class Remove_Duplicates_from_Sorted_Array { 2 | public int removeDuplicates(int[] A) { 3 | if(A.length == 0 || A == null) 4 | return 0; 5 | 6 | int len = 1; 7 | for(int index = 1; index < A.length; index++){ 8 | if(A[index] != A[index-1]){ 9 | if(A[index] != A[len]) 10 | A[len] = A[index]; 11 | len++; 12 | } 13 | } 14 | return len; 15 | } 16 | }This file is added by Chenghui 17 | -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/init6-26.txt: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int removeDuplicates(vector& nums) { 4 | int pos = 0; 5 | //cout << nums[pos-1]; 6 | for(int i = 0; i < nums.size(); i++) 7 | { 8 | cout << i; 9 | if(i==0 || nums[i]!= nums[pos-1]) 10 | nums[pos++] = nums[i]; 11 | } 12 | return pos; 13 | } 14 | }; -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/liangxu.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int removeDuplicates(int* nums, int numsSize) 4 | { 5 | int pos = 0; 6 | int i = 0; 7 | 8 | if (nums == NULL || numsSize <= 0) 9 | return -1; 10 | 11 | for (i = 1; i < numsSize; i++) { 12 | if (nums[i] != nums[pos]) 13 | nums[++pos] = nums[i]; 14 | } 15 | return ++pos; 16 | } 17 | 18 | 19 | int main() 20 | { 21 | int nums[] = {0, 0, 1, 2, 2, 4, 5}; 22 | printf("result is: %d\n", removeDuplicates(nums, sizeof(nums)/sizeof(int))); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/nian.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def removeDuplicates(self, A): 3 | if A == []: 4 | return 0 5 | low = 0 6 | for i in range(1, len(A)): 7 | if A[low] != A[i]: 8 | low += 1 9 | A[low] = A[i] 10 | 11 | return low + 1 12 | 13 | -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/removeDuplicates.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int removeDuplicates(vector& nums) { 4 | 5 | int len = nums.size(); 6 | if(len < 1)return 0; 7 | int i = 0,j=1; 8 | while(i < len && j < len) 9 | { 10 | if(nums[i]==nums[j]) 11 | { 12 | j++; 13 | } 14 | else 15 | { 16 | nums[++i] = nums[j]; 17 | } 18 | } 19 | return i+1; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/reowst.c: -------------------------------------------------------------------------------- 1 | #include 2 | int RemoveDuplicates(int arr[],int n) 3 | { 4 | int i=0,j=0; 5 | for(;j nums[index]: 12 | index += 1 13 | nums[index] = num 14 | 15 | return index 16 | -------------------------------------------------------------------------------- /problems/0026_Remove_Duplicates_from_Sorted_Array/zchaos.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0026_Remove_Duplicates_from_Sorted_Array/zchaos.cpp -------------------------------------------------------------------------------- /problems/0027_Remove_Element/027_Remove_Element.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def removeElement(self, nums, val): 3 | l = len(nums) 4 | result = l 5 | j=0 6 | for i in range(l): 7 | if(val != nums[i]): 8 | temp = nums[i] 9 | nums[i] = nums[j] 10 | nums[j] = temp 11 | j+=1 12 | else: 13 | result-=1 14 | return result 15 | -------------------------------------------------------------------------------- /problems/0027_Remove_Element/ActivityTime.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int removeElement(int[] nums, int val) { 3 | 4 | int point = 0; 5 | 6 | for(int i = 0; i < nums.length; i++){ 7 | if(nums[i] != val){ 8 | nums[point++] = nums[i]; 9 | } 10 | } 11 | 12 | return point; 13 | } 14 | } -------------------------------------------------------------------------------- /problems/0027_Remove_Element/Bruce0027.cpp: -------------------------------------------------------------------------------- 1 | // 第27题 移除重复的元素 2 | // 这里判断数组的i号元素是不是要删除的,是的话, 计数, 3 | // 然后将其重新赋值给这个数组咯! 4 | 5 | class Solution { 6 | public: 7 | int removeElement(vector& nums, int val) { 8 | int cnt =0; 9 | for(int i = 0; i < nums.size(); i++){ 10 | if(nums[i] == val) 11 | cnt++; 12 | else 13 | nums[i - cnt] = nums[i]; 14 | } 15 | return nums.size()-cnt; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /problems/0027_Remove_Element/ElonPython3.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def removeElement(self, nums, val): 3 | """ 4 | :type nums: List[int] 5 | :type val: int 6 | :rtype: int 7 | """ 8 | dif = 0 9 | for i in range(len(nums)): 10 | if nums[i]!=val: 11 | nums[dif],nums[i] = nums[i],nums[dif] 12 | dif = dif +1 13 | return dif 14 | 15 | -------------------------------------------------------------------------------- /problems/0027_Remove_Element/RemoveElement_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0027_Remove_Element/RemoveElement_st.java -------------------------------------------------------------------------------- /problems/0027_Remove_Element/Remove_Element4.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int removeElement(vector& nums, int val) { 4 | int count = 0; 5 | for(int i = 0;i < nums.size() - count;i++){ 6 | if(nums[i] == val){ 7 | count++; //记录移除元素个数 8 | nums[i] = nums[nums.size() - count]; //最后一个元素替换当前位置的元素 9 | i--; //移除一个元素,长度减1; 10 | } 11 | } 12 | return nums.size() - count; 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /problems/0027_Remove_Element/nicefuture.c: -------------------------------------------------------------------------------- 1 | int removeElement(int* nums, int numsSize, int val) { 2 | for (int i=0; i& nums, int val) { 4 | int index = 0; 5 | for(int i=0;i &num) { 4 | int i, j, n = num.size(); 5 | for (i = n - 2; i >= 0; --i) { 6 | if (num[i + 1] > num[i]) { 7 | for (j = n - 1; j > i; --j) { 8 | if (num[j] > num[i]) break; 9 | } 10 | swap(num[i], num[j]); 11 | reverse(num.begin() + i + 1, num.end()); 12 | return; 13 | } 14 | } 15 | reverse(num.begin(), num.end()); 16 | } 17 | }; -------------------------------------------------------------------------------- /problems/0035_Search_Insert_Position/aSimpleSolution.cpp: -------------------------------------------------------------------------------- 1 | int searchInsert(vector& nums, int target) { 2 | int i=0; 3 | for(;i=target) return i; 5 | return i; 6 | } -------------------------------------------------------------------------------- /problems/0035_Search_Insert_Position/jasonvv0035.php: -------------------------------------------------------------------------------- 1 | class Solution { 2 | 3 | /** 4 | * @param Integer[] $nums 5 | * @param Integer $target 6 | * @return Integer 7 | */ 8 | function searchInsert($nums, $target) { 9 | $count = count($nums); 10 | if ($count == 0) return 0; 11 | if ($target > end($nums)) return $count; 12 | for ($i = 0; $i < $count; $i++) { 13 | if ($nums[$i] >= $target) { 14 | return $i; 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /problems/0035_Search_Insert_Position/nicefuture.c: -------------------------------------------------------------------------------- 1 | int searchInsert(int* nums, int numsSize, int target) { 2 | int lower = 0, ceiling = numsSize-1; 3 | while (lower <= ceiling) { 4 | int middle = (lower+ceiling) / 2; 5 | if (target < nums[middle]) { 6 | ceiling = middle - 1; 7 | } else if (target > nums[middle]) { 8 | lower = middle + 1; 9 | } else { 10 | return middle; 11 | } 12 | } 13 | return ceiling + 1; 14 | } 15 | -------------------------------------------------------------------------------- /problems/0038_Count_and_Say/Bruce0038.cpp: -------------------------------------------------------------------------------- 1 | # 这个链接很实在 2 | # https://blog.csdn.net/yinyanting1/article/details/56672961 3 | 4 | public int searchInsert(int[] A, int target){ 5 | int low = 0, high = A.length-1; 6 | while(low <= high){ 7 | int mid = (low + high)/2; 8 | if(A[mid] == target) return mid; 9 | else if(A[mid] > target) high = mid -1; 10 | else low = mid + 1; 11 | } 12 | return low; 13 | } 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /problems/0038_Count_and_Say/Bruce0038.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def countStr(self, s): 3 | count = 0 4 | ans = "" 5 | tmp = s[0] -------------------------------------------------------------------------------- /problems/0038_Count_and_Say/torresng.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0038_Count_and_Say/torresng.cpp -------------------------------------------------------------------------------- /problems/0041_First_Missing_Positive/nil.go: -------------------------------------------------------------------------------- 1 | package FirstMissingPositive 2 | 3 | 4 | func firstMissingPositive(nums []int) int { 5 | cnt := 1 6 | for i := 0; i < len(nums); i++ { 7 | if cnt == nums[i] { 8 | cnt ++ 9 | i = -1 10 | } 11 | } 12 | return cnt 13 | } 14 | -------------------------------------------------------------------------------- /problems/0050_Pow/4_秩秩斯干.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | double fastPow(double x, long long n) { 4 | if (n == 0) { 5 | return 1.0; 6 | } 7 | double half = fastPow(x, n / 2); 8 | if (n % 2 == 0) { 9 | return half * half; 10 | } else { 11 | return half * half * x; 12 | } 13 | } 14 | double myPow(double x, int n) { 15 | long long N = n; 16 | if (N < 0) { 17 | x = 1 / x; 18 | N = -N; 19 | } 20 | return fastPow(x, N); 21 | } 22 | }; 23 | -------------------------------------------------------------------------------- /problems/0053_Maximum_Subarray/fengdongsheng.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxSubArray(vector& nums) { 4 | vector result(nums.size()); 5 | result[0]=nums[0]; 6 | for(int i=1;i0) 8 | result[i]=nums[i]+result[i-1]; 9 | else 10 | result[i]=nums[i]; 11 | } 12 | return *max_element(result.begin(),result.end());//max_element返回的是迭代器,需要取值操作以匹配返回类型 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /problems/0053_Maximum_Subarray/linlijia.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int maxSubArray(int[] nums) { 3 | 4 | int max = nums[0]; 5 | // res[x] 表示从 0 到 x 的最大连续数组的和 6 | int[] res = new int[nums.length]; 7 | res[0] = nums[0]; 8 | 9 | for (int i = 1; i < nums.length; i++) { 10 | res[i] = Math.max(res[i - 1] + nums[i], nums[i]); 11 | max = Math.max(res[i], max); 12 | } 13 | 14 | return max; 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /problems/0053_Maximum_Subarray/nicefuture.c: -------------------------------------------------------------------------------- 1 | int maxSubArray(int* nums, int numsSize){ 2 | int result = nums[0], s = nums[0]; 3 | for (int i=1; i result) result = s; 7 | } 8 | return result; 9 | } 10 | -------------------------------------------------------------------------------- /problems/0053_Maximum_Subarray/shouwang_0053.c: -------------------------------------------------------------------------------- 1 | int maxSubArray(int* nums, int numsSize) { 2 | if(NULL == nums) 3 | return 0; 4 | int curMax = 0; 5 | int maxSum = -2147483647; 6 | int loop = 0; 7 | for(loop;loop < numsSize;loop++) 8 | { 9 | if(curMax+nums[loop] > nums[loop]) 10 | curMax = curMax+nums[loop]; 11 | else 12 | curMax = nums[loop]; 13 | if(curMax > maxSum) 14 | maxSum = curMax; 15 | } 16 | return maxSum; 17 | } 18 | -------------------------------------------------------------------------------- /problems/0053_Maximum_Subarray/石成玉.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxSubArray(vector& nums) { 4 | if(nums.size() < 1) 5 | return 0; 6 | int max_result = nums[0]; 7 | int sub_sum = nums[0]; 8 | for(int i=1; i max_result) 14 | max_result = sub_sum; 15 | } 16 | 17 | return max_result; 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /problems/0055_Jump_Game/0055nian.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def canJump(self, nums): 3 | """ 4 | :type nums: List[int] 5 | :rtype: bool 6 | """ 7 | far = 0 8 | for i in range(len(nums)): 9 | far = max(nums[i]+i,far) 10 | if(i>=far): 11 | break 12 | if(far>=len(nums)-1): 13 | return True 14 | else: 15 | return False 16 | -------------------------------------------------------------------------------- /problems/0056_Merge_Intervals/Merge_Servant.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0056_Merge_Intervals/Merge_Servant.java -------------------------------------------------------------------------------- /problems/0058_Length_of_Last_Word/0058_Length_of_Last_Word_bluesun.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def lengthOfLastWord(self, s): 3 | """ 4 | :type s: str 5 | :rtype: int 6 | """ 7 | return len(s.rstrip().split(" ")[-1]) 8 | -------------------------------------------------------------------------------- /problems/0058_Length_of_Last_Word/0058nian.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def lengthOfLastWord(self, s): 3 | """ 4 | :type s: str 5 | :rtype: int 6 | """ 7 | l = len(s) 8 | index = l-1 9 | while(index>=0 and s[index]==" "): 10 | index-=1 11 | temp = index 12 | while(index>=0 and s[index]!=" "): 13 | index-=1 14 | return temp - index 15 | -------------------------------------------------------------------------------- /problems/0058_Length_of_Last_Word/LengthOfLastWord_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0058_Length_of_Last_Word/LengthOfLastWord_st.java -------------------------------------------------------------------------------- /problems/0058_Length_of_Last_Word/Solution_58.java: -------------------------------------------------------------------------------- 1 | package leetcode_58; 2 | 3 | /** 4 | *给定一个仅包含大小写字母和空格 ' ' 的字符串,返回其最后一个单词的长度。 5 | * 如果不存在最后一个单词,请返回 0 。 6 | * 说明:一个单词是指由字母组成,但不包含任何空格的字符串。 7 | * 示例: 8 | * 输入: "Hello World" 9 | * 输出: 5 10 | */ 11 | public class Solution { 12 | public int lengthOfLastWord(String s) { 13 | //去除首尾空格,然后总长度-找到最后空格的索引在减去1(字符串从0开始)即为单词长度 14 | return s.trim().length()-s.trim().lastIndexOf(' ')-1; 15 | } 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /problems/0058_Length_of_Last_Word/jasonvv.php: -------------------------------------------------------------------------------- 1 | class Solution { 2 | function lengthOfLastWord($s) { 3 | $tem = rtrim($s); 4 | $arr = explode(' ', $tem); 5 | return strlen(end($arr)); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /problems/0058_Length_of_Last_Word/nicefuture.c: -------------------------------------------------------------------------------- 1 | int lengthOfLastWord(char* s) { 2 | int len = 0; 3 | char *c = s; 4 | 5 | while (*c != '\0') { 6 | if (*c != ' ') { 7 | len++; 8 | } else if (*c == ' ' && (*(c+1) != ' ' && *(c+1) != '\0')){ 9 | len = 0; 10 | } 11 | c++; 12 | } 13 | 14 | return len; 15 | } 16 | -------------------------------------------------------------------------------- /problems/0058_Length_of_Last_Word/peanwang.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int lengthOfLastWord(string s) { 4 | int len = 0; 5 | auto it = s.rbegin(); 6 | while (it != s.rend()) { 7 | if (*it == ' ') 8 | it++; 9 | else 10 | break; 11 | } 12 | for (; it != s.rend(); it++) { 13 | if (*it != ' ') 14 | len++; 15 | else 16 | break; 17 | } 18 | return len; 19 | } 20 | }; -------------------------------------------------------------------------------- /problems/0058_Length_of_Last_Word/zchaos.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int lengthOfLastWord(string s) { 4 | int slength=s.size(); 5 | int i=slength-1,length=0; 6 | if(s.size()==0)return 0; 7 | for(i;i>=0;i--) 8 | { 9 | if(s[i]!=' ') 10 | { 11 | break; 12 | } 13 | } 14 | for(i;s[i]!=' '&&i>=0;i--) 15 | { 16 | length++; 17 | } 18 | return length; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /problems/0066_Plus_One/ElonPython3.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def plusOne(self, digits): 3 | """ 4 | :type digits: List[int] 5 | :rtype: List[int] 6 | """ 7 | digits = digits[::-1] 8 | carry = 1 9 | for i in range(len(digits)): 10 | sums = digits[i]+carry 11 | carry ,digits[i] = sums // 10 , sums % 10 12 | if carry: 13 | digits.append(1) 14 | return digits[::-1] 15 | 16 | -------------------------------------------------------------------------------- /problems/0066_Plus_One/PlusOne_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0066_Plus_One/PlusOne_st.java -------------------------------------------------------------------------------- /problems/0069_Sqrtx/0069_Sqrtx_by_persiststudy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0069_Sqrtx/0069_Sqrtx_by_persiststudy.cpp -------------------------------------------------------------------------------- /problems/0069_Sqrtx/bbj.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int mySqrt(int x) { 4 | return int(sqrt(x)); 5 | } 6 | }; 7 | -------------------------------------------------------------------------------- /problems/0069_Sqrtx/nicefuture.c: -------------------------------------------------------------------------------- 1 | //牛顿迭代法 2 | int mySqrt(int x) { 3 | double xnn = x, xn = x; 4 | if (x == 0) return 0; 5 | do { 6 | xn = xnn; 7 | xnn = 1.0/2*xn + (x*xn)/(2*xn*xn); 8 | } while (xn-xnn > 0.00001); 9 | 10 | return (int)xnn; 11 | } 12 | 13 | //"皮一皮"法 14 | /* 15 | *int mySqrt(int x) { 16 | * return (int)sqrt(x); 17 | *} 18 | */ 19 | -------------------------------------------------------------------------------- /problems/0069_Sqrtx/peanwang.cpp: -------------------------------------------------------------------------------- 1 | 2 | class Solution { 3 | public: 4 | int mySqrt(int x) { 5 | if(x<=1) 6 | return x; 7 | int left = 0,right = x; 8 | while(left < right-1){ 9 | int mid = left+(right-left)/2; 10 | if(x/mid < mid) 11 | right = mid; 12 | else if(x/mid > mid) 13 | left = mid; 14 | else 15 | return mid; 16 | } 17 | return left; 18 | } 19 | }; -------------------------------------------------------------------------------- /problems/0070_Climbing_Stairs/0070nian.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def climbStairs(self,n): 3 | nums = [1 for i in range(n)] 4 | if(n==1): 5 | return 1 6 | nums[1] = 2 7 | for i in range(3,n+1): 8 | nums[i-1] = nums[i-2] + nums[i-3] 9 | return nums[n-1] 10 | -------------------------------------------------------------------------------- /problems/0070_Climbing_Stairs/MQQM2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 题目: 3 | 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 4 | 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 5 | 6 | 参考: 7 | https://blog.csdn.net/haimianxiaodao/article/details/52608536?utm_source=blogxgwz6 8 | */ 9 | class Solution { 10 | public: 11 | int climbStairs(int n) { 12 | int n_1 = 1; 13 | int n_2 = 0; 14 | 15 | int tmp; 16 | for(int i=1; i<=n; i++){ 17 | tmp = n_1+n_2; 18 | n_2 = n_1; 19 | n_1 = tmp; 20 | } 21 | 22 | return tmp; 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /problems/0070_Climbing_Stairs/init6.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int climbStairs(int n) { 4 | int pre = 1; 5 | int cur = 1; 6 | for(int i = 2; i <= n; i ++) 7 | { 8 | int tmp = cur; 9 | cur = pre + cur; 10 | pre = tmp; 11 | 12 | } 13 | return cur; 14 | } 15 | }; -------------------------------------------------------------------------------- /problems/0070_Climbing_Stairs/linlijia.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def climbStairs(self, n): 3 | """ 4 | :type n: int 5 | :rtype: int 6 | """ 7 | list = [1, 2]; 8 | for i in range(2, n, 1): 9 | list.append(list[i - 2] + list[i - 1]); 10 | return list[n - 1]; 11 | -------------------------------------------------------------------------------- /problems/0070_Climbing_Stairs/merwin_70.java: -------------------------------------------------------------------------------- 1 | /*递归消耗太大,这题只能用迭代*/ 2 | class Solution { 3 | public int climbStairs(int n) { 4 | if(n<=0){ 5 | return 0; 6 | } 7 | if(n<3){ 8 | return n; 9 | } 10 | int a = 1; 11 | int b = 2; 12 | for(int i=3; i<=n;i++){ 13 | int tem = a; 14 | a = b; 15 | b= tem+b; 16 | } 17 | return b; 18 | } 19 | } -------------------------------------------------------------------------------- /problems/0070_Climbing_Stairs/nicefuture.c: -------------------------------------------------------------------------------- 1 | //即斐波那契数列 2 | int climbStairs(int n) { 3 | int a = 0, b = 1, i = 0; 4 | while (i < n) { 5 | int s = a + b; 6 | a = b; 7 | b = s; 8 | i++; 9 | printf("%d ", s); 10 | } 11 | return b; 12 | } 13 | -------------------------------------------------------------------------------- /problems/0075_Sort_Colors/0075_Sort_Colors.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def sortColors(self, nums): 3 | l = len(nums) 4 | i,j = 0,0 5 | k=l-1 6 | while(i<=k): 7 | if(nums[i]==1): 8 | i+=1 9 | elif(nums[i]==0): 10 | nums[i],nums[j] = nums[j],nums[i] 11 | j+=1 12 | i+=1 13 | else: 14 | nums[i],nums[k] = nums[k],nums[i] 15 | k-=1 16 | -------------------------------------------------------------------------------- /problems/0078_Subsets/xiaoheng_3.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0078_Subsets/xiaoheng_3.cpp -------------------------------------------------------------------------------- /problems/0080_Remove_Duplicates_from_Sorted_Array_II/0080nian.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def removeDuplicates(self, nums): 3 | """ 4 | :type nums: List[int] 5 | :rtype: int 6 | """ 7 | n = len(nums) 8 | if(n<=2): 9 | return n 10 | count = 1 11 | result = 1 12 | for i in range(1,n): 13 | if(nums[i-1]==nums[i]): 14 | count+=1 15 | else: 16 | count=1 17 | if(count<=2): 18 | nums[result] = nums[i] 19 | result+=1 20 | return result 21 | -------------------------------------------------------------------------------- /problems/0080_Remove_Duplicates_from_Sorted_Array_II/RemoveDuplicates_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0080_Remove_Duplicates_from_Sorted_Array_II/RemoveDuplicates_st.java -------------------------------------------------------------------------------- /problems/0083_Remove_Duplicates_from_Sorted_List/DeleteDuplicates.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0083_Remove_Duplicates_from_Sorted_List/DeleteDuplicates.java -------------------------------------------------------------------------------- /problems/0083_Remove_Duplicates_from_Sorted_List/deleteDuplicates.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0083_Remove_Duplicates_from_Sorted_List/deleteDuplicates.c -------------------------------------------------------------------------------- /problems/0083_Remove_Duplicates_from_Sorted_List/liangxu.c: -------------------------------------------------------------------------------- 1 | struct ListNode { 2 | int val; 3 | struct ListNode *next; 4 | }; 5 | 6 | struct ListNode* deleteDuplicates(struct ListNode* head) 7 | { 8 | if (head == NULL) 9 | return NULL; 10 | 11 | struct ListNode* p = head; 12 | while (p->next != NULL) { 13 | if (p->val == p->next->val) 14 | p->next = p->next->next; 15 | else 16 | p = p->next; 17 | } 18 | 19 | return head; 20 | } 21 | -------------------------------------------------------------------------------- /problems/0088_Merge_Sorted_Array/Merge_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0088_Merge_Sorted_Array/Merge_st.java -------------------------------------------------------------------------------- /problems/0088_Merge_Sorted_Array/linlijia.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public void merge(int[] nums1, int m, int[] nums2, int n) { 3 | 4 | for (int i = m+n-1; i >= 0; i--) { 5 | if (m-1 < 0) { 6 | nums1[i] = nums2[n-1]; 7 | n--; 8 | continue; 9 | } 10 | 11 | if (n-1 < 0) { 12 | break; 13 | } 14 | 15 | if (nums1[m-1] > nums2[n-1]) { 16 | nums1[i] = nums1[m-1]; 17 | m--; 18 | } else { 19 | nums1[i] = nums2[n-1]; 20 | n--; 21 | } 22 | } 23 | 24 | } 25 | } -------------------------------------------------------------------------------- /problems/0091_Decode_Ways/22_黄有才.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0091_Decode_Ways/22_黄有才.cpp -------------------------------------------------------------------------------- /problems/0091_Decode_Ways/91.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0091_Decode_Ways/91.cpp -------------------------------------------------------------------------------- /problems/0091_Decode_Ways/Elon.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def numDecodings(self, s: str) -> int: 3 | dp = [1] 4 | dp.append(0 if s[0] == '0' else 1) 5 | for i, num in enumerate(s[1:], 1): 6 | connect = s[i - 1] + num 7 | if num == "0": 8 | if s[i - 1] == '1' or s[i - 1] == '2': 9 | dp.append(dp[i - 1]) 10 | else: 11 | dp.append(0) 12 | elif ("11" <= connect <= "26"): 13 | dp.append(dp[i - 1] + dp[i]) 14 | else: 15 | dp.append(dp[i]) 16 | return dp[-1] -------------------------------------------------------------------------------- /problems/0092_Reverse_Linked_List_II/ReverseBetween.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0092_Reverse_Linked_List_II/ReverseBetween.java -------------------------------------------------------------------------------- /problems/0096_Unique_Binary_Search_Trees/mark.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 1. 这个递归公式不太明白,卡特兰数 3 | 2. 参考:http://www.cnblogs.com/grandyang/p/4299608.html 4 | */ 5 | 6 | class Solution { 7 | public: 8 | int numTrees(int n) { 9 | vector sum(n+1,0); 10 | sum[0] = 1; 11 | sum[1] = 1; 12 | 13 | for(int i = 2; i < n+1; i++){ 14 | for(int j = 0; j < i; j++){ 15 | sum[i] += sum[j] * sum[i-j-1]; 16 | } 17 | } 18 | 19 | return sum[n]; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /problems/0100_Same_Tree/Ashbringer.java: -------------------------------------------------------------------------------- 1 | public class Ashbringer { 2 | public boolean isSameTree(TreeNode p, TreeNode q) { 3 | if (p == null && q == null){ 4 | return true; 5 | }else if (p==null && q!=null){ 6 | return false; 7 | }else if (p!=null && q==null){ 8 | return false; 9 | }else { 10 | if (p.val==q.val){ 11 | return isSameTree(p.left,q.left) && isSameTree(p.right,q.right); 12 | }else { 13 | return false; 14 | } 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /problems/0100_Same_Tree/ass.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for a binary tree node. 3 | * struct TreeNode { 4 | * int val; 5 | * struct TreeNode *left; 6 | * struct TreeNode *right; 7 | * }; 8 | */ 9 | 10 | //递归递归是真的强,要来一种非递归的才好 11 | //BFS应该可以实现但不免要麻烦一点 12 | bool isSameTree(struct TreeNode* p, struct TreeNode* q){ 13 | if(p == NULL &&q==NULL){ 14 | return true; 15 | } 16 | if(p!=NULL&&q!=NULL&&p->val==q->val){ 17 | return isSameTree(p->left,q->left)&&isSameTree(p->right,q->right); 18 | } 19 | else{ 20 | return false; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /problems/0100_Same_Tree/nicefuture.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for a binary tree node. 3 | * struct TreeNode { 4 | * int val; 5 | * struct TreeNode *left; 6 | * struct TreeNode *right; 7 | * }; 8 | */ 9 | bool isSameTree(struct TreeNode* p, struct TreeNode* q) { 10 | if (p == q && p == NULL) { 11 | return true; 12 | } 13 | if ((p == NULL && q != NULL) || 14 | (q == NULL && p != NULL) || 15 | (p != NULL && q != NULL && p->val != q->val)) { 16 | return false; 17 | } 18 | return isSameTree(p->left, q->left) && isSameTree(p->right, q->right); 19 | } 20 | -------------------------------------------------------------------------------- /problems/0100_Same_Tree/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isSameTree(self, p, q): 3 | if not p and not q: 4 | return True 5 | elif p and q: 6 | if p.val != q.val: 7 | return False 8 | else: 9 | return self.isSameTree(p.left, q.left) and self.isSameTree(p.right, q.right) 10 | else: 11 | return False 12 | -------------------------------------------------------------------------------- /problems/0100_Same_Tree/zhaoqianxilan.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0100_Same_Tree/zhaoqianxilan.cpp -------------------------------------------------------------------------------- /problems/0100_Same_Tree/石成玉.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 | bool isSameTree(TreeNode* p, TreeNode* q) { 13 | if(!p && !q) 14 | return true; 15 | if(p && q && p->val == q->val) { 16 | if(isSameTree(p->left, q->left) && isSameTree(p->right, q->right)) 17 | return true; 18 | } 19 | return false; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /problems/0101_Symmetric_Tree/IsSymmetric_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0101_Symmetric_Tree/IsSymmetric_st.java -------------------------------------------------------------------------------- /problems/0101_Symmetric_Tree/周三不加班.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0101_Symmetric_Tree/周三不加班.java -------------------------------------------------------------------------------- /problems/0101_Symmetric_Tree/活跃time.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0101_Symmetric_Tree/活跃time.java -------------------------------------------------------------------------------- /problems/0102_Binary_Tree_Level_Order_Traversal/0102_DFS.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | result=[] 3 | def levelOrder(self,root): 4 | self.result=[] 5 | if(root!=None): 6 | self.DFS(root,0) 7 | return self.result 8 | def DFS(self,node,depth): 9 | if(node!=None): 10 | print(node.val,depth) 11 | if(len(self.result) depth) depth = level; 15 | traverse(p->left, level+1); 16 | traverse(p->right, level+1); 17 | } 18 | 19 | int maxDepth(struct TreeNode* root) { 20 | depth = 0; 21 | traverse(root, 1); 22 | return depth; 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /problems/0104_Maximum_Depth_of_Binary_Tree/nil.go: -------------------------------------------------------------------------------- 1 | package MaximumDepthofBinaryTree 2 | 3 | import "for-an-offer/zs-leetcode-go/types" 4 | 5 | func maxDepth(root *types.TreeNode) int { 6 | if root == nil { 7 | return 0 8 | } 9 | left := maxDepth(root.Left)+1 10 | right := maxDepth(root.Right)+1 11 | if left > right { 12 | return left 13 | } 14 | return right 15 | } -------------------------------------------------------------------------------- /problems/0105_Construct_Binary_Tree_from_Preorder_and_Inorder_Traversal/Coke-105.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def buildTree(self, preorder: List[int], inorder: List[int]) -> TreeNode: 3 | 4 | if not preorder: 5 | return None 6 | root = TreeNode(preorder[0]) 7 | #找到根节点在中序遍历中的下标 8 | n = inorder.index(root.val) 9 | root.left = self.buildTree(preorder[1:n+1],inorder[:n]) 10 | root.right = self.buildTree(preorder[n+1:],inorder[n+1:]) 11 | return root -------------------------------------------------------------------------------- /problems/0113_Path_Sum_II/zhaoqianxilan.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0113_Path_Sum_II/zhaoqianxilan.cpp -------------------------------------------------------------------------------- /problems/0119_Pascals_Triangle_II/ALOHA.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector getRow(int rowIndex) { 4 | vector res(rowIndex + 1); 5 | res[0] = 1; 6 | for(int i = 1; i <= rowIndex; ++i) 7 | { 8 | /* 从右往左求 */ 9 | for(int j = i; j >= 0; --j) 10 | { 11 | int n = 0; 12 | n += (j > 0) ? res[j - 1] : 0; 13 | n += (j < i) ? res[j] : 0; 14 | res[j] = n; 15 | } 16 | } 17 | return res; 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /problems/0120_Triangle/4_秩秩斯干.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minimumTotal(vector>& triangle) { 4 | if (triangle.size() == 0) return 0; 5 | int row = triangle.size() - 2; 6 | for (; row >= 0; row--) { 7 | for (int col = 0; col < triangle[row].size(); col++) { 8 | triangle[row][col] += min(triangle[row + 1][col], triangle[row + 1][col + 1]); 9 | } 10 | } 11 | return triangle[0][0]; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /problems/0120_Triangle/Solution.py: -------------------------------------------------------------------------------- 1 | # 为了避免使用额外的存储空间,我们使用三角的最后一行来存储中间计算的结果 2 | # 我们最终目的是求每一行最小元素的和 3 | # 我们先求出最后一行的最小值放在最后一行的第一个元素 4 | # 然后遍历倒数第二行值第一行的所有数组, 5 | # 然后把每一行的最小值加到最后一行的第0个元素之上 6 | # 这样我们就得到三角行的最小路径之和了 7 | class Solution: 8 | def mininumTotal(self, triangle): 9 | if not triangle: 10 | return 0 11 | n = len(triangle) 12 | triangle[n-1][0] = min(triangle[n-1]) 13 | for i in range(n-2, -1, -1): 14 | triangle[n-1][0] += min(triangle[i]) 15 | return triangle[n-1][0] 16 | -------------------------------------------------------------------------------- /problems/0120_Triangle/君.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * 递推求解 3 | */ 4 | 5 | class Solution { 6 | public: 7 | int minimumTotal(vector >& triangle) { 8 | for (int i = triangle.size()-2; i >= 0; --i) { 9 | for (int j = 0; j <= i; ++j) { 10 | triangle[i][j] += min(triangle[i+1][j], triangle[i+1][j+1]); 11 | } 12 | } 13 | return triangle[0][0]; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /problems/0121_Best_Time_to_Buy_and_Sell_Stock/Solution.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def maxProfit(self, prices): 3 | """ 4 | :type prices: List[int] 5 | :rtype: int 6 | """ 7 | if not prices: 8 | return 0 9 | min_price = prices[0] 10 | max_profit = 0 11 | for price in prices: 12 | min_price = min(price, min_price) 13 | max_profit = max(max_profit, price - min_price) 14 | return max_profit -------------------------------------------------------------------------------- /problems/0121_Best_Time_to_Buy_and_Sell_Stock/linlijia.c: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int maxProfit(vector& prices) { 4 | 5 | int n = prices.size(); 6 | int maxProfit = 0; 7 | 8 | for (int i = 0; i < n - 1; i++) { 9 | for (int j = i + 1; j < n; j++) { 10 | int t = prices[j] - prices[i]; 11 | if (t > 0 && t > maxProfit) 12 | maxProfit = t; 13 | 14 | } 15 | } 16 | 17 | return maxProfit; 18 | } 19 | }; -------------------------------------------------------------------------------- /problems/0121_Best_Time_to_Buy_and_Sell_Stock/nicefuture.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int maxProfit(int[] prices) { 3 | int cur = 0, maxi = 0; 4 | for (int i=1; i maxi ? cur : maxi; 8 | } 9 | return maxi; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /problems/0125_Valid_Palindrome/0125_Valid_Palindrome.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def isPalindrome(self, s): 3 | if(len(s)==0 or len(s)==1): 4 | return True 5 | ss = [ch for ch in s.lower() if ch.isalpha() or ch.isdigit()] 6 | l = len(ss) 7 | for i in range(l/2): 8 | print(i,l-i-1) 9 | if(ss[i]!=ss[l-i-1]): 10 | return False 11 | return True 12 | -------------------------------------------------------------------------------- /problems/0125_Valid_Palindrome/IsPalindrome_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0125_Valid_Palindrome/IsPalindrome_st.java -------------------------------------------------------------------------------- /problems/0136_Single_Number/0136_Single_Number.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。 3 | 说明: 4 | 你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗? 5 | */ 6 | class Solution { 7 | public: 8 | int singleNumber(vector& nums) { 9 | sort(nums.begin(),nums.end()); 10 | 11 | int len=nums.size(); 12 | for(int i=0;i& nums) { 4 | if (1 == nums.size()){ 5 | return nums[0]; 6 | } 7 | int result = nums[0]; 8 | for (int i=1;i int: 4 | return (sum(set(nums))*3 - sum(nums)) // 2 5 | -------------------------------------------------------------------------------- /problems/0139_Word_Break/01klgentle.py: -------------------------------------------------------------------------------- 1 | # coding:utf8 2 | 3 | 4 | class Solution: 5 | def wordBreak(self, s, wordDict: list) -> bool: 6 | if not s: 7 | return True 8 | 9 | breakp = [0] 10 | for i in range(len(s) + 1): 11 | for j in breakp: 12 | if s[j:i] in wordDict: 13 | breakp.append(i) 14 | break 15 | print(f"breakp: {breakp}") 16 | return breakp[-1] == len(s) 17 | -------------------------------------------------------------------------------- /problems/0141_Linked_List_Cycle/HasCycle.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0141_Linked_List_Cycle/HasCycle.java -------------------------------------------------------------------------------- /problems/0141_Linked_List_Cycle/LingHuChong.java: -------------------------------------------------------------------------------- 1 | public class Solution { 2 | public Boolean hasCycle(ListNode head) { 3 | if (head == null || head.next == null) { 4 | return false; 5 | } 6 | 7 | ListNode fast, slow; 8 | fast = head.next; 9 | slow = head; 10 | while (fast != slow) { 11 | if(fast==null || fast.next==null) 12 | return false; 13 | fast = fast.next.next; 14 | slow = slow.next; 15 | } 16 | return true; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /problems/0141_Linked_List_Cycle/nicefuture.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for singly-linked list. 3 | * struct ListNode { 4 | * int val; 5 | * struct ListNode *next; 6 | * }; 7 | */ 8 | bool hasCycle(struct ListNode *head) { 9 | struct ListNode *p = head; 10 | struct ListNode *q = head; 11 | if (q != NULL) q = q->next; 12 | while (p != NULL && q != NULL) { 13 | if (p == q) return true; 14 | p = p->next; 15 | q = q->next; 16 | if (q != NULL) q = q->next; 17 | else break; 18 | } 19 | return false; 20 | } 21 | -------------------------------------------------------------------------------- /problems/0141_Linked_List_Cycle/一碗机智的糖浆.java: -------------------------------------------------------------------------------- 1 | public class Solution { 2 | public boolean hasCycle(ListNode head) { 3 | Set nodesSeen = new HashSet<>(); 4 | while (head != null) { 5 | if (nodesSeen.contains(head)) { 6 | return true; 7 | } else { 8 | nodesSeen.add(head); 9 | } 10 | head = head.next; 11 | } 12 | return false; 13 | } 14 | } -------------------------------------------------------------------------------- /problems/0142_Linked_List_Cycle_II/DetectCycle.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0142_Linked_List_Cycle_II/DetectCycle.java -------------------------------------------------------------------------------- /problems/0151_Reverse_Words/ReverseWords_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0151_Reverse_Words/ReverseWords_st.java -------------------------------------------------------------------------------- /problems/0160_Intersection_of_Two_Linked_Lists/zhaxinle.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0160_Intersection_of_Two_Linked_Lists/zhaxinle.c -------------------------------------------------------------------------------- /problems/0167_Two_Sum_II_Input_array_is_sorted/167_Two_Sum_II_Input_array_is_sorted.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def twoSum(self, numbers, target): 3 | d = dict() 4 | for i in range(len(numbers)): 5 | com = target - numbers[i] 6 | if(d.has_key(numbers[i])): 7 | return [d[numbers[i]],i+1] 8 | d.setdefault(com,i+1) 9 | -------------------------------------------------------------------------------- /problems/0167_Two_Sum_II_Input_array_is_sorted/twoSum.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def twoSum(self, numbers, target): 3 | d=dict() 4 | for i, num in enumerate(numbers, start = 1): 5 | tmp = target - num 6 | if tmp in d: 7 | return sorted([i, d[tmp]]) 8 | d[num] = i -------------------------------------------------------------------------------- /problems/0168_Excel_Sheet_Column_Title/0168nian.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def convertToTitle(self, n): 3 | """ 4 | :type n: int 5 | :rtype: str 6 | """ 7 | result="" 8 | while(n!=0): 9 | if(n%26==0): 10 | result+="Z" 11 | n=n/26-1 12 | else: 13 | result+=chr(n%26+64) 14 | n=n/26 15 | return result[::-1] 16 | -------------------------------------------------------------------------------- /problems/0169_Majority_Element/22k.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int majorityElement(int[] nums) { 3 | int res=nums[0]; 4 | int count=1; 5 | for(int i=1;i& nums) { 4 | unordered_map M; 5 | for(auto i:nums) 6 | M[i]++; 7 | pair max = {-1,-1}; 8 | for(auto p:M){ 9 | if(max.second < p.second){ 10 | max = p; 11 | } 12 | } 13 | return max.first; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /problems/0171_Excel_Sheet_Column_Number/0171nian.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def titleToNumber(self, s): 3 | """ 4 | :type s: str 5 | :rtype: int 6 | """ 7 | result=0 8 | for i in range(len(s)): 9 | result+= (ord(s[i])-64)*(26**(len(s)-i-1)) 10 | return result 11 | -------------------------------------------------------------------------------- /problems/0171_Excel_Sheet_Column_Number/dachuan.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int titleToNumber(String s) { 3 | if (s != null && s.length() > 0) { 4 | char[] chars = s.toCharArray(); 5 | int len = chars.length; 6 | int sum = 0; 7 | for (int i = 0; i < len; i++) { 8 | sum += ((int) chars[i] - 64) * Math.pow(26, len - i - 1); 9 | } 10 | return sum; 11 | } else { 12 | return 0; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /problems/0171_Excel_Sheet_Column_Number/nicefuture.c: -------------------------------------------------------------------------------- 1 | int titleToNumber(char* s) { 2 | // 26进制 3 | int sum = 0; 4 | char *p = s; 5 | while (*p != '\0') { 6 | sum = sum*26 + (*p-'A'+ 1); 7 | p++; 8 | } 9 | // printf("%d\n", sum); 10 | return sum; 11 | } 12 | -------------------------------------------------------------------------------- /problems/0171_Excel_Sheet_Column_Number/peanwang.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0171_Excel_Sheet_Column_Number/peanwang.cpp -------------------------------------------------------------------------------- /problems/0172_Factorial_Trailing_Zeroes/ALOHA.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int trailingZeroes(int n) { 4 | int i = 0; 5 | if(n<5) 6 | return 0; 7 | while(n>=5){ 8 | n=n/5; 9 | i=i+n; 10 | } 11 | return i; 12 | } 13 | }; -------------------------------------------------------------------------------- /problems/0177_Nth_Highest_Salary/蒋小米.sql: -------------------------------------------------------------------------------- 1 | CREATE FUNCTION getNthHighestSalary(N IN NUMBER) RETURN NUMBER IS 2 | result NUMBER; 3 | BEGIN 4 | /* Write your PL/SQL query statement below */ 5 | select salary into result from 6 | (select id,salary,DENSE_RANK() OVER(ORDER BY salary desc ) RANK from employee ) t 7 | where rownum=1 and t.RANK = n ; 8 | RETURN result; 9 | END; -------------------------------------------------------------------------------- /problems/0182_Duplicate_Emails/0182_Duplicate_Emails.sql: -------------------------------------------------------------------------------- 1 | select Email from (select Email, count(*) from Person group by Email having count(*) > 1) as a -------------------------------------------------------------------------------- /problems/0190_Reverse_Bits/peanwang.txt: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | uint32_t reverseBits(uint32_t n) { 4 | n = (n >> 16) | (n << 16); 5 | n = ((n & 0xff00ff00) >> 8) | ((n & 0x00ff00ff) << 8); 6 | n = ((n & 0xf0f0f0f0) >> 4) | ((n & 0x0f0f0f0f) << 4); 7 | n = ((n & 0xcccccccc) >> 2) | ((n & 0x33333333) << 2); 8 | n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1); 9 | return n; 10 | } 11 | }; -------------------------------------------------------------------------------- /problems/0191_hammingWeight/hammingWeight.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int hammingWeight(uint32_t n) { 4 | uint32_t count = 0; 5 | while(n) 6 | { 7 | if(n&1) 8 | count++; 9 | n = n>>1; 10 | } 11 | return count; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /problems/0191_hammingWeight/peanwang.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int hammingWeight(uint32_t n) { 4 | const int array[]={0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4}; 5 | int count=0; 6 | uint32_t m = n>>16; 7 | for(int i=0;i<4;i++){ 8 | count += array[(n & 0xf)]; 9 | count += array[(m & 0xf)]; 10 | n = n>>4; 11 | m = m>>4; 12 | if(n == 0 && m==0) 13 | break; 14 | } 15 | return count; 16 | } 17 | }; -------------------------------------------------------------------------------- /problems/0203_Remove_Linked_List_Elements/Elon.py: -------------------------------------------------------------------------------- 1 | # Definition for singly-linked list. 2 | # class ListNode: 3 | # def __init__(self, x): 4 | # self.val = x 5 | # self.next = None 6 | 7 | 8 | class Solution: 9 | def removeElements(self, head: ListNode, val: int) -> ListNode: 10 | dummy = ListNode(-1) 11 | dummy.next = head 12 | now = dummy 13 | while now.next != None: 14 | if now.next.val != val: 15 | now = now.next 16 | else : 17 | now.next = now.next.next 18 | 19 | return dummy.next -------------------------------------------------------------------------------- /problems/0203_Remove_Linked_List_Elements/RemoveElement-ByDecadence.java: -------------------------------------------------------------------------------- 1 | /* 2 | Remove all elements from a linked list of integers that have value val. 3 | 4 | Example: 5 | 6 | Input: 1->2->6->3->4->5->6, val = 6 7 | Output: 1->2->3->4->5 8 | 9 | */ 10 | 11 | public class Solution { 12 | public ListNode removeElements(ListNode head, int val) { 13 | while (head != null && head.val == val) head = head.next; 14 | ListNode curr = head; 15 | while (curr != null && curr.next != null) 16 | if (curr.next.val == val) curr.next = curr.next.next; 17 | else curr = curr.next; 18 | return head; 19 | } 20 | } -------------------------------------------------------------------------------- /problems/0203_Remove_Linked_List_Elements/RemoveElements.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0203_Remove_Linked_List_Elements/RemoveElements.java -------------------------------------------------------------------------------- /problems/0203_Remove_Linked_List_Elements/dachuan.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for singly-linked list. 3 | * public class ListNode { 4 | * int val; 5 | * ListNode next; 6 | * ListNode(int x) { val = x; } 7 | * } 8 | */ 9 | class Solution { 10 | public ListNode removeElements(ListNode head, int val) { 11 | if(head == null){ 12 | return null; 13 | } 14 | //2、对以 head.next 开头的链重新执行一遍 removeElements() 15 | head.next = removeElements(head.next, val); 16 | //1、对以 head 开头的链进行去除处理; 17 | return head.val == val ? head.next : head; 18 | } 19 | } -------------------------------------------------------------------------------- /problems/0203_Remove_Linked_List_Elements/jacklynd.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0203_Remove_Linked_List_Elements/jacklynd.c -------------------------------------------------------------------------------- /problems/0204_Count_Primes/bbj.cpp: -------------------------------------------------------------------------------- 1 | // 有点问题,跑的太慢了 2 | class Solution { 3 | public: 4 | int isprime(int n){ 5 | for (int i = 2; i <= sqrt(n); i++){ 6 | if (n % i == 0){ 7 | return 0; 8 | } 9 | } 10 | return 1; 11 | } 12 | int countPrimes(int n) { 13 | int cnt = 0; 14 | for (int i = 2; i < n; i++){ 15 | if (isprime(i)){ 16 | ++cnt; 17 | } 18 | } 19 | return cnt; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /problems/0205_Isomorphic_Strings/isIsomorphic.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isIsomorphic(self, s, t): 3 | for i in range(len(s)): 4 | if(s.find(s[i]) != t.find(t[i])): 5 | return False 6 | return True -------------------------------------------------------------------------------- /problems/0206_Reverse_Linked_List/206_HH.py: -------------------------------------------------------------------------------- 1 | # Definition for singly-linked list. 2 | # class ListNode: 3 | # def __init__(self, x): 4 | # self.val = x 5 | # self.next = None 6 | #206反转链表 7 | class Solution: 8 | def reverseList(self, head): 9 | """ 10 | :type head: ListNode 11 | :rtype: ListNode 12 | """ 13 | cur, prev = head, None 14 | while cur: 15 | cur.next, prev, cur = prev, cur, cur.next 16 | return prev -------------------------------------------------------------------------------- /problems/0206_Reverse_Linked_List/ListNode.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0206_Reverse_Linked_List/ListNode.java -------------------------------------------------------------------------------- /problems/0206_Reverse_Linked_List/ReverseLinkNode.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0206_Reverse_Linked_List/ReverseLinkNode.java -------------------------------------------------------------------------------- /problems/0206_Reverse_Linked_List/nian_pointer.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def reverseList(self, head): 3 | """ 4 | :type head: ListNode 5 | :rtype: ListNode 6 | """ 7 | pre = None 8 | while(head): 9 | temp = head.next # 保存下一个节点 10 | head.next = pre # 当前节点指向前一个节点(实现反转) 11 | pre = head # 前一个节点设为当前节点 12 | head = temp # 当前节点后移 13 | return pre 14 | -------------------------------------------------------------------------------- /problems/0206_Reverse_Linked_List/nian_stack.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def reverseList(self, head): 3 | """ 4 | :type head: ListNode 5 | :rtype: ListNode 6 | """ 7 | l = [] 8 | while(head!=None): 9 | l.append(head.val) 10 | head = head.next 11 | if(len(l)): 12 | r = ListNode(l.pop()) 13 | p = r 14 | else: 15 | return head 16 | while(len(l)): 17 | n = ListNode(l.pop()) 18 | p.next = n 19 | p = p.next 20 | return r 21 | -------------------------------------------------------------------------------- /problems/0215_Kth_Largest_Element_in_an_Array/0215_Rocky.c: -------------------------------------------------------------------------------- 1 | static int cmpint(const void *p1, const void *p2) { 2 | return *(int *) p2 - *(int *) p1; 3 | } 4 | 5 | int findKthLargest(int* nums, int numsSize, int k) { 6 | qsort(nums, numsSize, sizeof(int), cmpint); 7 | return nums[k - 1]; 8 | } 9 | -------------------------------------------------------------------------------- /problems/0215_Kth_Largest_Element_in_an_Array/FindKMaxNumber.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | public class FindKMaxNumber { 4 | public static void main(String[] argu) { 5 | int[] a = {9, 8, 7, 2, 3, 4, 1, 0, 6, 5}; 6 | Arrays.sort(a); 7 | System.out.println(a[a.length - 2]); 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /problems/0215_Kth_Largest_Element_in_an_Array/FindKthLargest_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0215_Kth_Largest_Element_in_an_Array/FindKthLargest_st.java -------------------------------------------------------------------------------- /problems/0215_Kth_Largest_Element_in_an_Array/LX.kt: -------------------------------------------------------------------------------- 1 | import java.util.* 2 | 3 | class LX { 4 | 5 | //Kth Largest Element in an Array 6 | 7 | fun findKthLargest(nums: IntArray, k: Int): Int { 8 | var ak= arrayOfNulls(k+1) 9 | for(i in ak.indices){ 10 | ak[i]=Int.MIN_VALUE; 11 | } 12 | for(i in nums.indices){ 13 | if(nums[i]>ak[1]!!){ 14 | ak[0]=nums[i] 15 | Arrays.sort(ak) 16 | } 17 | } 18 | return ak[1]!! 19 | } 20 | } -------------------------------------------------------------------------------- /problems/0215_Kth_Largest_Element_in_an_Array/MQQM.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 题目: 3 | 在未排序的数组中找到第k大的元素。 4 | */ 5 | class Solution { 6 | public: 7 | int findKthLargest(vector& nums, int k) { 8 | sort(nums.begin(), nums.end()); 9 | return nums[nums.size()-k]; 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /problems/0215_Kth_Largest_Element_in_an_Array/Solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findKthLargest(self, nums, k): 3 | """ 4 | :type nums: List[int] 5 | :type k: int 6 | :rtype: int 7 | """ 8 | nums.sort(reverse=True) 9 | return nums[k-1] -------------------------------------------------------------------------------- /problems/0215_Kth_Largest_Element_in_an_Array/Tony the Cyclist.py: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int findKthLargest(int[] nums, int k) { 3 | // 经过调优的快速排序法 4 | Arrays.sort(nums); 5 | return nums[nums.length-k]; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /problems/0217_Contains_Duplicate/217_charlie.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def containsDuplicate(self, nums: List[int]) -> bool: 3 | after_set_list = list(set(nums)) 4 | if len(after_set_list) != len(nums): 5 | return True 6 | else: 7 | return False 8 | -------------------------------------------------------------------------------- /problems/0217_Contains_Duplicate/MQQM.py: -------------------------------------------------------------------------------- 1 | /* 2 | 题目: 3 | 给定一个整数数组,判断是否存在重复元素。 4 | 如果任何值在数组中出现至少两次,函数返回 true。如果数组中每个元素都不相同,则返回 false。 5 | */ 6 | class Solution: 7 | def containsDuplicate(self, nums): 8 | """ 9 | :type nums: List[int] 10 | :rtype: bool 11 | """ 12 | #第一种 13 | d = {} #字典 14 | for i in nums: 15 | if i in d: 16 | return True 17 | else: 18 | d[i] = 1 19 | return False 20 | 21 | #第二种 22 | #return len(nums) != len(set(nums)) 23 | -------------------------------------------------------------------------------- /problems/0217_Contains_Duplicate/containsDuplicate.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def containsDuplicate(self, nums): 3 | return len(nums) != len(list(set(nums))) -------------------------------------------------------------------------------- /problems/0219_Contains_Duplicate_II/nicefuture.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public boolean containsNearbyDuplicate(int[] nums, int k) { 3 | // 使用滑动窗口 side window,每次检查滑动窗口内部是否包含新进入窗口的数字 4 | Set set = new HashSet(); 5 | for (int i=0; i k) set.remove(nums[i-k-1]); 7 | if (!set.add(nums[i])) return true; 8 | } 9 | return false; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /problems/0226_Invert_Binary_Tree/ALOHA.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | TreeNode* invertTree(TreeNode* root) { 4 | if(root==NULL||(root->left==NULL&&root->right==NULL)) return root; 5 | TreeNode *temp=root->left; 6 | root->left=invertTree(root->right); 7 | root->right=invertTree(temp); 8 | return root; 9 | } 10 | }; -------------------------------------------------------------------------------- /problems/0231_Power_of_Two/MQQM.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 题目: 3 | 给定一个整数,编写一个函数来判断它是否是 2 的幂次方。 4 | */ 5 | class Solution { 6 | public: 7 | bool isPowerOfTwo(int n) { 8 | if(n < 0){//负数不会是2的幂 9 | return false; 10 | } 11 | 12 | int cnt = 0; 13 | for(int i=0; i<=30; i++){//在31位上,数一下1的个数 14 | int mask = 1 << i; 15 | if( (mask & n) == mask ){ 16 | cnt++; 17 | } 18 | } 19 | if(cnt == 1){ 20 | return true; 21 | } 22 | 23 | return false; 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /problems/0231_Power_of_Two/peanwang.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isPowerOfTwo(int n) { 4 | if(n==0) 5 | return false; 6 | else if(n == 1) 7 | return true; 8 | else 9 | return isPowerOfTwo(n/2) && !(n%2); 10 | } 11 | }; -------------------------------------------------------------------------------- /problems/0234_Palindrome_Linked_List/IsPalindrome_Servant.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0234_Palindrome_Linked_List/IsPalindrome_Servant.java -------------------------------------------------------------------------------- /problems/0234_Palindrome_Linked_List/test.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0234_Palindrome_Linked_List/test.c -------------------------------------------------------------------------------- /problems/0234_Palindrome_Linked_List/xiaxi.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0234_Palindrome_Linked_List/xiaxi.c -------------------------------------------------------------------------------- /problems/0237_Delete_Node_in_a_Linked_List/Adam.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Definition for singly-linked list. 3 | * public class ListNode { 4 | * int val; 5 | * ListNode next; 6 | * ListNode(int x) { val = x; } 7 | * } 8 | */ 9 | public class Solution { 10 | public void deleteNode(ListNode node) { 11 | node.val=node.next.val; 12 | node.next=node.next.next; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /problems/0237_Delete_Node_in_a_Linked_List/bbj.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 | void deleteNode(ListNode* node) { 12 | while(node->next->next!=NULL) 13 | { 14 | node->val=node->next->val; 15 | node=node->next; 16 | } 17 | node->val=node->next->val; 18 | node->next=NULL; 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /problems/0242_Valid_Anagram/Valid_Anagram.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isAnagram(string s, string t) { 4 | int alp1[26]{0},alp2[26]{0}; 5 | for(auto ch:s) 6 | alp1[ch-'a']++; 7 | for(auto ch:t) 8 | alp2[ch-'a']++; 9 | return equal(cbegin(alp1),cend(alp1),cbegin(alp2)); 10 | } 11 | }; -------------------------------------------------------------------------------- /problems/0258_Add_Digits/258_Add_Digits_22k.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int addDigits(int num) { 3 | int temp=0; 4 | while(num>0) 5 | { 6 | temp+=num%10; 7 | num/=10; 8 | } 9 | if(temp<10) 10 | return temp; 11 | else 12 | return addDigits(temp); 13 | } 14 | } -------------------------------------------------------------------------------- /problems/0258_Add_Digits/Solution_258.java: -------------------------------------------------------------------------------- 1 | 2 | class Solution { 3 | public int addDigits(int num) { 4 | return 1+(num-1)%9; 5 | } 6 | } -------------------------------------------------------------------------------- /problems/0258_Add_Digits/add_digits_banana.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def addDigits(self, num): 3 | while(num > 9): 4 | num = int(num/10) + num % 10 5 | return num -------------------------------------------------------------------------------- /problems/0258_Add_Digits/dachuan.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int addDigits(int num) { 3 | if(num < 10){ 4 | return num; 5 | } 6 | int sum = 0; 7 | while(num > 9){ 8 | sum += num % 10; 9 | num = num / 10; 10 | } 11 | sum += num; 12 | return addDigits(sum); 13 | } 14 | } -------------------------------------------------------------------------------- /problems/0263_Ugly_Number/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def isUgly(self, num: int) -> bool: 3 | if num > 0: 4 | while num % 2 == 0: 5 | num /= 2 6 | while num % 3 == 0: 7 | num /= 3 8 | while num % 5 == 0: 9 | num /= 5 10 | else: 11 | return False 12 | 13 | return num == 1 14 | -------------------------------------------------------------------------------- /problems/0264_ugly-number-ii/0263_Ugly_Number/liangxu.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define NUM 8 5 | 6 | bool isUgly(int num) 7 | { 8 | int i = 0; 9 | 10 | for (i = 2; i < 6 && num; i++) { 11 | while (num % i == 0) 12 | num /= i; 13 | } 14 | return num == 1; 15 | } 16 | 17 | int main() 18 | { 19 | printf("number %d %s ugly number.\n", NUM, isUgly(NUM)?"is":"is not"); 20 | } 21 | -------------------------------------------------------------------------------- /problems/0264_ugly-number-ii/0263_Ugly_Number/linlijia.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | 3 | public boolean isUgly(int num) { 4 | 5 | if (num == 0) 6 | return false; 7 | 8 | while (num % 2 == 0) { 9 | num = num >> 1; 10 | } 11 | while (num % 3 == 0) { 12 | num = num / 3; 13 | } 14 | while (num % 5 == 0) { 15 | num = num / 5; 16 | } 17 | 18 | return num == 1 ? true : false; 19 | 20 | } 21 | 22 | 23 | } -------------------------------------------------------------------------------- /problems/0264_ugly-number-ii/0263_Ugly_Number/nicefuture.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0264_ugly-number-ii/0263_Ugly_Number/nicefuture.c -------------------------------------------------------------------------------- /problems/0264_ugly-number-ii/0264_ugly-number-ii.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0264_ugly-number-ii/0264_ugly-number-ii.cpp -------------------------------------------------------------------------------- /problems/0264_ugly-number-ii/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def nthUglyNumber(self, n: int) -> int: 3 | ids = [0, 0, 0] 4 | uglys = [1,] 5 | for i in range(1, n): 6 | a = uglys[ids[0]] * 2 7 | b = uglys[ids[1]] * 3 8 | c = uglys[ids[2]] * 5 9 | min_ = min(a, b, c) 10 | if a == min_: ids[0] += 1 11 | if b == min_: ids[1] += 1 12 | if c == min_: ids[2] += 1 13 | uglys.append(min_) 14 | return uglys[-1] 15 | -------------------------------------------------------------------------------- /problems/0268_Missing_Number/Missing_Number2.cpp: -------------------------------------------------------------------------------- 1 | //20ms 2 | /* 3 | 题目: 4 | 给定一个包含 0, 1, 2, ..., n 中 n 个数的序列,找出 0 .. n 中没有出现在序列中的那个数。 5 | */ 6 | class Solution { 7 | public: 8 | int missingNumber(vector& nums) { 9 | int miss=nums.size(); 10 | for(int i=0; i& nums) { 12 | int len=nums.size(); 13 | int rst=0; 14 | 15 | for(int i=0;i 2 | #include 3 | 4 | int missingNumber(int* nums, int numsSize) { 5 | int i; 6 | int a[10000] = {0}; 7 | for (i = 0; i < numsSize; i++) { 8 | a[nums[i]] = 1; 9 | } 10 | for (i = 0; i < numsSize + 1; i++) { 11 | if (a[i] != 1) 12 | return i; 13 | } 14 | return -1; 15 | } 16 | 17 | int main() 18 | { 19 | int a[10] = {0, 2, 3, 1, 5, 6, 4, 7, 8, 9}; 20 | printf("%d", missingNumber(a, 10)); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /problems/0268_Missing_Number/nicefuture.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0268_Missing_Number/nicefuture.c -------------------------------------------------------------------------------- /problems/0274_H-Index/H-Index_nian.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def hIndex(self, citations): 3 | """ 4 | :type citations: List[int] 5 | :rtype: int 6 | """ 7 | citations.sort(reverse=True) 8 | maxH = 0 9 | for i in range(len(citations)): 10 | if(citations[i]>=i+1): 11 | maxH = i+1 12 | return maxH 13 | -------------------------------------------------------------------------------- /problems/0275_H-index_II/nian0275.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def hIndex(self, citations): 3 | n = len(citations) 4 | ma = n-1 5 | mi = 0 6 | while(mi<=ma): 7 | mid = (ma+mi)/2 8 | print(ma,mi,mid) 9 | if(citations[mid]>=n-mid): 10 | ma = mid-1 11 | else: 12 | mi = mid+1 13 | return n-ma-1 14 | -------------------------------------------------------------------------------- /problems/0278_First_Bad_Version/torresng.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0278_First_Bad_Version/torresng.cpp -------------------------------------------------------------------------------- /problems/0283_Move_Zeroes/Tony the Cyclist.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def moveZeroes(self, nums): 3 | """ 4 | :type nums: List[int] 5 | :rtype: None Do not return anything, modify nums in-place instead. 6 | """ 7 | cot = 0 8 | while 0 in nums: 9 | nums.remove(0) 10 | cot += 1 11 | while cot: 12 | nums.append(0) 13 | cot -= 1 14 | -------------------------------------------------------------------------------- /problems/0287_Find_the_Duplicate_Number/0287_Find_the_Duplicate_Number.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def findDuplicate(self, nums): 3 | s = nums[nums[0]] 4 | f = nums[nums[s]] 5 | while(s!=f): 6 | s = nums[s] 7 | f = nums[nums[f]] 8 | s = 0 9 | while(s!=f): 10 | s = nums[s] 11 | f = nums[f] 12 | return s 13 | -------------------------------------------------------------------------------- /problems/0303_Range_Sum_Query/303.cpp: -------------------------------------------------------------------------------- 1 | class NumArray { 2 | public: 3 | NumArray(vector& nums) { 4 | if(!nums.empty()) 5 | { 6 | _arr.push_back(nums[0]); 7 | for(int i = 1;i _arr; 23 | }; -------------------------------------------------------------------------------- /problems/0303_Range_Sum_Query/Elon.py: -------------------------------------------------------------------------------- 1 | class NumArray: 2 | def __init__(self, nums: List[int]): 3 | self.sums = [0] 4 | dp_sum = 0 5 | for num in nums: 6 | dp_sum += num 7 | self.sums.append(dp_sum) 8 | 9 | def sumRange(self, i: int, j: int) -> int: 10 | return self.sums[j + 1] - self.sums[i] 11 | 12 | 13 | # Your NumArray object will be instantiated and called as such: 14 | # obj = NumArray(nums) 15 | # param_1 = obj.sumRange(i,j) -------------------------------------------------------------------------------- /problems/0303_Range_Sum_Query/liuxiang.java: -------------------------------------------------------------------------------- 1 | class NumArray { 2 | //定义一个sum数组用来存储左边的和,例如sum[2]表示nums[0]+nums[1] 3 | //很容易可以得出sum[i]=sum[i-1]+nums[i-1]; 4 | 5 | int[] sum; 6 | 7 | public NumArray(int[] nums) { 8 | int n=nums.length; 9 | sum=new int[n+1]; 10 | sum[0]=0; 11 | for(int i=1;i<=n;i++){ 12 | sum[i]=sum[i-1]+nums[i-1]; 13 | } 14 | } 15 | 16 | public int sumRange(int i, int j) { 17 | return sum[j+1]-sum[i]; 18 | 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /problems/0322_Coin_Change/小恒_3.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number[]} coins 3 | * @param {number} amount 4 | * @return {number} 5 | */ 6 | var coinChange = function(coins, amount) { 7 | let f = Array(amount + 1).fill(Number.MAX_SAFE_INTEGER) 8 | f[0] = 0 9 | 10 | for (const c of coins) { 11 | for (let i = c; i <= amount; i++) { 12 | f[i] = Math.min(f[i], f[i - c] + 1) 13 | } 14 | } 15 | 16 | if (f[amount] === Number.MAX_SAFE_INTEGER) return -1 17 | return f[amount] 18 | }; -------------------------------------------------------------------------------- /problems/0326_Power_of_Three/peanwang.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool isPowerOfThree(int n) { 4 | return n>0 && (1162261467%n==0); 5 | } 6 | }; -------------------------------------------------------------------------------- /problems/0334_Increasing_Triplet_Subsequence/ElonPython.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def increasingTriplet(self, nums: List[int]) -> bool: 3 | first = second = float('inf') 4 | for num in nums: 5 | if num <= first: 6 | first = num 7 | elif num <= second: 8 | second = num 9 | else: 10 | return True 11 | return False -------------------------------------------------------------------------------- /problems/0334_Increasing_Triplet_Subsequence/abelZW.c: -------------------------------------------------------------------------------- 1 | bool increasingTriplet(int* nums, int numsSize) { 2 | if(numsSize < 3) 3 | return false;//数组小于三个直接返回false 4 | int l = nums[0], max = 0x7fffffff;//最大正数 5 | for(int i = 1; i < numsSize; i++) 6 | { 7 | int a = nums[i]; //a开始为三个数中间的那个 8 | if(a <= l) 9 | l = a; 10 | else if(a < max) 11 | max = a; 12 | else if(a > max) //a大于前面两个数 13 | return true; 14 | } 15 | return false; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /problems/0334_Increasing_Triplet_Subsequence/lionfly.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def increasingTriplet(self, nums): 3 | """ 4 | :type nums: List[int] 5 | :rtype: bool 6 | """ 7 | a = b = 0x7fffffff 8 | for n in nums: 9 | if n <= a: 10 | a = n 11 | elif n <= b: 12 | b = n 13 | else: 14 | return True 15 | return False 16 | -------------------------------------------------------------------------------- /problems/0334_Increasing_Triplet_Subsequence/reowst.c: -------------------------------------------------------------------------------- 1 | bool increasingTriplet(int* nums, int numsSize) { 2 | int a = INT_MAX, b = INT_MAX; 3 | int n = 0; 4 | while(n < numsSize) 5 | { 6 | if(nums[n] > b) 7 | return true; 8 | else if(nums[n] > a) 9 | b = nums[n]; 10 | else 11 | a = nums[n]; 12 | n++; 13 | } 14 | return false; 15 | } -------------------------------------------------------------------------------- /problems/0343_Integer_Break/0343_IntegerBreak.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | //DP 8 | int integerBreak(int n) 9 | { 10 | int nums[n+1]; 11 | memset(nums,0,sizeof(nums)); 12 | nums[1]=1; 13 | for(int i=2;i<=n;i++) 14 | { 15 | for(int j=1;j<=i-1;j++) 16 | { 17 | nums[i]=max(nums[i],max(j*nums[i-j],j*(i-j))); 18 | } 19 | } 20 | return nums[n]; 21 | } 22 | 23 | int main() 24 | { 25 | int nums; 26 | cin>>nums; 27 | int ans=integerBreak(nums); 28 | cout< List[int]: 4 | return [d[0] for d in Counter(nums).most_common(k)] 5 | -------------------------------------------------------------------------------- /problems/0349_Intersection_of_Two_Arrays/Tony the Cyclist.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def intersection(self, nums1, nums2): 3 | """ 4 | :type nums1: List[int] 5 | :type nums2: List[int] 6 | :rtype: List[int] 7 | """ 8 | result = [] 9 | for i in set(nums1): 10 | if i in nums2: 11 | result.append(i) 12 | return result 13 | 14 | -------------------------------------------------------------------------------- /problems/0349_Intersection_of_Two_Arrays/init6-349.txt: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def intersection(self, nums1, nums2): 3 | """ 4 | :type nums1: List[int] 5 | :type nums2: List[int] 6 | :rtype: List[int] 7 | """ 8 | return list(set(nums1) & set(nums2)) -------------------------------------------------------------------------------- /problems/0350_Intersection_of_Two_Arrays_II/Tony the Cyclist.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def intersect(self, nums1, nums2): 3 | """ 4 | :type nums1: List[int] 5 | :type nums2: List[int] 6 | :rtype: List[int] 7 | """ 8 | result = [] 9 | for i in nums1: 10 | if i in nums2: 11 | result.append(i) 12 | nums2.remove(i) 13 | return result 14 | -------------------------------------------------------------------------------- /problems/0371_Sum_Of_TwoIntegers/Sum_Of_Twointegers.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int getSum(int a, int b) { 4 | int carry = a & b; 5 | carry = (carry & __INT_MAX__)<<1; 6 | //carry = carry<<1; 7 | if(carry==0) 8 | { 9 | return a ^ b; 10 | } 11 | else 12 | { 13 | return getSum(a ^ b,carry); 14 | } 15 | 16 | 17 | } 18 | }; -------------------------------------------------------------------------------- /problems/0371_Sum_of_Two_Integers/Elon.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def getSum(self, a: int, b: int) -> int: 3 | MAX = 0x7FFFFFFF 4 | mask = 0xFFFFFFFF 5 | while b != 0: 6 | a, b = (a ^ b) & mask, ((a & b) << 1) & mask 7 | return a if a <= MAX else ~(a ^ mask) -------------------------------------------------------------------------------- /problems/0371_Sum_of_Two_Integers/reowst.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int getSum(int a, int b) { 4 | if (b == 0) return a; 5 | return getSum(a ^ b, (a & b) << 1); 6 | } 7 | }; -------------------------------------------------------------------------------- /problems/0374_Guess_Number_Higher_or_Lower/nicefuture.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0374_Guess_Number_Higher_or_Lower/nicefuture.java -------------------------------------------------------------------------------- /problems/0378_Kth_Smallest_Element_in_a_Sorted_Matrix /washing.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def kthSmallest(self, matrix, k): 3 | """ 4 | :type matrix: List[List[int]] 5 | :type k: int 6 | :rtype: int 7 | """ 8 | r_list = [] 9 | for i in range(len(matrix)): 10 | for j in range(len(matrix)): 11 | r_list.append(matrix[i][j]) 12 | r_list.sort() 13 | 14 | return r_list[k - 1] -------------------------------------------------------------------------------- /problems/0378_Kth_Smallest_Element_in_a_Sorted_Matrix/0378.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def kthSmallest(self, matrix, k): 3 | """ 4 | :type matrix: List[List[int]] 5 | :type k: int 6 | :rtype: int 7 | """ 8 | r_list = [] 9 | for i in range(len(matrix)): 10 | for j in range(len(matrix)): 11 | r_list.append(matrix[i][j]) 12 | r_list.sort() 13 | 14 | return r_list[k - 1] 15 | -------------------------------------------------------------------------------- /problems/0383_Ransom_Note/0383_Ransom_Note_blueusn.py: -------------------------------------------------------------------------------- 1 | from matplotlib import collections 2 | 3 | 4 | class Solution(object): 5 | def canConstruct(self, ransomNote, magazine): 6 | """ 7 | :type ransomNote: str 8 | :type magazine: str 9 | :rtype: bool 10 | """ 11 | c=collections.Counter(magazine) 12 | for i in ransomNote: 13 | if c[i]==0 or i not in c: 14 | return False 15 | else: 16 | c[i]-=1 17 | return True -------------------------------------------------------------------------------- /problems/0387_First_Unique_Character_in_a_String/0387_First_Unique_Character_in_a_String_bluesun.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def firstUniqChar(self, s): 3 | """ 4 | :type s: str 5 | :rtype: int 6 | """ 7 | flag_list = [] 8 | for i in range(len(s)): 9 | if s[i] not in flag_list: 10 | if s.count(s[i]) == 1: 11 | return i 12 | else: 13 | flag_list.append(s[i]) 14 | return -1 -------------------------------------------------------------------------------- /problems/0387_First_Unique_Character_in_a_String/FirstUniqChar_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0387_First_Unique_Character_in_a_String/FirstUniqChar_st.java -------------------------------------------------------------------------------- /problems/0387_First_Unique_Character_in_a_String/nian.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def firstUniqChar(self, s): 3 | """ 4 | :type s: str 5 | :rtype: int 6 | """ 7 | hash_table = {e:index for index, e in enumerate(s)} 8 | flag=0 9 | for index,item in enumerate(s): 10 | if(index==hash_table[item]): 11 | flag=1 12 | return index 13 | else: 14 | hash_table[item]=-1 15 | if(flag==0): 16 | return -1 17 | -------------------------------------------------------------------------------- /problems/0387_First_Unique_Character_in_a_String/nicefuture.c: -------------------------------------------------------------------------------- 1 | int firstUniqChar(char* s) { 2 | char *p = s; 3 | int cnt[300] = {}; 4 | 5 | while (*p != '\0') { 6 | cnt[*p]++; 7 | p++; 8 | } 9 | 10 | int count = 0; 11 | p = s; 12 | while (*p != '\0') { 13 | if (cnt[*p] == 1) { 14 | return count; 15 | } 16 | count++; 17 | p++; 18 | } 19 | 20 | return -1; 21 | } 22 | -------------------------------------------------------------------------------- /problems/0392_IsSubsequence/Adam.java: -------------------------------------------------------------------------------- 1 | public class Solution { 2 | public boolean isSubsequence(String s, String t) { 3 | if (s.length()==0) { 4 | return true; 5 | } 6 | int is = 0,it = 0; 7 | while(it len(t): return False 9 | if not s: return True 10 | 11 | i = 0 12 | for c in t: 13 | if c == s[i]: 14 | if i == len(s) - 1: return True 15 | else: i += 1 16 | return False 17 | -------------------------------------------------------------------------------- /problems/0400_Nth_Digit/FindNthDigit_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0400_Nth_Digit/FindNthDigit_st.java -------------------------------------------------------------------------------- /problems/0400_Nth_Digit/nicefuture.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0400_Nth_Digit/nicefuture.c -------------------------------------------------------------------------------- /problems/0400_Nth_Digit/wanxu_pursue.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0400_Nth_Digit/wanxu_pursue.java -------------------------------------------------------------------------------- /problems/0401_Binary_Watch/wanxu_pursue_0401.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0401_Binary_Watch/wanxu_pursue_0401.java -------------------------------------------------------------------------------- /problems/0402_Remove_K_Digits/wanxu_pursue_0402.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0402_Remove_K_Digits/wanxu_pursue_0402.java -------------------------------------------------------------------------------- /problems/0405_Convert_a_Number_to_Hexadecimal/ToHex_Servant.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0405_Convert_a_Number_to_Hexadecimal/ToHex_Servant.java -------------------------------------------------------------------------------- /problems/0405_Convert_a_Number_to_Hexadecimal/wanxu_pursue.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0405_Convert_a_Number_to_Hexadecimal/wanxu_pursue.java -------------------------------------------------------------------------------- /problems/0434_Number_of_Segments_in_a_String/nicefuture.c: -------------------------------------------------------------------------------- 1 | int countSegments(char* s) { 2 | char *p = s; 3 | int cnt = 0; 4 | 5 | if (*p != '\0' && *p == 0) return 0; 6 | while (*p != '\0') { 7 | if (*p != ' ' && (*(p+1) == ' ' || *(p+1) == '\0')) { 8 | cnt++; 9 | } 10 | p++; 11 | } 12 | return cnt; 13 | } 14 | -------------------------------------------------------------------------------- /problems/0443_Compress/Compress_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0443_Compress/Compress_st.java -------------------------------------------------------------------------------- /problems/0448_Find_All_Numbers_Disappeared_in_an_Array/ElonPython3.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findDisappearedNumbers(self, nums: List[int]) -> List[int]: 3 | index = 0 4 | while(index < len(nums)): 5 | if nums[index] != index + 1 and nums[index]!= nums[nums[index]-1]: 6 | nums[nums[index] - 1],nums[index], = nums[index], nums[nums[index]-1] 7 | else : 8 | index += 1 9 | result = [] 10 | for index, num in enumerate(nums): 11 | if num != index + 1 : 12 | result.append(index + 1) 13 | return result -------------------------------------------------------------------------------- /problems/0448_Find_All_Numbers_Disappeared_in_an_Array/小恒_3.js: -------------------------------------------------------------------------------- 1 | var findDisappearedNumbers = function(nums) { 2 | let count = {} 3 | let out = [] 4 | 5 | for(let li of nums){ 6 | count[li] = 1 7 | } 8 | for(let i = 1;i <= nums.length;++i){ 9 | if(count[i] !== 1) 10 | out.push(i) 11 | } 12 | return out 13 | }; -------------------------------------------------------------------------------- /problems/0476_Number_Complement/0476_Number_Complement_Rocky.c: -------------------------------------------------------------------------------- 1 | int findComplement(int num) { 2 | int temp = num; 3 | int mask = 1; 4 | 5 | while (temp > 0) { 6 | temp = temp >> 1; 7 | mask = mask << 1; 8 | } 9 | mask--; 10 | 11 | return ~num & mask; 12 | } 13 | -------------------------------------------------------------------------------- /problems/0485_Max_Consecutive_Ones/jiangmimin.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findMaxConsecutiveOnes(self, nums: List[int]) -> int: 3 | count = 0 4 | maxvalue = 0 5 | for i in nums: 6 | if i == 1: 7 | count += 1 8 | else: 9 | if count > maxvalue: 10 | maxvalue = count 11 | count = 0 12 | if count > maxvalue: 13 | return count 14 | return maxvalue -------------------------------------------------------------------------------- /problems/0485_Max_Consecutive_Ones/nicefuture.c: -------------------------------------------------------------------------------- 1 | int findMaxConsecutiveOnes(int* nums, int numsSize){ 2 | int maxi = 0, cnt = 0; 3 | for (int i=0; i maxi) maxi = cnt; 8 | cnt = 0; 9 | } 10 | } 11 | if (cnt > maxi) maxi = cnt; 12 | return maxi; 13 | } 14 | -------------------------------------------------------------------------------- /problems/0485_findMaxConsecutiveOnes/Sam.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0485_findMaxConsecutiveOnes/Sam.c -------------------------------------------------------------------------------- /problems/0496_nextGreaterElement/Sam.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0496_nextGreaterElement/Sam.c -------------------------------------------------------------------------------- /problems/0509_Fibonacci_Number/nicefuture.c: -------------------------------------------------------------------------------- 1 | // 递归 2 | // Runtime: 12 ms 3 | // Memory Usage: 6.9 MB 4 | int fib(int N){ 5 | if (N == 0) return 0; 6 | if (N == 1) return 1; 7 | return fib(N-1)+fib(N-2); 8 | } 9 | -------------------------------------------------------------------------------- /problems/0509_Fibonacci_Number/nicefuture.java: -------------------------------------------------------------------------------- 1 | // 循环 2 | // Runtime: 0 ms 3 | // Memory Usage: 6.7 MB 4 | int fib(int N){ 5 | if (N == 0) return 0; 6 | if (N == 1) return 1; 7 | int a = 0, b = 1, c = 0; 8 | for (int i=2; i<=N; i++) { 9 | c = a+b; 10 | a = b; 11 | b = c; 12 | } 13 | return c; 14 | } 15 | -------------------------------------------------------------------------------- /problems/0521_Longest_Uncommon_Subsequence_I/dachuan.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int findLUSlength(String a, String b) { 3 | int aLen = a.length(); 4 | int bLen = b.length(); 5 | if(aLen != bLen){ 6 | return Math.max(aLen, bLen); 7 | }else{ 8 | if(a.equals(b)){ 9 | return -1; 10 | }else{ 11 | return aLen; 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /problems/0521_Longest_Uncommon_Subsequence_I/nicefuture.c: -------------------------------------------------------------------------------- 1 | int findLUSlength(char* a, char* b) { 2 | if (strcmp(a, b) == 0) { 3 | return -1; 4 | } else { 5 | int len_a = strlen(a), len_b = strlen(b); 6 | return len_a > len_b ? len_a : len_b; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /problems/0539findMinDifference/findMinDifference.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0539findMinDifference/findMinDifference.c -------------------------------------------------------------------------------- /problems/0540_Single_Element_in_a_Sorted_Array/Tony the Cyclist.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def singleNonDuplicate(self, nums): 3 | """ 4 | :type nums: List[int] 5 | :rtype: int 6 | """ 7 | cot = 1 8 | pre = nums[0] 9 | for i in range(1, len(nums), 1): 10 | if nums[i] == pre: 11 | cot += 1 12 | else: 13 | if cot == 1: 14 | return pre 15 | else: 16 | pre = nums[i] 17 | cot = 1 18 | return nums[-1] 19 | -------------------------------------------------------------------------------- /problems/0541_Reverse_String_II/nicefuture.c: -------------------------------------------------------------------------------- 1 | void reverse(char* s, int low, int k) { 2 | for (int i=low; i<(low+k/2); i++) { 3 | char t = s[i]; 4 | s[i] = s[low+k-1-(i-low)]; 5 | s[low+k-1-(i-low)] = t; 6 | } 7 | } 8 | 9 | char* reverseStr(char* s, int k) { 10 | int len = strlen(s); 11 | int i; 12 | for (i=0; (i+2*k) k) reverse(s, i, k); 16 | else reverse(s, i, len-i); 17 | 18 | return s; 19 | } 20 | -------------------------------------------------------------------------------- /problems/0557_Reverse_Words_in_a_String_III/ReverseWords_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0557_Reverse_Words_in_a_String_III/ReverseWords_st.java -------------------------------------------------------------------------------- /problems/0557_Reverse_Words_in_a_String_III/boom米花.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {string} s 3 | * @return {string} 4 | */ 5 | var reverseWords = function(s) { 6 | let arr = s.split(' ') 7 | let result = arr.map(item => { 8 | return item.split('').reverse().join('') 9 | }) 10 | return result.join(' ') 11 | }; -------------------------------------------------------------------------------- /problems/0557_Reverse_Words_in_a_String_III/nicefuture.c: -------------------------------------------------------------------------------- 1 | void reverse(char *low, char *ceiling) { 2 | int len = ceiling-low+1; 3 | for (int i=0; i List[List[int]]: 3 | total_len = 0 4 | nums_one = [] 5 | for lst in nums: 6 | total_len += len(lst) 7 | nums_one += lst 8 | if r * c != total_len: 9 | return nums 10 | # print(f"nums_one{nums_one}") 11 | 12 | nums_ret = [] 13 | for i in range(0, r): 14 | j = i * c 15 | nums_ret.append(nums_one[j : j + c]) 16 | return nums_ret 17 | -------------------------------------------------------------------------------- /problems/0566_Reshape_the_Matrix/Elon.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def matrixReshape(self, nums, r, c): 3 | """ 4 | :type nums: List[List[int]] 5 | :type r: int 6 | :type c: int 7 | :rtype: List[List[int]] 8 | """ 9 | #code by Elon 10 | flat = sum(nums,[]) 11 | result = [] 12 | if len(flat)==r*c: 13 | for index in range(r): 14 | result.append(flat[index*c:index*c+c]) 15 | return result 16 | else : return nums -------------------------------------------------------------------------------- /problems/0566_Reshape_the_Matrix/Reshape_the_Matrix.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector> matrixReshape(vector>& nums, int r, int c) { 4 | int row = nums.size(), colum = nums[0].size(); 5 | if (row * colum != r * c) return nums; 6 | vector> res(r, vector(c)); 7 | for (int i = 0; i < r; i++) { 8 | for (int j = 0; j < c; j++) { 9 | int k = i * c + j; 10 | res[i][j] = nums[k / colum][k % colum]; 11 | } 12 | } 13 | return res; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /problems/0566_Reshape_the_Matrix/reowst.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector> matrixReshape(vector>& nums, int r, int c) { 4 | int row = nums.size(); 5 | int column = nums[0].size(); 6 | vector> R(r, vector(c, 0)); 7 | if(row * column != r*c) 8 | return nums; 9 | for(int i = 0; i < row; i++) 10 | for(int j = 0; j < column; j++) 11 | { 12 | int n = i * column + j; 13 | R[n/c][n%c] = nums[i][j]; 14 | } 15 | return R; 16 | } 17 | }; -------------------------------------------------------------------------------- /problems/0566_Reshape_the_Matrix/solution.py: -------------------------------------------------------------------------------- 1 | # 首先,需要对边界的情况做出处理 2 | # 如果重塑后的矩阵的元素数量大于原始矩阵的元素数量,则为异常情况 3 | # 对于正常情况,我们遍历原来的矩阵, 4 | # 并且定义两个数组,一个用来存放新的矩阵,一个用来存放矩阵每行的元素 5 | # 在遍历时,如果行数组的元素数量满足新矩阵对列元素数量的要求 6 | # 那么将该行数组放入新矩阵数组中,然后清空行数组,继续遍历,直至结束 7 | class Solution: 8 | def matrixReshape(self, nums, r, c): 9 | if r * c > len(nums) * len(nums[0]): 10 | return nums 11 | else: 12 | res = [] 13 | tmp = [] 14 | for line in nums: 15 | for value in line: 16 | tmp.append(value) 17 | if len(tmp) == c: 18 | res.append(tmp) 19 | tmp = [] 20 | return res 21 | -------------------------------------------------------------------------------- /problems/0581_Shortest_Unsorted_Continuous_Subarray/xiaoheng_3_0581.js: -------------------------------------------------------------------------------- 1 | var findUnsortedSubarray = function(nums) { 2 | 3 | let [left, right, Nums] = [0, nums.length-1, [...nums]]; 4 | 5 | nums.sort((x,y)=>x-y); 6 | 7 | while(right > left){ 8 | nums[left] === Nums[left] && left++; 9 | nums[right] === Nums[right] && right--; 10 | 11 | if(nums[left] !== Nums[left] && nums[right] !== Nums[right]) break; 12 | } 13 | 14 | return right === left ? 0 : right-left+1; 15 | }; -------------------------------------------------------------------------------- /problems/0633_Sum_of_Square_Numbers/bbj.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | bool judgeSquareSum(int c) { 4 | int head = 0; 5 | long long n = int(sqrt(c)); 6 | long long tail = n; 7 | while (head <= tail){ 8 | long long res = head * head + tail * tail; 9 | if (res == c) return true; 10 | else if (res > c) 11 | tail -= 1; 12 | else head += 1; 13 | } 14 | return false; 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /problems/0646_Maximum_Length_of_Pair_Chain/Elon.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def findLongestChain(self, pairs: List[List[int]]) -> int: 3 | cur, result = float('-inf'), 0 4 | for x, y in sorted(pairs, key = lambda x : x[1]): 5 | if cur < x: 6 | cur = y 7 | result += 1 8 | return result -------------------------------------------------------------------------------- /problems/0646_Maximum_Length_of_Pair_Chain/Maximum_Length_of_Pair_Chain.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | static bool cmp(vector &a, vector &b) { 4 | return a[1] < b[1]; 5 | } 6 | int findLongestChain(vector>& pairs) { 7 | sort(pairs.begin(), pairs.end(), cmp); 8 | int end = INT_MIN; 9 | int res = 0; 10 | for (auto pair : pairs) { 11 | if (pair[0] > end) { 12 | res++; 13 | end = pair[1]; 14 | } 15 | } 16 | return res; 17 | } 18 | }; -------------------------------------------------------------------------------- /problems/0650_2_Keys_Keyboard/xiaoheng_3.c: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int minSteps(int n) { 4 | int res = 0; 5 | for (int i = 2; i <= n; i++) { 6 | while (n % i == 0) { 7 | res += i; 8 | n /= i; 9 | } 10 | } 11 | return res; 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /problems/0657_Robot_Return_to_Origin/nicefuture.c: -------------------------------------------------------------------------------- 1 | bool judgeCircle(char* moves) { 2 | int cnt[255] = {}; 3 | char *p = moves; 4 | while (*p != '\0') { 5 | cnt[*p]++; 6 | p++; 7 | } 8 | if (cnt['U'] == cnt['D'] && cnt['L'] == cnt['R']) return true; 9 | else return false; 10 | } 11 | -------------------------------------------------------------------------------- /problems/0665_Non_decreasing_Array/nil.go: -------------------------------------------------------------------------------- 1 | package NondecreasingArray 2 | 3 | 4 | func judge(nums []int) bool { 5 | for i := 0; i < len(nums)-1; i++ { 6 | if nums[i] > nums[i+1] { 7 | return false 8 | } 9 | } 10 | return true 11 | } 12 | 13 | func checkPossibility(nums []int) bool { 14 | tmp := make([]int, len(nums)) 15 | copy(tmp, nums) 16 | for i := 0; i < len(nums); i++ { 17 | old := nums[i] 18 | if i > 0 { 19 | tmp[i] = tmp[i-1] 20 | } else { 21 | tmp[i] = -(1<<10) 22 | } 23 | if judge(tmp) { 24 | return true 25 | } 26 | tmp[i] = old 27 | } 28 | return false 29 | } -------------------------------------------------------------------------------- /problems/0704_Binary_Search/0704_Binary_Search_by_persiststudy.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0704_Binary_Search/0704_Binary_Search_by_persiststudy.c -------------------------------------------------------------------------------- /problems/0707_MyLinkedList/MyLinkedList.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0707_MyLinkedList/MyLinkedList.cpp -------------------------------------------------------------------------------- /problems/0709_To_Lower_Case/0709_To_Lower_Case.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {string} str 3 | * @return {string} 4 | */ 5 | var toLowerCase = function(str) { 6 | var i = 0; 7 | while(str[i]) 8 | { 9 | if( (str[i]>='A') 10 | &&(str[i]<='Z') 11 | ) 12 | { 13 | str[i] ^= 32; 14 | } 15 | i++; 16 | } 17 | 18 | return str; 19 | }; -------------------------------------------------------------------------------- /problems/0709_To_Lower_Case/709_To_Lower_Case.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public String toLowerCase(String str) { 3 | 4 | String ans=""; 5 | for(int i=0;i='A' && t<='Z') 16 | { 17 | t=(char)(t+32); 18 | } 19 | return t; 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /problems/0709_To_Lower_Case/709_To_Lower_Case/nicefuture.c: -------------------------------------------------------------------------------- 1 | char* toLowerCase(char* str) { 2 | char *p = str; 3 | while (*p != '\0') { 4 | if (*p >= 'A' && *p <= 'Z') *p = 'a' + (*p - 'A'); 5 | p++; 6 | } 7 | return str; 8 | } 9 | -------------------------------------------------------------------------------- /problems/0717_1-bit and 2-bit Characters/xiaoheng_3.js: -------------------------------------------------------------------------------- 1 | var isOneBitCharacter = function(bits) { 2 | let i = 0 3 | 4 | while(i < bits.length-1){ 5 | i = bits[i] === 0 ? i + 1 : i + 2 6 | } 7 | 8 | return i === bits.length-1 && bits[bits.length-1] === 0 9 | }; -------------------------------------------------------------------------------- /problems/0769_Max_Chunks_To_Make_Sorted/Elon.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxChunksToSorted(self, arr: List[int]) -> int: 3 | maxval, result = 0, 0 4 | for index,num in enumerate(arr): 5 | maxval = max(maxval, num) 6 | if index == maxval: 7 | result += 1 8 | return result 9 | -------------------------------------------------------------------------------- /problems/0769_Max_Chunks_To_Make_Sorted/jiangxiaomi.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxChunksToSorted(self, arr: List[int]) -> int: 3 | count = 0 4 | for key,value in enumerate(arr): 5 | if key == max(arr[:key+1]): 6 | count +=1 7 | return count -------------------------------------------------------------------------------- /problems/0769_Max_Chunks_To_Make_Sorted/mark.cpp: -------------------------------------------------------------------------------- 1 | // 我们只要维护一个数组max[],max[i]表示输入数字arr[0...i]这个区间最大的值。因为这个输入数组包含所有0到n-1的数字,所以我们只需要从左到右来判断是否max[i] == i,如果满足就说明了小于等于i的数都在包含了,这里可以是所谓chunk的一个分割点 2 | 3 | class Solution { 4 | public: 5 | int maxChunksToSorted(vector& arr) { 6 | 7 | int num = 0; 8 | int max = arr[0]; 9 | int len = arr.size(); 10 | for(int i = 0; i < len; i++){ 11 | max = arr[i] > max ? arr[i] : max; 12 | if (max == i) 13 | num++; 14 | } 15 | 16 | return num; 17 | } 18 | 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /problems/0769_Max_Chunks_To_Make_Sorted/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def maxChunksToSorted(self, arr): 3 | max_index = 0 4 | result = 0 5 | for i, a in enumerate(arr): 6 | if a > max_index: 7 | max_index = a 8 | if max_index == i: 9 | result += 1 10 | return result 11 | -------------------------------------------------------------------------------- /problems/0769_Max_Chunks_To_Make_Sorted/zhaoqianxilan.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0769_Max_Chunks_To_Make_Sorted/zhaoqianxilan.cpp -------------------------------------------------------------------------------- /problems/0771_Jewels_And_Stones/0771_Jewels_And_Stones.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {string} J 3 | * @param {string} S 4 | * @return {number} 5 | */ 6 | var numJewelsInStones = function(J, S) { 7 | var i,k,count=0; 8 | for(i=0;S[i];i++) 9 | { 10 | for(k=0;J[k];k++) 11 | { 12 | if(J[k]==S[i]) 13 | count++; 14 | } 15 | } 16 | return count; 17 | }; -------------------------------------------------------------------------------- /problems/0783_Min_Diff_In_BST/solution.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def inOrder(self, root, res): 3 | if root is None: 4 | return 5 | self.inOrder(root.left, res) 6 | res.append(root.val) 7 | self.inOrder(root.right, res) 8 | def minDiffInBST(self, root): 9 | if root is None: 10 | return 0 11 | else: 12 | res = [] 13 | self.inOrder(root, res) 14 | if len(res) == 1: 15 | return res[0] 16 | min_val = res[1] - res[0] 17 | for i in range(2, len(res)): 18 | if res[i] - res[i-1] < min_val: 19 | min_val = res[i] - res[i-1] 20 | return min_val 21 | -------------------------------------------------------------------------------- /problems/0784_Letter_Case_Permutation/Elon.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def letterCasePermutation(self, S: str) -> List[str]: 3 | result = [''] 4 | for c in S: 5 | if c.isalpha(): 6 | result = [prefix + char for prefix in result for char in [c.lower(),c.upper()]] 7 | else: 8 | result = [prefix + c for prefix in result] 9 | return result 10 | -------------------------------------------------------------------------------- /problems/0784_Letter_Case_Permutation/zhaoqianxilan.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0784_Letter_Case_Permutation/zhaoqianxilan.cpp -------------------------------------------------------------------------------- /problems/0788_Rotated_Digits/0788_Rotated_Digits.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def rotatedDigits(self, N): 3 | """ 4 | :type N: int 5 | :rtype: int 6 | """ 7 | res = 0 8 | for num in range(N + 1): 9 | string_num = str(num) 10 | if "3" in string_num or "4" in string_num or "7" in string_num: 11 | continue 12 | elif "2" in string_num or "5" in string_num or "6" in string_num or "9" in string_num: 13 | res += 1 14 | return res 15 | -------------------------------------------------------------------------------- /problems/0788_Rotated_Digits/0788_Rotated_DigitsbyMagnetStone.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0788_Rotated_Digits/0788_Rotated_DigitsbyMagnetStone.scala -------------------------------------------------------------------------------- /problems/0788_Rotated_Digits/ElonPython3.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def rotatedDigits(self, N): 3 | """ 4 | :type N: int 5 | :rtype: int 6 | """ 7 | badSet = {'3','4','7'} 8 | goodSet = {'2','5','6','9'} 9 | count = 0 10 | for i in range(N + 1): 11 | numSet = set(str(i)) 12 | if badSet & numSet: 13 | continue 14 | elif goodSet & numSet: 15 | count += 1 16 | return count 17 | -------------------------------------------------------------------------------- /problems/0788_Rotated_Digits/RotatedDigits_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0788_Rotated_Digits/RotatedDigits_st.java -------------------------------------------------------------------------------- /problems/0788_Rotated_Digits/Rotated_Digits.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | int rotatedDigits(int N) { 4 | int res = 0; 5 | for (int i = 1; i <= N; ++i) { 6 | if (check(i)) ++res; 7 | } 8 | return res; 9 | } 10 | bool check(int k) { 11 | string str = to_string(k); 12 | bool flag = false; 13 | for (char c : str) { 14 | if (c == '3' || c == '4' || c == '7') return false; 15 | if (c == '2' || c == '5' || c == '6' || c == '9') flag = true;; 16 | } 17 | return flag; 18 | } 19 | }; 20 | -------------------------------------------------------------------------------- /problems/0788_Rotated_Digits/protea_ban.py: -------------------------------------------------------------------------------- 1 | class Solution(object) 2 | def rotatedDigits(self, N) 3 | 4 | type N int 5 | rtype int 6 | 7 | valid = [2, 5, 6, 9] 8 | nonValid = [3, 4, 7] 9 | def isGood(num) 10 | for y in nonValid 11 | if str(y) in str(num) 12 | return False 13 | return any(str(x) in str(num) for x in valid) 14 | return sum(map(int, [isGood(n) for n in range(1, N + 1)])) 15 | -------------------------------------------------------------------------------- /problems/0788_Rotated_Digits/yyh.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def rotatedDigits(self, N): 3 | res = 0 4 | for n in range(1, N + 1): 5 | nset = set(map(int, str(n))) 6 | if any(x in nset for x in (2, 5, 6, 9)): 7 | if not any(x in nset for x in (3, 4, 7)): 8 | res += 1 9 | return res -------------------------------------------------------------------------------- /problems/0788_Rotated_Digits/จุ๊บ.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int rotatedDigits(int N) { 3 | int answer = 0; 4 | for(int i=0;i<=N;i++) { //数字中包含2、5、6、9,而不含3、4、7的都是好数 5 | String str = String.valueOf(i); 6 | if((str.contains("2")||str.contains("5")||str.contains("6")||str.contains("9"))&&(!str.contains("3")&&!str.contains("7")&&!str.contains("4"))) { 7 | answer++; 8 | } 9 | } 10 | return answer; 11 | } 12 | } -------------------------------------------------------------------------------- /problems/0804_Unique_Morse_Code_Words/804_Unique_Morse_Code_Words.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {string[]} words 3 | * @return {number} 4 | */ 5 | var uniqueMorseRepresentations = function (words) { 6 | const dic = [".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."] 7 | return new Set(words.map(item => [...item].map(ch => dic[ch.charCodeAt() - 97]).join(''))).size 8 | }; -------------------------------------------------------------------------------- /problems/0817_Linked_List_Components/numComponents.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | 3 | class Solution: 4 | def numComponents(self, head: ListNode, G: List[int]) -> int: 5 | g_set = set(G) 6 | count = 0 7 | while head: 8 | if head.val in g_set and (head.next is None or head.next.val not in g_set): 9 | count += 1 10 | head = head.next 11 | return count 12 | -------------------------------------------------------------------------------- /problems/0852_Peak_Index_in_a_Mountain_Array/0852_Peak_Index_in_a_Mountain_Array.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {number[]} A 3 | * @return {number} 4 | */ 5 | var peakIndexInMountainArray = function(A) { 6 | let min = 0 7 | let max = A.length - 1 8 | while (min <= max) { 9 | let mid = ~~((min + max) / 2) 10 | if (A[mid] < A[mid + 1]) { 11 | min = mid 12 | } else if (A[mid] < A[mid - 1]) { 13 | max = mid 14 | } else { 15 | return mid 16 | } 17 | } 18 | }; -------------------------------------------------------------------------------- /problems/0867_Transpose_Matrix/dachuan.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int[][] transpose(int[][] A) { 3 | //产生确定新数组的两个数字 4 | int[][] B = new int[A[0].length][A.length]; 5 | //重新布阵 6 | for (int i = 0; i < A.length; i++) { 7 | for (int j = 0; j < A[0].length; j++) { 8 | B[j][i] = A[i][j]; 9 | } 10 | } 11 | return B; 12 | } 13 | } -------------------------------------------------------------------------------- /problems/0867_Transpose_Matrix/jiangxiaomi.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def transpose(self, A: List[List[int]]) -> List[List[int]]: 3 | list = [] 4 | for i in range (len(A[0])): 5 | temp = [ j[i] for j in A] 6 | list.append(temp) 7 | return list -------------------------------------------------------------------------------- /problems/0876_Middle_of_the_Linked_List/qingcaibaiyutang17.c: -------------------------------------------------------------------------------- 1 | struct ListNode* middleNode(struct ListNode* head){ 2 | struct ListNode *fast=head,*slow=head; 3 | while(fast&&fast->next){ 4 | slow=slow->next; 5 | fast=fast->next->next; 6 | } 7 | return slow; 8 | } -------------------------------------------------------------------------------- /problems/0890_Find_And_Replace_Pattern/FindAndReplacePattern_st.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0890_Find_And_Replace_Pattern/FindAndReplacePattern_st.java -------------------------------------------------------------------------------- /problems/0890_Find_And_Replace_Pattern/sanwuqiyan.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0890_Find_And_Replace_Pattern/sanwuqiyan.java -------------------------------------------------------------------------------- /problems/0905_Sort_Array_By_Parity/SortArrayByParity_Servant.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0905_Sort_Array_By_Parity/SortArrayByParity_Servant.java -------------------------------------------------------------------------------- /problems/0905_Sort_Array_By_Parity/peanwang.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Time complexy O(n) 3 | Space complexy O(1) 4 | */ 5 | class Solution { 6 | public: 7 | vector sortArrayByParity(vector& A) { 8 | for(int i=0,j=0;j K * 2) { 9 | return max - min - K * 2; 10 | }else{ 11 | return 0; 12 | } 13 | } 14 | } 15 | //这道题的解答倒是很简答,就是题目看了好几遍,完全不知道出题的想表达什么,在理解题目的意思上花了大量的时间 -------------------------------------------------------------------------------- /problems/0929_Unique_Email_Addresses/0929_Unique_Email_Addresses.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {string[]} emails 3 | * @return {number} 4 | */ 5 | var numUniqueEmails = function(emails) { 6 | return [...new Set( emails.map(e => e.split('@')[0].split('.').join('').split('+')[0] + '@' + e.split('@')[1]))].length; 7 | } 8 | -------------------------------------------------------------------------------- /problems/0929_Unique_Email_Addresses/dachuan.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int numUniqueEmails(String[] emails) { 3 | Set sets = new HashSet(); 4 | for (String email : emails) { 5 | String[] strs = email.split("@"); 6 | String left = strs[0]; 7 | left = left.replace(".", ""); 8 | int index = left.indexOf("+"); 9 | left = left.substring(0, index); 10 | 11 | String right = strs[1]; 12 | String content = left + right; 13 | sets.add(content); 14 | } 15 | return sets.size(); 16 | } 17 | } -------------------------------------------------------------------------------- /problems/0961_ N-Repeated_Element_in_Size_2N_Array/qingcaibaiyutang17.c: -------------------------------------------------------------------------------- 1 | int repeatedNTimes(int* A, int ASize) { 2 | int i,j,temp; 3 | for(i=0;iA[j]){ 6 | temp=A[i]; 7 | A[i]=A[j]; 8 | A[j]=temp; 9 | } 10 | } 11 | } 12 | if(A[(ASize-1)/2]==A[(ASize-1)/2-1]){ 13 | return A[(ASize-1)/2]; 14 | }else{ 15 | return A[ASize/2]; 16 | } 17 | } -------------------------------------------------------------------------------- /problems/0961_N-Repeated_Element_in_Size_2N_Array/dachuan.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int repeatedNTimes(int[] A) { 3 | Arrays.sort(A); 4 | int num = 0; 5 | int tmp = 0; 6 | int len = A.length; 7 | for (int i = 0; i < len; i++) { 8 | if (A[i] != tmp) { 9 | if (num == len / 2) { 10 | return A[i - 1]; 11 | } 12 | num = 1; 13 | tmp = A[i]; 14 | }else{ 15 | num++; 16 | } 17 | } 18 | return A[len - 1]; 19 | } 20 | } -------------------------------------------------------------------------------- /problems/0977_Squares_of_a_Sorted_Array/bbj.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector sortedSquares(vector& A) { 4 | vector res; 5 | for (int i = 0; i < A.size(); i++){ 6 | res.push_back(abs(A[i] * A[i])); 7 | } 8 | sort(res.begin(), res.end()); 9 | return res; 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /problems/0977_Squares_of_a_Sorted_Array/dachuan.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int[] sortedSquares(int[] A) { 3 | int[] B = new int[A.length]; 4 | for (int i = 0; i < A.length; i++) { 5 | int m = A[i] * A[i]; 6 | B[i] = m; 7 | } 8 | Arrays.sort(B); 9 | return B; 10 | } 11 | } -------------------------------------------------------------------------------- /problems/0989_Add_to_Array_Form_of_Integer/989_22k.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public List addToArrayForm(int[] A, int k) { 3 | List res = new LinkedList<>(); 4 | for(int i=A.length-1;i>=0;i--){ 5 | res.add(0 ,(A[i] + k) % 10); 6 | k=(k+A[i])/10; 7 | } 8 | while(k>0){ 9 | res.add(0,k%10); 10 | k = k/10; 11 | } 12 | return res; 13 | } 14 | } -------------------------------------------------------------------------------- /problems/0995_Sort_Array_By_Parity/21_no995.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def sortArrayByParity(self, A: List[int]) -> List[int]: 3 | # more pythonic 4 | result = list(filter(lambda x: x % 2 == 0, A)) + list(filter(lambda x: x % 2 != 0, A)) 5 | return result 6 | -------------------------------------------------------------------------------- /problems/0997_Find_the_Town_Judge/ass.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/problems/0997_Find_the_Town_Judge/ass.c -------------------------------------------------------------------------------- /problems/1013_Partition_Array_Into_Three_Parts_With_Equal_Sum/qingcaibaiyutang17.c: -------------------------------------------------------------------------------- 1 | bool canThreePartsEqualSum(int* A, int ASize){ 2 | int i,sum=0,m=0,j=0; 3 | for(i=0;i int: 3 | def findOnes(i, j): 4 | A[i][j] = 0 5 | for x, y in (i - 1, j), (i, j - 1), (i + 1, j), (i, j + 1): 6 | if 0 <= x < m and 0 <= y < n and A[x][y] == 1: 7 | findOnes(x, y) 8 | m, n = len(A), len(A[0]) 9 | for i in range(m): 10 | for j in range(n): 11 | if (i == 0 or i == m-1 or j == 0 or j == n-1) and A[i][j] == 1: 12 | findOnes(i,j) 13 | return sum(sum(row) for row in A) -------------------------------------------------------------------------------- /problems/1021_Remove_Outermost_Parentheses/21_charlie.py: -------------------------------------------------------------------------------- 1 | class Solution: 2 | def removeOuterParentheses(self, S: str) -> str: 3 | count = 0 4 | new_string = "" 5 | for index in S: 6 | if index == '(': 7 | count += 1 8 | if count > 1: 9 | new_string += '(' 10 | else: 11 | count -= 1 12 | if count > 0: 13 | new_string += ')' 14 | return new_string 15 | -------------------------------------------------------------------------------- /problems/1025_Divisor_Game/dachuan.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public boolean divisorGame(int N) { 3 | return N % 2 == 0 ? true : false; 4 | } 5 | } 6 | //这道题看了半天,最后发现怎么成了智力题了,谁拿到奇数谁就输了 -------------------------------------------------------------------------------- /submittors/01nicefuture.txt: -------------------------------------------------------------------------------- 1 | 657f4ab6e64f5d030f109a435f1e9429287fb980 2 | -------------------------------------------------------------------------------- /submittors/05KevinHe.txt: -------------------------------------------------------------------------------- 1 | 6354293d15487575e5b448c7538eb08ff4a1d242 -------------------------------------------------------------------------------- /submittors/05_KevinHe.txt: -------------------------------------------------------------------------------- 1 | ee32dd3b5ffb9112fdbb4f4e2a9a15183d5ada0a -------------------------------------------------------------------------------- /submittors/05__KevinHe.txt: -------------------------------------------------------------------------------- 1 | d92a7466de45a4f7d3fbb2a8de0d5a82edd9c3b3 -------------------------------------------------------------------------------- /submittors/1-nicefuture.txt: -------------------------------------------------------------------------------- 1 | 9d7299c7809af5c93586f86064727af35cf9e497 2 | -------------------------------------------------------------------------------- /submittors/10_O-Ra2f.py: -------------------------------------------------------------------------------- 1 | 906a7593a4b950eecaa159852a7e959392548123 2 | -------------------------------------------------------------------------------- /submittors/10_O_Ra2f: -------------------------------------------------------------------------------- 1 | 4813d0562e2902deda5b074200f109ed1fd0b85b 2 | -------------------------------------------------------------------------------- /submittors/10_RA2F: -------------------------------------------------------------------------------- 1 | 2 | 0eb2fcc2824cf233c3951be4c0573919f2916bdf 3 | -------------------------------------------------------------------------------- /submittors/15 - 活跃time:101.txt: -------------------------------------------------------------------------------- 1 | befe25c453cfa0307a759a73fb482b2c158ac5fd -------------------------------------------------------------------------------- /submittors/15 - 活跃time:120.txt: -------------------------------------------------------------------------------- 1 | aa51667dfb1b350dd86bc1f1e581eb5820b2b358 -------------------------------------------------------------------------------- /submittors/15 - 活跃time:76: -------------------------------------------------------------------------------- 1 | 5540319081732f82a139e79dc32a9dbe163a6931 2 | -------------------------------------------------------------------------------- /submittors/16_klgentle_smile_3w.txt: -------------------------------------------------------------------------------- 1 | c5be818eff499506bf8a12137f7792534937c323 2 | -------------------------------------------------------------------------------- /submittors/16_klgentle_smile_4w.txt: -------------------------------------------------------------------------------- 1 | d7b64c42d1ba8544291b9e2ed3e0e5430a09416f 2 | -------------------------------------------------------------------------------- /submittors/18_Decadence.txt: -------------------------------------------------------------------------------- 1 | 48d34b0b28d17d704160c8911a275abc37f265aa 2 | -------------------------------------------------------------------------------- /submittors/19_大船_0609.txt: -------------------------------------------------------------------------------- 1 | 305d7497942db0ec0a64a207b35104518a8317ab -------------------------------------------------------------------------------- /submittors/19_大船_0616.txt: -------------------------------------------------------------------------------- 1 | 0139fba27c7882b32824ebf0a31266ada4a7ea21 -------------------------------------------------------------------------------- /submittors/19大船.txt: -------------------------------------------------------------------------------- 1 | 24e8a0c68cc0265cc47d1bf7c1cb7f3198a7f774 -------------------------------------------------------------------------------- /submittors/1nicefuture.txt: -------------------------------------------------------------------------------- 1 | 329df719f20e9d3907d5698e4acc8bc47f4b0d2d 2 | -------------------------------------------------------------------------------- /submittors/2-lionfly.txt: -------------------------------------------------------------------------------- 1 | 840087ce8232ca80f60b5477ba5d214dc1de8a39 2 | fd0ecff1fb6e30105632bfdc007d83efdc86acf1 3 | -------------------------------------------------------------------------------- /submittors/20_Painting、时光.txt: -------------------------------------------------------------------------------- 1 | a597bf704bc75afb5246e627df4d28cc20effa0c -------------------------------------------------------------------------------- /submittors/22_黄有才_1.txt: -------------------------------------------------------------------------------- 1 | commit 110c301a9f81611ccc5ccd2e62cf688f561e850c 2 | -------------------------------------------------------------------------------- /submittors/22_黄有才_第三周.txt: -------------------------------------------------------------------------------- 1 | commit 7a7e0b257dd2a4e410697ca69562cd77363e328b 2 | -------------------------------------------------------------------------------- /submittors/22_黄有才_第四周.txt: -------------------------------------------------------------------------------- 1 | commit 521b0722cab3e308192cdbfe8aaacf1035f38d4a -------------------------------------------------------------------------------- /submittors/22k.txt: -------------------------------------------------------------------------------- 1 | 2b8db0b7deb996c846437e0194b9e2362a54e37e -------------------------------------------------------------------------------- /submittors/23令狐冲.java: -------------------------------------------------------------------------------- 1 | 2018-06-09 提交: 0101和0102的题解 2 | 3 | 4 | 66b89ddde6f36f7b05841af4f4da7722a83d4d8e -------------------------------------------------------------------------------- /submittors/23令狐冲_0616.java: -------------------------------------------------------------------------------- 1 | 2 | 91632c2246e835e20a22a244e683294e6687a693 23——令狐冲提交_ 0616 -------------------------------------------------------------------------------- /submittors/24-北极熊.txt: -------------------------------------------------------------------------------- 1 | 第一周: f5104bb3acbfd834454c234f330c6df5be08cdaa 2 | 第二周: d0e4d9d5b80226f4caf9a703d56be43e25634b3d 3 | 第三周: f697dd6d1414506ed90e3a977170f7ce3be353a7 4 | 第四周: 44f56f7a1eb88e1eb4fa74980e5e63d5604f98c5 -------------------------------------------------------------------------------- /submittors/27_Torres@Ng: -------------------------------------------------------------------------------- 1 | a34066aa0cfa70d8cfe17996c91f5aa72a4c49e0 2 | -------------------------------------------------------------------------------- /submittors/28_dev_bin.txt: -------------------------------------------------------------------------------- 1 | cea65b7054f92a64d509c793e09d550c907eb4e8 2 | -------------------------------------------------------------------------------- /submittors/2_lionfly.txt: -------------------------------------------------------------------------------- 1 | fd0ecff1fb6e30105632bfdc007d83efdc86acf1 2 | 173cc1fd589331069b57c75f641312a68d024841 3 | -------------------------------------------------------------------------------- /submittors/30_bigfish.txt: -------------------------------------------------------------------------------- 1 | c24c1493913f62a867d6c89e22bb6fb853994831 2 | -------------------------------------------------------------------------------- /submittors/39_Abel.txt: -------------------------------------------------------------------------------- 1 | 101:c0b0e2f67cdc90d912d6ad4e9d747300ebabb31e 2 | 120:72a7a51915416a1292975ac4398041647da3b36b 3 | -------------------------------------------------------------------------------- /submittors/39_Abel_6月8日.txt: -------------------------------------------------------------------------------- 1 | commit c1a6a43fef1b69b3da519d1cdd664767dc41e937 2 | -------------------------------------------------------------------------------- /submittors/39_Abel_Alan.txt: -------------------------------------------------------------------------------- 1 | commit 110c301a9f81611ccc5ccd2e62cf688f561e850c 2 | -------------------------------------------------------------------------------- /submittors/4_秩秩斯干.txt: -------------------------------------------------------------------------------- 1 | da01e1c34cdca4601a4edd971341a745aa36c8a8 2 | 08045eeb02a76f6b3a8383f22bea3e0e7ea30a74 3 | -------------------------------------------------------------------------------- /submittors/6-hebust-fengyu_0004.寻找两个有序数组的中位数.txt: -------------------------------------------------------------------------------- 1 | ac890541d8bfa5d2cca820f0e1783c6730ec76c1 -------------------------------------------------------------------------------- /submittors/6-hebust-fengyu_0075_Sort_Colors.txt: -------------------------------------------------------------------------------- 1 | 3b94bafb28dbcd9bc9652ff593ee155c52134676 -------------------------------------------------------------------------------- /submittors/6-hebust-fengyu_0101_Symmetric_Tree.txt: -------------------------------------------------------------------------------- 1 | 8688ab0e8d2e1bdb78dcafcbc120b625af4d3d3b -------------------------------------------------------------------------------- /submittors/ALOHA.txt: -------------------------------------------------------------------------------- 1 | ad4102e0c5fb49a7d264ea434d45540c88744f5a -------------------------------------------------------------------------------- /submittors/dev_bin_28-3.txt: -------------------------------------------------------------------------------- 1 | 527a10516d9a1bb21555297e1d3a3736a250bedd 2 | -------------------------------------------------------------------------------- /submittors/dev_bin_28.txt: -------------------------------------------------------------------------------- 1 | f70d70ee510944dc4f94491ca1e028ea28175e50 2 | -------------------------------------------------------------------------------- /submittors/jasonvv_35_0028.txt: -------------------------------------------------------------------------------- 1 | 82becf38eb2590bf29475b1bd6edf0af1b29bbf1 2 | -------------------------------------------------------------------------------- /submittors/jasonvv_35_0035.txt: -------------------------------------------------------------------------------- 1 | 819bd7c1bcfa98bb4fb920d3bfd2dcd965ed95d8 2 | -------------------------------------------------------------------------------- /submittors/jasonvv_35_0058.txt: -------------------------------------------------------------------------------- 1 | 654b856cf142883a010471b9dbd0ce7b65c3e84c 2 | -------------------------------------------------------------------------------- /submittors/liangxu.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yychuyu/LeetCode/48384483a55e120caf5d8d353e9aa287fce3cf4a/submittors/liangxu.txt -------------------------------------------------------------------------------- /submittors/qingcaibaiyutang17_2.txt: -------------------------------------------------------------------------------- 1 | 4fa4158a9cabcf89588055ef95a9d1aab5906397 -------------------------------------------------------------------------------- /submittors/qingcaibaiyutang17_3.txt: -------------------------------------------------------------------------------- 1 | aa50e558c8d7a0d0d95f973eba340e8a92ab64da -------------------------------------------------------------------------------- /submittors/qingcaibaiyutang17_4.txt: -------------------------------------------------------------------------------- 1 | 8478145abb9867e6711de199ebe6f9270cfabd13 -------------------------------------------------------------------------------- /submittors/tyrone2497-31.txt: -------------------------------------------------------------------------------- 1 | b007f07a430004925c1d76ec4f5f91276250dfaf 2 | -------------------------------------------------------------------------------- /submittors/washing_add_0007: -------------------------------------------------------------------------------- 1 | c4f5a5a0c11e6a388bf311e1a2b54a75d9707384 2 | -------------------------------------------------------------------------------- /submittors/小恒_3_581题.txt: -------------------------------------------------------------------------------- 1 | 0b0827c917675716e92c74562dc5a3795b213637 -------------------------------------------------------------------------------- /submittors/小恒_3_650题.txt: -------------------------------------------------------------------------------- 1 | 0b0827c917675716e92c74562dc5a3795b213637 -------------------------------------------------------------------------------- /submittors/小恒_3_717题.txt: -------------------------------------------------------------------------------- 1 | 0b0827c917675716e92c74562dc5a3795b213637 -------------------------------------------------------------------------------- /submittors/小恒_3_78题.txt: -------------------------------------------------------------------------------- 1 | 0b0827c917675716e92c74562dc5a3795b213637 -------------------------------------------------------------------------------- /submittors/第三周_25pg_1.txt: -------------------------------------------------------------------------------- 1 | d03bd93539666fe718b7af7aad3fa2283a81b7b5 -------------------------------------------------------------------------------- /submittors/第三周_25pg_2.txt: -------------------------------------------------------------------------------- 1 | 8ff9ef77d02c4bf58d9dea90af3681b32d0d3fb9 -------------------------------------------------------------------------------- /submittors/第二周_25pg.txt: -------------------------------------------------------------------------------- 1 | eab839f767aa7aacef4fe6b119893c25bc490f42 2 | -------------------------------------------------------------------------------- /submittors/第四周_25pg.txt: -------------------------------------------------------------------------------- 1 | 3a8e16bb45417e7927abed91251e1b3867224684 --------------------------------------------------------------------------------