leetcode
Zlase
这个作者很懒,什么都没留下…
展开
-
【Leetcode 27】 Remove Element
问题翻译:给定一个vector,去除掉里边的和val相同的值。解决方案:很简单,只需要遍历一下,之后使用 it=num.erase(it)即可实现该功能。#include <iostream>#include <vector>using namespace std;class Solution {public: int remove...原创 2018-09-27 17:42:59 · 198 阅读 · 0 评论 -
【Leetcode 20】Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of b...原创 2018-09-21 12:38:51 · 261 阅读 · 0 评论 -
【Leetcode 26】Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyi...原创 2018-09-26 12:55:00 · 209 阅读 · 0 评论 -
【Leetcode 14】Longest Common Prefix
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 "".Example 1:Input: ["flower","flow","flight"]Output:...原创 2018-09-20 11:35:11 · 215 阅读 · 0 评论 -
【Leetcode 13】Roman to Integer
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2018-09-19 14:20:16 · 365 阅读 · 0 评论 -
【Leetcode 9】Palindrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -121Output: falseExpl...原创 2018-09-18 10:27:53 · 232 阅读 · 0 评论 -
【Leetcode 7】 Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note:Assume we are dea...原创 2018-09-17 11:43:10 · 168 阅读 · 0 评论 -
【Leet code 1】 Two sum
Given an array of integers, returnindicesof the two numbers such that they add up to a specific target.You may assume that each input would haveexactlyone solution, and you may not use thesame...原创 2018-09-16 10:54:21 · 171 阅读 · 0 评论 -
【Leetcode 135】Candy
题目:现在很多家长都会送小孩子去培训中心学习舞蹈,有一次舞蹈培训中心考试,因为小孩子要哄着才能更喜欢学,所以老师给孩子们准备了小贴纸奖励孩子,考试结束以后孩子们按照大小个站成一排,老师按照顺序给孩子们发小贴纸,每个孩子都会至少得到一个小贴纸,因为是按照大小个站成一排的,所以相邻的孩子成绩略有高低,为了鼓励相邻孩子向成绩好的孩子学习,成绩高的孩子会比成绩弱的孩子得到的小贴纸多,请问需要多少小贴纸发给...原创 2018-08-30 11:28:11 · 251 阅读 · 0 评论 -
【Leetcode 139】Word Break
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may assu...原创 2018-08-28 11:13:57 · 205 阅读 · 0 评论