随笔分类 - LeetCode_Algorithms
https://leetcode.com/problemset/algorithms/
摘要:Description: Show that the following problem is NP-complete. MAXIMUM COMMON SUBGRAPH Input: Tswo graphes G1=(V1,E1) and G2=(V2,E2); a budget b. Output
阅读全文
摘要:Description: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct wa
阅读全文
摘要:Description: 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
阅读全文
摘要:Description: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If
阅读全文
摘要:Decription: Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 解题思路: 分别从a和b字符串的最后一位开始遍历,用char
阅读全文
摘要:Description: Implement pow(x, n). Example 1: Example 2: 解法二: 一开始用迭代法实现,一直超时,我真的要疯了- -,优化了很久。 INT_MAX = 2147483647而INT_MIN = -2147483648。所以,x的INT_MIN次幂
阅读全文
摘要:Description: Implement int sqrt(int x). Compute and return the square root of x. x is guaranteed to be a non-negative integer. Example 1: Example 2: 解
阅读全文
摘要:Description: 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
阅读全文
摘要:Description: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:You may assume that nums1 has enough sp
阅读全文
摘要:Description: Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: E
阅读全文
摘要:Description: 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 li
阅读全文
摘要:Description: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must
阅读全文
摘要:Description: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurall
阅读全文
摘要:Description: 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 as
阅读全文
摘要:Description: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in th
阅读全文
摘要:Description: Given a non-negative integer represented as a non-empty array of digits, plus one to the integer. You may assume the integer do not conta
阅读全文
摘要:Spiral Matrix II: Description: Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example,Given n = 3
阅读全文
摘要:Description: Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for anothe
阅读全文
摘要:Decription: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 解题思路: 将罗马数字的字符串转换成阿拉伯数字。 先来查阅资
阅读全文
摘要:Description: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) I
阅读全文

浙公网安备 33010602011771号