├── .gitignore ├── LICENSE ├── LeetCode.Test ├── 0001-0050 │ ├── 001-TwoSume-Test.cs │ ├── 002-AddTwoNumbers-Test.cs │ ├── 003-LongestSubstringWithoutRepeatingCharacters-Test.cs │ ├── 004-MedianOfTwoSortedArrays-Test.cs │ ├── 005-LongestPalindromicSubstring-Test.cs │ ├── 006-ZigZagConversion-Test.cs │ ├── 007-ReverseInteger-Test.cs │ ├── 008-StringToInteger-Test.cs │ ├── 009-PalindromeNumber-Test.cs │ ├── 010-RegularExpressionMatching-Test.cs │ ├── 011_ContainerWithMostWater-Test.cs │ ├── 012-IntegerToRoman-Test.cs │ ├── 013-RomanToInteger-Test.cs │ ├── 014-LongestCommonPrefix_Test.cs │ ├── 015-3Sum-Test.cs │ ├── 016-3SumClosest-Test.cs │ ├── 017-LetterCombinationsOfAPhoneNumber-Test.cs │ ├── 018-FourSum-Test.cs │ ├── 019-RemoveNthNodeFromEndOfList-Test.cs │ ├── 020-ValidParentheses-Test.cs │ ├── 021-MergeTwoSortedLists-Test.cs │ ├── 022-GenerateParentheses-Test.cs │ ├── 023-MergeKSortedLists-Test.cs │ ├── 024-SwapNodesInPairs-Test.cs │ ├── 025-ReverseNodesInKGroup-TEst.cs │ ├── 026-RemoveDuplicatesFromSortedArray-Test.cs │ ├── 027-RemoveElement-Test.cs │ ├── 028-ImplementStrStr-Test.cs │ ├── 029-DivideTwoIntegers-Test.cs │ ├── 030-SubstringWithConcatenationOfAllWords-Test.cs │ ├── 031-NextPermutation-Test.cs │ ├── 032-LongestValidParentheses-Test.cs │ ├── 033-SearchInRotatedSortedArray-Test.cs │ ├── 034-SearchForARange-Test.cs │ ├── 035-SearchInsertPosition-Test.cs │ ├── 036-ValidSudoku-Test.cs │ ├── 037-SudokuSolver-Test.cs │ ├── 038-CountAndSay-Test.cs │ ├── 039-CombinationSum-Test.cs │ ├── 040-CombinationSum2-Test.cs │ ├── 041-FirstMissingPositive-Test.cs │ ├── 042-TrappingRainWater-Test.cs │ ├── 043-MultiplyStrings-Test.cs │ ├── 044-WildcardMatching-Test.cs │ ├── 045-JumpGame2-Test.cs │ ├── 046-Permutations-Test.cs │ ├── 047-Permutations2-Test.cs │ ├── 048-RotateImage-Test.cs │ ├── 049-GroupAnagrams-Test.cs │ └── 050-Pow-Test.cs ├── 0051-0100 │ ├── 051-NQueens-Test.cs │ ├── 052-NQueens2-Test.cs │ ├── 053-MaximumSubarray-Test.cs │ ├── 054-SpiralMatrix-Test.cs │ ├── 055-JumpGame-Test.cs │ ├── 056-MergeIntervals-Test.cs │ ├── 057-InsertInterval-Test.cs │ ├── 058-LengthOfLastWord-Test.cs │ ├── 059-SpiralMatrix2-Test.cs │ ├── 060-PermutationSequence-Test.cs │ ├── 061-RotateList-Test.cs │ ├── 062-UniquePaths-Test.cs │ ├── 063-UniquePaths2-Test.cs │ ├── 064-MinimumPathSum-Test.cs │ ├── 065-ValidNumber-Test.cs │ ├── 066-PlusOne-Test.cs │ ├── 067-AddBinary-Test.cs │ ├── 068-TextJustification-Test.cs │ ├── 069-Sqrt(x)-Test.cs │ ├── 070-ClimbingStairs-Test.cs │ ├── 071-SimplifyPath-Test.cs │ ├── 072-EditDistance-Test.cs │ ├── 073-SetMatrixZeroes-Test.cs │ ├── 074-SearchA2DMatrix-Test.cs │ ├── 075-SortColors-Test.cs │ ├── 076-MinimumWindowSubstring-Test.cs │ ├── 077-Combinations-Test.cs │ ├── 078-Subsets-Test.cs │ ├── 079-WordSearch-Test.cs │ ├── 080-RemoveDuplicatesFromSortedArray2-Test.cs │ ├── 081-SearchInRotatedSortedArray2-Test.cs │ ├── 082-RemoveDuplicatesFromSortedList2-Test.cs │ ├── 083-RemoveDuplicatesFromSortedList-Test.cs │ ├── 084-LargestRectangleInHistogram-Test.cs │ ├── 085-MaximalRectangle-Test.cs │ ├── 086-PartitionList-Test.cs │ ├── 087-ScrambleString-Test.cs │ ├── 088-MergeSortedArray-Test.cs │ ├── 089-GrayCode-Test.cs │ ├── 090-Subsets2-Test.cs │ ├── 091-DecodeWays-Test.cs │ ├── 092-ReverseLinkedList2-Test.cs │ ├── 093-RestoreIPAddresses-Test.cs │ ├── 094-BinaryTreeInorderTraversal-Test.cs │ ├── 095-UniqueBinarySearchTree2-Test.cs │ ├── 096-UniqueBinarySearchTree-Test.cs │ ├── 097-InterleavingString-Test.cs │ ├── 098-ValidateBinarySearchTree-Test.cs │ ├── 099-RecoverBinarySearchTree-Test.cs │ └── 100-SameTree-Test.cs ├── 0101-0150 │ ├── 0116-PopulatingNextRightPointersInEachNode-Test.cs │ ├── 0121-BestTimeToBuyAndSellStock-Test.cs │ ├── 0122-BestTimeToBuyAndSellStock2-Test.cs │ ├── 0123-BestTimeToBuyAndSellStock3-Test.cs │ ├── 0124-BinaryTreeMaximumPathSum-Test.cs │ ├── 0125-ValidPalindrome-Test.cs │ ├── 0126-WordLadderII-Test.cs │ ├── 0127-WordLadder-Test.cs │ ├── 0128-LongestConsecutiveSequence-Test.cs │ ├── 0129-SumRootToLeafNumbersTest.cs │ ├── 0130-SurroundedRegions-Test.cs │ ├── 0131-PalindromePartitioning-Test.cs │ ├── 0133-CloneGraph-Test.cs │ ├── 0134-GasStation-Test.cs │ ├── 0136-SingleNumber-Test.cs │ ├── 0137-SingleNumberII-Test.cs │ ├── 0138-CopyListWithRandomPointer-Test.cs │ ├── 0139-WordBreak-Test.cs │ ├── 0140-WordBreakII-Test.cs │ ├── 0141-LinkedListCycle-Test.cs │ ├── 0143-ReorderList-Test.cs │ ├── 0146-LRUCache-Test.cs │ ├── 0148-SortList-Test.cs │ ├── 101-SymmetricTree-Test.cs │ ├── 102-BinaryTreeLevelOrderTraversal-Test.cs │ ├── 103-BinaryTreeZigzagLevelOrderTraversal-Test.cs │ ├── 104-MaximumDepthOfBinaryTree-Test.cs │ ├── 105-ConstructBinaryTreeFromPreorderAndInorderTraversal-Test.cs │ ├── 106-ConstructBinaryTreeFromInorderAndPostorderTraversal-Test.cs │ ├── 107-BinaryTreeLevelOrderTraversal2-Test.cs │ ├── 108-ConvertSortedArrayToBinarySearchTree-Test.cs │ ├── 109-ConvertSortedListToBinarySearchTree-Test.cs │ ├── 110-BalancedBinaryTree-Test.cs │ ├── 111-MinimumDepthOfBinaryTree-Test.cs │ ├── 112-PathSum-Test.cs │ ├── 113-PathSum2-Test.cs │ ├── 114-FlattenBinaryTreeToLinkedList-Test.cs │ ├── 115-DistinctSubsequences-Test.cs │ ├── 117-PopulatingNextRightPointersInEachNode2-Test.cs │ ├── 118-PascalsTriangle-Test.cs │ ├── 119-PascalsTriangle2-Test.cs │ └── 120-Triangle-Test.cs ├── 0151-0200 │ ├── 0151-ReverseWordsInAString-Test.cs │ ├── 0152-MaximumProductSubarray-Test.cs │ ├── 0153-FindMinimumInRotatedSortedArray-Test.cs │ ├── 0154-FindMinimumInRotatedSortedArrayII-Test.cs │ ├── 0155-MinStack-Test.cs │ ├── 0157-ReadNCharactersGivenRead4-Test.cs │ ├── 0158-ReadNCharactersGivenRead4II-Test.cs │ ├── 0159-LongestSubstringWithAtMostTwoDistinctCharacters-Test.cs │ ├── 0160-IntersectionOfTwoLinkedLists-Test.cs │ ├── 0162-FindPeakElement-Test.cs │ ├── 0165-CompareVersionNumbers-Test.cs │ ├── 0166-FractionToRecurringDecimal-Test.cs │ ├── 0167-TwoSumII-Test.cs │ ├── 0168-ExcelSheetColumnTitle-Test.cs │ ├── 0169-MajorityElement-Test.cs │ ├── 0170-TwoSumIIIDataStructureDesign-Test.cs │ ├── 0171-ExcelSheetColumnNumber-Test.cs │ ├── 0172-FactorialTrailingZeroes-Test.cs │ ├── 0173-BinarySearchTreeIterator-Test.cs │ ├── 0174-DungeonGame-Test.cs │ ├── 0179-LargestNumber-Test.cs │ ├── 0189-RotateArray-Test.cs │ ├── 0190-ReverseBits-Test.cs │ ├── 0191-NumberOf1Bits-Test.cs │ ├── 0198-HouseRobber-Test.cs │ ├── 0199-BinaryTreeRightSideView-Test.cs │ └── 0200-NumberOfIslands-Test.cs ├── 0201-0250 │ ├── 0201-BitwiseANDOfNumbersRange-Test.cs │ ├── 0202-HappyNumber-Test.cs │ ├── 0203-RemoveLinkedListElements-Test.cs │ ├── 0204-CountPrimes-Test.cs │ ├── 0205-IsomorphicStrings-Test.cs │ ├── 0206-ReverseLinkedList-Test.cs │ ├── 0207-CourseSchedule-Test.cs │ ├── 0208-ImplementTrie-Test.cs │ ├── 0209-MinimumSizeSubarraySum-Test.cs │ ├── 0210-CourseScheduleII-Test.cs │ ├── 0211-AddAndSearchWordDataStructureDesign-Test.cs │ ├── 0212-WordSearchII-Test.cs │ ├── 0213-HouseRobberII-Test.cs │ ├── 0215-KthLargestElementInAnArray-Test.cs │ ├── 0216-CombinationSumIII-Test.cs │ ├── 0217-ContainsDuplicate-Test.cs │ ├── 0218-TheSkylineProblem-Test.cs │ ├── 0219-ContainsDuplicateII-Test.cs │ ├── 0220-ContainsDuplicateIII-Test.cs │ ├── 0221-MaximalSquare-Test.cs │ ├── 0222-CountCompleteTreeNodes-Test.cs │ ├── 0224-BasicCalculator-Test.cs │ ├── 0225-ImplementStackUsingQueues-Test.cs │ ├── 0226-InvertBinaryTree-Test.cs │ ├── 0227-BasicCalculatorII-Test.cs │ ├── 0229-MajorityElementII-Test.cs │ ├── 0230-KthSmallestElementInABST-Test.cs │ ├── 0231-PowerOfTwo-Test.cs │ ├── 0232-ImplementQueueUsingStacks-Test.cs │ ├── 0234-PalindromeLinkedList-Test.cs │ ├── 0235-LowestCommonAncestorOfABinarySearchTree-Test.cs │ ├── 0236-LowestCommonAncestorOfABinaryTree-Test.cs │ ├── 0237-DeleteNodeInALinkedList-Test.cs │ ├── 0238-ProductOfArrayExceptSelf-Test.cs │ ├── 0239-SlidingWindowMaximum-Test.cs │ ├── 0240-SearchA2DMatrixII-Test.cs │ ├── 0242-ValidAnagram-Test.cs │ ├── 0243-ShortestWordDistance-Test.cs │ └── 0246-StrobogrammaticNumber-Test.cs ├── 0251-0300 │ ├── 0252-MeetingRooms-Test.cs │ ├── 0253-MeetingRoomsII-Test.cs │ ├── 0256-PaintHouse-Test.cs │ ├── 0257-BinaryTreePaths-Test.cs │ ├── 0258-AddDigits-Test.cs │ ├── 0260-SingleNumberIII-Test.cs │ ├── 0263-UglyNumber-Test.cs │ ├── 0264-UglyNumberII-Test.cs │ ├── 0266-PalindromePermutation-Test.cs │ ├── 0268-MissingNumber-Test.cs │ ├── 0269-AlienDictionary-Test.cs │ ├── 0270-ClosestBinarySearchTreeValue-Test.cs │ ├── 0271-EncodeAndDecodeStrings-Test.cs │ ├── 0273-IntegerToEnglishWords-Test.cs │ ├── 0274-HIndex-Test.cs │ ├── 0275-HIndexII-Test.cs │ ├── 0276-PaintFence-Test.cs │ ├── 0278-FirstBadVersion-Test.cs │ ├── 0279-PerfectSquares-Test.cs │ ├── 0280-WiggleSort-Test.cs │ ├── 0283-MoveZeroes-Test.cs │ ├── 0285-InorderSuccessorInBST-Test.cs │ ├── 0287-FindTheDuplicateNumber-Test.cs │ ├── 0289-GameOfLife-Test.cs │ ├── 0290-WordPattern-Test.cs │ ├── 0292-NimGame-Test.cs │ ├── 0293-FlipGame-Test.cs │ ├── 0295-FindMedianFromDataStream-Test.cs │ ├── 0297-SerializeandDeserializeBinaryTree-Test.cs │ ├── 0299-BullsAndCows-Test.cs │ └── 0300-LongestIncreasingSubsequence-Test.cs ├── 0301-0350 │ ├── 0301-RemoveInvalidParentheses-Test.cs │ ├── 0303-RangeSumQueryImmutable-Test.cs │ ├── 0305-NumberOfIslandsII-Test.cs │ ├── 0309-BestTimeToBuyAndSellStockWithCooldown-Test.cs │ ├── 0311-SparseMatrixMultiplication-Test.cs │ ├── 0312-BurstBalloons-Test.cs │ ├── 0314-BinaryTreeVerticalOrderTraversal-Test.cs │ ├── 0315-CountOfSmallerNumbersAfterSelf-Test.cs │ ├── 0316-RemoveDuplicateLetters-Test.cs │ ├── 0317-ShortestDistanceFromAllBuildings-Test.cs │ ├── 0322-CoinChange-Test.cs │ ├── 0326-PowerOfThree-Test.cs │ ├── 0327-CountOfRangeSum-Test.cs │ ├── 0328-OddEvenLinkedList-Test.cs │ ├── 0329-LongestIncreasingPathInAMatrix-Test.cs │ ├── 0332-ReconstructItinerary-Test.cs │ ├── 0336-PalindromePairs-Test.cs │ ├── 0338-CountingBits-Test.cs │ ├── 0339-NestedListWeightSum-Test.cs │ ├── 0340-LongestSubstringWithAtMostKDistinctCharacters-Test.cs │ ├── 0341-FlattenNestedListIterator-Test.cs │ ├── 0342-PowerOfFour-Test.cs │ ├── 0344-ReverseString-Test.cs │ ├── 0345-ReverseVowelsOfAString-Test.cs │ ├── 0346-MovingAverageFromDataStream-Test.cs │ ├── 0347-TopKFrequentElements-Test.cs │ ├── 0348-DesignTicTacToe-Test.cs │ ├── 0349-IntersectionOfTwoArrays-Test.cs │ └── 0350-IntersectionOfTwoArraysII-Test.cs ├── 0351-0400 │ ├── 0352-DataStreamAsDisjointIntervals-Test.cs │ ├── 0355-DesignTwitter-Test.cs │ ├── 0359-LoggerRateLimiter-Test.cs │ ├── 0362-DesignHitCounter-Test.cs │ ├── 0364-NestedListWeightSumII-Test.cs │ ├── 0366-FindLeavesOfBinaryTree-Test.cs │ ├── 0367-ValidPerfectSquare-Test.cs │ ├── 0368-LargestDivisibleSubset-Test.cs │ ├── 0370-RangeAddition-Test.cs │ ├── 0371-SumOfTwoIntegers-Test.cs │ ├── 0374-GuessNumberHigherOrLower-Test.cs │ ├── 0375-GuessNumberHigherOrLowerII-Test.cs │ ├── 0380-InsertDeleteGetRandom-Test.cs │ ├── 0381-InsertDeleteGetrandomDuplicatesAllowed-Test.cs │ ├── 0383-RansomNote-Test.cs │ ├── 0387-FirstUniqueCharacterInAString-Test.cs │ ├── 0389-FindTheDifference-Test.cs │ ├── 0392-IsSubsequence-Test.cs │ ├── 0393-UTF8Validation-Test.cs │ ├── 0394-DecodeString-Test.cs │ └── 0399-EvaluateDivision-Test.cs ├── 0401-0450 │ ├── 0401-BinaryWatch-Test.cs │ ├── 0402-RemoveKDigits-Test.cs │ ├── 0403-FrogJump-Test.cs │ ├── 0404-SumOfLeftLeaves-Test.cs │ ├── 0405-ConvertANumberToHexadecimal-Test.cs │ ├── 0406-QueueReconstructionByHeight-Test.cs │ ├── 0408-ValidWordAbbreviation-Test.cs │ ├── 0409-LongestPalindrome-Test.cs │ ├── 0410-SplitArrayLargestSum-Test.cs │ ├── 0412-FizzBuzz-Test.cs │ ├── 0414-ThirdMaximumNumber-Test.cs │ ├── 0415-AddStrings-Test.cs │ ├── 0416-PartitionEqualSubsetSum-Test.cs │ ├── 0419-BattleshipsInABoard-Test.cs │ ├── 0420-StrongPasswordChecker-Test.cs │ ├── 0421-MaximumXOROfTwoNumbersInAnArray-Test.cs │ ├── 0422-ValidWordSquare-Test.cs │ ├── 0425-WordSquares-Test.cs │ ├── 0426-ConvertBinarySearchTreeToSortedDoublyLinkedList-Test.cs │ ├── 0427-ConstructQuadTree-Test.cs │ ├── 0428-SerializeAndDeserializeNAryTree-Test.cs │ ├── 0429-NAryTreeLevelOrderTraversal-Test.cs │ ├── 0430-FlattenAMultilevelDoublyLinkedList-Test.cs │ ├── 0432-AllOOneDataStructure-Test.cs │ ├── 0434-NumberOfSegmentsInAString-Test.cs │ ├── 0435-NonOverlappingIntervals-Test.cs │ ├── 0436-FindRightInterval-Test.cs │ ├── 0437-PathSumIII-Test.cs │ ├── 0438-FindAllAnagramsInAString-Test.cs │ ├── 0441-ArrangingCoins-Test.cs │ ├── 0442-FindAllDuplicatesInAnArray-Test.cs │ ├── 0443-StringCompression-Test.cs │ ├── 0445-AddTwoNumbersII-Test.cs │ ├── 0447-NumberOfBoomerangs-Test.cs │ ├── 0448-FindAllNumbersDisappearedInAnArray-Test.cs │ ├── 0449-SerializeAndDeserializeBST-Test.cs │ └── 0450-DeleteNodeInABST-Test.cs ├── 0451-0500 │ ├── 0451-SortCharactersByFrequency-Test.cs │ ├── 0452-MinimumNumberOfArrowsToBurstBalloons-Test.cs │ ├── 0453-MinimumMovesToEqualArrayElements-Test.cs │ ├── 0455-AssignCookies-Test.cs │ ├── 0458-PoorPigs-Test.cs │ ├── 0459-RepeatedSubstringPattern-Test.cs │ ├── 0460-LFUCache-Test.cs │ ├── 0461-HammingDistance-Test.cs │ ├── 0463-IslandPerimeter-Test.cs │ ├── 0465-OptimalAccountBalancing-Test.cs │ ├── 0468-ValidateIPAddress-Test.cs │ ├── 0470-ImplementRand10UsingRand7-Test.cs │ ├── 0472-ConcatenatedWords-Test.cs │ ├── 0475-Heaters-Test.cs │ ├── 0476-NumberComplement-Test.cs │ ├── 0480-SlidingWindowMedian-Test.cs │ ├── 0482-LicenseKeyFormatting-Test.cs │ ├── 0484-FindPermutation-Test.cs │ ├── 0485-MaxConsecutiveOnes-Test.cs │ ├── 0489-RobotRoomCleaner-Test.cs │ ├── 0490-TheMaze-Test.cs │ ├── 0492-ConstructTheRectangle-Test.cs │ ├── 0493-ReversePairs-Test.cs │ ├── 0495-TeemoAttacking-Test.cs │ ├── 0496-NextGreaterElementI-Test.cs │ ├── 0497-RandomPointInNonOverlappingRectangles-Test.cs │ ├── 0498-DiagonalTraverse-Test.cs │ └── 0500-KeyboardRow-Test.cs ├── 0501-0550 │ ├── 0501-FindModeInBinarySearchTree-Test.cs │ ├── 0503-NextGreaterElementII-Test.cs │ ├── 0504-Base7-Test.cs │ ├── 0506-RelativeRanks-Test.cs │ ├── 0507-PerfectNumber-Test.cs │ ├── 0509-FibonacciNumber-Test.cs │ ├── 0510-InorderSuccessorInBSTII-Test.cs │ ├── 0513-FindBottomLeftTreeValue-Test.cs │ ├── 0515-FindLargestValueInEachTreeRow-Test.cs │ ├── 0518-CoinChange2-Test.cs │ ├── 0520-DetectCapital-Test.cs │ ├── 0521-LongestUncommonSubsequenceI-Test.cs │ ├── 0523-ContinuousSubarraySum-Test.cs │ ├── 0525-ContiguousArray-Test.cs │ ├── 0528-RandomPickWithWeight-Test.cs │ ├── 0529-Minesweeper-Test.cs │ ├── 0530-MinimumAbsoluteDifferenceInBST-Test.cs │ ├── 0532-KDiffPairsInAnArray-Test.cs │ ├── 0535-EncodeAndDecodeTinyURL-Test.cs │ ├── 0537-ComplexNumberMultiplication-Test.cs │ ├── 0538-ConvertBSTToGreaterTree-Test.cs │ ├── 0540-SingleElementInASortedArray-Test.cs │ ├── 0541-ReverseStringII-Test.cs │ ├── 0543-DiameterOfBinaryTree-Test.cs │ ├── 0544-OutputContestMatches-Test.cs │ ├── 0545-BoundaryOfBinaryTree-Test.cs │ └── 0547-FriendCircles-Test.cs ├── 0551-0600 │ ├── 0551-StudentAttendanceRecordI-Test.cs │ ├── 0552-StudentAttendanceRecordII-Test.cs │ ├── 0557-ReverseWordsInAStringIII-Test.cs │ ├── 0559-MaximumDepthOfNAryTree-Test.cs │ ├── 0560-SubarraySumEqualsK-Test.cs │ ├── 0561-ArrayPartitionI-Test.cs │ ├── 0563-BinaryTreeTilt-Test.cs │ ├── 0566-ReshapeTheMatrix-Test.cs │ ├── 0567-PermutationInString-Test.cs │ ├── 0572-SubtreeOfAnotherTree-Test.cs │ ├── 0575-DistributeCandies-Test.cs │ ├── 0581-ShortestUnsortedContinuousSubarray-Test.cs │ ├── 0582-KillProcess-Test.cs │ ├── 0588-DesignInMemoryFileSystem-Test.cs │ ├── 0589-NAryTreePreorderTraversal-Test.cs │ ├── 0590-NAryTreePostorderTraversal-Test.cs │ ├── 0594-LongestHarmoniousSubsequence-Test.cs │ ├── 0598-RangeAdditionII-Test.cs │ └── 0599-MinimumIndexSumOfTwoLists-Test.cs ├── 0601-0650 │ ├── 0604-DesignCompressedStringIterator-Test.cs │ ├── 0605-CanPlaceFlowers-Test.cs │ ├── 0606-ConstructStringFromBinaryTree-Test.cs │ ├── 0609-FindDuplicateFileInSystem-Test.cs │ ├── 0616-AddBoldTagInString-Test.cs │ ├── 0617-MergeTwoBinaryTrees-Test.cs │ ├── 0621-TaskScheduler-Test.cs │ ├── 0624-MaximumDistanceInArrays-Test.cs │ ├── 0628-MaximumProductOfThreeNumbers-Test.cs │ ├── 0633-SumOfSquareNumbers-Test.cs │ ├── 0636-ExclusiveTimeOfFunctions-Test.cs │ ├── 0637-AverageOfLevelsInBinaryTree-Test.cs │ ├── 0642-DesignSearchAutocompleteSystem-Test.cs │ ├── 0643-MaximumAverageSubarrayI-Test.cs │ ├── 0645-SetMismatch-Test.cs │ └── 0647-PalindromicSubstrings-Test.cs ├── 0651-0700 │ ├── 0653-TwoSumIVInputIsABST-Test.cs │ ├── 0654-MaximumBinaryTree-Test.cs │ ├── 0657-RobotReturnToOrigin-Test.cs │ ├── 0661-ImageSmoother-Test.cs │ ├── 0662-MaximumWidthOfBinaryTree-Test.cs │ ├── 0665-NonDecreasingArray-Test.cs │ ├── 0668-KthSmallestNumberInMultiplicationTable-Test.cs │ ├── 0669-TrimABinarySearchTree-Test.cs │ ├── 0671-SecondMinimumNodeInABinaryTree-Test.cs │ ├── 0674-LongestContinuousIncreasingSubsequence-Test.cs │ ├── 0678-ValidParenthesisString-Test.cs │ ├── 0680-ValidPalindromeII-Test.cs │ ├── 0681-NextClosestTime-Test.cs │ ├── 0682-BaseballGame-Test.cs │ ├── 0683-KEmptySlots-Test.cs │ ├── 0686-RepeatedStringMatch-Test.cs │ ├── 0687-LongestUnivaluePath-Test.cs │ ├── 0690-EmployeeImportance-Test.cs │ ├── 0692-TopKFrequentWords-Test.cs │ ├── 0693-BinaryNumberWithAlternatingBits-Test.cs │ ├── 0695-MaxAreaOfIsland-Test.cs │ ├── 0696-CountBinarySubstrings-Test.cs │ ├── 0697-DegreeOfAnArray-Test.cs │ ├── 0698-PartitionToKEqualSumSubsets-Test.cs │ └── 0700-SearchInABinarySearchTree-Test.cs ├── 0701-0750 │ ├── 0701-InsertIntoABinarySearchTree-Test.cs │ ├── 0702-SearchInASortedArrayOfUnknownSize-Test.cs │ ├── 0703-KthLargestElementInAStream-Test.cs │ ├── 0704-BinarySearch-Test.cs │ ├── 0705-DesignHashset-Test.cs │ ├── 0706-DesignHashmap-Test.cs │ ├── 0708-InsertIntoASortedCircularLinkedList-Test.cs │ ├── 0709-ToLowerCase-Test.cs │ ├── 0713-SubarrayProductLessThanK-Test.cs │ ├── 0715-RangeModule-Test.cs │ ├── 0716-MaxStack-Test.cs │ ├── 0717-1BitAnd2BitCharacters-Test.cs │ ├── 0720-LongestWordInDictionary-Test.cs │ ├── 0721-AccountsMerge-Test.cs │ ├── 0722-RemoveComments-Test.cs │ ├── 0723-CandyCrush-Test.cs │ ├── 0724-FindPivotIndex-Test.cs │ ├── 0726-NumberOfAtoms-Test.cs │ ├── 0727-MinimumWindowSubsequence-Test.cs │ ├── 0728-SelfDividingNumbers-Test.cs │ ├── 0733-FloodFill-Test.cs │ ├── 0734-SentenceSimilarity-Test.cs │ ├── 0735-AsteroidCollision-Test.cs │ ├── 0739-DailyTemperatures-Test.cs │ ├── 0742-ClosestLeafInABinaryTree-Test.cs │ ├── 0743-NetworkDelayTime-Test.cs │ ├── 0744-FindSmallestLetterGreaterThanTarget-Test.cs │ ├── 0746-MinCostClimbingStairs-Test.cs │ ├── 0747-LargestNumberAtLeastTwiceOfOthers-Test.cs │ ├── 0748-ShortestCompletingWord-Test.cs │ └── 0750-NumberOfCornerRectangles-Test.cs ├── 0751-0800 │ ├── 0751-IPToCIDR-Test.cs │ ├── 0753-CrackingtheSafe-Test.cs │ ├── 0758-BoldWordsInString-Test.cs │ ├── 0759-EmployeeFreeTime-Test.cs │ ├── 0760-FindAnagramMappings-Test.cs │ ├── 0762-PrimeNumberOfSetBitsInBinaryRepresentation-Test.cs │ ├── 0763-PartitionLabels-Test.cs │ ├── 0765-CouplesHoldingHands-Test.cs │ ├── 0766-ToeplitzMatrix-Test.cs │ ├── 0767-ReorganizeString-Test.cs │ ├── 0771-JewelsAndStones-Test.cs │ ├── 0772-BasicCalculatorIII-Test.cs │ ├── 0773-SlidingPuzzle-Test.cs │ ├── 0777-SwapAdjacentInLRString-Test.cs │ ├── 0780-ReachingPoints-Test.cs │ ├── 0783-MinimumDistanceBetweenBSTNodes-Test.cs │ ├── 0784-LetterCasePermutation-Test.cs │ ├── 0787-CheapestFlightsWithinKStops-Test.cs │ ├── 0788-RotatedDigits-Test.cs │ ├── 0791-CustomSortString-Test.cs │ ├── 0794-ValidTicTacToeState-Test.cs │ ├── 0796-RotateString-Test.cs │ ├── 0797-AllPathsFromSourceToTarget-Test.cs │ └── 0800-SimilarRGBColor-Test.cs ├── 0801-0850 │ ├── 0804-UniqueMorseCodeWords-Test.cs │ ├── 0806-NumberOfLinesToWriteString-Test.cs │ ├── 0807-MaxIncreaseToKeepCitySkyline-Test.cs │ ├── 0809-ExpressiveWords-Test.cs │ ├── 0811-SubdomainVisitCount-Test.cs │ ├── 0812-LargestTriangleArea-Test.cs │ ├── 0814-BinaryTreePruning-Test.cs │ ├── 0818-RaceCar-Test.cs │ ├── 0819-MostCommonWord-Test.cs │ ├── 0821-ShortestDistanceToACharacter-Test.cs │ ├── 0824-GoatLatin-Test.cs │ ├── 0829-ConsecutiveNumbersSum-Test.cs │ ├── 0830-PositionsOfLargeGroups-Test.cs │ ├── 0832-FlippingAnImage-Test.cs │ ├── 0833-FindAndReplaceInString-Test.cs │ ├── 0835-ImageOverlap-Test.cs │ ├── 0836-RectangleOverlap-Test.cs │ ├── 0837-New21Game-Test.cs │ ├── 0840-MagicSquaresInGrid-Test.cs │ ├── 0841-KeysAndRooms-Test.cs │ ├── 0843-GuesstheWord-Test.cs │ ├── 0844-BackspaceStringCompare-Test.cs │ ├── 0846-HandOfStraights-Test.cs │ └── 0849-MaximizeDistanceToClosestPerson-Test.cs ├── 0851-0900 │ ├── 0852-PeakIndexInAMountainArray-Test.cs │ ├── 0856-ScoreOfParentheses-Test.cs │ ├── 0857-MinimumCostToHireKWorkers-Test.cs │ ├── 0859-BuddyStrings-Test.cs │ ├── 0860-LemonadeChange-Test.cs │ ├── 0861-ScoreAfterFlippingMatrix-Test.cs │ ├── 0863-AllNodesDistanceKInBinaryTree-Test.cs │ ├── 0865-SmallestSubtreeWithAllTheDeepestNodes-Test.cs │ ├── 0867-TransposeMatrix-Test.cs │ ├── 0868-BinaryGap-Test.cs │ ├── 0872-LeafSimilarTrees-Test.cs │ ├── 0874-WalkingRobotSimulation-Test.cs │ ├── 0876-MiddleOfTheLinkedList-Test.cs │ ├── 0877-StoneGame-Test.cs │ ├── 0883-ProjectionAreaOf3DShapes-Test.cs │ ├── 0884-UncommonWordsFromTwoSentences-Test.cs │ ├── 0885-SpiralMatrixIII-Test.cs │ ├── 0886-PossibleBipartition-Test.cs │ ├── 0888-FairCandySwap-Test.cs │ ├── 0889-ConstructBinaryTreeFromPreorderAndPostorderTraversal-Test.cs │ ├── 0890-FindAndReplacePattern-Test.cs │ ├── 0892-SurfaceAreaOf3DShapes-Test.cs │ ├── 0893-GroupsOfSpecialEquivalentStrings-Test.cs │ ├── 0894-AllPossibleFullBinaryTrees-Test.cs │ ├── 0895-MaximumFrequencyStack-Test.cs │ ├── 0896-MonotonicArray-Test.cs │ └── 0897-IncreasingOrderSearchTree-Test.cs ├── 0901-0950 │ ├── 0901-OnlineStockSpan-Test.cs │ ├── 0904-FruitIntoBaskets-Test.cs │ ├── 0905-SortArrayByParity-Test.cs │ ├── 0908-SmallestRangeI-Test.cs │ ├── 0912-SortAnArray-Test.cs │ ├── 0913-CatAndMouse-Test.cs │ ├── 0914-XOfAKindInADeckOfCards-Test.cs │ ├── 0917-ReverseOnlyLetters-Test.cs │ ├── 0918-MaximumSumCircularSubarray-Test.cs │ ├── 0921-MinimumAddToMakeParenthesesValid-Test.cs │ ├── 0922-SortArrayByParityII-Test.cs │ ├── 0925-LongPressedName-Test.cs │ ├── 0929-UniqueEmailAddresses-Test.cs │ ├── 0931-MinimumFallingPathSum-Test.cs │ ├── 0933-NumberOfRecentCalls-Test.cs │ ├── 0937-ReorderDataInLogFiles-Test.cs │ ├── 0938-RangeSumOfBST-Test.cs │ ├── 0939-MinimumAreaRectangle-Test.cs │ ├── 0941-ValidMountainArray-Test.cs │ ├── 0942-DIStringMatch-Test.cs │ ├── 0944-DeleteColumnsToMakeSorted-Test.cs │ ├── 0946-ValidateStackSequences-Test.cs │ ├── 0947-MostStonesRemovedWithSameRoworColumn-Test.cs │ ├── 0949-LargestTimeForGivenDigits-Test.cs │ └── 0950-RevealCardsInIncreasingOrder-Test.cs ├── 0951-1000 │ ├── 0951-FlipEquivalentBinaryTrees-Test.cs │ ├── 0952-LargestComponentSizeByCommonFactor-Test.cs │ ├── 0953-VerifyingAnAlienDictionary-Test.cs │ ├── 0957-PrisonCellsAfterNDays-Test.cs │ ├── 0959-RegionsCutBySlashes-Test.cs │ ├── 0961-NRepeatedElementInSize2NArray-Test.cs │ ├── 0965-UnivaluedBinaryTree-Test.cs │ ├── 0967-NumbersWithSameConsecutiveDifferences-Test.cs │ ├── 0969-PancakeSorting-Test.cs │ ├── 0970-PowerfulIntegers-Test.cs │ ├── 0973-KClosestPointsToOrigin-Test.cs │ ├── 0975-OddEvenJump-Test.cs │ ├── 0976-LargestPerimeterTriangle-Test.cs │ ├── 0977-SquaresOfASortedArray-Test.cs │ ├── 0979-DistributeCoinsInBinaryTree-Test.cs │ ├── 0980-UniquePathsIII-Test.cs │ ├── 0981-TimeBasedKeyValueStore-Test.cs │ ├── 0983-MinimumCostForTickets-Test.cs │ ├── 0985-SumOfEvenNumbersAfterQueries-Test.cs │ ├── 0986-IntervalListIntersections-Test.cs │ ├── 0987-VerticalOrderTraversalOfABinaryTree-Test.cs │ ├── 0989-AddToArrayFormOfInteger-Test.cs │ ├── 0993-CousinsInBinaryTree-Test.cs │ ├── 0994-RottingOranges-Test.cs │ ├── 0997-FindTheTownJudge-Test.cs │ ├── 0998-MaximumBinaryTreeII-Test.cs │ └── 0999-AvailableCapturesForRook-Test.cs ├── 1001-1050 │ ├── 1002-FindCommonCharacters-Test.cs │ ├── 1005-MaximizeSumOfArrayAfterKNegations-Test.cs │ ├── 1007-MinimumDominoRotationsForEqualRow-Test.cs │ ├── 1008-ConstructBinarySearchTreeFromPreorderTraversal-Test.cs │ ├── 1009-ComplementOfBase10Integer-Test.cs │ ├── 1010-PairsOfSongsWithTotalDurationsDivisibleBy60-Test.cs │ ├── 1011-CapacityToShipPackagesWithinDDays-Test.cs │ ├── 1013-PartitionArrayIntoThreePartsWithEqualSum-Test.cs │ ├── 1018-BinaryPrefixDivisibleBy5-Test.cs │ ├── 1021-RemoveOutermostParentheses-Test.cs │ ├── 1022-SumOfRootToLeafBinaryNumbers-Test.cs │ ├── 1024-VideoStitching-Test.cs │ ├── 1025-DivisorGame-Test.cs │ ├── 1026-MaximumDifferenceBetweenNodeAndAncestor-Test.cs │ ├── 1029-TwoCityScheduling-Test.cs │ ├── 1030-MatrixCellsInDistanceOrder-Test.cs │ ├── 1032-StreamOfCharacters-Test.cs │ ├── 1033-MovingStonesUntilConsecutive-Test.cs │ ├── 1035-UncrossedLines-Test.cs │ ├── 1037-ValidBoomerang-Test.cs │ ├── 1038-BinarySearchTreeToGreaterSumTree-Test.cs │ ├── 1041-RobotBoundedInCircle-Test.cs │ ├── 1042-FlowerPlantingWithNoAdjacent-Test.cs │ ├── 1043-PartitionArrayForMaximumSum-Test.cs │ ├── 1044-LongestDuplicateSubstring-Test.cs │ ├── 1046-LastStoneWeight-Test.cs │ ├── 1047-RemoveAllAdjacentDuplicatesInString-Test.cs │ └── 1048-LongestStringChain-Test.cs ├── 1051-1100 │ ├── 1051-HeightChecker-Test.cs │ ├── 1055-ShortestWaytoFormString-Test.cs │ ├── 1056-ConfusingNumber-Test.cs │ ├── 1057-CampusBikes-Test.cs │ ├── 1061-LexicographicallySmallestEquivalentString-Test.cs │ ├── 1062-LongestRepeatingSubstring-Test.cs │ ├── 1064-FixedPoint-Test.cs │ ├── 1065-IndexPairsOfAString-Test.cs │ ├── 1066-CampusBikesII-Test.cs │ ├── 1071-GreatestCommonDivisorOfStrings-Test.cs │ ├── 1072-FlipColumnsForMaximumNumberOfEqualRows-Test.cs │ ├── 1078-OccurrencesAfterBigram-Test.cs │ ├── 1079-LetterTilePossibilities-Test.cs │ ├── 1081-SmallestSubsequenceOfDistinctCharacters-Test.cs │ ├── 1085-SumOfDigitsInTheMinimumNumber-Test.cs │ ├── 1086-HighFive-Test.cs │ ├── 1087-BraceExpansion-Test.cs │ ├── 1089-DuplicateZeros-Test.cs │ ├── 1094-CarPooling-Test.cs │ ├── 1096-BraceExpansionII-Test.cs │ ├── 1099-TwoSumLessThanK-Test.cs │ └── 1100-FindKLengthSubstringsWithNoRepeatedCharacters-Test.cs ├── 1101-1150 │ ├── 1101-TheEarliestMomentWhenEveryoneBecomeFriends-Test.cs │ ├── 1102-PathWithMaximumMinimumValue-Test.cs │ ├── 1103-DistributeCandiesToPeople-Test.cs │ ├── 1104-PathInZigzagLabelledBinaryTree-Test.cs │ ├── 1108-DefangingAnIPAddress-Test.cs │ ├── 1110-DeleteNodesAndReturnForest-Test.cs │ ├── 1111-MaximumNestingDepthOfTwoValidParenthesesStrings-Test.cs │ ├── 1118-NumberOfDaysInAMonth-Test.cs │ ├── 1119-RemoveVowelsFromAString-Test.cs │ ├── 1120-MaximumAverageSubtree-Test.cs │ ├── 1122-RelativeSortArray-Test.cs │ ├── 1123-LowestCommonAncestorOfDeepestLeaves-Test.cs │ ├── 1128-NumberOfEquivalentDominoPairs-Test.cs │ ├── 1130-MinimumCostTreeFromLeafValues-Test.cs │ ├── 1133-LargestUniqueNumber-Test.cs │ ├── 1134-ArmstrongNumber-Test.cs │ ├── 1137-NThTribonacciNumber-Test.cs │ ├── 1140-StoneGameII-Test.cs │ ├── 1143-LongestCommonSubsequence-Test.cs │ └── 1150-CheckIfANumberIsMajorityElementInASortedArray-Test.cs ├── 1151-1200 │ ├── 1152-AnalyzeUserWebsiteVisitPattern-Test.cs │ ├── 1154-DayOfTheYear-Test.cs │ ├── 1160-FindWordsThatCanBeFormedByCharacters-Test.cs │ ├── 1161-MaximumLevelSumOfABinaryTree-Test.cs │ ├── 1165-SingleRowKeyboard-Test.cs │ ├── 1167-MinimumCostToConnectSticks-Test.cs │ ├── 1170-CompareStringsByFrequencyOfTheSmallestCharacter-Test.cs │ ├── 1175-PrimeArrangements-Test.cs │ ├── 1176-DietPlanPerformance-Test.cs │ ├── 1180-CountSubstringsWithOnlyOneDistinctLetter-Test.cs │ ├── 1184-DistanceBetweenBusStops-Test.cs │ ├── 1185-DayOfTheWeek-Test.cs │ ├── 1189-MaximumNumberOfBalloons-Test.cs │ ├── 1190-ReverseSubstringsBetweenEachPairOfParentheses-Test.cs │ ├── 1192-CriticalConnectionsInANetwork-Test.cs │ ├── 1196-HowManyApplesCanYouPutIntoTheBasket-Test.cs │ ├── 1197-MinimumKnightMoves-Test.cs │ ├── 1198-FindSmallestCommonElementInAllRows-Test.cs │ └── 1200-MinimumAbsoluteDifference-Test.cs ├── 1201-1250 │ ├── 1207-UniqueNumberOfOccurrences-Test.cs │ ├── 1213-IntersectionOfThreeSortedArrays-Test.cs │ ├── 1214-TwoSumBsts-Test.cs │ ├── 1217-PlayWithChips-Test.cs │ ├── 1219-PathWithMaximumGold-Test.cs │ ├── 1221-SplitAStringInBalancedStrings-Test.cs │ ├── 1222-QueensThatCanAttackTheKing-Test.cs │ ├── 1227-AirplaneSeatAssignmentProbability-Test.cs │ ├── 1228-MissingNumberInArithmeticProgression-Test.cs │ ├── 1229-MeetingScheduler-Test.cs │ ├── 1232-CheckIfItIsAStraightLine-Test.cs │ ├── 1235-MaximumProfitInJobScheduling-Test.cs │ ├── 1236-WebCrawler-Test.cs │ ├── 1237-FindPositiveIntegerSolutionForAGivenEquation-Test.cs │ ├── 1238-CircularPermutationInBinaryRepresentation-Test.cs │ ├── 1242-WebCrawlerMultithreaded-Test.cs │ ├── 1243-ArrayTransformation-Test.cs │ ├── 1245-TreeDiameter-Test.cs │ ├── 1247-MinimumSwapsToMakeStringsEqual-Test.cs │ └── 1249-MinimumRemoveToMakeValidParentheses-Test.cs ├── 1251-1300 │ ├── 1252-CellsWithOddValuesInAMatrix-Test.cs │ ├── 1254-NumberOfClosedIslands-Test.cs │ ├── 1256-EncodeNumber-Test.cs │ ├── 1258-SynonymousSentences-Test.cs │ ├── 1260-Shift2DGrid-Test.cs │ ├── 1261-FindElementsInAContaminatedBinaryTree-Test.cs │ ├── 1265-PrintImmutableLinkedListInReverse-Test.cs │ ├── 1266-MinimumTimeVisitingAllPoints-Test.cs │ ├── 1268-SearchSuggestionsSystem-Test.cs │ ├── 1271-Hexspeak-Test.cs │ ├── 1273-DeleteTreeNodes-Test.cs │ ├── 1275-FindWinnerOnATicTacToeGame-Test.cs │ ├── 1277-CountSquareSubmatricesWithAllOnes-Test.cs │ ├── 1281-SubtractTheProductAndSumOfDigitsOfAnInteger-Test.cs │ ├── 1282-GroupThePeopleGivenTheGroupSizeTheyBelongTo-Test.cs │ ├── 1286-IteratorForCombination-Test.cs │ ├── 1287-ElementAppearingMoreThan25InSortedArray-Test.cs │ ├── 1288-RemoveCoveredIntervals-Test.cs │ ├── 1290-ConvertBinaryNumberInALinkedListToInteger-Test.cs │ ├── 1291-SequentialDigits-Test.cs │ ├── 1295-FindNumbersWithEvenNumberOfDigits-Test.cs │ ├── 1296-DivideArrayInSetsOfKConsecutiveNumbers-Test.cs │ └── 1299-ReplaceElementsWithGreatestElementOnRightSide-Test.cs ├── 1301-1350 │ ├── 1302-DeepestLeavesSum-Test.cs │ ├── 1304-FindNUniqueIntegersSumUpToZero-Test.cs │ ├── 1305-AllElementsInTwoBinarySearchTrees-Test.cs │ ├── 1306-JumpGameIII-Test.cs │ ├── 1309-DecryptStringFromAlphabetToIntegerMapping-Test.cs │ ├── 1310-XORQueriesOfASubarray-Test.cs │ ├── 1313-DecompressRunLengthEncodedList-Test.cs │ ├── 1314-MatrixBlockSum-Test.cs │ ├── 1315-SumOfNodesWithEvenValuedGrandparent-Test.cs │ ├── 1317-ConvertIntegerToTheSumOfTwoNoZeroIntegers-Test.cs │ ├── 1318-MinimumFlipsToMakeAORBEqualToC-Test.cs │ ├── 1323-Maximum69Numberr-Test.cs │ ├── 1325-DeleteLeavesWithAGivenValue-Test.cs │ ├── 1326-MinimumNumberOfTapsToOpenToWaterAGarden-Test.cs │ ├── 1329-SortTheMatrixDiagonally-Test.cs │ ├── 1331-RankTransformOfAnArray-Test.cs │ ├── 1332-RemovePalindromicSubsequences-Test.cs │ ├── 1337-TheKWeakestRowsInAMatrix-Test.cs │ ├── 1338-ReduceArraySizeToTheHalf-Test.cs │ ├── 1342-NumberOfStepsToReduceANumberToZero-Test.cs │ ├── 1343-NumberOfSubArraysOfSizeKAndAverageGreaterThanOrEqualToThreshold-Test.cs │ ├── 1344-AngleBetweenHandsOfAClock-Test.cs │ ├── 1346-CheckIfNAndItsDoubleExist-Test.cs │ └── 1347-MinimumNumberOfStepsToMakeTwoStringsAnagram-Test.cs ├── 1351-1400 │ ├── 1351-CountNegativeNumbersInASortedMatrix-Test.cs │ ├── 1353-MaximumNumberOfEventsThatCanBeAttended-Test.cs │ ├── 1356-SortIntegersByTheNumberOf1Bits-Test.cs │ ├── 1357-ApplyDiscountEveryNOrders-Test.cs │ ├── 1360-NumberOfDaysBetweenTwoDates-Test.cs │ ├── 1365-HowManyNumbersAreSmallerThanTheCurrentNumber-Test.cs │ ├── 1370-IncreasingDecreasingString-Test.cs │ ├── 1374-GenerateAStringWithCharactersThatHaveOddCounts-Test.cs │ ├── 1375-BulbSwitcherIII-Test.cs │ ├── 1379-FindACorrespondingNodeOfABinaryTreeInACloneOfThatTree-Test.cs │ ├── 1380-LuckyNumbersInAMatrix-Test.cs │ ├── 1381-DesignAStackWithIncrementOperation-Test.cs │ ├── 1382-BalanceABinarySearchTree-Test.cs │ ├── 1385-FindTheDistanceValueBetweenTwoArrays-Test.cs │ ├── 1387-SortIntegersByThePowerValue-Test.cs │ ├── 1389-CreateTargetArrayInTheGivenOrder-Test.cs │ ├── 1394-FindLuckyIntegerInAnArray-Test.cs │ ├── 1395-CountNumberOfTeams-Test.cs │ ├── 1396-DesignUndergroundSystem-Test.cs │ ├── 1399-CountLargestGroup-Test.cs │ └── 1400-ConstructKPalindromeStrings-Test.cs ├── 1401-1450 │ ├── 1403-MinimumSubsequenceInNonIncreasingOrder-Test.cs │ ├── 1408-StringMatchingInAnArray-Test.cs │ ├── 1409-QueriesOnAPermutationWithKey-Test.cs │ ├── 1413-MinimumValueToGetPositiveStepByStepSum-Test.cs │ ├── 1414-FindTheMinimumNumberOfFibonacciNumbersWhoseSumIsK-Test.cs │ ├── 1415-TheKThLexicographicalStringOfAllHappyStringsOfLengthN-Test.cs │ ├── 1417-ReformatTheString-Test.cs │ ├── 1418-DisplayTableOfFoodOrdersInARestaurant-Test.cs │ ├── 1422-MaximumScoreAfterSplittingAString-Test.cs │ ├── 1426-CountingElements-Test.cs │ ├── 1427-PerformStringShifts-Test.cs │ ├── 1428-LeftmostColumnWithAtLeastAOne-Test.cs │ ├── 1429-FirstUniqueNumber-Test.cs │ ├── 1430-CheckIfAStringIsAValidSequenceFromRootToLeavesPathInABinaryTree-Test.cs │ ├── 1431-KidsWithTheGreatestNumberOfCandies-Test.cs │ ├── 1433-CheckIfAStringCanBreakAnotherString-Test.cs │ ├── 1436-DestinationCity-Test.cs │ ├── 1437-CheckIfAll1SAreAtLeastLengthKPlacesAway-Test.cs │ ├── 1441-BuildAnArrayWithStackOperations-Test.cs │ ├── 1442-CountTripletsThatCanFormTwoArraysOfEqualXOR-Test.cs │ ├── 1446-ConsecutiveCharacters-Test.cs │ ├── 1447-SimplifiedFractions-Test.cs │ ├── 1448-CountGoodNodesInBinaryTree-Test.cs │ └── 1450-NumberOfStudentsDoingHomeworkAtAGivenTime-Test.cs ├── 1451-1500 │ ├── 1455-CheckIfAWordOccursAsAPrefixOfAnyWordInASentence-Test.cs │ ├── 1457-PseudoPalindromicPathsInABinaryTree-Test.cs │ ├── 1460-MakeTwoArraysEqualByReversingSubArrays-Test.cs │ ├── 1464-MaximumProductOfTwoElementsInAnArray-Test.cs │ ├── 1466-ReorderRoutesToMakeAllPathsLeadToTheCityZero-Test.cs │ ├── 1469-FindAllTheLonelyNodes-Test.cs │ ├── 1470-ShuffleTheArray-Test.cs │ ├── 1472-DesignBrowserHistory-Test.cs │ ├── 1474-DeleteNNodesAfterMNodesOfALinkedList-Test.cs │ ├── 1475-FinalPricesWithASpecialDiscountInAShop-Test.cs │ ├── 1476-SubrectangleQueries-Test.cs │ ├── 1480-RunningSumOf1DArray-Test.cs │ ├── 1485-CloneBinaryTreeWithRandomPointer-Test.cs │ ├── 1486-XOROperationInAnArray-Test.cs │ ├── 1490-CloneNAryTree-Test.cs │ ├── 1491-AverageSalaryExcludingTheMinimumAndMaximumSalary-Test.cs │ ├── 1492-TheKthFactorOfN-Test.cs │ └── 1496-PathCrossing-Test.cs ├── 1501-1550 │ ├── 1502-CanMakeArithmeticProgressionFromSequence-Test.cs │ ├── 1504-CountSubmatricesWithAllOnes-Test.cs │ ├── 1506-FindRootOfNAryTree-Test.cs │ ├── 1507-ReformatDate-Test.cs │ ├── 1508-RangeSumOfSortedSubarraySums-Test.cs │ ├── 1512-NumberOfGoodPairs-Test.cs │ └── 1518-WaterBottles-Test.cs ├── AssertHelper.cs ├── LeetCode.Test.csproj ├── Properties │ └── AssemblyInfo.cs └── TestHelper.cs ├── LeetCode.sln ├── LeetCode ├── 0001-0050 │ ├── 001-TwoSum.cs │ ├── 002-AddTwoNumbers.cs │ ├── 003-LongestSubstringWithoutRepeatingCharacters.cs │ ├── 004-MedianOfTwoSortedArrays.cs │ ├── 005-LongestPalindromicSubstring.cs │ ├── 006-ZigZagConversion.cs │ ├── 007-ReverseInteger.cs │ ├── 008-StringToInteger(atoi).cs │ ├── 009-PalindromeNumber.cs │ ├── 010-RegularExpressionMatching.cs │ ├── 011-ContainerWithMostWater.cs │ ├── 012-IntegerToRoman.cs │ ├── 013-RomanToInteger.cs │ ├── 014-LongestCommonPrefix.cs │ ├── 015-3Sum.cs │ ├── 016-3SumClosest.cs │ ├── 017-LetterCombinationsOfAPhoneNumber.cs │ ├── 018-4Sum.cs │ ├── 019-RemoveNthNodeFromEndOfList.cs │ ├── 020-ValidParentheses.cs │ ├── 021-MergeTwoSortedLists.cs │ ├── 022-GenerateParentheses.cs │ ├── 023-MergeKSortedLists.cs │ ├── 024-SwapNodesInPairs.cs │ ├── 025-ReverseNodesInKGroup.cs │ ├── 026-RemoveDuplicatesFromSortedArray.cs │ ├── 027-RemoveElement.cs │ ├── 028-ImplementStrStr.cs │ ├── 029-DivideTwoIntegers.cs │ ├── 030-SubstringWithConcatenationOfAllWords.cs │ ├── 031-NextPermutation.cs │ ├── 032-LongestValidParentheses.cs │ ├── 033-SearchInRotatedSortedArray.cs │ ├── 034-SearchForARange.cs │ ├── 035-SearchInsertPosition.cs │ ├── 036-ValidSudoku.cs │ ├── 037-SudokuSolver.cs │ ├── 038-CountAndSay.cs │ ├── 039-CombinationSum.cs │ ├── 040-CombinationSum2.cs │ ├── 041-FirstMissingPositive.cs │ ├── 042-TrappingRainWater.cs │ ├── 043-MultiplyStrings.cs │ ├── 044-WildcardMatching.cs │ ├── 045-JumpGame2.cs │ ├── 046-Permutations.cs │ ├── 047-Permutations2.cs │ ├── 048-RotateImage.cs │ ├── 049-GroupAnagrams.cs │ └── 050-Pow.cs ├── 0051-0100 │ ├── 051-NQueens.cs │ ├── 052-NQueens2.cs │ ├── 053-MaximumSubarray.cs │ ├── 054-SpiralMatrix.cs │ ├── 055-JumpGame.cs │ ├── 056-MergeIntervals.cs │ ├── 057-InsertInterval.cs │ ├── 058-LengthOfLastWord.cs │ ├── 059-SpiralMatrix2.cs │ ├── 060-PermutationSequence.cs │ ├── 061-RotateList.cs │ ├── 062-UniquePaths.cs │ ├── 063-UniquePaths2.cs │ ├── 064-MinimumPathSum.cs │ ├── 065-ValidNumber.cs │ ├── 066-PlusOne.cs │ ├── 067-AddBinary.cs │ ├── 068-TextJustification.cs │ ├── 069-Sqrt(x).cs │ ├── 070-ClimbingStairs.cs │ ├── 071-SimplifyPath.cs │ ├── 072-EditDistance.cs │ ├── 073-SetMatrixZeroes.cs │ ├── 074-SearchA2DMatrix.cs │ ├── 075-SortColors.cs │ ├── 076-MinimumWindowSubstring.cs │ ├── 077-Combinations.cs │ ├── 078-Subsets.cs │ ├── 079-WordSearch.cs │ ├── 080-RemoveDuplicatesFromSortedArray2.cs │ ├── 081-SearchInRotatedSortedArray2.cs │ ├── 082-RemoveDuplicatesFromSortedList2.cs │ ├── 083-RemoveDuplicatesFromSortedList.cs │ ├── 084-LargestRectangleInHistogram.cs │ ├── 085-MaximalRectangle.cs │ ├── 086-PartitionList.cs │ ├── 087-ScrambleString.cs │ ├── 088-MergeSortedArray.cs │ ├── 089-GrayCode.cs │ ├── 090-Subsets2.cs │ ├── 091-DecodeWays.cs │ ├── 092-ReverseLinkedList2.cs │ ├── 093-RestoreIPAddresses.cs │ ├── 094-BinaryTreeInorderTraversal.cs │ ├── 095-UniqueBinarySearchTree2.cs │ ├── 096-UniqueBinarySearchTree.cs │ ├── 097-InterleavingString.cs │ ├── 098-ValidateBinarySearchTree.cs │ ├── 099-RecoverBinarySearchTree.cs │ └── 100-SameTree.cs ├── 0101-0150 │ ├── 0116-PopulatingNextRightPointersInEachNode.cs │ ├── 0117-PopulatingNextRightPointersInEachNode2.cs │ ├── 0121-BestTimeToBuyAndSellStock.cs │ ├── 0122-BestTimeToBuyAndSellStock2.cs │ ├── 0123-BestTimeToBuyAndSellStock3.cs │ ├── 0124-BinaryTreeMaximumPathSum.cs │ ├── 0125-ValidPalindrome.cs │ ├── 0126-WordLadderII.cs │ ├── 0127-WordLadder.cs │ ├── 0128-LongestConsecutiveSequence.cs │ ├── 0129-SumRootToLeafNumbers.cs │ ├── 0130-SurroundedRegions.cs │ ├── 0131-PalindromePartitioning.cs │ ├── 0133-CloneGraph.cs │ ├── 0134-GasStation.cs │ ├── 0136-SingleNumber.cs │ ├── 0137-SingleNumberII.cs │ ├── 0138-CopyListWithRandomPointer.cs │ ├── 0139-WordBreak.cs │ ├── 0140-WordBreakII.cs │ ├── 0141-LinkedListCycle.cs │ ├── 0143-ReorderList.cs │ ├── 0146-LRUCache.cs │ ├── 0148-SortList.cs │ ├── 101-SymmetricTree.cs │ ├── 102-BinaryTreeLevelOrderTraversal.cs │ ├── 103-BinaryTreeZigzagLevelOrderTraversal.cs │ ├── 104-MaximumDepthOfBinaryTree.cs │ ├── 105-ConstructBinaryTreeFromPreorderAndInorderTraversal.cs │ ├── 106-ConstructBinaryTreeFromInorderAndPostorderTraversal.cs │ ├── 107-BinaryTreeLevelOrderTraversal2.cs │ ├── 108-ConvertSortedArrayToBinarySearchTree.cs │ ├── 109-ConvertSortedListToBinarySearchTree.cs │ ├── 110-BalancedBinaryTree.cs │ ├── 111-MinimumDepthOfBinaryTree.cs │ ├── 112-PathSum.cs │ ├── 113-PathSum2.cs │ ├── 114-FlattenBinaryTreeToLinkedList.cs │ ├── 115-DistinctSubsequences.cs │ ├── 118-PascalsTriangle.cs │ ├── 119-PascalsTriangle2.cs │ └── 120-Triangle.cs ├── 0151-0200 │ ├── 0151-ReverseWordsInAString.cs │ ├── 0152-MaximumProductSubarray.cs │ ├── 0153-FindMinimumInRotatedSortedArray.cs │ ├── 0154-FindMinimumInRotatedSortedArrayII.cs │ ├── 0155-MinStack.cs │ ├── 0157-ReadNCharactersGivenRead4.cs │ ├── 0158-ReadNCharactersGivenRead4II.cs │ ├── 0159-LongestSubstringWithAtMostTwoDistinctCharacters.cs │ ├── 0160-IntersectionOfTwoLinkedLists.cs │ ├── 0162-FindPeakElement.cs │ ├── 0165-CompareVersionNumbers.cs │ ├── 0166-FractionToRecurringDecimal.cs │ ├── 0167-TwoSumII.cs │ ├── 0168-ExcelSheetColumnTitle.cs │ ├── 0169-MajorityElement.cs │ ├── 0170-TwoSumIIIDataStructureDesign.cs │ ├── 0171-ExcelSheetColumnNumber.cs │ ├── 0172-FactorialTrailingZeroes.cs │ ├── 0173-BinarySearchTreeIterator.cs │ ├── 0174-DungeonGame.cs │ ├── 0179-LargestNumber.cs │ ├── 0189-RotateArray.cs │ ├── 0190-ReverseBits.cs │ ├── 0191-NumberOf1Bits.cs │ ├── 0198-HouseRobber.cs │ ├── 0199-BinaryTreeRightSideView.cs │ └── 0200-NumberOfIslands.cs ├── 0201-0250 │ ├── 0201-BitwiseANDOfNumbersRange.cs │ ├── 0202-HappyNumber.cs │ ├── 0203-RemoveLinkedListElements.cs │ ├── 0204-CountPrimes.cs │ ├── 0205-IsomorphicStrings.cs │ ├── 0206-ReverseLinkedList.cs │ ├── 0207-CourseSchedule.cs │ ├── 0208-ImplementTrie.cs │ ├── 0209-MinimumSizeSubarraySum.cs │ ├── 0210-CourseScheduleII.cs │ ├── 0211-AddAndSearchWordDataStructureDesign.cs │ ├── 0212-WordSearchII.cs │ ├── 0213-HouseRobberII.cs │ ├── 0215-KthLargestElementInAnArray.cs │ ├── 0216-CombinationSumIII.cs │ ├── 0217-ContainsDuplicate.cs │ ├── 0218-TheSkylineProblem.cs │ ├── 0219-ContainsDuplicateII.cs │ ├── 0220-ContainsDuplicateIII.cs │ ├── 0221-MaximalSquare.cs │ ├── 0222-CountCompleteTreeNodes.cs │ ├── 0224-BasicCalculator.cs │ ├── 0225-ImplementStackUsingQueues.cs │ ├── 0226-InvertBinaryTree.cs │ ├── 0227-BasicCalculatorII.cs │ ├── 0229-MajorityElementII.cs │ ├── 0230-KthSmallestElementInABST.cs │ ├── 0231-PowerOfTwo.cs │ ├── 0232-ImplementQueueUsingStacks.cs │ ├── 0234-PalindromeLinkedList.cs │ ├── 0235-LowestCommonAncestorOfABinarySearchTree.cs │ ├── 0236-LowestCommonAncestorOfABinaryTree.cs │ ├── 0237-DeleteNodeInALinkedList.cs │ ├── 0238-ProductOfArrayExceptSelf.cs │ ├── 0239-SlidingWindowMaximum.cs │ ├── 0240-SearchA2DMatrixII.cs │ ├── 0242-ValidAnagram.cs │ ├── 0243-ShortestWordDistance.cs │ └── 0246-StrobogrammaticNumber.cs ├── 0251-0300 │ ├── 0252-MeetingRooms.cs │ ├── 0253-MeetingRoomsII.cs │ ├── 0256-PaintHouse.cs │ ├── 0257-BinaryTreePaths.cs │ ├── 0258-AddDigits.cs │ ├── 0260-SingleNumberIII.cs │ ├── 0263-UglyNumber.cs │ ├── 0264-UglyNumberII.cs │ ├── 0266-PalindromePermutation.cs │ ├── 0268-MissingNumber.cs │ ├── 0269-AlienDictionary.cs │ ├── 0270-ClosestBinarySearchTreeValue.cs │ ├── 0271-EncodeAndDecodeStrings.cs │ ├── 0273-IntegerToEnglishWords.cs │ ├── 0274-HIndex.cs │ ├── 0275-HIndexII.cs │ ├── 0276-PaintFence.cs │ ├── 0278-FirstBadVersion.cs │ ├── 0279-PerfectSquares.cs │ ├── 0280-WiggleSort.cs │ ├── 0283-MoveZeroes.cs │ ├── 0285-InorderSuccessorInBST.cs │ ├── 0287-FindTheDuplicateNumber.cs │ ├── 0289-GameOfLife.cs │ ├── 0290-WordPattern.cs │ ├── 0292-NimGame.cs │ ├── 0293-FlipGame.cs │ ├── 0295-FindMedianFromDataStream.cs │ ├── 0297-SerializeandDeserializeBinaryTree.cs │ ├── 0299-BullsAndCows.cs │ └── 0300-LongestIncreasingSubsequence.cs ├── 0301-0350 │ ├── 0301-RemoveInvalidParentheses.cs │ ├── 0303-RangeSumQueryImmutable.cs │ ├── 0305-NumberOfIslandsII.cs │ ├── 0309-BestTimeToBuyAndSellStockWithCooldown.cs │ ├── 0311-SparseMatrixMultiplication.cs │ ├── 0312-BurstBalloons.cs │ ├── 0314-BinaryTreeVerticalOrderTraversal.cs │ ├── 0315-CountOfSmallerNumbersAfterSelf.cs │ ├── 0316-RemoveDuplicateLetters.cs │ ├── 0317-ShortestDistanceFromAllBuildings.cs │ ├── 0322-CoinChange.cs │ ├── 0326-PowerOfThree.cs │ ├── 0327-CountOfRangeSum.cs │ ├── 0328-OddEvenLinkedList.cs │ ├── 0329-LongestIncreasingPathInAMatrix.cs │ ├── 0332-ReconstructItinerary.cs │ ├── 0336-PalindromePairs.cs │ ├── 0338-CountingBits.cs │ ├── 0339-NestedListWeightSum.cs │ ├── 0340-LongestSubstringWithAtMostKDistinctCharacters.cs │ ├── 0341-FlattenNestedListIterator.cs │ ├── 0342-PowerOfFour.cs │ ├── 0344-ReverseString.cs │ ├── 0345-ReverseVowelsOfAString.cs │ ├── 0346-MovingAverageFromDataStream.cs │ ├── 0347-TopKFrequentElements.cs │ ├── 0348-DesignTicTacToe.cs │ ├── 0349-IntersectionOfTwoArrays.cs │ └── 0350-IntersectionOfTwoArraysII.cs ├── 0351-0400 │ ├── 0352-DataStreamAsDisjointIntervals.cs │ ├── 0355-DesignTwitter.cs │ ├── 0359-LoggerRateLimiter.cs │ ├── 0362-DesignHitCounter.cs │ ├── 0364-NestedListWeightSumII.cs │ ├── 0366-FindLeavesOfBinaryTree.cs │ ├── 0367-ValidPerfectSquare.cs │ ├── 0368-LargestDivisibleSubset.cs │ ├── 0370-RangeAddition.cs │ ├── 0371-SumOfTwoIntegers.cs │ ├── 0374-GuessNumberHigherOrLower.cs │ ├── 0375-GuessNumberHigherOrLowerII.cs │ ├── 0380-InsertDeleteGetRandom.cs │ ├── 0381-InsertDeleteGetrandomDuplicatesAllowed.cs │ ├── 0383-RansomNote.cs │ ├── 0387-FirstUniqueCharacterInAString.cs │ ├── 0389-FindTheDifference.cs │ ├── 0392-IsSubsequence.cs │ ├── 0393-UTF8Validation.cs │ ├── 0394-DecodeString.cs │ └── 0399-EvaluateDivision.cs ├── 0401-0450 │ ├── 0401-BinaryWatch.cs │ ├── 0402-RemoveKDigits.cs │ ├── 0403-FrogJump.cs │ ├── 0404-SumOfLeftLeaves.cs │ ├── 0405-ConvertANumberToHexadecimal.cs │ ├── 0406-QueueReconstructionByHeight.cs │ ├── 0408-ValidWordAbbreviation.cs │ ├── 0409-LongestPalindrome.cs │ ├── 0410-SplitArrayLargestSum.cs │ ├── 0412-FizzBuzz.cs │ ├── 0414-ThirdMaximumNumber.cs │ ├── 0415-AddStrings.cs │ ├── 0416-PartitionEqualSubsetSum.cs │ ├── 0419-BattleshipsInABoard.cs │ ├── 0420-StrongPasswordChecker.cs │ ├── 0421-MaximumXOROfTwoNumbersInAnArray.cs │ ├── 0422-ValidWordSquare.cs │ ├── 0425-WordSquares.cs │ ├── 0426-ConvertBinarySearchTreeToSortedDoublyLinkedList.cs │ ├── 0427-ConstructQuadTree.cs │ ├── 0428-SerializeAndDeserializeNAryTree.cs │ ├── 0429-NAryTreeLevelOrderTraversal.cs │ ├── 0430-FlattenAMultilevelDoublyLinkedList.cs │ ├── 0432-AllOOneDataStructure.cs │ ├── 0434-NumberOfSegmentsInAString.cs │ ├── 0435-NonOverlappingIntervals.cs │ ├── 0436-FindRightInterval.cs │ ├── 0437-PathSumIII.cs │ ├── 0438-FindAllAnagramsInAString.cs │ ├── 0441-ArrangingCoins.cs │ ├── 0442-FindAllDuplicatesInAnArray.cs │ ├── 0443-StringCompression.cs │ ├── 0445-AddTwoNumbersII.cs │ ├── 0447-NumberOfBoomerangs.cs │ ├── 0448-FindAllNumbersDisappearedInAnArray.cs │ ├── 0449-SerializeAndDeserializeBST.cs │ └── 0450-DeleteNodeInABST.cs ├── 0451-0500 │ ├── 0451-SortCharactersByFrequency.cs │ ├── 0452-MinimumNumberOfArrowsToBurstBalloons.cs │ ├── 0453-MinimumMovesToEqualArrayElements.cs │ ├── 0455-AssignCookies.cs │ ├── 0458-PoorPigs.cs │ ├── 0459-RepeatedSubstringPattern.cs │ ├── 0460-LFUCache.cs │ ├── 0461-HammingDistance.cs │ ├── 0463-IslandPerimeter.cs │ ├── 0465-OptimalAccountBalancing.cs │ ├── 0468-ValidateIPAddress.cs │ ├── 0470-ImplementRand10UsingRand7.cs │ ├── 0472-ConcatenatedWords.cs │ ├── 0475-Heaters.cs │ ├── 0476-NumberComplement.cs │ ├── 0480-SlidingWindowMedian.cs │ ├── 0482-LicenseKeyFormatting.cs │ ├── 0484-FindPermutation.cs │ ├── 0485-MaxConsecutiveOnes.cs │ ├── 0489-RobotRoomCleaner.cs │ ├── 0490-TheMaze.cs │ ├── 0492-ConstructTheRectangle.cs │ ├── 0493-ReversePairs.cs │ ├── 0495-TeemoAttacking.cs │ ├── 0496-NextGreaterElementI.cs │ ├── 0497-RandomPointInNonOverlappingRectangles.cs │ ├── 0498-DiagonalTraverse.cs │ └── 0500-KeyboardRow.cs ├── 0501-0550 │ ├── 0501-FindModeInBinarySearchTree.cs │ ├── 0503-NextGreaterElementII.cs │ ├── 0504-Base7.cs │ ├── 0506-RelativeRanks.cs │ ├── 0507-PerfectNumber.cs │ ├── 0509-FibonacciNumber.cs │ ├── 0510-InorderSuccessorInBSTII.cs │ ├── 0513-FindBottomLeftTreeValue.cs │ ├── 0515-FindLargestValueInEachTreeRow.cs │ ├── 0518-CoinChange2.cs │ ├── 0520-DetectCapital.cs │ ├── 0521-LongestUncommonSubsequenceI.cs │ ├── 0523-ContinuousSubarraySum.cs │ ├── 0525-ContiguousArray.cs │ ├── 0528-RandomPickWithWeight.cs │ ├── 0529-Minesweeper.cs │ ├── 0530-MinimumAbsoluteDifferenceInBST.cs │ ├── 0532-KDiffPairsInAnArray.cs │ ├── 0535-EncodeAndDecodeTinyURL.cs │ ├── 0537-ComplexNumberMultiplication.cs │ ├── 0538-ConvertBSTToGreaterTree.cs │ ├── 0540-SingleElementInASortedArray.cs │ ├── 0541-ReverseStringII.cs │ ├── 0543-DiameterOfBinaryTree.cs │ ├── 0544-OutputContestMatches.cs │ ├── 0545-BoundaryOfBinaryTree.cs │ └── 0547-FriendCircles.cs ├── 0551-0600 │ ├── 0551-StudentAttendanceRecordI.cs │ ├── 0552-StudentAttendanceRecordII.cs │ ├── 0557-ReverseWordsInAStringIII.cs │ ├── 0559-MaximumDepthOfNAryTree.cs │ ├── 0560-SubarraySumEqualsK.cs │ ├── 0561-ArrayPartitionI.cs │ ├── 0563-BinaryTreeTilt.cs │ ├── 0566-ReshapeTheMatrix.cs │ ├── 0567-PermutationInString.cs │ ├── 0572-SubtreeOfAnotherTree.cs │ ├── 0575-DistributeCandies.cs │ ├── 0581-ShortestUnsortedContinuousSubarray.cs │ ├── 0582-KillProcess.cs │ ├── 0588-DesignInMemoryFileSystem.cs │ ├── 0589-NAryTreePreorderTraversal.cs │ ├── 0590-NAryTreePostorderTraversal.cs │ ├── 0594-LongestHarmoniousSubsequence.cs │ ├── 0598-RangeAdditionII.cs │ └── 0599-MinimumIndexSumOfTwoLists.cs ├── 0601-0650 │ ├── 0604-DesignCompressedStringIterator.cs │ ├── 0605-CanPlaceFlowers.cs │ ├── 0606-ConstructStringFromBinaryTree.cs │ ├── 0609-FindDuplicateFileInSystem.cs │ ├── 0616-AddBoldTagInString.cs │ ├── 0617-MergeTwoBinaryTrees.cs │ ├── 0621-TaskScheduler.cs │ ├── 0624-MaximumDistanceInArrays.cs │ ├── 0628-MaximumProductOfThreeNumbers.cs │ ├── 0633-SumOfSquareNumbers.cs │ ├── 0636-ExclusiveTimeOfFunctions.cs │ ├── 0637-AverageOfLevelsInBinaryTree.cs │ ├── 0642-DesignSearchAutocompleteSystem.cs │ ├── 0643-MaximumAverageSubarrayI.cs │ ├── 0645-SetMismatch.cs │ └── 0647-PalindromicSubstrings.cs ├── 0651-0700 │ ├── 0653-TwoSumIVInputIsABST.cs │ ├── 0654-MaximumBinaryTree.cs │ ├── 0657-RobotReturnToOrigin.cs │ ├── 0661-ImageSmoother.cs │ ├── 0662-MaximumWidthOfBinaryTree.cs │ ├── 0665-NonDecreasingArray.cs │ ├── 0668-KthSmallestNumberInMultiplicationTable.cs │ ├── 0669-TrimABinarySearchTree.cs │ ├── 0671-SecondMinimumNodeInABinaryTree.cs │ ├── 0674-LongestContinuousIncreasingSubsequence.cs │ ├── 0678-ValidParenthesisString.cs │ ├── 0680-ValidPalindromeII.cs │ ├── 0681-NextClosestTime.cs │ ├── 0682-BaseballGame.cs │ ├── 0683-KEmptySlots.cs │ ├── 0686-RepeatedStringMatch.cs │ ├── 0687-LongestUnivaluePath.cs │ ├── 0690-EmployeeImportance.cs │ ├── 0692-TopKFrequentWords.cs │ ├── 0693-BinaryNumberWithAlternatingBits.cs │ ├── 0695-MaxAreaOfIsland.cs │ ├── 0696-CountBinarySubstrings.cs │ ├── 0697-DegreeOfAnArray.cs │ ├── 0698-PartitionToKEqualSumSubsets.cs │ └── 0700-SearchInABinarySearchTree.cs ├── 0701-0750 │ ├── 0701-InsertIntoABinarySearchTree.cs │ ├── 0702-SearchInASortedArrayOfUnknownSize.cs │ ├── 0703-KthLargestElementInAStream.cs │ ├── 0704-BinarySearch.cs │ ├── 0705-DesignHashset.cs │ ├── 0706-DesignHashmap.cs │ ├── 0708-InsertIntoASortedCircularLinkedList.cs │ ├── 0709-ToLowerCase.cs │ ├── 0713-SubarrayProductLessThanK.cs │ ├── 0715-RangeModule.cs │ ├── 0716-MaxStack.cs │ ├── 0717-1BitAnd2BitCharacters.cs │ ├── 0720-LongestWordInDictionary.cs │ ├── 0721-AccountsMerge.cs │ ├── 0722-RemoveComments.cs │ ├── 0723-CandyCrush.cs │ ├── 0724-FindPivotIndex.cs │ ├── 0726-NumberOfAtoms.cs │ ├── 0727-MinimumWindowSubsequence.cs │ ├── 0728-SelfDividingNumbers.cs │ ├── 0733-FloodFill.cs │ ├── 0734-SentenceSimilarity.cs │ ├── 0735-AsteroidCollision.cs │ ├── 0739-DailyTemperatures.cs │ ├── 0742-ClosestLeafInABinaryTree.cs │ ├── 0743-NetworkDelayTime.cs │ ├── 0744-FindSmallestLetterGreaterThanTarget.cs │ ├── 0746-MinCostClimbingStairs.cs │ ├── 0747-LargestNumberAtLeastTwiceOfOthers.cs │ ├── 0748-ShortestCompletingWord.cs │ └── 0750-NumberOfCornerRectangles.cs ├── 0751-0800 │ ├── 0751-IPToCIDR.cs │ ├── 0753-CrackingtheSafe.cs │ ├── 0758-BoldWordsInString.cs │ ├── 0759-EmployeeFreeTime.cs │ ├── 0760-FindAnagramMappings.cs │ ├── 0762-PrimeNumberOfSetBitsInBinaryRepresentation.cs │ ├── 0763-PartitionLabels.cs │ ├── 0765-CouplesHoldingHands.cs │ ├── 0766-ToeplitzMatrix.cs │ ├── 0767-ReorganizeString.cs │ ├── 0771-JewelsAndStones.cs │ ├── 0772-BasicCalculatorIII.cs │ ├── 0773-SlidingPuzzle.cs │ ├── 0777-SwapAdjacentInLRString.cs │ ├── 0780-ReachingPoints.cs │ ├── 0783-MinimumDistanceBetweenBSTNodes.cs │ ├── 0784-LetterCasePermutation.cs │ ├── 0787-CheapestFlightsWithinKStops.cs │ ├── 0788-RotatedDigits.cs │ ├── 0791-CustomSortString.cs │ ├── 0794-ValidTicTacToeState.cs │ ├── 0796-RotateString.cs │ ├── 0797-AllPathsFromSourceToTarget.cs │ └── 0800-SimilarRGBColor.cs ├── 0801-0850 │ ├── 0804-UniqueMorseCodeWords.cs │ ├── 0806-NumberOfLinesToWriteString.cs │ ├── 0807-MaxIncreaseToKeepCitySkyline.cs │ ├── 0809-ExpressiveWords.cs │ ├── 0811-SubdomainVisitCount.cs │ ├── 0812-LargestTriangleArea.cs │ ├── 0814-BinaryTreePruning.cs │ ├── 0818-RaceCar.cs │ ├── 0819-MostCommonWord.cs │ ├── 0821-ShortestDistanceToACharacter.cs │ ├── 0824-GoatLatin.cs │ ├── 0829-ConsecutiveNumbersSum.cs │ ├── 0830-PositionsOfLargeGroups.cs │ ├── 0832-FlippingAnImage.cs │ ├── 0833-FindAndReplaceInString.cs │ ├── 0835-ImageOverlap.cs │ ├── 0836-RectangleOverlap.cs │ ├── 0837-New21Game.cs │ ├── 0840-MagicSquaresInGrid.cs │ ├── 0841-KeysAndRooms.cs │ ├── 0843-GuesstheWord.cs │ ├── 0844-BackspaceStringCompare.cs │ ├── 0846-HandOfStraights.cs │ └── 0849-MaximizeDistanceToClosestPerson.cs ├── 0851-0900 │ ├── 0852-PeakIndexInAMountainArray.cs │ ├── 0856-ScoreOfParentheses.cs │ ├── 0857-MinimumCostToHireKWorkers.cs │ ├── 0859-BuddyStrings.cs │ ├── 0860-LemonadeChange.cs │ ├── 0861-ScoreAfterFlippingMatrix.cs │ ├── 0863-AllNodesDistanceKInBinaryTree.cs │ ├── 0865-SmallestSubtreeWithAllTheDeepestNodes.cs │ ├── 0867-TransposeMatrix.cs │ ├── 0868-BinaryGap.cs │ ├── 0872-LeafSimilarTrees.cs │ ├── 0874-WalkingRobotSimulation.cs │ ├── 0876-MiddleOfTheLinkedList.cs │ ├── 0877-StoneGame.cs │ ├── 0883-ProjectionAreaOf3DShapes.cs │ ├── 0884-UncommonWordsFromTwoSentences.cs │ ├── 0885-SpiralMatrixIII.cs │ ├── 0886-PossibleBipartition.cs │ ├── 0888-FairCandySwap.cs │ ├── 0889-ConstructBinaryTreeFromPreorderAndPostorderTraversal.cs │ ├── 0890-FindAndReplacePattern.cs │ ├── 0892-SurfaceAreaOf3DShapes.cs │ ├── 0893-GroupsOfSpecialEquivalentStrings.cs │ ├── 0894-AllPossibleFullBinaryTrees.cs │ ├── 0895-MaximumFrequencyStack.cs │ ├── 0896-MonotonicArray.cs │ └── 0897-IncreasingOrderSearchTree.cs ├── 0901-0950 │ ├── 0901-OnlineStockSpan.cs │ ├── 0904-FruitIntoBaskets.cs │ ├── 0905-SortArrayByParity.cs │ ├── 0908-SmallestRangeI.cs │ ├── 0912-SortAnArray.cs │ ├── 0913-CatAndMouse.cs │ ├── 0914-XOfAKindInADeckOfCards.cs │ ├── 0917-ReverseOnlyLetters.cs │ ├── 0918-MaximumSumCircularSubarray.cs │ ├── 0921-MinimumAddToMakeParenthesesValid.cs │ ├── 0922-SortArrayByParityII.cs │ ├── 0925-LongPressedName.cs │ ├── 0929-UniqueEmailAddresses.cs │ ├── 0931-MinimumFallingPathSum.cs │ ├── 0933-NumberOfRecentCalls.cs │ ├── 0937-ReorderDataInLogFiles.cs │ ├── 0938-RangeSumOfBST.cs │ ├── 0939-MinimumAreaRectangle.cs │ ├── 0941-ValidMountainArray.cs │ ├── 0942-DIStringMatch.cs │ ├── 0944-DeleteColumnsToMakeSorted.cs │ ├── 0946-ValidateStackSequences.cs │ ├── 0947-MostStonesRemovedWithSameRoworColumn.cs │ ├── 0949-LargestTimeForGivenDigits.cs │ └── 0950-RevealCardsInIncreasingOrder.cs ├── 0951-1000 │ ├── 0951-FlipEquivalentBinaryTrees.cs │ ├── 0952-LargestComponentSizeByCommonFactor.cs │ ├── 0953-VerifyingAnAlienDictionary.cs │ ├── 0957-PrisonCellsAfterNDays.cs │ ├── 0959-RegionsCutBySlashes.cs │ ├── 0961-NRepeatedElementInSize2NArray.cs │ ├── 0965-UnivaluedBinaryTree.cs │ ├── 0967-NumbersWithSameConsecutiveDifferences.cs │ ├── 0969-PancakeSorting.cs │ ├── 0970-PowerfulIntegers.cs │ ├── 0973-KClosestPointsToOrigin.cs │ ├── 0975-OddEvenJump.cs │ ├── 0976-LargestPerimeterTriangle.cs │ ├── 0977-SquaresOfASortedArray.cs │ ├── 0979-DistributeCoinsInBinaryTree.cs │ ├── 0980-UniquePathsIII.cs │ ├── 0981-TimeBasedKeyValueStore.cs │ ├── 0983-MinimumCostForTickets.cs │ ├── 0985-SumOfEvenNumbersAfterQueries.cs │ ├── 0986-IntervalListIntersections.cs │ ├── 0987-VerticalOrderTraversalOfABinaryTree.cs │ ├── 0989-AddToArrayFormOfInteger.cs │ ├── 0993-CousinsInBinaryTree.cs │ ├── 0994-RottingOranges.cs │ ├── 0997-FindTheTownJudge.cs │ ├── 0998-MaximumBinaryTreeII.cs │ └── 0999-AvailableCapturesForRook.cs ├── 1001-1050 │ ├── 1002-FindCommonCharacters.cs │ ├── 1005-MaximizeSumOfArrayAfterKNegations.cs │ ├── 1007-MinimumDominoRotationsForEqualRow.cs │ ├── 1008-ConstructBinarySearchTreeFromPreorderTraversal.cs │ ├── 1009-ComplementOfBase10Integer.cs │ ├── 1010-PairsOfSongsWithTotalDurationsDivisibleBy60.cs │ ├── 1011-CapacityToShipPackagesWithinDDays.cs │ ├── 1013-PartitionArrayIntoThreePartsWithEqualSum.cs │ ├── 1018-BinaryPrefixDivisibleBy5.cs │ ├── 1021-RemoveOutermostParentheses.cs │ ├── 1022-SumOfRootToLeafBinaryNumbers.cs │ ├── 1024-VideoStitching.cs │ ├── 1025-DivisorGame.cs │ ├── 1026-MaximumDifferenceBetweenNodeAndAncestor.cs │ ├── 1029-TwoCityScheduling.cs │ ├── 1030-MatrixCellsInDistanceOrder.cs │ ├── 1032-StreamOfCharacters.cs │ ├── 1033-MovingStonesUntilConsecutive.cs │ ├── 1035-UncrossedLines.cs │ ├── 1037-ValidBoomerang.cs │ ├── 1038-BinarySearchTreeToGreaterSumTree.cs │ ├── 1041-RobotBoundedInCircle.cs │ ├── 1042-FlowerPlantingWithNoAdjacent.cs │ ├── 1043-PartitionArrayForMaximumSum.cs │ ├── 1044-LongestDuplicateSubstring.cs │ ├── 1046-LastStoneWeight.cs │ ├── 1047-RemoveAllAdjacentDuplicatesInString.cs │ ├── 1048-LongestStringChain.cs │ └── HashMap.cs ├── 1051-1100 │ ├── 1051-HeightChecker.cs │ ├── 1055-ShortestWaytoFormString.cs │ ├── 1056-ConfusingNumber.cs │ ├── 1057-CampusBikes.cs │ ├── 1061-LexicographicallySmallestEquivalentString.cs │ ├── 1062-LongestRepeatingSubstring.cs │ ├── 1064-FixedPoint.cs │ ├── 1065-IndexPairsOfAString.cs │ ├── 1066-CampusBikesII.cs │ ├── 1071-GreatestCommonDivisorOfStrings.cs │ ├── 1072-FlipColumnsForMaximumNumberOfEqualRows.cs │ ├── 1078-OccurrencesAfterBigram.cs │ ├── 1079-LetterTilePossibilities.cs │ ├── 1081-SmallestSubsequenceOfDistinctCharacters.cs │ ├── 1085-SumOfDigitsInTheMinimumNumber.cs │ ├── 1086-HighFive.cs │ ├── 1087-BraceExpansion.cs │ ├── 1089-DuplicateZeros.cs │ ├── 1094-CarPooling.cs │ ├── 1096-BraceExpansionII.cs │ ├── 1099-TwoSumLessThanK.cs │ └── 1100-FindKLengthSubstringsWithNoRepeatedCharacters.cs ├── 1101-1150 │ ├── 1101-TheEarliestMomentWhenEveryoneBecomeFriends.cs │ ├── 1102-PathWithMaximumMinimumValue.cs │ ├── 1103-DistributeCandiesToPeople.cs │ ├── 1104-PathInZigzagLabelledBinaryTree.cs │ ├── 1108-DefangingAnIPAddress.cs │ ├── 1110-DeleteNodesAndReturnForest.cs │ ├── 1111-MaximumNestingDepthOfTwoValidParenthesesStrings.cs │ ├── 1114-PrintInOrder.cs │ ├── 1118-NumberOfDaysInAMonth.cs │ ├── 1119-RemoveVowelsFromAString.cs │ ├── 1120-MaximumAverageSubtree.cs │ ├── 1122-RelativeSortArray.cs │ ├── 1123-LowestCommonAncestorOfDeepestLeaves.cs │ ├── 1128-NumberOfEquivalentDominoPairs.cs │ ├── 1130-MinimumCostTreeFromLeafValues.cs │ ├── 1133-LargestUniqueNumber.cs │ ├── 1134-ArmstrongNumber.cs │ ├── 1137-NThTribonacciNumber.cs │ ├── 1140-StoneGameII.cs │ ├── 1143-LongestCommonSubsequence.cs │ └── 1150-CheckIfANumberIsMajorityElementInASortedArray.cs ├── 1151-1200 │ ├── 1152-AnalyzeUserWebsiteVisitPattern.cs │ ├── 1154-DayOfTheYear.cs │ ├── 1160-FindWordsThatCanBeFormedByCharacters.cs │ ├── 1161-MaximumLevelSumOfABinaryTree.cs │ ├── 1165-SingleRowKeyboard.cs │ ├── 1167-MinimumCostToConnectSticks.cs │ ├── 1170-CompareStringsByFrequencyOfTheSmallestCharacter.cs │ ├── 1175-PrimeArrangements.cs │ ├── 1176-DietPlanPerformance.cs │ ├── 1180-CountSubstringsWithOnlyOneDistinctLetter.cs │ ├── 1184-DistanceBetweenBusStops.cs │ ├── 1185-DayOfTheWeek.cs │ ├── 1189-MaximumNumberOfBalloons.cs │ ├── 1190-ReverseSubstringsBetweenEachPairOfParentheses.cs │ ├── 1192-CriticalConnectionsInANetwork.cs │ ├── 1196-HowManyApplesCanYouPutIntoTheBasket.cs │ ├── 1197-MinimumKnightMoves.cs │ ├── 1198-FindSmallestCommonElementInAllRows.cs │ └── 1200-MinimumAbsoluteDifference.cs ├── 1201-1250 │ ├── 1207-UniqueNumberOfOccurrences.cs │ ├── 1213-IntersectionOfThreeSortedArrays.cs │ ├── 1214-TwoSumBsts.cs │ ├── 1217-PlayWithChips.cs │ ├── 1219-PathWithMaximumGold.cs │ ├── 1221-SplitAStringInBalancedStrings.cs │ ├── 1222-QueensThatCanAttackTheKing.cs │ ├── 1227-AirplaneSeatAssignmentProbability.cs │ ├── 1228-MissingNumberInArithmeticProgression.cs │ ├── 1229-MeetingScheduler.cs │ ├── 1232-CheckIfItIsAStraightLine.cs │ ├── 1235-MaximumProfitInJobScheduling.cs │ ├── 1236-WebCrawler.cs │ ├── 1237-FindPositiveIntegerSolutionForAGivenEquation.cs │ ├── 1238-CircularPermutationInBinaryRepresentation.cs │ ├── 1242-WebCrawlerMultithreaded.cs │ ├── 1243-ArrayTransformation.cs │ ├── 1245-TreeDiameter.cs │ ├── 1247-MinimumSwapsToMakeStringsEqual.cs │ └── 1249-MinimumRemoveToMakeValidParentheses.cs ├── 1251-1300 │ ├── 1252-CellsWithOddValuesInAMatrix.cs │ ├── 1254-NumberOfClosedIslands.cs │ ├── 1256-EncodeNumber.cs │ ├── 1258-SynonymousSentences.cs │ ├── 1260-Shift2DGrid.cs │ ├── 1261-FindElementsInAContaminatedBinaryTree.cs │ ├── 1265-PrintImmutableLinkedListInReverse.cs │ ├── 1266-MinimumTimeVisitingAllPoints.cs │ ├── 1268-SearchSuggestionsSystem.cs │ ├── 1271-Hexspeak.cs │ ├── 1273-DeleteTreeNodes.cs │ ├── 1275-FindWinnerOnATicTacToeGame.cs │ ├── 1277-CountSquareSubmatricesWithAllOnes.cs │ ├── 1279-TrafficLightControlledIntersection.cs │ ├── 1281-SubtractTheProductAndSumOfDigitsOfAnInteger.cs │ ├── 1282-GroupThePeopleGivenTheGroupSizeTheyBelongTo.cs │ ├── 1286-IteratorForCombination.cs │ ├── 1287-ElementAppearingMoreThan25InSortedArray.cs │ ├── 1288-RemoveCoveredIntervals.cs │ ├── 1290-ConvertBinaryNumberInALinkedListToInteger.cs │ ├── 1291-SequentialDigits.cs │ ├── 1295-FindNumbersWithEvenNumberOfDigits.cs │ ├── 1296-DivideArrayInSetsOfKConsecutiveNumbers.cs │ └── 1299-ReplaceElementsWithGreatestElementOnRightSide.cs ├── 1301-1350 │ ├── 1302-DeepestLeavesSum.cs │ ├── 1304-FindNUniqueIntegersSumUpToZero.cs │ ├── 1305-AllElementsInTwoBinarySearchTrees.cs │ ├── 1306-JumpGameIII.cs │ ├── 1309-DecryptStringFromAlphabetToIntegerMapping.cs │ ├── 1310-XORQueriesOfASubarray.cs │ ├── 1313-DecompressRunLengthEncodedList.cs │ ├── 1314-MatrixBlockSum.cs │ ├── 1315-SumOfNodesWithEvenValuedGrandparent.cs │ ├── 1317-ConvertIntegerToTheSumOfTwoNoZeroIntegers.cs │ ├── 1318-MinimumFlipsToMakeAORBEqualToC.cs │ ├── 1323-Maximum69Numberr.cs │ ├── 1325-DeleteLeavesWithAGivenValue.cs │ ├── 1326-MinimumNumberOfTapsToOpenToWaterAGarden.cs │ ├── 1329-SortTheMatrixDiagonally.cs │ ├── 1331-RankTransformOfAnArray.cs │ ├── 1332-RemovePalindromicSubsequences.cs │ ├── 1337-TheKWeakestRowsInAMatrix.cs │ ├── 1338-ReduceArraySizeToTheHalf.cs │ ├── 1342-NumberOfStepsToReduceANumberToZero.cs │ ├── 1343-NumberOfSubArraysOfSizeKAndAverageGreaterThanOrEqualToThreshold.cs │ ├── 1344-AngleBetweenHandsOfAClock.cs │ ├── 1346-CheckIfNAndItsDoubleExist.cs │ └── 1347-MinimumNumberOfStepsToMakeTwoStringsAnagram.cs ├── 1351-1400 │ ├── 1351-CountNegativeNumbersInASortedMatrix.cs │ ├── 1353-MaximumNumberOfEventsThatCanBeAttended.cs │ ├── 1356-SortIntegersByTheNumberOf1Bits.cs │ ├── 1357-ApplyDiscountEveryNOrders.cs │ ├── 1360-NumberOfDaysBetweenTwoDates.cs │ ├── 1365-HowManyNumbersAreSmallerThanTheCurrentNumber.cs │ ├── 1370-IncreasingDecreasingString.cs │ ├── 1374-GenerateAStringWithCharactersThatHaveOddCounts.cs │ ├── 1375-BulbSwitcherIII.cs │ ├── 1379-FindACorrespondingNodeOfABinaryTreeInACloneOfThatTree.cs │ ├── 1380-LuckyNumbersInAMatrix.cs │ ├── 1381-DesignAStackWithIncrementOperation.cs │ ├── 1382-BalanceABinarySearchTree.cs │ ├── 1385-FindTheDistanceValueBetweenTwoArrays.cs │ ├── 1387-SortIntegersByThePowerValue.cs │ ├── 1389-CreateTargetArrayInTheGivenOrder.cs │ ├── 1394-FindLuckyIntegerInAnArray.cs │ ├── 1395-CountNumberOfTeams.cs │ ├── 1396-DesignUndergroundSystem.cs │ ├── 1399-CountLargestGroup.cs │ └── 1400-ConstructKPalindromeStrings.cs ├── 1401-1450 │ ├── 1403-MinimumSubsequenceInNonIncreasingOrder.cs │ ├── 1408-StringMatchingInAnArray.cs │ ├── 1409-QueriesOnAPermutationWithKey.cs │ ├── 1413-MinimumValueToGetPositiveStepByStepSum.cs │ ├── 1414-FindTheMinimumNumberOfFibonacciNumbersWhoseSumIsK.cs │ ├── 1415-TheKThLexicographicalStringOfAllHappyStringsOfLengthN.cs │ ├── 1417-ReformatTheString.cs │ ├── 1418-DisplayTableOfFoodOrdersInARestaurant.cs │ ├── 1422-MaximumScoreAfterSplittingAString.cs │ ├── 1426-CountingElements.cs │ ├── 1427-PerformStringShifts.cs │ ├── 1428-LeftmostColumnWithAtLeastAOne.cs │ ├── 1429-FirstUniqueNumber.cs │ ├── 1430-CheckIfAStringIsAValidSequenceFromRootToLeavesPathInABinaryTree.cs │ ├── 1431-KidsWithTheGreatestNumberOfCandies.cs │ ├── 1433-CheckIfAStringCanBreakAnotherString.cs │ ├── 1436-DestinationCity.cs │ ├── 1437-CheckIfAll1SAreAtLeastLengthKPlacesAway.cs │ ├── 1441-BuildAnArrayWithStackOperations.cs │ ├── 1442-CountTripletsThatCanFormTwoArraysOfEqualXOR.cs │ ├── 1446-ConsecutiveCharacters.cs │ ├── 1447-SimplifiedFractions.cs │ ├── 1448-CountGoodNodesInBinaryTree.cs │ └── 1450-NumberOfStudentsDoingHomeworkAtAGivenTime.cs ├── 1451-1500 │ ├── 1455-CheckIfAWordOccursAsAPrefixOfAnyWordInASentence.cs │ ├── 1457-PseudoPalindromicPathsInABinaryTree.cs │ ├── 1460-MakeTwoArraysEqualByReversingSubArrays.cs │ ├── 1464-MaximumProductOfTwoElementsInAnArray.cs │ ├── 1466-ReorderRoutesToMakeAllPathsLeadToTheCityZero.cs │ ├── 1469-FindAllTheLonelyNodes.cs │ ├── 1470-ShuffleTheArray.cs │ ├── 1472-DesignBrowserHistory.cs │ ├── 1474-DeleteNNodesAfterMNodesOfALinkedList.cs │ ├── 1475-FinalPricesWithASpecialDiscountInAShop.cs │ ├── 1476-SubrectangleQueries.cs │ ├── 1480-RunningSumOf1DArray.cs │ ├── 1485-CloneBinaryTreeWithRandomPointer.cs │ ├── 1486-XOROperationInAnArray.cs │ ├── 1490-CloneNAryTree.cs │ ├── 1491-AverageSalaryExcludingTheMinimumAndMaximumSalary.cs │ ├── 1492-TheKthFactorOfN.cs │ └── 1496-PathCrossing.cs ├── 1501-1550 │ ├── 1502-CanMakeArithmeticProgressionFromSequence.cs │ ├── 1504-CountSubmatricesWithAllOnes.cs │ ├── 1506-FindRootOfNAryTree.cs │ ├── 1507-ReformatDate.cs │ ├── 1508-RangeSumOfSortedSubarraySums.cs │ ├── 1512-NumberOfGoodPairs.cs │ └── 1518-WaterBottles.cs ├── Interval.cs ├── LeetCode.csproj ├── ListNode.cs ├── Properties │ └── AssemblyInfo.cs ├── TreeLinkNode.cs └── TreeNode.cs └── README.md /LeetCode.Test/0051-0100/096-UniqueBinarySearchTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _096_UniqueBinarySearchTree_Test 7 | { 8 | [TestMethod] 9 | public void MyTestMethod() 10 | { 11 | var solution = new _096_UniqueBinarySearchTree(); 12 | var result = solution.NumTrees(0); 13 | Assert.AreEqual(1, result); 14 | result = solution.NumTrees(1); 15 | Assert.AreEqual(1, result); 16 | result = solution.NumTrees(2); 17 | Assert.AreEqual(2, result); 18 | result = solution.NumTrees(3); 19 | Assert.AreEqual(5, result); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode.Test/0101-0150/0131-PalindromePartitioning-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System.Collections.Generic; 3 | 4 | namespace LeetCode.Test 5 | { 6 | [TestClass] 7 | public class _0131_PalindromePartitioning_Test 8 | { 9 | [TestMethod] 10 | public void PartitionTest() 11 | { 12 | var solution = new _0131_PalindromePartitioning(); 13 | var result = solution.Partition("aab"); 14 | AssertHelper.AssertList(new List>() 15 | { 16 | new List() { "a", "a", "b" }, 17 | new List() { "aa", "b" }, 18 | }, result); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode.Test/0101-0150/0136-SingleNumber-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0136_SingleNumber_Test 7 | { 8 | [TestMethod] 9 | public void SingleNumberTest_1() 10 | { 11 | var solution = new _0136_SingleNumber(); 12 | var result = solution.SingleNumber(new int[] { 2, 2, 1 }); 13 | Assert.AreEqual(1, result); 14 | } 15 | 16 | [TestMethod] 17 | public void SingleNumberTest_2() 18 | { 19 | var solution = new _0136_SingleNumber(); 20 | var result = solution.SingleNumber(new int[] { 4, 1, 2, 1, 2 }); 21 | Assert.AreEqual(4, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0101-0150/0137-SingleNumberII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0137_SingleNumberII_Test 7 | { 8 | [TestMethod] 9 | public void SingleNumber_1() 10 | { 11 | var solution = new _0137_SingleNumberII(); 12 | var result = solution.SingleNumber(new int[] { 2, 2, 3, 2 }); 13 | Assert.AreEqual(3, result); 14 | } 15 | 16 | [TestMethod] 17 | public void SingleNumber_2() 18 | { 19 | var solution = new _0137_SingleNumberII(); 20 | var result = solution.SingleNumber(new int[] { 0, 1, 0, 1, 0, 1, 99 }); 21 | Assert.AreEqual(99, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0151-0200/0155-MinStack-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0155_MinStack_Test 7 | { 8 | [TestMethod] 9 | public void MinStackTest() 10 | { 11 | _0155_MinStack minStack = new _0155_MinStack(); 12 | 13 | minStack.Push(-2); 14 | minStack.Push(0); 15 | minStack.Push(-3); 16 | 17 | var result = minStack.GetMin(); 18 | Assert.AreEqual(-3, result); 19 | 20 | minStack.Pop(); 21 | result = minStack.Top(); 22 | Assert.AreEqual(0, result); 23 | 24 | result = minStack.GetMin(); 25 | Assert.AreEqual(-2, result); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /LeetCode.Test/0151-0200/0162-FindPeakElement-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0162_FindPeakElement_Test 7 | { 8 | [TestMethod] 9 | public void FindPeakElementTest_1() 10 | { 11 | var solution = new _0162_FindPeakElement(); 12 | var result = solution.FindPeakElement(new int[] { 1, 2, 3, 1 }); 13 | Assert.AreEqual(2, result); 14 | } 15 | 16 | [TestMethod] 17 | public void FindPeakElementTest_2() 18 | { 19 | var solution = new _0162_FindPeakElement(); 20 | var result = solution.FindPeakElement(new int[] { 1, 2, 1, 3, 5, 6, 4 }); 21 | Assert.AreEqual(5, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0151-0200/0167-TwoSumII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0167_TwoSumII_Test 7 | { 8 | [TestMethod] 9 | public void TwoSumTest_1() 10 | { 11 | var solution = new _0167_TwoSumII(); 12 | var result = solution.TwoSum(new int[] { 2, 7, 11, 15 }, 9); 13 | AssertHelper.AssertArray(new int[] { 1, 2 }, result); 14 | } 15 | 16 | [TestMethod] 17 | public void TwoSumTest_2() 18 | { 19 | var solution = new _0167_TwoSumII(); 20 | var result = solution.TwoSum(new int[] { 2, 7, 11, 15 }, 10); 21 | AssertHelper.AssertArray(new int[] { }, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0151-0200/0169-MajorityElement-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0169_MajorityElement_Test 7 | { 8 | [TestMethod] 9 | public void MajorityElementTest_1() 10 | { 11 | var solution = new _0169_MajorityElement(); 12 | var result = solution.MajorityElement(new int[] { 3, 2, 3 }); 13 | Assert.AreEqual(3, result); 14 | } 15 | 16 | [TestMethod] 17 | public void MajorityElementTest_2() 18 | { 19 | var solution = new _0169_MajorityElement(); 20 | var result = solution.MajorityElement(new int[] { 2, 2, 1, 1, 1, 2, 2 }); 21 | Assert.AreEqual(2, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0151-0200/0172-FactorialTrailingZeroes-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0172_FactorialTrailingZeroes_Test 7 | { 8 | [TestMethod] 9 | public void TrailingZeroes_1() 10 | { 11 | var solution = new _0172_FactorialTrailingZeroes(); 12 | var result = solution.TrailingZeroes(3); 13 | Assert.AreEqual(0, result); 14 | } 15 | 16 | [TestMethod] 17 | public void TrailingZeroes_2() 18 | { 19 | var solution = new _0172_FactorialTrailingZeroes(); 20 | var result = solution.TrailingZeroes(5); 21 | Assert.AreEqual(1, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0151-0200/0174-DungeonGame-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0174_DungeonGame_Test 7 | { 8 | [TestMethod] 9 | public void CalculateMinimumHP_1() 10 | { 11 | var solution = new _0174_DungeonGame(); 12 | var result = solution.CalculateMinimumHP(new int[][] { 13 | new int[] { -2, -3, 3 }, 14 | new int[] { -5, -10, 1 }, 15 | new int[] { 10, 30, -5 }, 16 | }); 17 | Assert.AreEqual(7, result); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0151-0200/0179-LargestNumber-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0179_LargestNumber_Test 7 | { 8 | [TestMethod] 9 | public void LargestNumber_1() 10 | { 11 | var solution = new _0179_LargestNumber(); 12 | var result = solution.LargestNumber(new int[] { 10, 2 }); 13 | Assert.AreEqual("210", result); 14 | } 15 | 16 | [TestMethod] 17 | public void LargestNumber_2() 18 | { 19 | var solution = new _0179_LargestNumber(); 20 | var result = solution.LargestNumber(new int[] { 3, 30, 34, 5, 9 }); 21 | Assert.AreEqual("9534330", result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0151-0200/0190-ReverseBits-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0190_ReverseBits_Test 7 | { 8 | [TestMethod] 9 | public void reverseBits_1() 10 | { 11 | var solution = new _0190_ReverseBits(); 12 | var result = solution.reverseBits((uint)43261596); 13 | Assert.AreEqual((uint)964176192, result); 14 | } 15 | 16 | [TestMethod] 17 | public void reverseBits_2() 18 | { 19 | var solution = new _0190_ReverseBits(); 20 | var result = solution.reverseBits((uint)4294967293); 21 | Assert.AreEqual((uint)3221225471, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0151-0200/0199-BinaryTreeRightSideView-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0199_BinaryTreeRightSideView_Test 7 | { 8 | [TestMethod] 9 | public void RightSideViewTest() 10 | { 11 | var solution = new _0199_BinaryTreeRightSideView(); 12 | var result = solution.RightSideView(TestHelper.GenerateTree(new int?[] { 1, 2, 3, null, 5, null, 4 })); 13 | AssertHelper.AssertList(new int[] { 1, 3, 4 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0201-BitwiseANDOfNumbersRange-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0201_BitwiseANDOfNumbersRange_Test 7 | { 8 | [TestMethod] 9 | public void RangeBitwiseAnd_1() 10 | { 11 | var solution = new _0201_BitwiseANDOfNumbersRange(); 12 | var result = solution.RangeBitwiseAnd(5, 7); 13 | Assert.AreEqual(4, result); 14 | } 15 | 16 | [TestMethod] 17 | public void RangeBitwiseAnd_2() 18 | { 19 | var solution = new _0201_BitwiseANDOfNumbersRange(); 20 | var result = solution.RangeBitwiseAnd(0, 1); 21 | Assert.AreEqual(0, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0202-HappyNumber-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0202_HappyNumber_Test 7 | { 8 | [TestMethod] 9 | public void IsHappyTest() 10 | { 11 | var solution = new _0202_HappyNumber(); 12 | var result = solution.IsHappy(19); 13 | Assert.IsTrue(result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0203-RemoveLinkedListElements-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0203_RemoveLinkedListElements_Test 7 | { 8 | [TestMethod] 9 | public void RemoveElements_1() 10 | { 11 | var head = TestHelper.GenerateList(new int[] { 1, 2, 6, 3, 4, 5, 6 }); 12 | 13 | var solution = new _0203_RemoveLinkedListElements(); 14 | var result = solution.RemoveElements(head, 6); 15 | AssertHelper.AssertLinkList(new int[] { 1, 2, 3, 4, 5 }, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0204-CountPrimes-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0204_CountPrimes_Test 7 | { 8 | [TestMethod] 9 | public void CountPrimes_1() 10 | { 11 | var solution = new _0204_CountPrimes(); 12 | var result = solution.CountPrimes(10); 13 | Assert.AreEqual(4, result); 14 | } 15 | 16 | [TestMethod] 17 | public void CountPrimes_2() 18 | { 19 | var solution = new _0204_CountPrimes(); 20 | var result = solution.CountPrimes(20); 21 | Assert.AreEqual(8, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0206-ReverseLinkedList-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0206_ReverseLinkedList_Test 7 | { 8 | [TestMethod] 9 | public void ReverseListTest() 10 | { 11 | var head = TestHelper.GenerateList(new int[] { 1, 2, 3, 4, 5 }); 12 | 13 | var solution = new _0206_ReverseLinkedList(); 14 | var newHead = solution.ReverseList(head); 15 | AssertHelper.AssertLinkList(new int[] { 5, 4, 3, 2, 1 }, newHead); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0207-CourseSchedule-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0207_CourseSchedule_Test 7 | { 8 | [TestMethod] 9 | public void CanFinishTest_1() 10 | { 11 | var solution = new _0207_CourseSchedule(); 12 | var result = solution.CanFinish(2, new int[][] { new int[] { 1, 0 } }); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void CanFinishTest_2() 18 | { 19 | var solution = new _0207_CourseSchedule(); 20 | var result = solution.CanFinish(2, new int[][] { new int[] { 1, 0 }, new int[] { 0, 1 } }); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0208-ImplementTrie-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0208_ImplementTrie_Test 7 | { 8 | [TestMethod] 9 | public void TrieTest() 10 | { 11 | var trie = new _0208_ImplementTrie(); 12 | 13 | trie.Insert("apple"); 14 | Assert.IsTrue(trie.Search("apple")); 15 | Assert.IsFalse(trie.Search("app")); 16 | Assert.IsTrue(trie.StartsWith("app")); 17 | trie.Insert("app"); 18 | Assert.IsTrue(trie.Search("app")); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0209-MinimumSizeSubarraySum-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0209_MinimumSizeSubarraySum_Test 7 | { 8 | [TestMethod] 9 | public void MinSubArrayLen_1() 10 | { 11 | var solution = new _0209_MinimumSizeSubarraySum(); 12 | var result = solution.MinSubArrayLen(7, new int[] { 2, 3, 1, 2, 4, 3 }); 13 | Assert.AreEqual(2, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0225-ImplementStackUsingQueues-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0225_ImplementStackUsingQueues_Test 7 | { 8 | [TestMethod] 9 | public void ImplementStackUsingQueues_1() 10 | { 11 | var solution = new _0225_ImplementStackUsingQueues(); 12 | solution.Push(1); 13 | solution.Push(2); 14 | Assert.AreEqual(2, solution.Top()); 15 | Assert.AreEqual(2, solution.Pop()); 16 | Assert.IsFalse(solution.Empty()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0226-InvertBinaryTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0226_InvertBinaryTree_Test 7 | { 8 | [TestMethod] 9 | public void InvertTreeTest() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 4, 2, 7, 1, 3, 6, 9 }); 12 | var solution = new _0226_InvertBinaryTree(); 13 | var newRoot = solution.InvertTree(root); 14 | AssertHelper.AssertTree(new int?[] { 4, 7, 2, 9, 6, 3, 1 }, newRoot); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0232-ImplementQueueUsingStacks-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0232_ImplementQueueUsingStacks_Test 7 | { 8 | [TestMethod] 9 | public void ImplementQueueUsingStacks_1() 10 | { 11 | var solution = new _0232_ImplementQueueUsingStacks(); 12 | solution.Push(1); 13 | solution.Push(2); 14 | Assert.AreEqual(1, solution.Peek()); 15 | Assert.AreEqual(1, solution.Pop()); 16 | Assert.IsFalse(solution.Empty()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0239-SlidingWindowMaximum-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0239_SlidingWindowMaximum_Test 7 | { 8 | [TestMethod] 9 | public void MyTestMethod() 10 | { 11 | var solution = new _0239_SlidingWindowMaximum(); 12 | var result = solution.MaxSlidingWindow(new int[] { 1, 3, -1, -3, 5, 3, 6, 7 }, 3); 13 | AssertHelper.AssertArray(new int[] { 3, 3, 5, 5, 6, 7 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0240-SearchA2DMatrixII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0240_SearchA2DMatrixII_Test 7 | { 8 | [TestMethod] 9 | public void SearchMatrixTest_1() 10 | { 11 | var input = new int[,] 12 | { 13 | { 1, 4, 7, 11, 15 }, 14 | { 2, 5, 8, 12, 19 }, 15 | { 3, 6, 9, 16, 22 }, 16 | { 10, 13, 14, 17, 24 }, 17 | { 18, 21, 23, 26, 30 } 18 | }; 19 | 20 | var solution = new _0240_SearchA2DMatrixII(); 21 | Assert.IsTrue(solution.SearchMatrix(input, 5)); 22 | Assert.IsFalse(solution.SearchMatrix(input, 20)); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode.Test/0201-0250/0242-ValidAnagram-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0242_ValidAnagram_Test 7 | { 8 | [TestMethod] 9 | public void IsAnagram_1() 10 | { 11 | var solution = new _0242_ValidAnagram(); 12 | var result = solution.IsAnagram("anagram", "nagaram"); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void IsAnagram_2() 18 | { 19 | var solution = new _0242_ValidAnagram(); 20 | var result = solution.IsAnagram("rat", "car"); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0256-PaintHouse-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0256_PaintHouse_Test 7 | { 8 | [TestMethod] 9 | public void MinCost_1() 10 | { 11 | var solution = new _0256_PaintHouse(); 12 | var result = solution.MinCost(new int[][] { 13 | new int[] { 17, 2, 17 }, 14 | new int[] { 16, 16, 5 }, 15 | new int[] { 14, 3, 19 }, 16 | }); 17 | Assert.AreEqual(10, result); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0258-AddDigits-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0258_AddDigits_Test 7 | { 8 | [TestMethod] 9 | public void AddDigits_1() 10 | { 11 | var solution = new _0258_AddDigits(); 12 | var result = solution.AddDigits(38); 13 | Assert.AreEqual(2, result); 14 | } 15 | 16 | [TestMethod] 17 | public void AddDigits_2() 18 | { 19 | var solution = new _0258_AddDigits(); 20 | var result = solution.AddDigits(0); 21 | Assert.AreEqual(0, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0260-SingleNumberIII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0260_SingleNumberIII_Test 7 | { 8 | [TestMethod] 9 | public void SingleNumber_1() 10 | { 11 | var solution = new _0260_SingleNumberIII(); 12 | var result = solution.SingleNumber(new int[] { 1, 2, 1, 3, 2, 5 }); 13 | AssertHelper.AssertArray(new int[] { 3, 5 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0271-EncodeAndDecodeStrings-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0271_EncodeAndDecodeStrings_Test 7 | { 8 | [TestMethod] 9 | public void EncodeDecodeTest() 10 | { 11 | var input = new string[] { "Hello", "", "World" }; 12 | 13 | var solution = new _0271_EncodeAndDecodeStrings(); 14 | var result = solution.decode(solution.encode(input)); 15 | AssertHelper.AssertList(input, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0274-HIndex-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0274_HIndex_Test 7 | { 8 | [TestMethod] 9 | public void HIndex_1() 10 | { 11 | var solution = new _0274_HIndex(); 12 | var result = solution.HIndex(new int[] { 3,0,6,1,5}); 13 | Assert.AreEqual(3, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0275-HIndexII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0275_HIndexII_Test 7 | { 8 | [TestMethod] 9 | public void HIndex_1() 10 | { 11 | var solution = new _0275_HIndexII(); 12 | var result = solution.HIndex(new int[] { 0, 1, 3, 5, 6 }); 13 | Assert.AreEqual(3, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0276-PaintFence-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0276_PaintFence_Test 7 | { 8 | [TestMethod] 9 | public void NumWays_1() 10 | { 11 | var solution = new _0276_PaintFence(); 12 | var result = solution.NumWays(3, 2); 13 | Assert.AreEqual(6, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0278-FirstBadVersion-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0278_FirstBadVersion_Test 7 | { 8 | [TestMethod] 9 | public void FirstBadVersion_1() 10 | { 11 | var solution = new _0278_FirstBadVersion(); 12 | var result = solution.FirstBadVersion(5); 13 | Assert.AreEqual(4, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0280-WiggleSort-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0280_WiggleSort_Test 7 | { 8 | [TestMethod] 9 | public void WiggleSort_1() 10 | { 11 | var arr = new int[] { 3, 5, 2, 1, 6, 4 }; 12 | 13 | var solution = new _0280_WiggleSort(); 14 | solution.WiggleSort(arr); 15 | AssertHelper.AssertArray(new int[] { 3, 5, 1, 6, 2, 4 }, arr); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0295-FindMedianFromDataStream-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0295_FindMedianFromDataStream_Test 7 | { 8 | [TestMethod] 9 | public void MedianFinderTest() 10 | { 11 | var medianFinder = new _0295_FindMedianFromDataStream(); 12 | 13 | medianFinder.AddNum(1); 14 | medianFinder.AddNum(2); 15 | Assert.AreEqual(1.5, medianFinder.FindMedian()); 16 | medianFinder.AddNum(3); 17 | Assert.AreEqual(2, medianFinder.FindMedian()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0251-0300/0297-SerializeandDeserializeBinaryTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0297_SerializeandDeserializeBinaryTree_Test 7 | { 8 | [TestMethod] 9 | public void SerializeandDeserializeBinaryTreeTest() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 1, 2, 3, null, null, 4, 5 }); 12 | var solution = new _0297_SerializeandDeserializeBinaryTree(); 13 | var newRoot = solution.Deserialize(solution.Serialize(root)); 14 | 15 | AssertHelper.AssertTree(root, newRoot); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0303-RangeSumQueryImmutable-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0303_RangeSumQueryImmutable_Test 7 | { 8 | [TestMethod] 9 | public void RangeSumQueryImmutable_1() 10 | { 11 | var solution = new _0303_RangeSumQueryImmutable(new int[] { -2, 0, 3, -5, 2, -1 }); 12 | Assert.AreEqual(1, solution.SumRange(0, 2)); 13 | Assert.AreEqual(-1, solution.SumRange(2, 5)); 14 | Assert.AreEqual(-3, solution.SumRange(0, 5)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0309-BestTimeToBuyAndSellStockWithCooldown-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0309_BestTimeToBuyAndSellStockWithCooldown_Test 7 | { 8 | [TestMethod] 9 | public void MaxProfit_1() 10 | { 11 | var solution = new _0309_BestTimeToBuyAndSellStockWithCooldown(); 12 | var result = solution.MaxProfit(new int[] { 1, 2, 3, 0, 2 }); 13 | Assert.AreEqual(3, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0312-BurstBalloons-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0312_BurstBalloons_Test 7 | { 8 | [TestMethod] 9 | public void MaxCoinsTest() 10 | { 11 | var solution = new _0312_BurstBalloons(); 12 | var result = solution.MaxCoins(new int[] { 3, 1, 5, 8 }); 13 | Assert.AreEqual(167, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0317-ShortestDistanceFromAllBuildings-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0317_ShortestDistanceFromAllBuildings_Test 7 | { 8 | [TestMethod] 9 | public void ShortestDistance_1() 10 | { 11 | var solution = new _0317_ShortestDistanceFromAllBuildings(); 12 | var result = solution.ShortestDistance(new int[][] { 13 | new int[] { 1, 0, 2, 0, 1 }, 14 | new int[] { 0, 0, 0, 0, 0 }, 15 | new int[] { 0, 0, 1, 0, 0 }, 16 | }); 17 | Assert.AreEqual(7, result); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0322-CoinChange-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0322_CoinChange_Test 7 | { 8 | [TestMethod] 9 | public void CoinChange_1() 10 | { 11 | var solution = new _0322_CoinChange(); 12 | var result = solution.CoinChange(new int[] { 1, 2, 5 }, 11); 13 | Assert.AreEqual(3, result); 14 | } 15 | 16 | [TestMethod] 17 | public void CoinChange_2() 18 | { 19 | var solution = new _0322_CoinChange(); 20 | var result = solution.CoinChange(new int[] { 2 }, 3); 21 | Assert.AreEqual(-1, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0327-CountOfRangeSum-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0327_CountOfRangeSum_Test 7 | { 8 | [TestMethod] 9 | public void CountRangeSumTest() 10 | { 11 | var solution = new _0327_CountOfRangeSum(); 12 | var result = solution.CountRangeSum(new int[] { -2, 5, -1 }, -2, 2); 13 | Assert.AreEqual(3, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0338-CountingBits-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0338_CountingBits_Test 7 | { 8 | [TestMethod] 9 | public void CountBits_1() 10 | { 11 | var solution = new _0338_CountingBits(); 12 | var result = solution.CountBits(2); 13 | AssertHelper.AssertArray(new int[] { 0, 1, 1 }, result); 14 | } 15 | 16 | [TestMethod] 17 | public void CountBits_2() 18 | { 19 | var solution = new _0338_CountingBits(); 20 | var result = solution.CountBits(5); 21 | AssertHelper.AssertArray(new int[] { 0, 1, 1, 2, 1, 2 }, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0342-PowerOfFour-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0342_PowerOfFour_Test 7 | { 8 | [TestMethod] 9 | public void IsPowerOfFour_1() 10 | { 11 | var solution = new _0342_PowerOfFour(); 12 | var result = solution.IsPowerOfFour(16); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void IsPowerOfFour_2() 18 | { 19 | var solution = new _0342_PowerOfFour(); 20 | var result = solution.IsPowerOfFour(5); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0346-MovingAverageFromDataStream-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0346_MovingAverageFromDataStream_Test 7 | { 8 | [TestMethod] 9 | public void Next_1() 10 | { 11 | var solution = new _0346_MovingAverageFromDataStream(3); 12 | var result = solution.Next(1); 13 | Assert.AreEqual(1, result); 14 | 15 | result = solution.Next(10); 16 | Assert.AreEqual(5.5, result); 17 | 18 | result = solution.Next(3); 19 | Assert.AreEqual(4.66666666666667, result, 0.000001); 20 | 21 | result = solution.Next(5); 22 | Assert.AreEqual(6, result); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0347-TopKFrequentElements-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0347_TopKFrequentElements_Test 7 | { 8 | [TestMethod] 9 | public void TopKFrequentTest_1() 10 | { 11 | var solution = new _0347_TopKFrequentElements(); 12 | var result = solution.TopKFrequent(new int[] { 1, 1, 1, 2, 2, 3 }, 2); 13 | AssertHelper.AssertList(new int[] { 1, 2 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0301-0350/0348-DesignTicTacToe-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0348_DesignTicTacToe_Test 7 | { 8 | [TestMethod] 9 | public void TicTacToe_1() 10 | { 11 | var toe = new _0348_DesignTicTacToe(3); 12 | 13 | Assert.AreEqual(0, toe.Move(0, 0, 1)); 14 | Assert.AreEqual(0, toe.Move(0, 2, 2)); 15 | Assert.AreEqual(0, toe.Move(2, 2, 1)); 16 | Assert.AreEqual(0, toe.Move(1, 1, 2)); 17 | Assert.AreEqual(0, toe.Move(2, 0, 1)); 18 | Assert.AreEqual(0, toe.Move(1, 0, 2)); 19 | Assert.AreEqual(1, toe.Move(2, 1, 1)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode.Test/0351-0400/0366-FindLeavesOfBinaryTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System.Collections.Generic; 3 | 4 | namespace LeetCode.Test 5 | { 6 | [TestClass] 7 | public class _0366_FindLeavesOfBinaryTree_Test 8 | { 9 | [TestMethod] 10 | public void FindLeaves_1() 11 | { 12 | var root = TestHelper.GenerateTree(new int?[] { 1, 2, 3, 4, 5 }); 13 | 14 | var solution = new _0366_FindLeavesOfBinaryTree(); 15 | var result = solution.FindLeaves(root); 16 | AssertHelper.AssertList(new List>() { 17 | new int[] { 4, 5, 3 }, 18 | new int[] { 2 }, 19 | new int[] { 1 }, 20 | }, result); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode.Test/0351-0400/0370-RangeAddition-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0370_RangeAddition_Test 7 | { 8 | [TestMethod] 9 | public void GetModifiedArray_1() 10 | { 11 | var solution = new _0370_RangeAddition(); 12 | var result = solution.GetModifiedArray(5, new int[][] { 13 | new int[] { 1, 3, 2 }, 14 | new int[] { 2, 4, 3 }, 15 | new int[] { 0, 2, -2 }, 16 | }); 17 | AssertHelper.AssertArray(new int[] { -2, 0, 3, 5, 3 }, result); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0351-0400/0374-GuessNumberHigherOrLower-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0374_GuessNumberHigherOrLower_Test 7 | { 8 | [TestMethod] 9 | public void GuessNumber_1() 10 | { 11 | var solution = new _0374_GuessNumberHigherOrLower(6); 12 | var result = solution.GuessNumber(10); 13 | Assert.AreEqual(6, result); 14 | } 15 | 16 | [TestMethod] 17 | public void GuessNumber_2() 18 | { 19 | var solution = new _0374_GuessNumberHigherOrLower(4); 20 | var result = solution.GuessNumber(6); 21 | Assert.AreEqual(4, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0351-0400/0375-GuessNumberHigherOrLowerII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0375_GuessNumberHigherOrLowerII_Test 7 | { 8 | [TestMethod] 9 | public void GetMoneyAmountTest_1() 10 | { 11 | var solution = new _0375_GuessNumberHigherOrLowerII(); 12 | var result = solution.GetMoneyAmount(10); 13 | Assert.AreEqual(16, result); 14 | } 15 | 16 | [TestMethod] 17 | public void GetMoneyAmountTest_2() 18 | { 19 | var solution = new _0375_GuessNumberHigherOrLowerII(); 20 | var result = solution.GetMoneyAmount(5); 21 | Assert.AreEqual(6, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0351-0400/0387-FirstUniqueCharacterInAString-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0387_FirstUniqueCharacterInAString_Test 7 | { 8 | [TestMethod] 9 | public void FirstUniqChar_1() 10 | { 11 | var solution = new _0387_FirstUniqueCharacterInAString(); 12 | var result = solution.FirstUniqChar("leetcode"); 13 | Assert.AreEqual(0, result); 14 | } 15 | 16 | [TestMethod] 17 | public void FirstUniqChar_2() 18 | { 19 | var solution = new _0387_FirstUniqueCharacterInAString(); 20 | var result = solution.FirstUniqChar("loveleetcode"); 21 | Assert.AreEqual(2, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0351-0400/0389-FindTheDifference-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0389_FindTheDifference_Test 7 | { 8 | [TestMethod] 9 | public void FindTheDifference_1() 10 | { 11 | var solution = new _0389_FindTheDifference(); 12 | var result = solution.FindTheDifference("abcd", "abcde"); 13 | Assert.AreEqual('e', result); 14 | } 15 | 16 | [TestMethod] 17 | public void FindTheDifference_2() 18 | { 19 | var solution = new _0389_FindTheDifference(); 20 | var result = solution.FindTheDifference("abcd", "bedac"); 21 | Assert.AreEqual('e', result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0351-0400/0392-IsSubsequence-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0392_IsSubsequence_Test 7 | { 8 | [TestMethod] 9 | public void IsSubsequence_1() 10 | { 11 | var solution = new _0392_IsSubsequence(); 12 | var result = solution.IsSubsequence("abc", "ahbgdc"); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void IsSubsequence_2() 18 | { 19 | var solution = new _0392_IsSubsequence(); 20 | var result = solution.IsSubsequence("axc", "ahbgdc"); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0351-0400/0393-UTF8Validation-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0393_UTF8Validation_Test 7 | { 8 | [TestMethod] 9 | public void ValidUtf8_1() 10 | { 11 | var solution = new _0393_UTF8Validation(); 12 | var result = solution.ValidUtf8(new int[] { 197, 130, 1 }); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void ValidUtf8_2() 18 | { 19 | var solution = new _0393_UTF8Validation(); 20 | var result = solution.ValidUtf8(new int[] { 235, 140, 4 }); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0401-BinaryWatch-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0401_BinaryWatch_Test 7 | { 8 | [TestMethod] 9 | public void ReadBinaryWatch_1() 10 | { 11 | var solution = new _0401_BinaryWatch(); 12 | var result = solution.ReadBinaryWatch(1); 13 | AssertHelper.AssertList(new string[] { "0:01", "0:02", "0:04", "0:08", "0:16", "0:32", "1:00", "2:00", "4:00", "8:00" }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0403-FrogJump-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0403_FrogJump_Test 7 | { 8 | [TestMethod] 9 | public void CanCross_1() 10 | { 11 | var solution = new _0403_FrogJump(); 12 | var result = solution.CanCross(new int[] { 0, 1, 3, 5, 6, 8, 12, 17 }); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void CanCross_2() 18 | { 19 | var solution = new _0403_FrogJump(); 20 | var result = solution.CanCross(new int[] { 0, 1, 2, 3, 4, 8, 9, 11 }); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0404-SumOfLeftLeaves-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0404_SumOfLeftLeaves_Test 7 | { 8 | [TestMethod] 9 | public void SumOfLeftLeaves_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 3, 9, 20, null, null, 15, 7 }); 12 | 13 | var solution = new _0404_SumOfLeftLeaves(); 14 | var result = solution.SumOfLeftLeaves(root); 15 | Assert.AreEqual(24, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0412-FizzBuzz-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0412_FizzBuzz_Test 7 | { 8 | [TestMethod] 9 | public void FizzBuzz_1() 10 | { 11 | var solution = new _0412_FizzBuzz(); 12 | var result = solution.FizzBuzz(15); 13 | AssertHelper.AssertList(new string[] { "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz" }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0415-AddStrings-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0415_AddStrings_Test 7 | { 8 | [TestMethod] 9 | public void AddStrings_1() 10 | { 11 | var solution = new _0415_AddStrings(); 12 | var result = solution.AddStrings("123", "987"); 13 | Assert.AreEqual("1110", result); 14 | } 15 | 16 | [TestMethod] 17 | public void AddStrings_2() 18 | { 19 | var solution = new _0415_AddStrings(); 20 | var result = solution.AddStrings("111", "1"); 21 | Assert.AreEqual("112", result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0419-BattleshipsInABoard-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0419_BattleshipsInABoard_Test 7 | { 8 | [TestMethod] 9 | public void CountBattleships_1() 10 | { 11 | var solution = new _0419_BattleshipsInABoard(); 12 | var result = solution.CountBattleships(new char[][] { 13 | new char[] { 'X', '.', '.', 'X' }, 14 | new char[] { '.', '.', '.', 'X' }, 15 | new char[] { '.', '.', '.', 'X' }, 16 | }); 17 | Assert.AreEqual(2, result); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0421-MaximumXOROfTwoNumbersInAnArray-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0421_MaximumXOROfTwoNumbersInAnArray_Test 7 | { 8 | [TestMethod] 9 | public void FindMaximumXORTest() 10 | { 11 | var solution = new _0421_MaximumXOROfTwoNumbersInAnArray(); 12 | var result = solution.FindMaximumXOR(new int[] { 3, 10, 5, 25, 2, 8 }); 13 | Assert.AreEqual(28, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0434-NumberOfSegmentsInAString-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0434_NumberOfSegmentsInAString_Test 7 | { 8 | [TestMethod] 9 | public void CountSegments_1() 10 | { 11 | var solution = new _0434_NumberOfSegmentsInAString(); 12 | var result = solution.CountSegments("Hello, my name is John"); 13 | Assert.AreEqual(5, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0441-ArrangingCoins-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0441_ArrangingCoins_Test 7 | { 8 | [TestMethod] 9 | public void ArrangeCoins_1() 10 | { 11 | var solution = new _0441_ArrangingCoins(); 12 | var result = solution.ArrangeCoins(5); 13 | Assert.AreEqual(2, result); 14 | } 15 | 16 | [TestMethod] 17 | public void ArrangeCoins_2() 18 | { 19 | var solution = new _0441_ArrangingCoins(); 20 | var result = solution.ArrangeCoins(8); 21 | Assert.AreEqual(3, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0442-FindAllDuplicatesInAnArray-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0442_FindAllDuplicatesInAnArray_Test 7 | { 8 | [TestMethod] 9 | public void FindDuplicates_1() 10 | { 11 | var solution = new _0442_FindAllDuplicatesInAnArray(); 12 | var result = solution.FindDuplicates(new int[] { 4, 3, 2, 7, 8, 2, 3, 1 }); 13 | AssertHelper.AssertList(new int[] { 2, 3 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0447-NumberOfBoomerangs-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0447_NumberOfBoomerangs_Test 7 | { 8 | [TestMethod] 9 | public void NumberOfBoomerangs_1() 10 | { 11 | var solution = new _0447_NumberOfBoomerangs(); 12 | var result = solution.NumberOfBoomerangs(new int[][] { 13 | new int[] { 0, 0 }, 14 | new int[] { 1, 0 }, 15 | new int[] { 2, 0 }, 16 | }); 17 | Assert.AreEqual(2, result); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0448-FindAllNumbersDisappearedInAnArray-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0448_FindAllNumbersDisappearedInAnArray_Test 7 | { 8 | [TestMethod] 9 | public void FindDisappearedNumbers_1() 10 | { 11 | var solution = new _0448_FindAllNumbersDisappearedInAnArray(); 12 | var result = solution.FindDisappearedNumbers(new int[] { 4, 3, 2, 7, 8, 2, 3, 1 }); 13 | AssertHelper.AssertList(new int[] { 5, 6 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0401-0450/0450-DeleteNodeInABST-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0450_DeleteNodeInABST_Test 7 | { 8 | [TestMethod] 9 | public void DeleteNode_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 5, 3, 6, 2, 4, null, 7 }); 12 | 13 | var solution = new _0450_DeleteNodeInABST(); 14 | var result = solution.DeleteNode(root, 3); 15 | AssertHelper.AssertTree(new int?[] { 5, 4, 6, 2, null, null, 7 }, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0458-PoorPigs-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0458_PoorPigs_Test 7 | { 8 | [TestMethod] 9 | public void PoorPigsTest() 10 | { 11 | var solution = new _0458_PoorPigs(); 12 | Assert.AreEqual(2, solution.PoorPigs(3, 15, 15)); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0461-HammingDistance-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0461_HammingDistance_Test 7 | { 8 | [TestMethod] 9 | public void HammingDistanceTest() 10 | { 11 | var solution = new _0461_HammingDistance(); 12 | var result = solution.HammingDistance(1, 4); 13 | Assert.AreEqual(2, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0463-IslandPerimeter-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0463_IslandPerimeter_Test 7 | { 8 | [TestMethod] 9 | public void IslandPerimeter_1() 10 | { 11 | var solution = new _0463_IslandPerimeter(); 12 | var result = solution.IslandPerimeter(new int[][] { 13 | new int[] { 0, 1, 0, 0 }, 14 | new int[] { 1, 1, 1, 0 }, 15 | new int[] { 0, 1, 0, 0 }, 16 | new int[] { 1, 1, 0, 0 }, 17 | }); 18 | Assert.AreEqual(16, result); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0470-ImplementRand10UsingRand7-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0470_ImplementRand10UsingRand7_Test 7 | { 8 | [TestMethod] 9 | public void Rand10_1() 10 | { 11 | var solution = new _0470_ImplementRand10UsingRand7(); 12 | 13 | for (int i = 0; i < 1000; i++) 14 | { 15 | var result = solution.Rand10(); 16 | Assert.IsTrue(result > 0); 17 | Assert.IsTrue(result <= 10); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0475-Heaters-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0475_Heaters_Test 7 | { 8 | [TestMethod] 9 | public void FindRadius_1() 10 | { 11 | var solution = new _0475_Heaters(); 12 | var result = solution.FindRadius(new int[] { 1, 2, 3 }, new int[] { 2 }); 13 | Assert.AreEqual(1, result); 14 | } 15 | 16 | [TestMethod] 17 | public void FindRadius_2() 18 | { 19 | var solution = new _0475_Heaters(); 20 | var result = solution.FindRadius(new int[] { 1, 2, 3, 4 }, new int[] { 1, 4 }); 21 | Assert.AreEqual(1, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0476-NumberComplement-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0476_NumberComplement_Test 7 | { 8 | [TestMethod] 9 | public void FindComplement_1() 10 | { 11 | var solution = new _0476_NumberComplement(); 12 | var result = solution.FindComplement(5); 13 | Assert.AreEqual(2, result); 14 | } 15 | 16 | [TestMethod] 17 | public void FindComplement_2() 18 | { 19 | var solution = new _0476_NumberComplement(); 20 | var result = solution.FindComplement(1); 21 | Assert.AreEqual(0, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0485-MaxConsecutiveOnes-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0485_MaxConsecutiveOnes_Test 7 | { 8 | [TestMethod] 9 | public void FindMaxConsecutiveOnes_1() 10 | { 11 | var solution = new _0485_MaxConsecutiveOnes(); 12 | var result = solution.FindMaxConsecutiveOnes(new int[] { 1, 1, 0, 1, 1, 1 }); 13 | Assert.AreEqual(3, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0492-ConstructTheRectangle-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0492_ConstructTheRectangle_Test 7 | { 8 | [TestMethod] 9 | public void ConstructRectangle_1() 10 | { 11 | var solution = new _0492_ConstructTheRectangle(); 12 | var result = solution.ConstructRectangle(4); 13 | AssertHelper.AssertArray(new int[] { 2, 2 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0495-TeemoAttacking-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0495_TeemoAttacking_Test 7 | { 8 | [TestMethod] 9 | public void FindPoisonedDuration_1() 10 | { 11 | var solution = new _0495_TeemoAttacking(); 12 | var result = solution.FindPoisonedDuration(new int[] { 1, 4 }, 2); 13 | Assert.AreEqual(4, result); 14 | } 15 | 16 | [TestMethod] 17 | public void FindPoisonedDuration_2() 18 | { 19 | var solution = new _0495_TeemoAttacking(); 20 | var result = solution.FindPoisonedDuration(new int[] { 1, 2 }, 2); 21 | Assert.AreEqual(3, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0498-DiagonalTraverse-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0498_DiagonalTraverse_Test 7 | { 8 | [TestMethod] 9 | public void FindDiagonalOrder_1() 10 | { 11 | var solution = new _0498_DiagonalTraverse(); 12 | var result = solution.FindDiagonalOrder(new int[][] 13 | { 14 | new int[] { 1, 2, 3 }, 15 | new int[] { 4, 5, 6 }, 16 | new int[] { 7, 8, 9 }, 17 | }); 18 | AssertHelper.AssertArray(new int[] { 1, 2, 4, 7, 5, 3, 6, 8, 9 }, result); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode.Test/0451-0500/0500-KeyboardRow-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0500_KeyboardRow_Test 7 | { 8 | [TestMethod] 9 | public void FindWords_1() 10 | { 11 | var solution = new _0500_KeyboardRow(); 12 | var result = solution.FindWords(new string[] { "Hello", "Alaska", "Dad", "Peace" }); 13 | AssertHelper.AssertArray(new string[] { "Alaska", "Dad" }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0501-0550/0501-FindModeInBinarySearchTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0501_FindModeInBinarySearchTree_Test 7 | { 8 | [TestMethod] 9 | public void FindMode_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 1, null, 2, 2 }); 12 | 13 | var solution = new _0501_FindModeInBinarySearchTree(); 14 | var result = solution.FindMode(root); 15 | AssertHelper.AssertArray(new int[] { 2 }, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0501-0550/0503-NextGreaterElementII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0503_NextGreaterElementII_Test 7 | { 8 | [TestMethod] 9 | public void NextGreaterElements_1() 10 | { 11 | var solution = new _0503_NextGreaterElementII(); 12 | var result = solution.NextGreaterElements(new int[] { 1, 2, 1 }); 13 | AssertHelper.AssertArray(new int[] { 2, -1, 2 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0501-0550/0506-RelativeRanks-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0506_RelativeRanks_Test 7 | { 8 | [TestMethod] 9 | public void FindRelativeRanks_1() 10 | { 11 | var solution = new _0506_RelativeRanks(); 12 | var result = solution.FindRelativeRanks(new int[] { 5, 4, 3, 2, 1 }); 13 | AssertHelper.AssertArray(new string[] { "Gold Medal", "Silver Medal", "Bronze Medal", "4", "5" }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0501-0550/0507-PerfectNumber-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0507_PerfectNumber_Test 7 | { 8 | [TestMethod] 9 | public void CheckPerfectNumber_1() 10 | { 11 | var solution = new _0507_PerfectNumber(); 12 | var result = solution.CheckPerfectNumber(28); 13 | Assert.IsTrue(result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0501-0550/0515-FindLargestValueInEachTreeRow-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0515_FindLargestValueInEachTreeRow_Test 7 | { 8 | [TestMethod] 9 | public void LargestValues_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 1, 3, 2, 5, 3, null, 9 }); 12 | 13 | var solution = new _0515_FindLargestValueInEachTreeRow(); 14 | var result = solution.LargestValues(root); 15 | AssertHelper.AssertList(new int[] { 1, 3, 9 }, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0501-0550/0523-ContinuousSubarraySum-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0523_ContinuousSubarraySum_Test 7 | { 8 | [TestMethod] 9 | public void CheckSubarraySum_1() 10 | { 11 | var solution = new _0523_ContinuousSubarraySum(); 12 | var result = solution.CheckSubarraySum(new int[] { 23, 2, 4, 6, 7 }, 6); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void CheckSubarraySum_2() 18 | { 19 | var solution = new _0523_ContinuousSubarraySum(); 20 | var result = solution.CheckSubarraySum(new int[] { 23, 2, 6, 4, 7 }, 6); 21 | Assert.IsTrue(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0501-0550/0535-EncodeAndDecodeTinyURL-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0535_EncodeAndDecodeTinyURL_Test 7 | { 8 | [TestMethod] 9 | public void EncodeAndDecodeTinyURLTest() 10 | { 11 | var input = "https://leetcode.com/problems/design-tinyurl"; 12 | 13 | var solution = new _0535_EncodeAndDecodeTinyURL(); 14 | var result = solution.decode(solution.encode(input)); 15 | Assert.AreEqual(result, input); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0501-0550/0538-ConvertBSTToGreaterTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0538_ConvertBSTToGreaterTree_Test 7 | { 8 | [TestMethod] 9 | public void ConvertBST_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 5, 2, 13 }); 12 | 13 | var solution = new _0538_ConvertBSTToGreaterTree(); 14 | var result = solution.ConvertBST(root); 15 | AssertHelper.AssertTree(new int?[] { 18, 20, 13 }, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0501-0550/0541-ReverseStringII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0541_ReverseStringII_Test 7 | { 8 | [TestMethod] 9 | public void ReverseStr_1() 10 | { 11 | var solution = new _0541_ReverseStringII(); 12 | var result = solution.ReverseStr("abcdefg", 2); 13 | Assert.AreEqual("bacdfeg", result); 14 | } 15 | 16 | [TestMethod] 17 | public void ReverseStr_2() 18 | { 19 | var solution = new _0541_ReverseStringII(); 20 | var result = solution.ReverseStr("a", 2); 21 | Assert.AreEqual("a", result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0501-0550/0543-DiameterOfBinaryTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0543_DiameterOfBinaryTree_Test 7 | { 8 | [TestMethod] 9 | public void DiameterOfBinaryTreeTest() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 1, 2, 3, 4, 5 }); 12 | 13 | var solution = new _0543_DiameterOfBinaryTree(); 14 | var result = solution.DiameterOfBinaryTree(root); 15 | Assert.AreEqual(3, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0551-0600/0551-StudentAttendanceRecordI-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0551_StudentAttendanceRecordI_Test 7 | { 8 | [TestMethod] 9 | public void CheckRecord_1() 10 | { 11 | var solution = new _0551_StudentAttendanceRecordI(); 12 | var result = solution.CheckRecord("PPALLP"); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void CheckRecord_2() 18 | { 19 | var solution = new _0551_StudentAttendanceRecordI(); 20 | var result = solution.CheckRecord("PPALLL"); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0551-0600/0557-ReverseWordsInAStringIII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0557_ReverseWordsInAStringIII_Test 7 | { 8 | [TestMethod] 9 | public void ReverseWords_1() 10 | { 11 | var solution = new _0557_ReverseWordsInAStringIII(); 12 | var result = solution.ReverseWords("Let's take LeetCode contest"); 13 | Assert.AreEqual("s'teL ekat edoCteeL tsetnoc", result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0551-0600/0560-SubarraySumEqualsK-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0560_SubarraySumEqualsK_Test 7 | { 8 | [TestMethod] 9 | public void SubarraySumTest_1() 10 | { 11 | var solution = new _0560_SubarraySumEqualsK(); 12 | var result = solution.SubarraySum(new int[] { 1, 1, 1 }, 2); 13 | Assert.AreEqual(2, result); 14 | } 15 | 16 | [TestMethod] 17 | public void SubarraySumTest_2() 18 | { 19 | var solution = new _0560_SubarraySumEqualsK(); 20 | var result = solution.SubarraySum(new int[] { 1, 1, 1, -1, 1 }, 3); 21 | Assert.AreEqual(2, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0551-0600/0561-ArrayPartitionI-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0561_ArrayPartitionI_Test 7 | { 8 | [TestMethod] 9 | public void ArrayPairSum_1() 10 | { 11 | var solution = new _0561_ArrayPartitionI(); 12 | var result = solution.ArrayPairSum(new int[] { 1, 4, 3, 2 }); 13 | Assert.AreEqual(4, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0551-0600/0563-BinaryTreeTilt-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0563_BinaryTreeTilt_Test 7 | { 8 | [TestMethod] 9 | public void FindTilt_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 1, 2, 3 }); 12 | 13 | var solution = new _0563_BinaryTreeTilt(); 14 | var result = solution.FindTilt(root); 15 | Assert.AreEqual(1, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0551-0600/0567-PermutationInString-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0567_PermutationInString_Test 7 | { 8 | [TestMethod] 9 | public void CheckInclusion_1() 10 | { 11 | var solution = new _0567_PermutationInString(); 12 | var result = solution.CheckInclusion("ab" , "eidbaooo"); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void CheckInclusion_2() 18 | { 19 | var solution = new _0567_PermutationInString(); 20 | var result = solution.CheckInclusion("ab", "eidboaoo"); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0551-0600/0575-DistributeCandies-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0575_DistributeCandies_Test 7 | { 8 | [TestMethod] 9 | public void DistributeCandies_1() 10 | { 11 | var solution = new _0575_DistributeCandies(); 12 | var result = solution.DistributeCandies(new int[] { 1, 1, 2, 2, 3, 3 }); 13 | Assert.AreEqual(3, result); 14 | } 15 | 16 | [TestMethod] 17 | public void DistributeCandies_2() 18 | { 19 | var solution = new _0575_DistributeCandies(); 20 | var result = solution.DistributeCandies(new int[] { 1, 1, 2, 3 }); 21 | Assert.AreEqual(2, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0551-0600/0581-ShortestUnsortedContinuousSubarray-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0581_ShortestUnsortedContinuousSubarray_Test 7 | { 8 | [TestMethod] 9 | public void FindUnsortedSubarray_1() 10 | { 11 | var solution = new _0581_ShortestUnsortedContinuousSubarray(); 12 | var result = solution.FindUnsortedSubarray(new int[] { 2, 6, 4, 8, 10, 9, 15 }); 13 | Assert.AreEqual(5, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0551-0600/0588-DesignInMemoryFileSystem-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0588_DesignInMemoryFileSystem_Test 7 | { 8 | [TestMethod] 9 | public void DesignInMemoryFileSystem_1() 10 | { 11 | var solution = new _0588_DesignInMemoryFileSystem(); 12 | Assert.AreEqual(0, solution.Ls("/").Count); 13 | solution.Mkdir("/a/b/c"); 14 | solution.AddContentToFile("/a/b/c", "Hello"); 15 | var list = solution.Ls("/"); 16 | Assert.AreEqual(1, list.Count); 17 | Assert.AreEqual("a", list[0]); 18 | 19 | Assert.AreEqual("Hello", solution.ReadContentFromFile("/a/b/c/d")); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode.Test/0551-0600/0594-LongestHarmoniousSubsequence-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0594_LongestHarmoniousSubsequence_Test 7 | { 8 | [TestMethod] 9 | public void FindLHS_1() 10 | { 11 | var solution = new _0594_LongestHarmoniousSubsequence(); 12 | var result = solution.FindLHS(new int[] { 1, 3, 2, 2, 5, 2, 3, 7 }); 13 | Assert.AreEqual(5, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0601-0650/0605-CanPlaceFlowers-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0605_CanPlaceFlowers_Test 7 | { 8 | [TestMethod] 9 | public void CanPlaceFlowers_1() 10 | { 11 | var solution = new _0605_CanPlaceFlowers(); 12 | var result = solution.CanPlaceFlowers(new int[] { 1, 0, 0, 0, 1 }, 1); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void CanPlaceFlowers_2() 18 | { 19 | var solution = new _0605_CanPlaceFlowers(); 20 | var result = solution.CanPlaceFlowers(new int[] { 1, 0, 0, 0, 1 }, 2); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0601-0650/0617-MergeTwoBinaryTrees-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0617_MergeTwoBinaryTrees_Test 7 | { 8 | [TestMethod] 9 | public void MergeTreesTest() 10 | { 11 | var root1 = TestHelper.GenerateTree(new int?[] { 1, 3, 2, 5 }); 12 | var root2 = TestHelper.GenerateTree(new int?[] { 2, 1, 3, null, 4, null, 7 }); 13 | 14 | var solution = new _0617_MergeTwoBinaryTrees(); 15 | var result = solution.MergeTrees(root1, root2); 16 | AssertHelper.AssertTree(new int?[] { 3, 4, 5, 5, 4, null, 7 }, result); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode.Test/0601-0650/0621-TaskScheduler-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0621_TaskScheduler_Test 7 | { 8 | [TestMethod] 9 | public void LeastIntervalTest_1() 10 | { 11 | var solution = new _0621_TaskScheduler(); 12 | var result = solution.LeastInterval(new char[] { 'A', 'A', 'A', 'B', 'B', 'B' }, 2); 13 | Assert.AreEqual(8, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0601-0650/0624-MaximumDistanceInArrays-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using System.Collections.Generic; 3 | 4 | namespace LeetCode.Test 5 | { 6 | [TestClass] 7 | public class _0624_MaximumDistanceInArrays_Test 8 | { 9 | [TestMethod] 10 | public void MaxDistance_1() 11 | { 12 | var solution = new _0624_MaximumDistanceInArrays(); 13 | var result = solution.MaxDistance(new List>() 14 | { 15 | new int[] { 1, 2, 3 }, 16 | new int[] { 4, 5 }, 17 | new int[] { 1, 2, 3 }, 18 | }); 19 | Assert.AreEqual(4, result); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode.Test/0601-0650/0636-ExclusiveTimeOfFunctions-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0636_ExclusiveTimeOfFunctions_Test 7 | { 8 | [TestMethod] 9 | public void ExclusiveTime_1() 10 | { 11 | var solution = new _0636_ExclusiveTimeOfFunctions(); 12 | var result = solution.ExclusiveTime(2, new string[] { "0:start:0", "1:start:2", "1:end:5", "0:end:6" }); 13 | AssertHelper.AssertArray(new int[] { 3, 4 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0601-0650/0637-AverageOfLevelsInBinaryTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0637_AverageOfLevelsInBinaryTree_Test 7 | { 8 | [TestMethod] 9 | public void AverageOfLevels_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 3, 9, 20, null, null, 15, 7 }); 12 | 13 | var solution = new _0637_AverageOfLevelsInBinaryTree(); 14 | var result = solution.AverageOfLevels(root); 15 | AssertHelper.AssertList(new double[] { 3, 14.5, 11 }, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0601-0650/0645-SetMismatch-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0645_SetMismatch_Test 7 | { 8 | [TestMethod] 9 | public void FindErrorNums_1() 10 | { 11 | var solution = new _0645_SetMismatch(); 12 | var result = solution.FindErrorNums(new int[] { 1, 2, 2, 4 }); 13 | AssertHelper.AssertArray(new int[] { 2, 3 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0601-0650/0647-PalindromicSubstrings-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0647_PalindromicSubstrings_Test 7 | { 8 | [TestMethod] 9 | public void CountSubstrings_1() 10 | { 11 | var solution = new _0647_PalindromicSubstrings(); 12 | var result = solution.CountSubstrings("abc"); 13 | Assert.AreEqual(3, result); 14 | } 15 | 16 | [TestMethod] 17 | public void CountSubstrings_2() 18 | { 19 | var solution = new _0647_PalindromicSubstrings(); 20 | var result = solution.CountSubstrings("aaa"); 21 | Assert.AreEqual(6, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0651-0700/0654-MaximumBinaryTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0654_MaximumBinaryTree_Test 7 | { 8 | [TestMethod] 9 | public void ConstructMaximumBinaryTree() 10 | { 11 | var solution = new _0654_MaximumBinaryTree(); 12 | var root = solution.ConstructMaximumBinaryTree(new int[] { 3, 2, 1, 6, 0, 5 }); 13 | AssertHelper.AssertTree(new int?[] { 6, 3, 5, null, 2, 0, null, null, 1 }, root); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0651-0700/0657-RobotReturnToOrigin-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0657_RobotReturnToOrigin_Test 7 | { 8 | [TestMethod] 9 | public void JudgeCircle_1() 10 | { 11 | var solution = new _0657_RobotReturnToOrigin(); 12 | var result = solution.JudgeCircle("UD"); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void JudgeCircle_2() 18 | { 19 | var solution = new _0657_RobotReturnToOrigin(); 20 | var result = solution.JudgeCircle("LL"); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0651-0700/0665-NonDecreasingArray-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0665_NonDecreasingArray_Test 7 | { 8 | [TestMethod] 9 | public void CheckPossibility_1() 10 | { 11 | var solution = new _0665_NonDecreasingArray(); 12 | var result = solution.CheckPossibility(new int[] { 4, 2, 3 }); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void CheckPossibility_2() 18 | { 19 | var solution = new _0665_NonDecreasingArray(); 20 | var result = solution.CheckPossibility(new int[] { 4, 2, 1 }); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0651-0700/0682-BaseballGame-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0682_BaseballGame_Test 7 | { 8 | [TestMethod] 9 | public void CalPoints_1() 10 | { 11 | var solution = new _0682_BaseballGame(); 12 | var result = solution.CalPoints(new string[] { "5", "2", "C", "D", "+" }); 13 | Assert.AreEqual(30, result); 14 | } 15 | 16 | [TestMethod] 17 | public void CalPoints_2() 18 | { 19 | var solution = new _0682_BaseballGame(); 20 | var result = solution.CalPoints(new string[] { "5", "-2", "4", "C", "D", "9", "+", "+" }); 21 | Assert.AreEqual(27, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0651-0700/0683-KEmptySlots-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0683_KEmptySlots_Test 7 | { 8 | [TestMethod] 9 | public void KEmptySlotsTest_1() 10 | { 11 | var solution = new _0683_KEmptySlots(); 12 | var result = solution.KEmptySlots(new int[] { 1, 3, 2 }, 1); 13 | Assert.AreEqual(2, result); 14 | } 15 | 16 | [TestMethod] 17 | public void KEmptySlotsTest_2() 18 | { 19 | var solution = new _0683_KEmptySlots(); 20 | var result = solution.KEmptySlots(new int[] { 1, 2, 3 }, 1); 21 | Assert.AreEqual(-1, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0651-0700/0686-RepeatedStringMatch-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0686_RepeatedStringMatch_Test 7 | { 8 | [TestMethod] 9 | public void RepeatedStringMatchTest() 10 | { 11 | var solution = new _0686_RepeatedStringMatch(); 12 | var result = solution.RepeatedStringMatch("abcd", "cdabcdab"); 13 | Assert.AreEqual(3, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0651-0700/0696-CountBinarySubstrings-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0696_CountBinarySubstrings_Test 7 | { 8 | [TestMethod] 9 | public void CountBinarySubstrings_1() 10 | { 11 | var solution = new _0696_CountBinarySubstrings(); 12 | var result = solution.CountBinarySubstrings("00110011"); 13 | Assert.AreEqual(6, result); 14 | } 15 | 16 | [TestMethod] 17 | public void CountBinarySubstrings_2() 18 | { 19 | var solution = new _0696_CountBinarySubstrings(); 20 | var result = solution.CountBinarySubstrings("10101"); 21 | Assert.AreEqual(4, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0651-0700/0697-DegreeOfAnArray-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0697_DegreeOfAnArray_Test 7 | { 8 | [TestMethod] 9 | public void FindShortestSubArray_1() 10 | { 11 | var solution = new _0697_DegreeOfAnArray(); 12 | var result = solution.FindShortestSubArray(new int[] { 1, 2, 2, 3, 1 }); 13 | Assert.AreEqual(2, result); 14 | } 15 | 16 | [TestMethod] 17 | public void FindShortestSubArray_2() 18 | { 19 | var solution = new _0697_DegreeOfAnArray(); 20 | var result = solution.FindShortestSubArray(new int[] { 1, 2, 2, 3, 1, 4, 2 }); 21 | Assert.AreEqual(6, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0701-0750/0703-KthLargestElementInAStream-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0703_KthLargestElementInAStream_Test 7 | { 8 | [TestMethod] 9 | public void KthLargestTest_1() 10 | { 11 | int k = 3; 12 | int[] arr = new int[] { 4, 5, 8, 2 }; 13 | 14 | var solution = new _0703_KthLargestElementInAStream(k, arr); 15 | Assert.AreEqual(4, solution.Add(3)); 16 | Assert.AreEqual(5, solution.Add(5)); 17 | Assert.AreEqual(5, solution.Add(10)); 18 | Assert.AreEqual(8, solution.Add(9)); 19 | Assert.AreEqual(8, solution.Add(4)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode.Test/0701-0750/0704-BinarySearch-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0704_BinarySearch_Test 7 | { 8 | [TestMethod] 9 | public void Search_1() 10 | { 11 | var solution = new _0704_BinarySearch(); 12 | var result = solution.Search(new int[] { -1, 0, 3, 5, 9, 12 }, 9); 13 | Assert.AreEqual(4, result); 14 | } 15 | 16 | [TestMethod] 17 | public void Search_2() 18 | { 19 | var solution = new _0704_BinarySearch(); 20 | var result = solution.Search(new int[] { -1, 0, 3, 5, 9, 12 }, 2); 21 | Assert.AreEqual(-1, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0701-0750/0705-DesignHashset-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0705_DesignHashset_Test 7 | { 8 | [TestMethod] 9 | public void MyHashSet_1() 10 | { 11 | var hashSet = new _0705_DesignHashset(); 12 | 13 | hashSet.Add(1); 14 | hashSet.Add(2); 15 | Assert.IsTrue(hashSet.Contains(1)); 16 | Assert.IsFalse(hashSet.Contains(3)); 17 | hashSet.Add(2); 18 | Assert.IsTrue(hashSet.Contains(2)); 19 | hashSet.Remove(2); 20 | Assert.IsFalse(hashSet.Contains(2)); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode.Test/0701-0750/0706-DesignHashmap-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0706_DesignHashmap_Test 7 | { 8 | [TestMethod] 9 | public void MyHashMap_1() 10 | { 11 | var hashMap = new _0706_DesignHashmap(); 12 | hashMap.Put(1, 1); 13 | hashMap.Put(2, 2); 14 | Assert.AreEqual(1, hashMap.Get(1)); 15 | Assert.AreEqual(-1, hashMap.Get(3)); 16 | hashMap.Put(2, 1); 17 | Assert.AreEqual(1, hashMap.Get(2)); 18 | hashMap.Remove(2); 19 | Assert.AreEqual(-1, hashMap.Get(2)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode.Test/0701-0750/0713-SubarrayProductLessThanK-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0713_SubarrayProductLessThanK_Test 7 | { 8 | [TestMethod] 9 | public void NumSubarrayProductLessThanK_1() 10 | { 11 | var solution = new _0713_SubarrayProductLessThanK(); 12 | var result = solution.NumSubarrayProductLessThanK(new int[] { 10, 5, 2, 6 }, 100); 13 | Assert.AreEqual(8, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0701-0750/0715-RangeModule-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0715_RangeModule_Test 7 | { 8 | [TestMethod] 9 | public void RangeModuleTest_1() 10 | { 11 | var solution = new _0715_RangeModule(); 12 | 13 | solution.AddRange(10, 20); 14 | solution.RemoveRange(14, 16); 15 | Assert.IsTrue(solution.QueryRange(10, 14)); 16 | Assert.IsFalse(solution.QueryRange(13, 15)); 17 | Assert.IsTrue(solution.QueryRange(16, 17)); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0701-0750/0717-1BitAnd2BitCharacters-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0717_1BitAnd2BitCharacters_Test 7 | { 8 | [TestMethod] 9 | public void IsOneBitCharacter_1() 10 | { 11 | var solution = new _0717_1BitAnd2BitCharacters(); 12 | var result = solution.IsOneBitCharacter(new int[] { 1, 0, 0 }); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void IsOneBitCharacter_2() 18 | { 19 | var solution = new _0717_1BitAnd2BitCharacters(); 20 | var result = solution.IsOneBitCharacter(new int[] { 1, 1, 1, 0 }); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0701-0750/0739-DailyTemperatures-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0739_DailyTemperatures_Test 7 | { 8 | [TestMethod] 9 | public void DailyTemperatures_1() 10 | { 11 | var solution = new _0739_DailyTemperatures(); 12 | var result = solution.DailyTemperatures(new int[] { 73, 74, 75, 71, 69, 72, 76, 73 }); 13 | AssertHelper.AssertArray(new int[] { 1, 1, 4, 2, 1, 1, 0, 0 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0701-0750/0743-NetworkDelayTime-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0743_NetworkDelayTime_Test 7 | { 8 | [TestMethod] 9 | public void NetworkDelayTimeTest() 10 | { 11 | var solution = new _0743_NetworkDelayTime(); 12 | var result = solution.NetworkDelayTime(new int[][] 13 | { 14 | new int[] { 2, 1, 1 }, 15 | new int[] { 2, 3, 1 }, 16 | new int[] { 3, 4, 1 } 17 | }, 4, 2); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0751-0800/0751-IPToCIDR-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0751_IPToCIDR_Test 7 | { 8 | [TestMethod] 9 | public void IpToCIDR_1() 10 | { 11 | var solution = new _0751_IPToCIDR(); 12 | var result = solution.IpToCIDR("255.0.0.7", 10); 13 | AssertHelper.AssertList(new string[] { "255.0.0.7/32", "255.0.0.8/29", "255.0.0.16/32" }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0751-0800/0760-FindAnagramMappings-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0760_FindAnagramMappings_Test 7 | { 8 | [TestMethod] 9 | public void AnagramMappings_1() 10 | { 11 | var solution = new _0760_FindAnagramMappings(); 12 | var result = solution.AnagramMappings(new int[] { 12, 28, 46, 32, 50 }, new int[] { 50, 12, 32, 46, 28 }); 13 | AssertHelper.AssertArray(new int[] { 1, 4, 3, 2, 0 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0751-0800/0763-PartitionLabels-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0763_PartitionLabels_Test 7 | { 8 | [TestMethod] 9 | public void PartitionLabels_1() 10 | { 11 | var solution = new _0763_PartitionLabels(); 12 | var result = solution.PartitionLabels("ababcbacadefegdehijhklij"); 13 | AssertHelper.AssertList(new int[] { 9, 7, 8 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0751-0800/0765-CouplesHoldingHands-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0765_CouplesHoldingHands_Test 7 | { 8 | [TestMethod] 9 | public void MinSwapsCouplesTest_1() 10 | { 11 | var solution = new _0765_CouplesHoldingHands(); 12 | var result = solution.MinSwapsCouples(new int[] { 0, 2, 1, 3 }); 13 | Assert.AreEqual(1, result); 14 | } 15 | 16 | [TestMethod] 17 | public void MinSwapsCouplesTest_2() 18 | { 19 | var solution = new _0765_CouplesHoldingHands(); 20 | var result = solution.MinSwapsCouples(new int[] { 3, 2, 0, 1 }); 21 | Assert.AreEqual(0, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0751-0800/0771-JewelsAndStones-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0771_JewelsAndStones_Test 7 | { 8 | [TestMethod] 9 | public void NumJewelsInStonesTest_1() 10 | { 11 | var solution = new _0771_JewelsAndStones(); 12 | var result = solution.NumJewelsInStones("aA", "aAAbbbb"); 13 | Assert.AreEqual(3, result); 14 | } 15 | 16 | [TestMethod] 17 | public void NumJewelsInStonesTest_2() 18 | { 19 | var solution = new _0771_JewelsAndStones(); 20 | var result = solution.NumJewelsInStones("z", "ZZ"); 21 | Assert.AreEqual(0, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0751-0800/0777-SwapAdjacentInLRString-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0777_SwapAdjacentInLRString_Test 7 | { 8 | [TestMethod] 9 | public void CanTransformTest() 10 | { 11 | var solution = new _0777_SwapAdjacentInLRString(); 12 | var result = solution.CanTransform("RXXLRXRXL", "XRLXXRRLX"); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void CanTransformTest_2() 18 | { 19 | var solution = new _0777_SwapAdjacentInLRString(); 20 | var result = solution.CanTransform("X", "L"); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0751-0800/0788-RotatedDigits-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0788_RotatedDigits_Test 7 | { 8 | [TestMethod] 9 | public void RotatedDigits_1() 10 | { 11 | var solution = new _0788_RotatedDigits(); 12 | var result = solution.RotatedDigits(10); 13 | Assert.AreEqual(4, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0751-0800/0791-CustomSortString-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0791_CustomSortString_Test 7 | { 8 | [TestMethod] 9 | public void CustomSortString_1() 10 | { 11 | var solution = new _0791_CustomSortString(); 12 | var result = solution.CustomSortString("cba", "abcd"); 13 | Assert.AreEqual("cbad", result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0751-0800/0796-RotateString-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0796_RotateString_Test 7 | { 8 | [TestMethod] 9 | public void RotateString_1() 10 | { 11 | var solution = new _0796_RotateString(); 12 | var result = solution.RotateString("abcde", "cdeab"); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void RotateString_2() 18 | { 19 | var solution = new _0796_RotateString(); 20 | var result = solution.RotateString("abcde", "abced"); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0751-0800/0800-SimilarRGBColor-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0800_SimilarRGBColor_Test 7 | { 8 | [TestMethod] 9 | public void SimilarRGB_1() 10 | { 11 | var solution = new _0800_SimilarRGBColor(); 12 | var result = solution.SimilarRGB("#09f166"); 13 | Assert.AreEqual("#11ee66", result); 14 | } 15 | 16 | [TestMethod] 17 | public void SimilarRGB_2() 18 | { 19 | var solution = new _0800_SimilarRGBColor(); 20 | var result = solution.SimilarRGB("#1c9e03"); 21 | Assert.AreEqual("#229900", result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0801-0850/0807-MaxIncreaseToKeepCitySkyline-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0807_MaxIncreaseToKeepCitySkyline_Test 7 | { 8 | [TestMethod] 9 | public void MaxIncreaseKeepingSkyline_1() 10 | { 11 | var solution = new _0807_MaxIncreaseToKeepCitySkyline(); 12 | var result = solution.MaxIncreaseKeepingSkyline(new int[][] { 13 | new int[] { 3, 0, 8, 4 }, 14 | new int[] { 2, 4, 5, 7 }, 15 | new int[] { 9, 2, 6, 3 }, 16 | new int[] { 0, 3, 1, 0 }, 17 | }); 18 | Assert.AreEqual(35, result); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode.Test/0801-0850/0812-LargestTriangleArea-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0812_LargestTriangleArea_Test 7 | { 8 | [TestMethod] 9 | public void LargestTriangleArea_1() 10 | { 11 | var solution = new _0812_LargestTriangleArea(); 12 | var result = solution.LargestTriangleArea(new int[][] { 13 | new int[] { 0, 0 }, 14 | new int[] { 0, 1 }, 15 | new int[] { 1, 0 }, 16 | new int[] { 0, 2 }, 17 | new int[] { 2, 0 }, 18 | }); 19 | Assert.AreEqual(2, result); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode.Test/0801-0850/0821-ShortestDistanceToACharacter-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0821_ShortestDistanceToACharacter_Test 7 | { 8 | [TestMethod] 9 | public void ShortestToChar_1() 10 | { 11 | var solution = new _0821_ShortestDistanceToACharacter(); 12 | var result = solution.ShortestToChar("loveleetcode", 'e'); 13 | AssertHelper.AssertArray(new int[] { 3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0801-0850/0843-GuesstheWord-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0843_GuesstheWord_Test 7 | { 8 | [TestMethod] 9 | public void FindSecretWordTest() 10 | { 11 | var wordlist = new string[] { "acckzz", "ccbazz", "eiowzz", "abcczz" }; 12 | var master = new Master("acckzz", wordlist); 13 | 14 | var solution = new _0843_GuesstheWord(); 15 | solution.FindSecretWord(wordlist, master); 16 | 17 | Assert.IsTrue(master.GuessCount <= 10); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0801-0850/0846-HandOfStraights-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0846_HandOfStraights_Test 7 | { 8 | [TestMethod] 9 | public void IsNStraightHand_1() 10 | { 11 | var solution = new _0846_HandOfStraights(); 12 | var result = solution.IsNStraightHand(new int[] { 1, 2, 3, 6, 2, 3, 4, 7, 8 }, 3); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void IsNStraightHand_2() 18 | { 19 | var solution = new _0846_HandOfStraights(); 20 | var result = solution.IsNStraightHand(new int[] { 1, 2, 3, 4, 5 }, 4); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0851-0900/0861-ScoreAfterFlippingMatrix-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0861_ScoreAfterFlippingMatrix_Test 7 | { 8 | [TestMethod] 9 | public void MatrixScore_1() 10 | { 11 | var solution = new _0861_ScoreAfterFlippingMatrix(); 12 | var result = solution.MatrixScore(new int[][] { 13 | new int[] { 0, 0, 1, 1 }, 14 | new int[] { 1, 0, 1, 0 }, 15 | new int[] { 1, 1, 0, 0 } 16 | }); 17 | Assert.AreEqual(39, result); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0851-0900/0865-SmallestSubtreeWithAllTheDeepestNodes-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0865_SmallestSubtreeWithAllTheDeepestNodes_Test 7 | { 8 | [TestMethod] 9 | public void SubtreeWithAllDeepest_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 3, 5, 1, 6, 2, 0, 8, null, null, 7, 4 }); 12 | 13 | var solution = new _0865_SmallestSubtreeWithAllTheDeepestNodes(); 14 | var result = solution.SubtreeWithAllDeepest(root); 15 | AssertHelper.AssertTree(new int?[] { 2, 7, 4 }, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0851-0900/0877-StoneGame-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0877_StoneGame_Test 7 | { 8 | [TestMethod] 9 | public void StoneGame_1() 10 | { 11 | var solution = new _0877_StoneGame(); 12 | var result = solution.StoneGame(new int[] { 5, 3, 4, 5 }); 13 | Assert.IsTrue(result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0851-0900/0889-ConstructBinaryTreeFromPreorderAndPostorderTraversal-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0889_ConstructBinaryTreeFromPreorderAndPostorderTraversal_Test 7 | { 8 | [TestMethod] 9 | public void ConstructFromPrePost_1() 10 | { 11 | var solution = new _0889_ConstructBinaryTreeFromPreorderAndPostorderTraversal(); 12 | var result = solution.ConstructFromPrePost(new int[] { 1, 2, 4, 5, 3, 6, 7 }, new int[] { 4, 5, 2, 6, 7, 3, 1 }); 13 | AssertHelper.AssertTree(new int?[] { 1, 2, 3, 4, 5, 6, 7 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0851-0900/0890-FindAndReplacePattern-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0890_FindAndReplacePattern_Test 7 | { 8 | [TestMethod] 9 | public void FindAndReplacePattern_1() 10 | { 11 | var solution = new _0890_FindAndReplacePattern(); 12 | var result = solution.FindAndReplacePattern(new string[] { "abc", "deq", "mee", "aqq", "dkd", "ccc" }, "abb"); 13 | AssertHelper.AssertList(new string[] { "mee", "aqq" }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0851-0900/0895-MaximumFrequencyStack-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0895_MaximumFrequencyStack_Test 7 | { 8 | [TestMethod] 9 | public void FreqStackTest() 10 | { 11 | var freqStack = new _0895_MaximumFrequencyStack(); 12 | 13 | freqStack.Push(5); 14 | freqStack.Push(7); 15 | freqStack.Push(5); 16 | freqStack.Push(7); 17 | freqStack.Push(4); 18 | freqStack.Push(5); 19 | Assert.AreEqual(5, freqStack.Pop()); 20 | Assert.AreEqual(7, freqStack.Pop()); 21 | Assert.AreEqual(5, freqStack.Pop()); 22 | Assert.AreEqual(4, freqStack.Pop()); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode.Test/0851-0900/0897-IncreasingOrderSearchTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0897_IncreasingOrderSearchTree_Test 7 | { 8 | [TestMethod] 9 | public void IncreasingBST_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 5, 3, 6, 2, 4, null, 8, 1, null, null, null, 7, 9 }); 12 | 13 | var solution = new _0897_IncreasingOrderSearchTree(); 14 | var result = solution.IncreasingBST(root); 15 | AssertHelper.AssertTree(new int?[] { 1, null, 2, null, 3, null, 4, null, 5, null, 6, null, 7, null, 8, null, 9 }, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/0901-0950/0901-OnlineStockSpan-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0901_OnlineStockSpan_Test 7 | { 8 | [TestMethod] 9 | public void OnlineStockSpanTest_1() 10 | { 11 | var solution = new _0901_OnlineStockSpan(); 12 | Assert.AreEqual(1, solution.Next(100)); 13 | Assert.AreEqual(1, solution.Next(80)); 14 | Assert.AreEqual(1, solution.Next(60)); 15 | Assert.AreEqual(2, solution.Next(70)); 16 | Assert.AreEqual(1, solution.Next(60)); 17 | Assert.AreEqual(4, solution.Next(75)); 18 | Assert.AreEqual(6, solution.Next(85)); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode.Test/0901-0950/0922-SortArrayByParityII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0922_SortArrayByParityII_Test 7 | { 8 | [TestMethod] 9 | public void SortArrayByParityII_1() 10 | { 11 | var solution = new _0922_SortArrayByParityII(); 12 | var result = solution.SortArrayByParityII(new int[] { 4, 2, 5, 7 }); 13 | AssertHelper.AssertArray(new int[] { 4, 5, 2, 7 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0901-0950/0929-UniqueEmailAddresses-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0929_UniqueEmailAddresses_Test 7 | { 8 | [TestMethod] 9 | public void NumUniqueEmailsTest() 10 | { 11 | var solution = new _0929_UniqueEmailAddresses(); 12 | var result = solution.NumUniqueEmails(new string[] { "test.email+alex@leetcode.com", "test.e.mail+bob.cathy@leetcode.com", "testemail+david@lee.tcode.com" }); 13 | Assert.AreEqual(2, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0901-0950/0931-MinimumFallingPathSum-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0931_MinimumFallingPathSum_Test 7 | { 8 | [TestMethod] 9 | public void MinFallingPathSum_1() 10 | { 11 | var solution = new _0931_MinimumFallingPathSum(); 12 | var result = solution.MinFallingPathSum(new int[][] { 13 | new int[] { 1, 2, 3 }, 14 | new int[] { 4, 5, 6 }, 15 | new int[] { 7, 8, 9 }, 16 | }); 17 | Assert.AreEqual(12, result); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/0901-0950/0933-NumberOfRecentCalls-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0933_NumberOfRecentCalls_Test 7 | { 8 | [TestMethod] 9 | public void PingTest_1() 10 | { 11 | var solution = new _0933_NumberOfRecentCalls(); 12 | var result = solution.Ping(1); 13 | Assert.AreEqual(1, result); 14 | 15 | result = solution.Ping(100); 16 | Assert.AreEqual(2, result); 17 | 18 | result = solution.Ping(3001); 19 | Assert.AreEqual(3, result); 20 | 21 | result = solution.Ping(3002); 22 | Assert.AreEqual(3, result); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode.Test/0901-0950/0950-RevealCardsInIncreasingOrder-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0950_RevealCardsInIncreasingOrder_Test 7 | { 8 | [TestMethod] 9 | public void DeckRevealedIncreasing_1() 10 | { 11 | var solution = new _0950_RevealCardsInIncreasingOrder(); 12 | var result = solution.DeckRevealedIncreasing(new int[] { 17, 13, 11, 2, 3, 5, 7 }); 13 | AssertHelper.AssertArray(new int[] { 2, 13, 3, 11, 5, 17, 7 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/0951-1000/0951-FlipEquivalentBinaryTrees-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0951_FlipEquivalentBinaryTrees_Test 7 | { 8 | [TestMethod] 9 | public void FlipEquiv_1() 10 | { 11 | var root1 = TestHelper.GenerateTree(new int?[] { 1, 2, 3, 4, 5, 6, null, null, null, 7, 8 }); 12 | var root2 = TestHelper.GenerateTree(new int?[] { 1, 3, 2, null, 6, 4, 5, null, null, null, null, 8, 7 }); 13 | 14 | var solution = new _0951_FlipEquivalentBinaryTrees(); 15 | var result = solution.FlipEquiv(root1, root2); 16 | Assert.IsTrue(result); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode.Test/0951-1000/0969-PancakeSorting-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0969_PancakeSorting_Test 7 | { 8 | [TestMethod] 9 | public void PancakeSort_1() 10 | { 11 | var solution = new _0969_PancakeSorting(); 12 | var result = solution.PancakeSort(new int[] { 3, 2, 4, 1 }); 13 | AssertHelper.AssertList(new int[] { 3, 4, 2, 3, 1, 2 }, result); 14 | } 15 | 16 | [TestMethod] 17 | public void PancakeSort_2() 18 | { 19 | var solution = new _0969_PancakeSorting(); 20 | var result = solution.PancakeSort(new int[] { 1, 2, 3 }); 21 | Assert.AreEqual(0, result.Count); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/0951-1000/0985-SumOfEvenNumbersAfterQueries-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _0985_SumOfEvenNumbersAfterQueries_Test 7 | { 8 | [TestMethod] 9 | public void SumEvenAfterQueries_1() 10 | { 11 | var solution = new _0985_SumOfEvenNumbersAfterQueries(); 12 | var result = solution.SumEvenAfterQueries(new int[] { 1, 2, 3, 4 }, new int[][] { 13 | new int[] { 1, 0 }, 14 | new int[] { -3, 1 }, 15 | new int[] { -4, 0 }, 16 | new int[] { 2, 3 }, 17 | }); 18 | AssertHelper.AssertArray(new int[] { 8, 6, 2, 4 }, result); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode.Test/1001-1050/1008-ConstructBinarySearchTreeFromPreorderTraversal-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1008_ConstructBinarySearchTreeFromPreorderTraversal_Test 7 | { 8 | [TestMethod] 9 | public void BstFromPreorder_1() 10 | { 11 | var solution = new _1008_ConstructBinarySearchTreeFromPreorderTraversal(); 12 | var result = solution.BstFromPreorder(new int[] { 8, 5, 1, 7, 10, 12 }); 13 | AssertHelper.AssertTree(new int?[] { 8, 5, 10, 1, 7, null, 12 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/1001-1050/1026-MaximumDifferenceBetweenNodeAndAncestor-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1026_MaximumDifferenceBetweenNodeAndAncestor_Test 7 | { 8 | [TestMethod] 9 | public void MaxAncestorDiff_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 8, 3, 10, 1, 6, null, 14, null, null, 4, 7, 13 }); 12 | 13 | var solution = new _1026_MaximumDifferenceBetweenNodeAndAncestor(); 14 | var result = solution.MaxAncestorDiff(root); 15 | Assert.AreEqual(7, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/1001-1050/1029-TwoCityScheduling-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1029_TwoCityScheduling_Test 7 | { 8 | [TestMethod] 9 | public void TwoCitySchedCost_1() 10 | { 11 | var solution = new _1029_TwoCityScheduling(); 12 | var result = solution.TwoCitySchedCost(new int[][] { 13 | new int[] { 10, 20 }, 14 | new int[] { 30, 200 }, 15 | new int[] { 400, 50 }, 16 | new int[] { 30, 20 }, 17 | }); 18 | Assert.AreEqual(110, result); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode.Test/1001-1050/1043-PartitionArrayForMaximumSum-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1043_PartitionArrayForMaximumSum_Test 7 | { 8 | [TestMethod] 9 | public void MaxSumAfterPartitioning_1() 10 | { 11 | var solution = new _1043_PartitionArrayForMaximumSum(); 12 | var result = solution.MaxSumAfterPartitioning(new int[] { 1, 15, 7, 9, 2, 5, 10 }, 3); 13 | Assert.AreEqual(84, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/1001-1050/1044-LongestDuplicateSubstring-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1044_LongestDuplicateSubstring_Test 7 | { 8 | [TestMethod] 9 | public void LongestDupSubstring_1() 10 | { 11 | var solution = new _1044_LongestDuplicateSubstring(); 12 | var result = solution.LongestDupSubstring("banana"); 13 | Assert.AreEqual("ana", result); 14 | } 15 | 16 | [TestMethod] 17 | public void LongestDupSubstring_2() 18 | { 19 | var solution = new _1044_LongestDuplicateSubstring(); 20 | var result = solution.LongestDupSubstring("abcd"); 21 | Assert.AreEqual("", result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1001-1050/1046-LastStoneWeight-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1046_LastStoneWeight_Test 7 | { 8 | [TestMethod] 9 | public void LastStoneWeightTest_1() 10 | { 11 | var solution = new _1046_LastStoneWeight(); 12 | var result = solution.LastStoneWeight(new int[] { 2, 7, 4, 1, 8, 1 }); 13 | Assert.AreEqual(1, result); 14 | } 15 | 16 | [TestMethod] 17 | public void LastStoneWeightTest_2() 18 | { 19 | var solution = new _1046_LastStoneWeight(); 20 | var result = solution.LastStoneWeight(new int[] { 1, 1 }); 21 | Assert.AreEqual(0, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1001-1050/1047-RemoveAllAdjacentDuplicatesInString-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1047_RemoveAllAdjacentDuplicatesInString_Test 7 | { 8 | [TestMethod] 9 | public void RemoveDuplicates_1() 10 | { 11 | var solution = new _1047_RemoveAllAdjacentDuplicatesInString(); 12 | var result = solution.RemoveDuplicates("abbaca"); 13 | Assert.AreEqual("ca", result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/1001-1050/1048-LongestStringChain-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1048_LongestStringChain_Test 7 | { 8 | [TestMethod] 9 | public void LongestStrChain_1() 10 | { 11 | var solution = new _1048_LongestStringChain(); 12 | var result = solution.LongestStrChain(new string[] { "a", "b", "ba", "bca", "bda", "bdca" }); 13 | Assert.AreEqual(4, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/1051-1100/1079-LetterTilePossibilities-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1079_LetterTilePossibilities_Test 7 | { 8 | [TestMethod] 9 | public void NumTilePossibilities_1() 10 | { 11 | var solution = new _1079_LetterTilePossibilities(); 12 | var result = solution.NumTilePossibilities("AAB"); 13 | Assert.AreEqual(8, result); 14 | } 15 | 16 | [TestMethod] 17 | public void NumTilePossibilities_2() 18 | { 19 | var solution = new _1079_LetterTilePossibilities(); 20 | var result = solution.NumTilePossibilities("AAABBC"); 21 | Assert.AreEqual(188, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1051-1100/1099-TwoSumLessThanK-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1099_TwoSumLessThanK_Test 7 | { 8 | [TestMethod] 9 | public void TwoSumLessThanK_1() 10 | { 11 | var solution = new _1099_TwoSumLessThanK(); 12 | var result = solution.TwoSumLessThanK(new int[] { 34, 23, 1, 24, 75, 33, 54, 8 }, 60); 13 | Assert.AreEqual(58, result); 14 | } 15 | 16 | [TestMethod] 17 | public void TwoSumLessThanK_2() 18 | { 19 | var solution = new _1099_TwoSumLessThanK(); 20 | var result = solution.TwoSumLessThanK(new int[] { 10, 20, 30 }, 15); 21 | Assert.AreEqual(-1, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1101-1150/1108-DefangingAnIPAddress-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1108_DefangingAnIPAddress_Test 7 | { 8 | [TestMethod] 9 | public void DefangIPaddr_1() 10 | { 11 | var solution = new _1108_DefangingAnIPAddress(); 12 | var result = solution.DefangIPaddr("1.1.1.1"); 13 | Assert.AreEqual("1[.]1[.]1[.]1", result); 14 | } 15 | 16 | [TestMethod] 17 | public void DefangIPaddr_2() 18 | { 19 | var solution = new _1108_DefangingAnIPAddress(); 20 | var result = solution.DefangIPaddr("255.100.50.0"); 21 | Assert.AreEqual("255[.]100[.]50[.]0", result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1101-1150/1120-MaximumAverageSubtree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1120_MaximumAverageSubtree_Test 7 | { 8 | 9 | [TestMethod] 10 | public void MaximumAverageSubtree_1() 11 | { 12 | var root = TestHelper.GenerateTree(new int?[] { 5, 6, 1 }); 13 | var solution = new _1120_MaximumAverageSubtree(); 14 | var result = solution.MaximumAverageSubtree(root); 15 | Assert.AreEqual(6.0, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/1101-1150/1122-RelativeSortArray-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1122_RelativeSortArray_Test 7 | { 8 | [TestMethod] 9 | public void RelativeSortArray_1() 10 | { 11 | var solution = new _1122_RelativeSortArray(); 12 | var result = solution.RelativeSortArray(new int[] { 2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19 }, new int[] { 2, 1, 4, 3, 9, 6 }); 13 | AssertHelper.AssertArray(new int[] { 2, 2, 2, 1, 4, 3, 3, 9, 6, 7, 19 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/1101-1150/1128-NumberOfEquivalentDominoPairs-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1128_NumberOfEquivalentDominoPairs_Test 7 | { 8 | [TestMethod] 9 | public void NumEquivDominoPairs_1() 10 | { 11 | var solution = new _1128_NumberOfEquivalentDominoPairs(); 12 | var result = solution.NumEquivDominoPairs(new int[][] { 13 | new int[] { 1, 2 }, 14 | new int[] { 2, 1 }, 15 | new int[] { 3, 4 }, 16 | new int[] { 5, 6 }, 17 | }); 18 | Assert.AreEqual(1, result); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode.Test/1101-1150/1134-ArmstrongNumber-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1134_ArmstrongNumber_Test 7 | { 8 | [TestMethod] 9 | public void IsArmstrong_1() 10 | { 11 | var solution = new _1134_ArmstrongNumber(); 12 | var result = solution.IsArmstrong(153); 13 | Assert.IsTrue(result); 14 | } 15 | 16 | [TestMethod] 17 | public void IsArmstrong_2() 18 | { 19 | var solution = new _1134_ArmstrongNumber(); 20 | var result = solution.IsArmstrong(123); 21 | Assert.IsFalse(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1101-1150/1137-NThTribonacciNumber-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1137_NThTribonacciNumber_Test 7 | { 8 | [TestMethod] 9 | public void Tribonacci_1() 10 | { 11 | var solution = new _1137_NThTribonacciNumber(); 12 | var result = solution.Tribonacci(4); 13 | Assert.AreEqual(4, result); 14 | } 15 | 16 | [TestMethod] 17 | public void Tribonacci_2() 18 | { 19 | var solution = new _1137_NThTribonacciNumber(); 20 | var result = solution.Tribonacci(25); 21 | Assert.AreEqual(1389537, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1101-1150/1140-StoneGameII-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1140_StoneGameII_Test 7 | { 8 | [TestMethod] 9 | public void StoneGameII_1() 10 | { 11 | var solution = new _1140_StoneGameII(); 12 | var result = solution.StoneGameII(new int[] { 2, 7, 9, 4, 4 }); 13 | Assert.AreEqual(10, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/1151-1200/1161-MaximumLevelSumOfABinaryTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1161_MaximumLevelSumOfABinaryTree_Test 7 | { 8 | [TestMethod] 9 | public void MaxLevelSum_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 1, 7, 0, 7, -8, null, null }); 12 | 13 | var solution = new _1161_MaximumLevelSumOfABinaryTree(); 14 | var result = solution.MaxLevelSum(root); 15 | Assert.AreEqual(2, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/1151-1200/1165-SingleRowKeyboard-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1165_SingleRowKeyboard_Test 7 | { 8 | [TestMethod] 9 | public void CalculateTime_1() 10 | { 11 | var solution = new _1165_SingleRowKeyboard(); 12 | var result = solution.CalculateTime("abcdefghijklmnopqrstuvwxyz", "cba"); 13 | Assert.AreEqual(4, result); 14 | } 15 | 16 | [TestMethod] 17 | public void CalculateTime_2() 18 | { 19 | var solution = new _1165_SingleRowKeyboard(); 20 | var result = solution.CalculateTime("pqrstuvwxyzabcdefghijklmno", "leetcode"); 21 | Assert.AreEqual(73, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1151-1200/1175-PrimeArrangements-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1175_PrimeArrangements_Test 7 | { 8 | [TestMethod] 9 | public void NumPrimeArrangements_1() 10 | { 11 | var solution = new _1175_PrimeArrangements(); 12 | var result = solution.NumPrimeArrangements(5); 13 | Assert.AreEqual(12, result); 14 | } 15 | 16 | [TestMethod] 17 | public void NumPrimeArrangements_2() 18 | { 19 | var solution = new _1175_PrimeArrangements(); 20 | var result = solution.NumPrimeArrangements(100); 21 | Assert.AreEqual(682289015, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1151-1200/1197-MinimumKnightMoves-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1197_MinimumKnightMoves_Test 7 | { 8 | [TestMethod] 9 | public void MinKnightMovesTest_1() 10 | { 11 | var solution = new _1197_MinimumKnightMoves(); 12 | var result = solution.MinKnightMoves(2, 1); 13 | Assert.AreEqual(1, result); 14 | } 15 | 16 | [TestMethod] 17 | public void MinKnightMovesTest_2() 18 | { 19 | var solution = new _1197_MinimumKnightMoves(); 20 | var result = solution.MinKnightMoves(5, 5); 21 | Assert.AreEqual(4, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1201-1250/1213-IntersectionOfThreeSortedArrays-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1213_IntersectionOfThreeSortedArrays_Test 7 | { 8 | [TestMethod] 9 | public void ArraysIntersection_1() 10 | { 11 | var solution = new _1213_IntersectionOfThreeSortedArrays(); 12 | var result = solution.ArraysIntersection(new int[] { 1, 2, 3, 4, 5 }, new int[] { 1, 2, 5, 7, 9 }, new int[] { 1, 3, 4, 5, 8 }); 13 | AssertHelper.AssertList(new int[] { 1, 5 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/1201-1250/1217-PlayWithChips-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1217_PlayWithChips_Test 7 | { 8 | [TestMethod] 9 | public void MinCostToMoveChips_1() 10 | { 11 | var solution = new _1217_PlayWithChips(); 12 | var result = solution.MinCostToMoveChips(new int[] { 1, 2, 3 }); 13 | Assert.AreEqual(1, result); 14 | } 15 | 16 | [TestMethod] 17 | public void MinCostToMoveChips_2() 18 | { 19 | var solution = new _1217_PlayWithChips(); 20 | var result = solution.MinCostToMoveChips(new int[] { 2, 2, 2, 3, 3 }); 21 | Assert.AreEqual(2, result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1251-1300/1256-EncodeNumber-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1256_EncodeNumber_Test 7 | { 8 | [TestMethod] 9 | public void Encode_1() 10 | { 11 | var solution = new _1256_EncodeNumber(); 12 | var result = solution.Encode(23); 13 | Assert.AreEqual("1000", result); 14 | } 15 | 16 | [TestMethod] 17 | public void Encode_2() 18 | { 19 | var solution = new _1256_EncodeNumber(); 20 | var result = solution.Encode(107); 21 | Assert.AreEqual("101100", result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1251-1300/1271-Hexspeak-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1271_Hexspeak_Test 7 | { 8 | [TestMethod] 9 | public void ToHexspeak_1() 10 | { 11 | var solution = new _1271_Hexspeak(); 12 | var result = solution.ToHexspeak("257"); 13 | Assert.AreEqual("IOI", result); 14 | } 15 | 16 | [TestMethod] 17 | public void ToHexspeak_2() 18 | { 19 | var solution = new _1271_Hexspeak(); 20 | var result = solution.ToHexspeak("3"); 21 | Assert.AreEqual("ERROR", result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode.Test/1251-1300/1286-IteratorForCombination-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1286_IteratorForCombination_Test 7 | { 8 | [TestMethod] 9 | public void IteratorForCombination_1() 10 | { 11 | _1286_IteratorForCombination iterator = new _1286_IteratorForCombination("abc", 2); // creates the iterator. 12 | Assert.AreEqual("ab", iterator.Next()); 13 | Assert.IsTrue(iterator.HasNext()); 14 | Assert.AreEqual("ac", iterator.Next()); 15 | Assert.IsTrue(iterator.HasNext()); 16 | Assert.AreEqual("bc", iterator.Next()); 17 | Assert.IsFalse(iterator.HasNext()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode.Test/1251-1300/1287-ElementAppearingMoreThan25InSortedArray-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1287_ElementAppearingMoreThan25InSortedArray_Test 7 | { 8 | [TestMethod] 9 | public void FindSpecialInteger_1() 10 | { 11 | var solution = new _1287_ElementAppearingMoreThan25InSortedArray(); 12 | var result = solution.FindSpecialInteger(new int[] { 1, 2, 2, 6, 6, 6, 6, 7, 10 }); 13 | Assert.AreEqual(6, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/1251-1300/1299-ReplaceElementsWithGreatestElementOnRightSide-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1299_ReplaceElementsWithGreatestElementOnRightSide_Test 7 | { 8 | [TestMethod] 9 | public void ReplaceElements_1() 10 | { 11 | var solution = new _1299_ReplaceElementsWithGreatestElementOnRightSide(); 12 | var result = solution.ReplaceElements(new int[] { 17, 18, 5, 4, 6, 1 }); 13 | AssertHelper.AssertArray(new int[] { 18, 6, 6, 6, 1, -1 }, result); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode.Test/1301-1350/1302-DeepestLeavesSum-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1302_DeepestLeavesSum_Test 7 | { 8 | [TestMethod] 9 | public void DeepestLeavesSum_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 1, 2, 3, 4, 5, null, 6, 7, null, null, null, null, 8 }); 12 | 13 | var solution = new _1302_DeepestLeavesSum(); 14 | var result = solution.DeepestLeavesSum(root); 15 | Assert.AreEqual(15, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/1301-1350/1315-SumOfNodesWithEvenValuedGrandparent-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1315_SumOfNodesWithEvenValuedGrandparent_Test 7 | { 8 | [TestMethod] 9 | public void SumEvenGrandparent_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 6, 7, 8, 2, 7, 1, 3, 9, null, 1, 4, null, null, null, 5 }); 12 | 13 | var solution = new _1315_SumOfNodesWithEvenValuedGrandparent(); 14 | var result = solution.SumEvenGrandparent(root); 15 | Assert.AreEqual(18, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/1351-1400/1382-BalanceABinarySearchTree-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1382_BalanceABinarySearchTree_Test 7 | { 8 | [TestMethod] 9 | public void BalanceBST_1() 10 | { 11 | var root = TestHelper.GenerateTree(new int?[] { 1, null, 2, null, 3, null, 4, null, null }); 12 | 13 | var solution = new _1382_BalanceABinarySearchTree(); 14 | var result = solution.BalanceBST(root); 15 | AssertHelper.AssertTree(new int?[] { 3, 2, 4, 1 }, result); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode.Test/1451-1500/1496-PathCrossing-Test.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace LeetCode.Test 4 | { 5 | [TestClass] 6 | public class _1496_PathCrossing_Test 7 | { 8 | [TestMethod] 9 | public void IsPathCrossing_1() 10 | { 11 | var solution = new _1496_PathCrossing(); 12 | var result = solution.IsPathCrossing("NES"); 13 | Assert.IsFalse(result); 14 | } 15 | 16 | [TestMethod] 17 | public void IsPathCrossing_2() 18 | { 19 | var solution = new _1496_PathCrossing(); 20 | var result = solution.IsPathCrossing("NESWW"); 21 | Assert.IsTrue(result); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/0001-0050/027-RemoveElement.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 236ms 3 | // Memory Usage: 30.1 MB 4 | // Link: https://leetcode.com/submissions/detail/351897187/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _027_RemoveElement 10 | { 11 | public int RemoveElement(int[] nums, int val) 12 | { 13 | var lastIndex = nums.Length - 1; 14 | 15 | for (int i = 0; i <= lastIndex; i++) 16 | { 17 | if (nums[i] == val) 18 | { 19 | nums[i--] = nums[lastIndex--]; 20 | } 21 | } 22 | 23 | return lastIndex + 1; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LeetCode/0001-0050/050-Pow.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 48ms 3 | // Memory Usage: 15 MB 4 | // Link: https://leetcode.com/submissions/detail/367515347/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _050_Pow 10 | { 11 | public double MyPow(double x, int n) 12 | { 13 | if (x == 0 || x == 1) return x; 14 | if (n == 0) return 1; 15 | 16 | var temp = MyPow(x, n / 2); 17 | 18 | if (n % 2 == 0) return temp * temp; 19 | return n > 0 ? x * temp * temp : (temp * temp) / x; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode/0051-0100/069-Sqrt(x).cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 44ms 3 | // Memory Usage: 14.7 MB 4 | // Link: https://leetcode.com/submissions/detail/359211280/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _069_Sqrt 10 | { 11 | public int MySqrt(int x) 12 | { 13 | if (x < 1) { return x; } 14 | 15 | double last = 0.0, result = 1.0; 16 | while (last != result) 17 | { 18 | last = result; 19 | result = (result + x / result) / 2; 20 | } 21 | 22 | return (int)last; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/0051-0100/070-ClimbingStairs.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 40ms 3 | // Memory Usage: 14.5 MB 4 | // Link: https://leetcode.com/submissions/detail/352318308/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _070_ClimbingStairs 10 | { 11 | public int ClimbStairs(int n) 12 | { 13 | if (n < 4) { return n; } 14 | 15 | int x1 = 2, x2 = 3, temp; 16 | for (int i = 4; i <= n; i++) 17 | { 18 | temp = x1 + x2; 19 | x1 = x2; 20 | x2 = temp; 21 | } 22 | 23 | return x2; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LeetCode/0051-0100/096-UniqueBinarySearchTree.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 36ms 3 | // Memory Usage: 14.6 MB 4 | // Link: https://leetcode.com/submissions/detail/357929135/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _096_UniqueBinarySearchTree 10 | { 11 | public int NumTrees(int n) 12 | { 13 | long result = 1; 14 | for (int i = 0; i < n; i++) 15 | result = result * 2 * (2 * i + 1) / (i + 2); 16 | 17 | return (int)result; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode/0051-0100/100-SameTree.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 84ms 3 | // Memory Usage: 24.3 MB 4 | // Link: https://leetcode.com/submissions/detail/343624904/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _100_SameTree 10 | { 11 | public bool IsSameTree(TreeNode p, TreeNode q) 12 | { 13 | if (q == null && p == null) return true; 14 | if (p == null || q == null) return false; 15 | if (p.val != q.val) return false; 16 | 17 | return IsSameTree(p.left, q.left) && IsSameTree(p.right, q.right); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode/0101-0150/0122-BestTimeToBuyAndSellStock2.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 92ms 3 | // Memory Usage: 25.1 MB 4 | // Link: https://leetcode.com/submissions/detail/340984824/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0122_BestTimeToBuyAndSellStock2 12 | { 13 | public int MaxProfit(int[] prices) 14 | { 15 | var maxProfit = 0; 16 | for (int i = 1; i < prices.Length; i++) 17 | maxProfit += Math.Max(0, prices[i] - prices[i - 1]); 18 | 19 | return maxProfit; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode/0101-0150/0136-SingleNumber.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 96ms 3 | // Memory Usage: 25.2 MB 4 | // Link: https://leetcode.com/submissions/detail/261543230/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0136_SingleNumber 10 | { 11 | public int SingleNumber(int[] nums) 12 | { 13 | var a = 0; 14 | foreach (var num in nums) 15 | a ^= num; 16 | 17 | return a; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode/0101-0150/0137-SingleNumberII.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 96ms 3 | // Memory Usage: 24.9 MB 4 | // Link: https://leetcode.com/submissions/detail/357933065/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0137_SingleNumberII 10 | { 11 | public int SingleNumber(int[] nums) 12 | { 13 | int seenOnce = 0, seenTwice = 0; 14 | 15 | foreach (int num in nums) 16 | { 17 | seenOnce = ~seenTwice & (seenOnce ^ num); 18 | seenTwice = ~seenOnce & (seenTwice ^ num); 19 | } 20 | 21 | return seenOnce; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/0101-0150/104-MaximumDepthOfBinaryTree.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 88ms 3 | // Memory Usage: 25.3 MB 4 | // Link: https://leetcode.com/submissions/detail/333021377/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _104_MaximumDepthOfBinaryTree 12 | { 13 | public int MaxDepth(TreeNode root) 14 | { 15 | if (root == null) return 0; 16 | return Math.Max(1 + MaxDepth(root.left), 1 + MaxDepth(root.right)); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode/0101-0150/111-MinimumDepthOfBinaryTree.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 96ms 3 | // Memory Usage: 26.1 MB 4 | // Link: https://leetcode.com/submissions/detail/358687367/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _111_MinimumDepthOfBinaryTree 12 | { 13 | public int MinDepth(TreeNode root) 14 | { 15 | if (root == null) return 0; 16 | if (root.left == null) return MinDepth(root.right) + 1; 17 | if (root.right == null) return MinDepth(root.left) + 1; 18 | return Math.Min(MinDepth(root.left), MinDepth(root.right)) + 1; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode/0101-0150/112-PathSum.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 96ms 3 | // Memory Usage: 26 MB 4 | // Link: https://leetcode.com/submissions/detail/352942498/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _112_PathSum 10 | { 11 | public bool HasPathSum(TreeNode root, int sum) 12 | { 13 | if (root == null) return false; 14 | 15 | sum = sum - root.val; 16 | if (root.left == null && root.right == null) return sum == 0; 17 | return HasPathSum(root.left, sum) || HasPathSum(root.right, sum); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode/0101-0150/114-FlattenBinaryTreeToLinkedList.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 112ms 3 | // Memory Usage: 4 | // Link: 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _114_FlattenBinaryTreeToLinkedList 10 | { 11 | TreeNode prev = null; 12 | 13 | public void Flatten(TreeNode root) 14 | { 15 | if (root == null) return; 16 | 17 | Flatten(root.right); 18 | Flatten(root.left); 19 | 20 | root.right = prev; 21 | root.left = null; 22 | prev = root; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/0151-0200/0151-ReverseWordsInAString.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 88ms 3 | // Memory Usage: 24.9 MB 4 | // Link: https://leetcode.com/submissions/detail/367112653/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | using System.Linq; 9 | 10 | namespace LeetCode 11 | { 12 | public class _0151_ReverseWordsInAString 13 | { 14 | public string ReverseWords(string s) { 15 | if (string.IsNullOrWhiteSpace(s)) return string.Empty; 16 | 17 | return string.Join(" ", s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Reverse()); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode/0151-0200/0162-FindPeakElement.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 92ms 3 | // Memory Usage: 4 | // Link: 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0162_FindPeakElement 10 | { 11 | public int FindPeakElement(int[] nums) 12 | { 13 | int left = 0, right = nums.Length - 1; 14 | while (left < right) 15 | { 16 | var mid = left + (right - left) / 2; 17 | if (nums[mid] > nums[mid + 1]) right = mid; 18 | else left = mid + 1; 19 | } 20 | return left; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/0151-0200/0169-MajorityElement.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 104ms 3 | // Memory Usage: 28.8 MB 4 | // Link: https://leetcode.com/submissions/detail/261553087/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0169_MajorityElement 10 | { 11 | public int MajorityElement(int[] nums) 12 | { 13 | int count = 0, candidate = 0; 14 | foreach (var num in nums) 15 | { 16 | if (count == 0) candidate = num; 17 | count += (num == candidate) ? 1 : -1; 18 | } 19 | 20 | return candidate; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/0151-0200/0171-ExcelSheetColumnNumber.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 72ms 3 | // Memory Usage: 24.8 MB 4 | // Link: https://leetcode.com/submissions/detail/342807812/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0171_ExcelSheetColumnNumber 10 | { 11 | public int TitleToNumber(string s) 12 | { 13 | var value = 0; 14 | foreach (var ch in s) 15 | { 16 | value *= 26; 17 | value += ch - 'A' + 1; 18 | } 19 | 20 | return value; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/0151-0200/0172-FactorialTrailingZeroes.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 40ms 3 | // Memory Usage: 14.6 MB 4 | // Link: https://leetcode.com/submissions/detail/358360122/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0172_FactorialTrailingZeroes 10 | { 11 | public int TrailingZeroes(int n) 12 | { 13 | var count = 0; 14 | while (n > 0) 15 | { 16 | n /= 5; 17 | count += n; 18 | } 19 | 20 | return count; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/0151-0200/0190-ReverseBits.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 44ms 3 | // Memory Usage: 15 MB 4 | // Link: https://leetcode.com/submissions/detail/358731194/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0190_ReverseBits 10 | { 11 | public uint reverseBits(uint n) 12 | { 13 | n = (n >> 16) | (n << 16); 14 | n = ((n & 0xff00ff00) >> 8) | ((n & 0x00ff00ff) << 8); 15 | n = ((n & 0xf0f0f0f0) >> 4) | ((n & 0x0f0f0f0f) << 4); 16 | n = ((n & 0xcccccccc) >> 2) | ((n & 0x33333333) << 2); 17 | n = ((n & 0xaaaaaaaa) >> 1) | ((n & 0x55555555) << 1); 18 | return n; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LeetCode/0151-0200/0191-NumberOf1Bits.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 36ms 3 | // Memory Usage: 14.7 MB 4 | // Link: https://leetcode.com/submissions/detail/335030341/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0191_NumberOf1Bits 10 | { 11 | public int HammingWeight(uint n) 12 | { 13 | var num = 0; 14 | while (n > 0) 15 | { 16 | n &= n - 1; 17 | num++; 18 | } 19 | 20 | return num; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/0201-0250/0201-BitwiseANDOfNumbersRange.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 48ms 3 | // Memory Usage: 15.6 MB 4 | // Link: https://leetcode.com/submissions/detail/329230476/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0201_BitwiseANDOfNumbersRange 10 | { 11 | public int RangeBitwiseAnd(int m, int n) 12 | { 13 | while (m < n) 14 | n = n & (n - 1); 15 | 16 | return m & n; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode/0201-0250/0217-ContainsDuplicate.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 112ms 3 | // Memory Usage: 31.4 MB 4 | // Link: https://leetcode.com/submissions/detail/342501480/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System.Collections.Generic; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0217_ContainsDuplicate 12 | { 13 | public bool ContainsDuplicate(int[] nums) 14 | { 15 | var set = new HashSet(); 16 | foreach (var num in nums) 17 | { 18 | if (set.Contains(num)) return true; 19 | set.Add(num); 20 | } 21 | return false; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/0201-0250/0226-InvertBinaryTree.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 92ms 3 | // Memory Usage: 22.9 MB 4 | // Link: https://leetcode.com/submissions/detail/262168882/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0226_InvertBinaryTree 10 | { 11 | public TreeNode InvertTree(TreeNode root) 12 | { 13 | if (root == null) return null; 14 | 15 | var left = root.left; 16 | root.left = InvertTree(root.right); 17 | root.right = InvertTree(left); 18 | 19 | return root; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode/0201-0250/0231-PowerOfTwo.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 36ms 3 | // Memory Usage: 14.5 MB 4 | // Link: https://leetcode.com/submissions/detail/350927502/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0231_PowerOfTwo 10 | { 11 | public bool IsPowerOfTwo(int n) 12 | { 13 | if (n == 0) return false; 14 | long x = n; 15 | return (x & -x) == x; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode/0201-0250/0237-DeleteNodeInALinkedList.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 96ms 3 | // Memory Usage: 24.2 MB 4 | // Link: https://leetcode.com/submissions/detail/263755695/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0237_DeleteNodeInALinkedList 10 | { 11 | public void DeleteNode(ListNode node) 12 | { 13 | node.val = node.next.val; 14 | node.next = node.next.next; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LeetCode/0251-0300/0252-MeetingRooms.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 100ms 3 | // Memory Usage: 26.9 MB 4 | // Link: https://leetcode.com/submissions/detail/342752135/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0252_MeetingRooms 12 | { 13 | public bool CanAttendMeetings(int[][] intervals) 14 | { 15 | Array.Sort(intervals, (a, b) => a[0].CompareTo(b[0])); 16 | for (int i = 0; i < intervals.Length - 1; i++) 17 | { 18 | if (intervals[i][1] > intervals[i + 1][0]) 19 | return false; 20 | } 21 | 22 | return true; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/0251-0300/0258-AddDigits.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 36ms 3 | // Memory Usage: 14.6 MB 4 | // Link: https://leetcode.com/submissions/detail/340981660/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0258_AddDigits 10 | { 11 | public int AddDigits(int num) 12 | { 13 | if (num == 0) return 0; 14 | var result = num % 9; 15 | return result == 0 ? 9 : result; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode/0251-0300/0263-UglyNumber.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 40ms 3 | // Memory Usage: 14.7 MB 4 | // Link: https://leetcode.com/submissions/detail/352933164/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0263_UglyNumber 10 | { 11 | public bool IsUgly(int num) 12 | { 13 | if (num <= 0) return false; 14 | 15 | while (num > 1 && (num % 2 == 0)) 16 | num /= 2; 17 | while (num > 1 && (num % 3 == 0)) 18 | num /= 3; 19 | while (num > 1 && (num % 5 == 0)) 20 | num /= 5; 21 | 22 | return num == 1; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/0251-0300/0268-MissingNumber.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 100ms 3 | // Memory Usage: 29.9 MB 4 | // Link: https://leetcode.com/submissions/detail/380050584/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0268_MissingNumber 10 | { 11 | public int MissingNumber(int[] nums) 12 | { 13 | int result = 0; 14 | for (int i = 0; i < nums.Length; ++i) 15 | result += (i + 1) - nums[i]; 16 | return result; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode/0251-0300/0274-HIndex.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 84ms 3 | // Memory Usage: 24.4 MB 4 | // Link: https://leetcode.com/submissions/detail/357948617/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0274_HIndex 12 | { 13 | public int HIndex(int[] citations) 14 | { 15 | int n = citations.Length; 16 | 17 | int[] papers = new int[n + 1]; 18 | foreach (int c in citations) 19 | papers[Math.Min(n, c)]++; 20 | 21 | int k = n; 22 | for (int s = papers[n]; k > s; s += papers[k]) 23 | k--; 24 | return k; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LeetCode/0251-0300/0280-WiggleSort.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 260ms 3 | // Memory Usage: 33.4 MB 4 | // Link: https://leetcode.com/submissions/detail/369274380/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0280_WiggleSort 10 | { 11 | public void WiggleSort(int[] nums) 12 | { 13 | for (int i = 0; i < nums.Length - 1; i++) 14 | { 15 | if (!(i % 2 == 0 ^ nums[i] > nums[i + 1])) 16 | { 17 | var temp = nums[i]; 18 | nums[i] = nums[i + 1]; 19 | nums[i + 1] = temp; 20 | } 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/0251-0300/0283-MoveZeroes.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 240ms 3 | // Memory Usage: 31.8 MB 4 | // Link: https://leetcode.com/submissions/detail/319930583/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0283_MoveZeroes 10 | { 11 | public void MoveZeroes(int[] nums) 12 | { 13 | if (nums == null || nums.Length <= 1) return; 14 | 15 | int cur = 0; 16 | for (int i = 0; i < nums.Length; i++) 17 | if (nums[i] != 0) 18 | nums[cur++] = nums[i]; 19 | 20 | for (; cur < nums.Length; cur++) 21 | nums[cur] = 0; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/0251-0300/0292-NimGame.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 36ms 3 | // Memory Usage: 13.7 MB 4 | // Link: https://leetcode.com/submissions/detail/263265508/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0292_NimGame 10 | { 11 | public bool CanWinNim(int n) 12 | { 13 | return n % 4 != 0; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode/0301-0350/0326-PowerOfThree.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 76ms 3 | // Memory Usage: 16.7 MB 4 | // Link: https://leetcode.com/submissions/detail/352829690/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0326_PowerOfThree 10 | { 11 | public bool IsPowerOfThree(int n) 12 | { 13 | return n > 0 && 1162261467 % n == 0; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode/0301-0350/0342-PowerOfFour.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 32ms 3 | // Memory Usage: 14.7 MB 4 | // Link: https://leetcode.com/submissions/detail/352931470/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0342_PowerOfFour 10 | { 11 | public bool IsPowerOfFour(int num) 12 | { 13 | return num > 0 && ((num & (num - 1)) == 0) && ((num & 0xaaaaaaaa) == 0); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode/0301-0350/0344-ReverseString.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 388ms 3 | // Memory Usage: 33.5 MB 4 | // Link: https://leetcode.com/submissions/detail/262779243/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0344_ReverseString 10 | { 11 | public void ReverseString(char[] s) 12 | { 13 | if (s == null || s.Length == 0) return; 14 | 15 | int i = 0, j = s.Length - 1; 16 | while (i < j) 17 | { 18 | var temp = s[i]; 19 | s[i] = s[j]; 20 | s[j] = temp; 21 | 22 | i++; j--; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LeetCode/0351-0400/0371-SumOfTwoIntegers.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 36ms 3 | // Memory Usage: 13.7 MB 4 | // Link: https://leetcode.com/submissions/detail/261549862/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0371_SumOfTwoIntegers 10 | { 11 | public int GetSum(int a, int b) 12 | { 13 | return b == 0 ? a : GetSum(a ^ b, (a & b) << 1); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode/0351-0400/0387-FirstUniqueCharacterInAString.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 80ms 3 | // Memory Usage: 31.6 MB 4 | // Link: https://leetcode.com/submissions/detail/334972755/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0387_FirstUniqueCharacterInAString 10 | { 11 | public int FirstUniqChar(string s) 12 | { 13 | var counts = new int[26]; 14 | foreach (var ch in s) 15 | counts[ch - 'a']++; 16 | 17 | for (int i = 0; i < s.Length; i++) 18 | if (counts[s[i] - 'a'] == 1) 19 | return i; 20 | 21 | return -1; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/0351-0400/0389-FindTheDifference.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 84ms 3 | // Memory Usage: 24.7 MB 4 | // Link: https://leetcode.com/submissions/detail/342531497/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0389_FindTheDifference 10 | { 11 | public char FindTheDifference(string s, string t) 12 | { 13 | char result = (char)0; 14 | foreach (var ch in s) 15 | result ^= ch; 16 | foreach (var ch in t) 17 | result ^= ch; 18 | 19 | return result; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode/0351-0400/0392-IsSubsequence.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 76ms 3 | // Memory Usage: 21.7 MB 4 | // Link: https://leetcode.com/submissions/detail/351443718/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0392_IsSubsequence 10 | { 11 | public bool IsSubsequence(string s, string t) 12 | { 13 | int i = 0, j = 0; 14 | while (i < s.Length && j < t.Length) 15 | { 16 | if (s[i] == t[j]) i++; 17 | j++; 18 | } 19 | 20 | return i == s.Length; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/0401-0450/0434-NumberOfSegmentsInAString.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 68ms 3 | // Memory Usage: 21.6 MB 4 | // Link: https://leetcode.com/submissions/detail/358362139/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0434_NumberOfSegmentsInAString 12 | { 13 | public int CountSegments(string s) 14 | { 15 | return s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Length; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode/0401-0450/0441-ArrangingCoins.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 40ms 3 | // Memory Usage: 14.6 MB 4 | // Link: https://leetcode.com/submissions/detail/352955327/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0441_ArrangingCoins 12 | { 13 | public int ArrangeCoins(int n) 14 | { 15 | return (int)(Math.Sqrt(2 * (long)n + 0.25) - 0.5); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode/0451-0500/0453-MinimumMovesToEqualArrayElements.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 128ms 3 | // Memory Usage: 34.6 MB 4 | // Link: https://leetcode.com/submissions/detail/344799358/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System.Linq; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0453_MinimumMovesToEqualArrayElements 12 | { 13 | public int MinMoves(int[] nums) 14 | { 15 | var min = nums.Min(); 16 | var count = 0; 17 | foreach (var num in nums) 18 | count += num - min; 19 | 20 | return count; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/0451-0500/0458-PoorPigs.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 36ms 3 | // Memory Usage: 4 | // Link: 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0458_PoorPigs 12 | { 13 | public int PoorPigs(int buckets, int minutesToDie, int minutesToTest) 14 | { 15 | int states = minutesToTest / minutesToDie + 1; 16 | return (int)Math.Ceiling(Math.Log(buckets) / Math.Log(states)); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode/0451-0500/0461-HammingDistance.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 36ms 3 | // Memory Usage: 13.7 MB 4 | // Link: https://leetcode.com/submissions/detail/261547622/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0461_HammingDistance 10 | { 11 | public int HammingDistance(int x, int y) 12 | { 13 | var xor = x ^ y; 14 | var count = 0; 15 | while (xor > 0) 16 | { 17 | if ((xor & 1) == 1) count++; 18 | xor >>= 1; 19 | } 20 | return count; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/0451-0500/0476-NumberComplement.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 32ms 3 | // Memory Usage: 14.5 MB 4 | // Link: https://leetcode.com/submissions/detail/334546822/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0476_NumberComplement 10 | { 11 | public int FindComplement(int num) 12 | { 13 | int mask = 1; 14 | while (mask < num) 15 | mask = (mask << 1) | 1; 16 | return num ^ mask; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode/0451-0500/0492-ConstructTheRectangle.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 200ms 3 | // Memory Usage: 25.3 MB 4 | // Link: https://leetcode.com/submissions/detail/345098085/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0492_ConstructTheRectangle 12 | { 13 | public int[] ConstructRectangle(int area) 14 | { 15 | var w = (int)Math.Sqrt(area); 16 | while (area % w != 0) w--; 17 | return new int[] { area / w, w }; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode/0451-0500/0495-TeemoAttacking.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 124ms 3 | // Memory Usage: 36.7 MB 4 | // Link: https://leetcode.com/submissions/detail/409239239/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0495_TeemoAttacking 12 | { 13 | public int FindPoisonedDuration(int[] timeSeries, int duration) 14 | { 15 | int n = timeSeries.Length; 16 | if (n == 0) return 0; 17 | 18 | int total = 0; 19 | for (int i = 0; i < n - 1; ++i) 20 | total += Math.Min(timeSeries[i + 1] - timeSeries[i], duration); 21 | return total + duration; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/0501-0550/0518-CoinChange2.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 92ms 3 | // Memory Usage: 23.7 MB 4 | // Link: https://leetcode.com/submissions/detail/350512612/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0518_CoinChange2 10 | { 11 | public int Change(int amount, int[] coins) 12 | { 13 | var dp = new int[amount + 1]; 14 | dp[0] = 1; 15 | 16 | foreach (var coin in coins) 17 | for (int x = coin; x <= amount; x++) 18 | dp[x] += dp[x - coin]; 19 | 20 | return dp[amount]; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/0501-0550/0520-DetectCapital.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 72ms 3 | // Memory Usage: 23.3 MB 4 | // Link: https://leetcode.com/submissions/detail/343638258/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0520_DetectCapital 10 | { 11 | public bool DetectCapitalUse(string word) 12 | { 13 | var upper = 0; 14 | foreach (var ch in word) 15 | if (ch >= 'A' && ch <= 'Z') 16 | upper++; 17 | 18 | if (upper == 1 && word[0] <= 'Z') return true; 19 | return upper == 0 || upper == word.Length; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode/0501-0550/0521-LongestUncommonSubsequenceI.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 68ms 3 | // Memory Usage: 22.1 MB 4 | // Link: https://leetcode.com/submissions/detail/338636813/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0521_LongestUncommonSubsequenceI 12 | { 13 | public int FindLUSlength(string a, string b) 14 | { 15 | if (a == b) return -1; 16 | return Math.Max(a.Length, b.Length); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode/0551-0600/0557-ReverseWordsInAStringIII.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 92ms 3 | // Memory Usage: 34.8 MB 4 | // Link: https://leetcode.com/submissions/detail/330119313/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System.Linq; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0557_ReverseWordsInAStringIII 12 | { 13 | public string ReverseWords(string s) 14 | { 15 | return string.Join(" ", s.Split(' ').Select(w => new string(w.ToCharArray().Reverse().ToArray()))); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode/0551-0600/0561-ArrayPartitionI.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 156ms 3 | // Memory Usage: 34.9 MB 4 | // Link: https://leetcode.com/submissions/detail/328332615/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0561_ArrayPartitionI 12 | { 13 | public int ArrayPairSum(int[] nums) 14 | { 15 | Array.Sort(nums); 16 | 17 | int sum = 0; 18 | for (var i = 0; i < nums.Length; i += 2) 19 | sum += nums[i]; 20 | 21 | return sum; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/0551-0600/0575-DistributeCandies.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 264ms 3 | // Memory Usage: 45.1 MB 4 | // Link: https://leetcode.com/submissions/detail/335623583/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | using System.Collections.Generic; 9 | 10 | namespace LeetCode 11 | { 12 | public class _0575_DistributeCandies 13 | { 14 | public int DistributeCandies(int[] candies) 15 | { 16 | var set = new HashSet(candies); 17 | return Math.Min(set.Count, candies.Length / 2); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode/0551-0600/0598-RangeAdditionII.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 100ms 3 | // Memory Usage: 26.3 MB 4 | // Link: https://leetcode.com/submissions/detail/345101395/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0598_RangeAdditionII 12 | { 13 | public int MaxCount(int m, int n, int[][] ops) 14 | { 15 | foreach (var op in ops) 16 | { 17 | m = Math.Min(m, op[0]); 18 | n = Math.Min(n, op[1]); 19 | } 20 | 21 | return m * n; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/0601-0650/0617-MergeTwoBinaryTrees.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 112ms 3 | // Memory Usage: 26.8 MB 4 | // Link: https://leetcode.com/submissions/detail/262171481/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0617_MergeTwoBinaryTrees 10 | { 11 | public TreeNode MergeTrees(TreeNode t1, TreeNode t2) 12 | { 13 | if (t1 == null) return t2; 14 | if (t2 == null) return t1; 15 | 16 | var newNode = new TreeNode(t1.val + t2.val); 17 | newNode.left = MergeTrees(t1.left, t2.left); 18 | newNode.right = MergeTrees(t1.right, t2.right); 19 | return newNode; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode/0701-0750/0709-ToLowerCase.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 76ms 3 | // Memory Usage: 22.4 MB 4 | // Link: https://leetcode.com/submissions/detail/327368136/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0709_ToLowerCase 10 | { 11 | public string ToLowerCase(string str) 12 | { 13 | return str.ToLower(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode/0751-0800/0760-FindAnagramMappings.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 236ms 3 | // Memory Usage: 30 MB 4 | // Link: https://leetcode.com/submissions/detail/326845848/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System.Collections.Generic; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0760_FindAnagramMappings 12 | { 13 | public int[] AnagramMappings(int[] A, int[] B) 14 | { 15 | var list = new List(B); 16 | 17 | var result = new int[A.Length]; 18 | for (int i = 0; i < A.Length; i++) 19 | result[i] = list.IndexOf(A[i]); 20 | 21 | return result; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/0801-0850/0829-ConsecutiveNumbersSum.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 40ms 3 | // Memory Usage: 14.4 MB 4 | // Link: https://leetcode.com/submissions/detail/372046471/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0829_ConsecutiveNumbersSum 12 | { 13 | public int ConsecutiveNumbersSum(int N) 14 | { 15 | var upper = (int)(Math.Sqrt(2 * N + 0.25) - 0.5); 16 | 17 | var count = 0; 18 | for (int i = 1; i <= upper; i++) 19 | { 20 | N -= i; 21 | if (N % i == 0) count++; 22 | } 23 | 24 | return count; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LeetCode/0801-0850/0836-RectangleOverlap.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 108ms 3 | // Memory Usage: 23.9 MB 4 | // Link: https://leetcode.com/submissions/detail/351821481/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0836_RectangleOverlap 10 | { 11 | public bool IsRectangleOverlap(int[] rec1, int[] rec2) 12 | { 13 | return rec1[2] > rec2[0] && 14 | rec1[3] > rec2[1] && 15 | rec1[0] < rec2[2] && 16 | rec1[1] < rec2[3]; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /LeetCode/0851-0900/0876-MiddleOfTheLinkedList.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 84ms 3 | // Memory Usage: 23.8 MB 4 | // Link: https://leetcode.com/submissions/detail/321762403/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0876_MiddleOfTheLinkedList 10 | { 11 | public ListNode MiddleNode(ListNode head) 12 | { 13 | var fast = head; 14 | var slow = head; 15 | 16 | while (fast != null && fast.next != null) 17 | { 18 | fast = fast.next.next; 19 | slow = slow.next; 20 | } 21 | 22 | return slow; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/0901-0950/0941-ValidMountainArray.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 116ms 3 | // Memory Usage: 33.2 MB 4 | // Link: https://leetcode.com/submissions/detail/359259406/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _0941_ValidMountainArray 10 | { 11 | public bool ValidMountainArray(int[] A) 12 | { 13 | int i = 0, N = A.Length; 14 | 15 | while (i + 1 < N && A[i] < A[i + 1]) 16 | i++; 17 | 18 | if (i == 0 || i == N - 1) return false; 19 | 20 | while (i + 1 < N && A[i] > A[i + 1]) 21 | i++; 22 | 23 | return i == N - 1; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LeetCode/0951-1000/0976-LargestPerimeterTriangle.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 128ms 3 | // Memory Usage: 32.7 MB 4 | // Link: https://leetcode.com/submissions/detail/338633310/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _0976_LargestPerimeterTriangle 12 | { 13 | public int LargestPerimeter(int[] A) 14 | { 15 | Array.Sort(A); 16 | for (int i = A.Length - 3; i >= 0; i--) 17 | { 18 | if (A[i] + A[i + 1] > A[i + 2]) 19 | return A[i] + A[i + 1] + A[i + 2]; 20 | } 21 | 22 | return 0; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/1001-1050/1009-ComplementOfBase10Integer.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 32ms 3 | // Memory Usage: 14.5 MB 4 | // Link: https://leetcode.com/submissions/detail/334548152/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1009_ComplementOfBase10Integer 10 | { 11 | public int BitwiseComplement(int N) 12 | { 13 | int mask = 1; 14 | while (mask < N) 15 | mask = (mask << 1) | 1; 16 | return N ^ mask; 17 | 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode/1001-1050/1029-TwoCityScheduling.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 88ms 3 | // Memory Usage: 24.7 MB 4 | // Link: https://leetcode.com/submissions/detail/348826564/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _1029_TwoCityScheduling 12 | { 13 | public int TwoCitySchedCost(int[][] costs) 14 | { 15 | Array.Sort(costs, (a, b) => (a[0] - a[1]) - (b[0] - b[1])); 16 | 17 | var n = costs.Length / 2; 18 | var result = 0; 19 | for (int i = 0; i < n; i++) 20 | result += costs[i][0] + costs[i + n][1]; 21 | 22 | return result; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/1001-1050/HashMap.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 3 | // Memory Usage: 4 | // Link: 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | internal class HashMap 10 | { 11 | public HashMap() 12 | { 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /LeetCode/1051-1100/1085-SumOfDigitsInTheMinimumNumber.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 72ms 3 | // Memory Usage: 24.1 MB 4 | // Link: https://leetcode.com/submissions/detail/327836848/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System.Linq; 8 | 9 | namespace LeetCode 10 | { 11 | public class _1085_SumOfDigitsInTheMinimumNumber 12 | { 13 | public int SumOfDigits(int[] A) 14 | { 15 | var min = A.Min(); 16 | var sum = 0; 17 | while (min > 0) 18 | { 19 | sum += min % 10; 20 | min /= 10; 21 | } 22 | 23 | return sum % 2 == 0 ? 1 : 0; 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LeetCode/1101-1150/1118-NumberOfDaysInAMonth.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 36ms 3 | // Memory Usage: 14.6 MB 4 | // Link: https://leetcode.com/submissions/detail/338640136/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1118_NumberOfDaysInAMonth 10 | { 11 | public int NumberOfDays(int Y, int M) 12 | { 13 | var days = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 14 | 15 | var result = days[M - 1]; 16 | if ((Y % 400 == 0 || Y % 100 != 0 && Y % 4 == 0) && M == 2) 17 | result++; 18 | 19 | return result; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode/1101-1150/1150-CheckIfANumberIsMajorityElementInASortedArray.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 84ms 3 | // Memory Usage: 24.4 MB 4 | // Link: https://leetcode.com/submissions/detail/336978508/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1150_CheckIfANumberIsMajorityElementInASortedArray 10 | { 11 | public bool IsMajorityElement(int[] nums, int target) 12 | { 13 | var count = 0; 14 | foreach (var num in nums) 15 | if (num == target) count++; 16 | 17 | return count > nums.Length / 2; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode/1151-1200/1185-DayOfTheWeek.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 80ms 3 | // Memory Usage: 22.5 MB 4 | // Link: https://leetcode.com/submissions/detail/333633527/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _1185_DayOfTheWeek 12 | { 13 | public string DayOfTheWeek(int day, int month, int year) 14 | { 15 | return new DateTime(year, month, day).DayOfWeek.ToString(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode/1201-1250/1217-PlayWithChips.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 84ms 3 | // Memory Usage: 24 MB 4 | // Link: https://leetcode.com/submissions/detail/334985149/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _1217_PlayWithChips 12 | { 13 | public int MinCostToMoveChips(int[] chips) 14 | { 15 | int odd = 0, even = 0; 16 | foreach (var chip in chips) 17 | { 18 | if (chip % 2 == 0) 19 | even++; 20 | else 21 | odd++; 22 | } 23 | 24 | return Math.Min(odd, even); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LeetCode/1201-1250/1221-SplitAStringInBalancedStrings.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 68ms 3 | // Memory Usage: 21.9 MB 4 | // Link: https://leetcode.com/submissions/detail/326842297/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1221_SplitAStringInBalancedStrings 10 | { 11 | public int BalancedStringSplit(string s) 12 | { 13 | var count = 0; 14 | var result = 0; 15 | foreach (var ch in s) 16 | { 17 | count += ch == 'L' ? 1 : -1; 18 | if (count == 0) 19 | result++; 20 | } 21 | 22 | return result; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/1201-1250/1227-AirplaneSeatAssignmentProbability.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 44ms 3 | // Memory Usage: 14.9 MB 4 | // Link: https://leetcode.com/submissions/detail/371134754/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1227_AirplaneSeatAssignmentProbability 10 | { 11 | public double NthPersonGetsNthSeat(int n) 12 | { 13 | return n == 1 ? 1.0 : 0.5; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LeetCode/1251-1300/1256-EncodeNumber.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 96ms 3 | // Memory Usage: 22.7 MB 4 | // Link: https://leetcode.com/submissions/detail/363520520/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _1256_EncodeNumber 12 | { 13 | public string Encode(int num) 14 | { 15 | return Convert.ToString(num + 1, 2).Substring(1); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode/1251-1300/1295-FindNumbersWithEvenNumberOfDigits.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 92ms 3 | // Memory Usage: 25.8 MB 4 | // Link: https://leetcode.com/submissions/detail/326443837/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System.Linq; 8 | 9 | namespace LeetCode 10 | { 11 | public class _1295_FindNumbersWithEvenNumberOfDigits 12 | { 13 | public int FindNumbers(int[] nums) 14 | { 15 | return nums.Count(num => num.ToString().Length % 2 == 0); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode/1301-1350/1313-DecompressRunLengthEncodedList.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 236ms 3 | // Memory Usage: 33.4 MB 4 | // Link: https://leetcode.com/submissions/detail/326429951/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System.Collections.Generic; 8 | 9 | namespace LeetCode 10 | { 11 | public class _1313_DecompressRunLengthEncodedList 12 | { 13 | public int[] DecompressRLElist(int[] nums) 14 | { 15 | var results = new List(); 16 | for (int i = 0; i < nums.Length; i += 2) 17 | for (int j = 0; j < nums[i]; j++) 18 | results.Add(nums[i + 1]); 19 | 20 | return results.ToArray(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/1301-1350/1317-ConvertIntegerToTheSumOfTwoNoZeroIntegers.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 196ms 3 | // Memory Usage: 25.5 MB 4 | // Link: https://leetcode.com/submissions/detail/339139993/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1317_ConvertIntegerToTheSumOfTwoNoZeroIntegers 10 | { 11 | public int[] GetNoZeroIntegers(int n) 12 | { 13 | int p1 = 1, p2 = n - 1; 14 | 15 | while (p1.ToString().Contains("0") || p2.ToString().Contains("0")) 16 | { 17 | p1++; 18 | p2--; 19 | } 20 | 21 | return new int[] { p1, p2 }; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/1301-1350/1332-RemovePalindromicSubsequences.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 68ms 3 | // Memory Usage: 21.8 MB 4 | // Link: https://leetcode.com/submissions/detail/338611018/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1332_RemovePalindromicSubsequences 10 | { 11 | public int RemovePalindromeSub(string s) 12 | { 13 | if (string.IsNullOrEmpty(s)) return 0; 14 | int lo = 0, hi = s.Length - 1; 15 | while (lo < hi) 16 | { 17 | if (s[lo] != s[hi]) return 2; 18 | lo++; 19 | hi--; 20 | } 21 | 22 | return 1; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/1301-1350/1342-NumberOfStepsToReduceANumberToZero.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 40ms 3 | // Memory Usage: 14.5 MB 4 | // Link: https://leetcode.com/submissions/detail/326415854/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1342_NumberOfStepsToReduceANumberToZero 10 | { 11 | public int NumberOfSteps(int num) 12 | { 13 | var step = 0; 14 | while (num > 0) 15 | { 16 | if ((num & 1) == 1) 17 | step++; 18 | num /= 2; 19 | step++; 20 | } 21 | return step > 0 ? step - 1 : 0; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LeetCode/1351-1400/1374-GenerateAStringWithCharactersThatHaveOddCounts.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 72ms 3 | // Memory Usage: 22.7 MB 4 | // Link: https://leetcode.com/submissions/detail/327826280/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1374_GenerateAStringWithCharactersThatHaveOddCounts 10 | { 11 | public string GenerateTheString(int n) 12 | { 13 | return n % 2 == 1 ? 14 | new string('a', n) : 15 | new string('a', n - 1) + 'b'; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LeetCode/1351-1400/1375-BulbSwitcherIII.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 164ms 3 | // Memory Usage: 39.9 MB 4 | // Link: https://leetcode.com/submissions/detail/370195128/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System; 8 | 9 | namespace LeetCode 10 | { 11 | public class _1375_BulbSwitcherIII 12 | { 13 | public int NumTimesAllBlue(int[] light) 14 | { 15 | int last_on = 0; 16 | int result = 0; 17 | 18 | for (int i = 0; i < light.Length; i++) 19 | { 20 | last_on = Math.Max(last_on, light[i]); 21 | if (last_on == i + 1) result++; 22 | } 23 | 24 | return result; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LeetCode/1351-1400/1389-CreateTargetArrayInTheGivenOrder.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 228ms 3 | // Memory Usage: 30 MB 4 | // Link: https://leetcode.com/submissions/detail/326840305/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System.Collections.Generic; 8 | 9 | namespace LeetCode 10 | { 11 | public class _1389_CreateTargetArrayInTheGivenOrder 12 | { 13 | public int[] CreateTargetArray(int[] nums, int[] index) 14 | { 15 | var result = new List(); 16 | for (int i = 0; i < nums.Length; i++) 17 | result.Insert(index[i], nums[i]); 18 | 19 | return result.ToArray(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /LeetCode/1401-1450/1436-DestinationCity.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 108ms 3 | // Memory Usage: 26.6 MB 4 | // Link: https://leetcode.com/submissions/detail/334995736/ 5 | //----------------------------------------------------------------------------- 6 | 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | 10 | namespace LeetCode 11 | { 12 | public class _1436_DestinationCity 13 | { 14 | public string DestCity(IList> paths) 15 | { 16 | var set = new HashSet(); 17 | foreach (var path in paths) 18 | set.Add(path[1]); 19 | foreach (var path in paths) 20 | set.Remove(path[0]); 21 | 22 | return set.First(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/1451-1500/1470-ShuffleTheArray.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 240ms 3 | // Memory Usage: 32.6 MB 4 | // Link: https://leetcode.com/submissions/detail/351033051/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1470_ShuffleTheArray 10 | { 11 | public int[] Shuffle(int[] nums, int n) 12 | { 13 | var results = new int[nums.Length]; 14 | 15 | var index = 0; 16 | for (int i = 0, j = n; i < n; i++, j++) 17 | { 18 | results[index++] = nums[i]; 19 | results[index++] = nums[j]; 20 | } 21 | 22 | return results; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LeetCode/1451-1500/1480-RunningSumOf1DArray.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 240ms 3 | // Memory Usage: 30.8 MB 4 | // Link: https://leetcode.com/submissions/detail/358263097/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1480_RunningSumOf1DArray 10 | { 11 | public int[] RunningSum(int[] nums) 12 | { 13 | var sum = nums[0]; 14 | for (int i = 1; i < nums.Length; i++) 15 | { 16 | sum += nums[i]; 17 | nums[i] = sum; 18 | } 19 | 20 | return nums; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LeetCode/1451-1500/1486-XOROperationInAnArray.cs: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // Runtime: 36ms 3 | // Memory Usage: 14.4 MB 4 | // Link: https://leetcode.com/submissions/detail/358271770/ 5 | //----------------------------------------------------------------------------- 6 | 7 | namespace LeetCode 8 | { 9 | public class _1486_XOROperationInAnArray 10 | { 11 | public int XorOperation(int n, int start) 12 | { 13 | var result = 0; 14 | for (int i = 0; i < n; i++) 15 | result ^= start + i * 2; 16 | 17 | return result; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LeetCode/Interval.cs: -------------------------------------------------------------------------------- 1 | namespace LeetCode 2 | { 3 | public class Interval 4 | { 5 | public int start; 6 | public int end; 7 | public Interval() { start = 0; end = 0; } 8 | public Interval(int s, int e) { start = s; end = e; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /LeetCode/ListNode.cs: -------------------------------------------------------------------------------- 1 | namespace LeetCode 2 | { 3 | public class ListNode 4 | { 5 | public int val; 6 | public ListNode next; 7 | public ListNode(int x) { val = x; } 8 | public ListNode(int val = 0, ListNode next = null) 9 | { 10 | this.val = val; 11 | this.next = next; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /LeetCode/TreeLinkNode.cs: -------------------------------------------------------------------------------- 1 | namespace LeetCode 2 | { 3 | public class TreeLinkNode 4 | { 5 | public int val; 6 | public TreeLinkNode left; 7 | public TreeLinkNode right; 8 | public TreeLinkNode next; 9 | 10 | public TreeLinkNode(int x) { val = x; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /LeetCode/TreeNode.cs: -------------------------------------------------------------------------------- 1 | namespace LeetCode 2 | { 3 | public class TreeNode 4 | { 5 | public int val; 6 | public TreeNode left; 7 | public TreeNode right; 8 | 9 | public TreeNode(int x) { val = x; } 10 | } 11 | } 12 | --------------------------------------------------------------------------------