LeetCode
蚂蚁的希望
CSDN说我人很懒,什么都没有写
展开
-
LeetCode(01TowSum)
LeetCode(01TowSum)#include <iostream>#include <vector>using namespace std;/**Given an array of integers, return indices of the two numberssuch that they add up to a specific target....原创 2018-12-31 22:31:28 · 106 阅读 · 0 评论 -
LeetCode(114. Flatten Binary Tree to Linked List)
转114. Flatten Binary Tree to Linked List的C++解法 题目描述:https://leetcode.com/problems/flatten-binary-tree-to-linked-list/这个题的关键是找到左右子树的最右下角的位置,因为这将是下一次接子树的起点。下面这个方法用了递归,假设左右子树将在helper中接好...转载 2019-03-29 19:40:33 · 109 阅读 · 0 评论 -
LeetCode(50. Pow(x, n))
简介Implement pow(x, n), which calculates&nbsp;x raised to the power n (xn).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Example 3:Input: 2.00000, -...原创 2019-03-18 11:24:48 · 181 阅读 · 0 评论 -
LeetCode(59. Spiral Matrix II)
简介Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.Example:Input: 3Output:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ]]解题思路设置一个二维数组,分别进行以下操...原创 2019-03-14 21:25:08 · 74 阅读 · 0 评论 -
08. String to Integer (atoi)
简介Implement atoi which&nbsp;converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting f...原创 2019-03-03 17:47:47 · 119 阅读 · 0 评论 -
LeetCode(150. Evaluate Reverse Polish Notation)
简介Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, , /. Each operand may be an integer or another expression.Note:Division between two integers ...原创 2019-03-02 20:16:04 · 119 阅读 · 0 评论 -
LeetCode(03 Longest Substring Without Repeating Characters)
简介Given a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcabcbb”Output: 3Explanation: The answer is “abc”, with the length of 3.Example 2:I...原创 2019-02-20 10:56:08 · 101 阅读 · 0 评论 -
LeetCode(100SameTree)
LeetCode(100SameTree)#include <iostream>using namespace std;/**Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if t...原创 2019-01-15 17:11:11 · 75 阅读 · 0 评论 -
西北工业大学考研复试201702
排序,输入n,有n组测试数输入样例21 4 7 2 58 9 4 3输出样例1 2 4 5 73 4 8 9#include &lt;iostream&gt;#include &lt;vector&gt;#include &lt;algorithm&gt;using namespace std;int main(){ int n; cin原创 2019-01-12 17:36:36 · 889 阅读 · 0 评论 -
LeetCode(02AddTwoNumers)
LeetCode(02AddTwoNumers)#include <iostream>using namespace std;/**You are given two non-empty linked lists representing two non-negative integers.The digits are stored in reverse order and...原创 2018-12-31 22:34:17 · 78 阅读 · 0 评论 -
LeetCode(24. Swap Nodes in Pairs)
简介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 changed.Example:Given 1->2->3->4, you ...原创 2019-03-30 12:27:13 · 81 阅读 · 0 评论