随笔分类 - LeetCode_OJ
摘要:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.题目:给一组字符串,返回所有满足Anagrams(回文构词法)的字符串;A...
阅读全文
摘要:Given two wordsword1andword2, find the minimum number of steps required to convertword1toword2. (each operation is counted as 1 step.)You have the fol...
阅读全文
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,...
阅读全文
摘要:Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:Yo...
阅读全文
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted fr...
阅读全文
摘要:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following req...
阅读全文
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the ...
阅读全文
摘要:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm sho...
阅读全文
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.Yo...
阅读全文
摘要:Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].题目:给一...
阅读全文
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2-...
阅读全文
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3. 题目要求: 给一有序链表,删除重复的结点,使得每个元素只出现一...
阅读全文
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of th...
阅读全文
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a...
阅读全文
摘要:1、Given a linked list, determine if it has a cycle in it.2、Given a linked list, return the node where the cycle begins. If there is no cycle, return n...
阅读全文
摘要:Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 –> 5 题目要求: 删除链表中包含val的元素结点 解题思路: 重点在于找到...
阅读全文
摘要:Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note:Given m, n satisfy the following co...
阅读全文
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.题目要求:合并两个...
阅读全文
摘要:Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not c...
阅读全文