LintCode之Strings Homomorphism
来源:互联网 发布:cdnn软件 编辑:程序博客网 时间:2024/05/20 04:12
判断两个字符串的结构是否相同。
样例:
Given s = “egg”, t = “add”, return true.
Given s = “foo”, t = “bar”, return false.
Given s = “paper”, t = “title”, return true.
public static boolean isIsomorphic(String s, String t) { String str1 = stringStructure(s); String str2 = stringStructure(t); if (str1.equals(str2)) { return true; } return false; } public static String stringStructure(String s) { List<String> list = new ArrayList<>(); for (int i = 0; i < s.length(); i++) { if (!list.contains(s.charAt(i) + "")) { list.add(s.charAt(i) + ""); } } StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { for (int j = 0; j < list.size(); j++) { if ((s.charAt(i)+"").equals(list.get(j))) { sb.append(j); } } } return sb+""; }
阅读全文
0 0
- LintCode之Strings Homomorphism
- lintcode(638)Strings Homomorphism
- Strings Homomorphism
- Strings Homomorphism
- Strings Homomorphism
- Strings Homomorphism
- LintCode python 小白-简单题-638-Strings Homomorphism
- Two Strings Are Anagrams-LintCode
- 【LintCode】 Compare Strings 比较字符串
- [LintCode]Compare Strings(C++|Python)
- lintcode 比较字符串(Compare Strings ) (Java)
- Lie group homomorphism
- LintCode Two Strings Are Anagrams 两个字符串是变位词
- [LintCode]Two Strings Are Anagrams(C++|Java|Python)
- Android之strings.xml
- Leetcode之Multiply Strings
- LeetCode之Multiply Strings
- linux 命令之strings
- 题目111-分数加减法
- Windows CMD命令
- C语言模拟终端执行shell命令
- 使用bcryptjs对密码加密时,其校验原理是怎样的?
- java日期转换
- LintCode之Strings Homomorphism
- mysql explain使用
- 微信总部大楼设计图曝光:拟建39层大楼高度207米
- swift
- 【注意事项】c#通过CallBack获取C++传递的数据
- CCF CSP 201512-2 消除类游戏(Java-100分)
- 【NOIP2012普及组原题】寻宝
- JavaScript 开发进阶:理解 JavaScript 作用域和作用域链
- Spring AOP实现(注解)