摘要:
class Solution {public: int numTrees(int n) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case. vector num; num.push_back(1); num.push_back(1); int temp = 1; for(int i = 2;i... 阅读全文
摘要:
Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given{1,2,3,4}, reorder it to{1,4,2,3}现在在Leetcode上也有了,这题的做法有很多,我是用的是一个舍友给我提供的一种方法,先把后面部分反转在重新插入即可。/** * Definition for singly-linked list. * s 阅读全文
摘要:
class Solution {public: int lengthOfLongestSubstring(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function if(s=="") return 0; map key; for(char i = 'a';iresult) { result = temp; ... 阅读全文
摘要:
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you are able to reach the last index.For example:A =[2,3,1,1,4], returntrue.A =[3,2,1,0,4], returnfalse.先想 阅读全文