随笔分类 - leetcode
leetcode 常见题目
摘要:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Input: s = "(()"O
阅读全文
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such an arrangement is not pos
阅读全文
摘要:You are given a string s and an array of strings words of the same length. Return all starting indices of substring(s) in s that is a concatenation of
阅读全文
摘要:Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator. Return the quotient after divid
阅读全文
摘要:Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Clarification: What shoul
阅读全文
摘要:Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another ar
阅读全文
摘要:Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length. Do not allocate extra s
阅读全文
摘要:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to
阅读全文
摘要:Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes. Only nodes itself may be ch
阅读全文
摘要:You are given an array of k linked-lists lists, each linked-list is sorted in ascending order. Merge all the linked-lists into one sorted linked-list
阅读全文
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Input: n = 3Output: ["((()))","(()())","(())()
阅读全文
摘要:Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists. I
阅读全文
摘要:Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if:
阅读全文
摘要:Given the head of a linked list, remove the nth node from the end of the list and return its head. Follow up: Could you do this in one pass? Input: he
阅读全文
摘要:Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c+ d = target? Find all unique qu
阅读全文
摘要:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any
阅读全文
摘要:Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the thr
阅读全文
摘要:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the s
阅读全文
摘要:Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Input:
阅读全文
摘要:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. For example, 2 is written as II in Roman numeral, just two one's ad
阅读全文