LeetCode-114. Flatten Binary Tree to Linked List Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ 5 \ 6 Hints: If you notice carefully in the flattened tree, each...
Find sum of top-left to bottom-right diagonals Find the longest gap! Find the middle element Form The Minimum Give me a Diamond Highest Rank Number in an Array How old will I be in 2099? Insert dashes Integer Difference Is n divisible by (...)? Land perimeter Largest pair sum in arra...
Commits BreadcrumbsHistory for leetcode Find the first node of loop in linked list - GFG onmain User selector All users DatepickerAll time Commit History Loading Footer © 2025 GitHub, Inc. Footer navigation Terms Privacy Security Status Docs Contact Manage cookies Do not...
Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be in the order of O(log n). If the target is not found in the array, return [-1, -1]. Example 1: Input: nums = [...
} last = nums[i]; }returnans; } Ref // when find a number i, flip the number at position i-1 to negative.// if the number at position i-1 is already negative, i is the number that occurs twice.publicList<Integer>findDuplicates(int[] nums){ ...
The article aims to describe a solution to leetcode 295. Problem: Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value. ...
0876-middle-of-the-linked-list.rs 0895-maximum-frequency-stack.rs 0901-online-stock-span.rs 0904-fruit-into-baskets.rs 0912-sort-an-array.rs 0918-maximum-sum-circular-subarray.rs 0926-flip-string-to-monotone-increasing.rs 0929-unique-email-addresses.rs 0953-verifying-an-alien-dictionary.rs 09...
创建一个数组vec[26],每个位置分别存储的是26个字母中对应字母的个数,以char-'a'的方式得到字母的索引 代码: classSolution {public: vector<int> getV(stringstrings){ vector<int> res(26);for(charstr: strings){ res[str-'a']++; }returnres; ...
The substring with start index = 2 is "ab", which is an anagram of "ab". 解法: 1classSolution {2public:3vector<int> findAnagrams(strings,stringp) {4unordered_map<char,int>freq;5vector<int>result;6if(p.size()>s.size()){7returnresult;8}9for(inti=0;i<p.size();i++){10freq[...