
算法
文章平均质量分 51
当年明月又天涯
从入门到放弃
展开
-
leetcode打卡——两数相加
题目给定两个非空链表来表示两个非负整数。位数按照逆序方式存储,它们的每个节点只存储单个数字。将两数相加返回一个新的链表。你可以假设除了数字 0 之外,这两个数字都不会以零开头。如输入:(2 -> 4 -> 3) + (5 -> 6 -> 4)输出:7 -> 0 -> 8原因:342 + 465 = 807这道题比较简单,不需要什么特殊的算法,...原创 2018-09-24 17:22:32 · 165 阅读 · 0 评论 -
leetcode打卡之 Binary Tree Zigzag Level Order Traversal
题目Given a binary tree, return the zigzag level order traversal of its nodes’ values. (ie, from left to right, then right to left for the next level and alternate between).题目大意就是:给定一颗二叉树,第一层从左向右遍历,第...原创 2018-12-09 20:52:18 · 166 阅读 · 0 评论 -
LeetCode 打卡之Integer to Roman
题目题目太长了:请看链接: Integer To Roman分析有一个简单粗暴的方法就是把0~9, 10 ~ 90, 100 ~ 900, 1000 ~ 3000的组合用数组存起来,然后从里面取就行了代码 string intToRoman(int num) { string M[] = {"", "M", "MM", "MMM"}; string C[...原创 2018-11-27 00:35:42 · 102 阅读 · 0 评论 -
LeetCode打卡之 Edit Distance
题目Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.You have the following 3 operations permitted on a word:Insert a characterDelete a char...原创 2018-11-19 10:33:32 · 156 阅读 · 0 评论 -
LeetCode打卡之Minimum Path Sum
题目Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at...原创 2018-11-08 20:02:45 · 104 阅读 · 0 评论 -
LeetCode打卡之Unique Paths II
题目A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the ...原创 2018-11-01 20:04:24 · 106 阅读 · 0 评论 -
leetcode打卡 Longest Valid Parentheses
题目Given a string containing just the characters'(' and')', find the length of the longest valid (well-formed) parentheses substring.大意就是:给定一个只包含 '('和 ')' 的字符串,找出最长的包含有效括号的子串的长度。示例1:Input: "(()"Ou...原创 2018-10-29 12:40:09 · 169 阅读 · 0 评论 -
LeetCode 打卡 SameTree
题目Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.大意就是判断给...原创 2018-10-21 19:13:16 · 119 阅读 · 0 评论 -
leetcode打卡——Longest Palindromic Substring
题目Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.大意就是找到字符串中最大的回文子串,如Input: "babad"Output: "bab"Note: "aba" is also a valid answ...原创 2018-09-29 19:38:18 · 195 阅读 · 0 评论 -
leetcode打卡4——Median of Two Sorted Arrays
题目There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You may assume nums1 and ...原创 2018-09-27 21:11:30 · 150 阅读 · 0 评论 -
leetcode打卡之ZigZag Conversion
题目The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I ...原创 2018-10-11 20:13:51 · 162 阅读 · 0 评论 -
Capacitated Facility Location Problem
题目Suppose there are n facilities and m customers. We wishto choose:(1) which of the n facilities to open(2) the assignment of customers to facilitiesThe objective is to minimize the sum of the op...原创 2018-12-21 22:59:02 · 252 阅读 · 0 评论