- 博客(10)
- 收藏
- 关注
原创 【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
187
原创 【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
194
原创 【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
245
原创 【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
202
原创 【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
349
原创 【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
216
原创 【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
153
原创 【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
156
原创 刷题:会议室问题
问题是从0-24小时,有人可以定会议室,但是会议室最后分配的准则是1.时间越长的越高优先级 2.之后是按照时间的先后排序。比如8-10点和9-13点的,会由9-13的点的申请成功。输入0,0的时候截止输入。输入示例:8,109,1113,150,0输出示例:8,1013,15 这个问题比较简单,但是有几个需要注意一下:1. 输入的用逗号隔开...很...
2018-09-08 21:55:36
1258
原创 笔试题:输入两个数n和m,现在只有两种变换方法,第一种是减1,第二种是*2,问:从n到m最少使用多少步?
输入两个数n和m,现在只有两种变换方法,第一种是减1,第二种是*2,问:从n到m最少使用多少步?输入:4 5 输出:3输入:5 12 输出:4输入:5 14 输出:4输入:4 6 输出:2 思路为分段改写:1. n>=m 说明*2根本用不上,只能用减法 步骤就是 n-m2.如果n<m && 2n>m 这...
2018-09-03 21:02:57
2519
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人