leetcode3】的更多相关文章

Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of 1.…
题目: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest s…
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c) The solut…
package hashmap; import java.util.HashMap; import java.util.Map; public class hashmap { public static void main(String[] args) { String s="dvdf"; if(s==null||s.length()==0){ System.out.println("null"); } int result=1; Map<Character,…
题意: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of…
Question: Design and implement a TwoSum class. It should support the following operations: add and find. add(input) – Add the number input to an internal data structure. find(value) – Find if there exists any pair of numbers which sum is equal to the…
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of 1.…
public class Solution { public int LengthOfLongestSubstring(string s) { var dic = new Dictionary<char, int>(); ; ; i < s.Length; i++) { var c = s[i]; if (!dic.ContainsKey(c)) { dic.Add(c, i); } else { i = dic[c]; var curLen = dic.Count; if (maxLe…
给定一个字符串,找出不含有重复字符的最长子串的长度. 示例: 给定 "abcabcbb" ,没有重复字符的最长子串是 "abc" ,那么长度就是3. 给定 "bbbbb" ,最长的子串就是 "b" ,长度是1. 给定 "pwwkew" ,最长子串是 "wke" ,长度是3.请注意答案必须是一个子串,"pwke" 是 子序列  而不是子串. 1.我的思路: class…
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line 思路:最多的点,必然是点连成线时,所有斜率相同的最多的组合情况:   那么如果不在同一直线点的组合也可能斜率相同,找其中一点与其它点连即可. #include <iostream> #include <vector> #include <map> using namespac…