自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(11)
  • 收藏
  • 关注

原创 找不同

class Solution { public char findTheDifference(String s, String t) { char res = 0; int s1 = s.length(); for(int i= 0;i<s1;i++){ res^=s.charAt(i)^t.charAt(i); } res^= t.charAt(s1); return re

2020-05-27 17:58:36 229

原创 双向链表和数组实现HashSet

class MyHashSet { class Node{ int val; Node prev,next; Node(int val){ this.val = val; } } private int length = 100; private Node[] data = new Node[length]; /** Initialize your data structure

2020-05-27 17:53:35 257

原创 两个数组的交集

class Solution { public int[] intersection(int[] nums1, int[] nums2) { if(nums1==null||nums1.length==0||nums2==null||nums2.length==0) return new int[0]; Set<Integer> set1 = new HashSet<>(); Set<Integer>

2020-05-20 16:16:58 135

原创 字符串中的第一个唯一字符

class Solution { public int firstUniqChar(String s) { if(s.length()==1) return 0; HashMap<Character, Integer> count = new HashMap<Character, Integer>(); int n = s.length(); // build hash map : character and

2020-05-20 16:14:36 79

原创 两个数组的交集2

class Solution { public int[] intersect(int[] nums1, int[] nums2) {//两个数组的交集2 if(nums1.length>nums2.length){ return intersect(nums2,nums1); } HashMap<Integer,Integer> map = new HashMap<>(); for

2020-05-15 18:31:47 109

原创 同构字符串

class Solution{ public boolean isIsomorphic(String s, String t) { int n = s.length(); HashMap<Character,Character> map = new HashMap<>(); for(int i = 0; i<n ; i++){ char c1 = s.charAt(i); c

2020-05-15 17:40:20 145

原创 栈和队列

栈栈又称为堆栈,是一种运算受限的线性表,这是因为它仅允许在线性表的固定一端(表尾)进行插入、删除和读取元素等运算,不允许在其他任何位置进行运算。相关名词:栈顶、栈顶元素、栈底、进栈(压栈)、出栈(退栈)特点:后进先出时间复杂度:O(1)顺序存储结构需要一个数组和整型变量,利用数组来存储元素,利用整型变量存储栈顶元素的下标,通常用top表示,也叫栈顶指针。top=-1时表示栈空;压栈时,首先将top增1,用来指代新的栈顶位置,然后把新元素赋值到栈顶位置上;退栈时,先取出栈顶元素,然后top减

2020-05-15 16:40:01 108

原创 最近请求的次数

class RecentCounter { Queue<Integer> l; public RecentCounter() { l = new LinkedList(); } public int ping(int t) { l.add(t); while(l.peek()< t-3000){ l.poll(); } return l.size

2020-05-15 16:35:53 117

原创 约瑟夫问题

import java.util.*;public class Joseph { public int getResult(int n) { // write code here if(n<1) return -1; LinkedList<Integer> list = new LinkedList<Integer>(); int count = 2,i,curr=0; for(i=1

2020-05-15 16:35:02 75

原创 猫狗收容所

import java.util.*;public class CatDogAsylum { public ArrayList<Integer> asylum(int[][] ope) {//猫狗收容所 // write code here ArrayList<Integer> input = new ArrayList&lt...

2020-05-05 16:32:50 169

原创 设计循环双端队列

class MyCircularDeque { int [] myquque; int front;//队头指针 int rear;//队尾指针 int size;//队列长度 int capacity;//队列的容量 /** Initialize your data structure here. Set the size of the deque...

2020-05-01 15:05:07 101

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除