十七

leetcode71. 简化路径

分析将path按照"/"拆分成字符串temp,如果temp为"."就什么都不干,为".."则弹出ans最后一个,其他情况则加入到ans中。class Solution {public: string simplifyPath(stri

十七 Published on 2022-02-25

leetcode67. 二进制求和

先将a,b逆置,然后再运算,最后再逆置即可。class Solution {public: string addBinary(string a, string b) { string ans; reverse(a.begin(),a.end()); r

十七 Published on 2022-02-24

leetcdoe58. 最后一个单词的长度

class Solution {public: int lengthOfLastWord(string s) { int ans=0,cur=s.length()-1; while(s[cur]==' '){ c

十七 Published on 2022-02-23

leetcode49. 字母异位词分组

分析string排序后的值相同的,可以使用字符串哈希将对应的字符串加进vector中,最后遍历哈希表,得到答案class Solution {public: vector<vector<string>> groupAnagrams(vector<string&gt

十七 Published on 2022-02-18
Previous Next