zoukankan      html  css  js  c++  java
  • 929. 独特的电子邮件地址

    class Solution {
    public int numUniqueEmails(String[] emails) {
    		HashSet<String> hs = new HashSet<String>();
    		for (int i = 0; i < emails.length; i++) {
    			StringBuffer temp = new StringBuffer();
    			int flag = 0;
    			for (int j = 0; j < emails[i].length(); j++) {
    				while (emails[i].charAt(j) == '.'&&flag==0)
    					j++;
    				if (emails[i].charAt(j) == '+')
    					while (emails[i].charAt(j) != '@') j++;
                    if(emails[i].charAt(j) == '@') flag++;
    				temp.append(emails[i].charAt(j));
    			}
    			System.out.println(temp.toString());
    			hs.add(String.valueOf(temp));
    		}
    		return hs.size();
    	}
    }
    
    
    class Solution {
    public int numUniqueEmails(String[] emails) {
    		HashSet<String> hs = new HashSet<String>();
    		for (String i : emails) {
    			int at = i.indexOf('@');                                     //用一些已知的方法来确定 并且划分 
    			StringBuffer name = new StringBuffer("");
    			for(int x = 0; x < at ; x++) {
    				if(i.charAt(x)=='+')
    					break;
    				if(i.charAt(x)=='.')
    					x++;
    				name.append(i.charAt(x));
    			}
    			name.append(i.substring(at,i.length()));
    			hs.add(String.valueOf(name));
    		}
    		return hs.size();
    	}
    }
    
  • 相关阅读:
    并列显示
    vertical-align,text-align 和 align的区别
    实现水平垂直居中
    overflow属性
    float属性
    table 标签
    idea中修改默认maven
    使用host的方式来破解idea
    mysql分区
    mysql数据库设计规范
  • 原文地址:https://www.cnblogs.com/cznczai/p/11320981.html
Copyright © 2011-2022 走看看