字符串刷题
刷的一些字符串
浮生若梦yoo
这个作者很懒,什么都没留下…
展开
-
实现strStr()
package LeetCodeDemo.primary;public class Demo38 { public static void main(String[] args){ System.out.println(new Demo38().strStr("mississippi", "issipi")); } public int strSt...原创 2019-12-28 14:27:07 · 100 阅读 · 0 评论 -
最长公共前缀
public String longestCommonPrefix(String[] strs) { if (strs.length == 0 ){ return ""; }else if (strs.length == 1){ return strs[0]; } int minLen = Integer.MAX_VALUE; ...原创 2019-12-28 14:26:20 · 99 阅读 · 0 评论 -
字符串转换整数
https://leetcode-cn.com/explore/featured/card/top-interview-questions-easy/5/strings/37/ static char star; // 用于标记符号 static int sum ; // 用于记录有效位数 public int myAtoi(String str) { ...原创 2019-12-28 14:25:18 · 108 阅读 · 0 评论 -
验证回文串
https://leetcode-cn.com/explore/featured/card/top-interview-questions-easy/5/strings/36/class Solution { public boolean isPalindrome(String s) { int sum = 0; char[] chars = s.t...原创 2019-12-28 14:23:06 · 87 阅读 · 0 评论 -
字符串中的第一个唯一字符
public int firstUniqChar(String s) { if(s.equals("")) { return -1; } char[] cArr = s.toCharArray(); int i; int[] arr = new int[26]; ArrayList<Character> lis...原创 2019-12-28 14:22:06 · 123 阅读 · 0 评论 -
整数转换
class Solution { public int reverse(int x) { boolean flat = false; if(x >= 0) { flat = true; } Integer temp = Integer.valueOf(x); char[] cArr = temp....原创 2019-12-28 14:20:46 · 438 阅读 · 0 评论 -
1.反转字符串
public void reverseString(char[] s) { int len = s.length; int i; for (i = 0; i < len / 2; i++ ) { char temp = s[i]; s[i] = s[len-i-1]; s[len-i-1] = temp; ...原创 2019-12-28 14:19:51 · 140 阅读 · 0 评论