摘要:
Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文
摘要:
Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".解法:从后往前对两个string相加即可。注意将char转换为int,注意进位,注意结果顺序。... 阅读全文
摘要:
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa... 阅读全文
摘要:
Write a function to find the longest common prefix string amongst an array of strings.解法:从所有的string的头到尾的字母逐一比较即可。class Solution {public: string lon... 阅读全文
摘要:
Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie... 阅读全文
摘要:
Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ... 阅读全文
摘要:
Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from l... 阅读全文
摘要:
You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?解法1:新开辟一个矩阵,空间复杂度O(... 阅读全文