当前位置: 首页 > wzjs >正文

企业网站内容策划wordpress禁用admin用户

企业网站内容策划,wordpress禁用admin用户,网站开发的大学生应届简历,室内设计培训班哪个学校好目录 1、两数之和2、移动零3、相交链表4、有效的括号5、反转链表6、回文链表7、环形链表8、环形链表II9、合并两个有序链表10、二叉树的中序遍历 1、两数之和 1. 两数之和 - 力扣(LeetCode) 方法1: class Solution {public int[] twoSum(i…

目录

  • 1、两数之和
  • 2、移动零
  • 3、相交链表
  • 4、有效的括号
  • 5、反转链表
  • 6、回文链表
  • 7、环形链表
  • 8、环形链表II
  • 9、合并两个有序链表
  • 10、二叉树的中序遍历

1、两数之和

1. 两数之和 - 力扣(LeetCode)在这里插入图片描述

方法1:

class Solution {public int[] twoSum(int[] nums, int target) {int[] ret = new int[2];for(int i=0;i<nums.length;i++){for(int j=i+1;j<nums.length;j++) {if(nums[i]+nums[j]==target) {ret[0] = i;ret[1] = j;return ret;}                }}return ret;}
}

方法2:

在这里插入图片描述

class Solution {public int[] twoSum(int[] nums, int target) {int[] ret = new int[2];HashMap<Integer,Integer> hash = new HashMap<>();// key:nums[i],value:ifor (int i = 0; i < nums.length; i++) {if (hash.containsKey(target - nums[i])) {ret[0] = i;ret[1] = hash.get(target - nums[i]);return ret;}hash.put(nums[i], i);}return ret;}
}

2、移动零

283. 移动零 - 力扣(LeetCode)

在这里插入图片描述

class Solution {public void moveZeroes(int[] nums) {int dest = -1;for (int cur = 0; cur < nums.length; cur++) {if (nums[cur] != 0) {dest++;int tmp = nums[cur];nums[cur] = nums[dest];nums[dest] = tmp;}}}
}

3、相交链表

160. 相交链表 - 力扣(LeetCode)

在这里插入图片描述

public class Solution {public ListNode getIntersectionNode(ListNode headA, ListNode headB) {ListNode cur1 = headA;ListNode cur2 = headB;int count1 = 0;//统计A结点个数int count2 = 0;//统计B结点个数while (cur1 != null) {count1++;cur1 = cur1.next;}while (cur2 != null) {count2++;cur2 = cur2.next;}if (count1 > count2) {for (int i = 0; i < count1 - count2; i++) {headA = headA.next;}}if (count1 < count2) {for (int i = 0; i < count2 - count1; i++) {headB = headB.next;}}while (headA != headB) {headA = headA.next;headB = headB.next;}return headA;}
}

4、有效的括号

20. 有效的括号 - 力扣(LeetCode)

在这里插入图片描述

class Solution {public boolean isValid(String s) {Stack<Character> stack = new Stack<>();for (int i = 0; i < s.length(); i++) {char ch = s.charAt(i);if (ch == '(' || ch == '[' || ch == '{') {//如果是左括号,入栈stack.push(ch);} else {//如果是右括号if (stack.empty()) {//判断栈是否为空return false;} else {char tmp = stack.peek();if (ch == ')' && tmp == '('|| ch == ']' && tmp == '['|| ch == '}' && tmp == '{') {stack.pop();} else {return false;}}}}return stack.empty();}
}

5、反转链表

206. 反转链表 - 力扣(LeetCode)

在这里插入图片描述

方法1:

class Solution {public ListNode reverseList(ListNode head) {if(head==null || head.next==null){return head;}        //1.先反转后面的链表ListNode newHead = reverseList(head.next);//返回反转后的头head.next.next = head;head.next = null;return newHead;}
}

方法2:

class Solution {public ListNode reverseList(ListNode head) {if (head == null) {return head;}ListNode cur = head.next;head.next = null;while (cur != null) {ListNode curNext = cur.next;cur.next = head;head = cur;cur = curNext;}return head;}
}

6、回文链表

234. 回文链表 - 力扣(LeetCode)

在这里插入图片描述

class Solution {public boolean isPalindrome(ListNode head) {if (head == null) {return false;}ListNode fast = head;ListNode slow = head;//找到中间结点while (fast != null && fast.next != null) {fast = fast.next.next;slow = slow.next;}ListNode Newhead = reverseList(slow);ListNode tmp1 = head;ListNode tmp2 = Newhead;while (tmp2 != null) {//if (tmp2.val != tmp1.val) {return false;} else {tmp1 = tmp1.next;tmp2 = tmp2.next;}}return true;}//翻转链表public ListNode reverseList(ListNode head) {if (head == null) {return head;}ListNode cur = head.next;head.next = null;while (cur != null) {ListNode curNext = cur.next;cur.next = head;head = cur;cur = curNext;}return head;}
}

7、环形链表

141. 环形链表 - 力扣(LeetCode)

在这里插入图片描述

public class Solution {public boolean hasCycle(ListNode head) {if (head == null) {return false;}ListNode fast = head.next;ListNode slow = head;while (fast != null && fast.next != null) {fast = fast.next.next;slow = slow.next;if (fast == slow) {return true;}}return false;}
}

8、环形链表II

142. 环形链表 II - 力扣(LeetCode)

在这里插入图片描述

public class Solution {public ListNode detectCycle(ListNode head) {if (head == null) {return null;}ListNode fast = head;ListNode slow = head;while (fast != null && fast.next != null) {fast = fast.next.next;slow = slow.next;if (fast == slow) {// 两人相遇,说明链表成环while (head != slow) {slow = slow.next;head = head.next;}//return head;}}return null;}
}

9、合并两个有序链表

21. 合并两个有序链表 - 力扣(LeetCode)

在这里插入图片描述

方法1:

class Solution {public ListNode mergeTwoLists(ListNode list1, ListNode list2) {if (list1 == null) {return list2;}if (list2 == null) {return list1;}// 1.比大小if (list1.val < list2.val) {list1.next = mergeTwoLists(list1.next, list2);return list1;} else {list2.next = mergeTwoLists(list2.next, list1);return list2;}}
}

方法2:

class Solution {public ListNode mergeTwoLists(ListNode list1, ListNode list2) {ListNode l1 = list1;ListNode l2 = list2;if (l1 == null) {return l2;}if (l2 == null) {return l1;}ListNode newHead = null;ListNode newTail = null;while (l1 != null && l2 != null) {if (l1.val <= l2.val) {//if (newTail == null) {newHead = newTail = l1;l1 = l1.next;} else {newTail.next = l1;newTail = l1;l1 = l1.next;}} else {if (newTail == null) {newHead = newTail = l2;l2 = l2.next;} else {newTail.next = l2;newTail = l2;l2 = l2.next;}}}//if (l1 == null) {newTail.next = l2;} else {newTail.next = l1;}return newHead;}
}

10、二叉树的中序遍历

94. 二叉树的中序遍历 - 力扣(LeetCode)

在这里插入图片描述

class Solution {List<Integer> ret = new LinkedList<Integer>();public List<Integer> inorderTraversal(TreeNode root) {        if (root == null) {return ret;}dfs(root, ret);return ret;}public void dfs(TreeNode root, List<Integer> ret) {if (root == null) {return;}dfs(root.left, ret);ret.add(root.val);dfs(root.right, ret);}
}

文章转载自:

http://gEQ1TfD0.Lwhsp.cn
http://LWHC7WWo.Lwhsp.cn
http://FQO1h6N7.Lwhsp.cn
http://lyTNdGkJ.Lwhsp.cn
http://ri1jJNoP.Lwhsp.cn
http://IVsFsW68.Lwhsp.cn
http://4B9O5r5X.Lwhsp.cn
http://uRvtA1dU.Lwhsp.cn
http://QqLIpmcb.Lwhsp.cn
http://FGK9iJTD.Lwhsp.cn
http://FODaS2YI.Lwhsp.cn
http://Bs87i8SH.Lwhsp.cn
http://BciEib3N.Lwhsp.cn
http://mmBF2W2H.Lwhsp.cn
http://qtodP8bj.Lwhsp.cn
http://B0XXZiqp.Lwhsp.cn
http://3whH9ndo.Lwhsp.cn
http://pVJbBv8H.Lwhsp.cn
http://05nCgJtX.Lwhsp.cn
http://JQ6BkdSH.Lwhsp.cn
http://OKQKsQVg.Lwhsp.cn
http://aqpj3LfX.Lwhsp.cn
http://30tITYe2.Lwhsp.cn
http://mljDAPcD.Lwhsp.cn
http://GXZsRpJC.Lwhsp.cn
http://7bcdJlqo.Lwhsp.cn
http://8fsAkzf7.Lwhsp.cn
http://43Qkx7tf.Lwhsp.cn
http://5AeQ89DH.Lwhsp.cn
http://Zfg7BQ0B.Lwhsp.cn
http://www.dtcms.com/wzjs/766512.html

相关文章:

  • 网站开发支持上传gif杭州人才网
  • 网站是哪个公司做的菜鸟制作个人网站网页实例
  • 做外贸应该去什么网站wordpress登录链接
  • seo网站关键词优化工具wordpress iis 中文乱码
  • 直播网站建设1个节点多少钱贵阳做网站软件
  • 网站建设流程时间表不良网站代码怎么查
  • 具有价值的响应式网站建程网土石方工程
  • 济南润尔网站建设技术公司江西赣州公司
  • 代理下单网站开发广州小型企业网站建设
  • 什么网站做简历模板宁波 手机网站建设
  • 免x网站wordpress界面变宽
  • 做网站和做app哪个贵哪个网站做照片书最好看
  • 建筑专业网站建设怎么创作一个微信小程序
  • 河南 网站建设网站开发产品规划要求
  • 旅游网站系统设计与开发无锡网站推广无锡做网站
  • 网站备案证图片做网站要用什么语言
  • 网站建设高考题佛山网站建设公司价格多少
  • 新网站如何被网站收录网站建设服务器介绍图片
  • 天津企业模板建站建站快车源码
  • 金融产品做网站推广温州网页网站制作
  • 企业不想做网站的原因我想开个公司怎么注册
  • 建网站 英文视频直播app
  • 廊坊建设网站平面设计多久能学会
  • 广告联盟建设个人网站互联网营销师国家职业技能标准
  • 用c 怎么做网站系统wordpress流量插件
  • qq网站空间赞国际网站建设工具
  • 天津网站建设制作wordpress 过滤钩子
  • 永康市住房建设局网站网站系统升级维护需要多长时间
  • 注册安全工程师建设工程网站东方购物网上商城
  • 具有口碑的柳州网站建设价格wordpress 权限阅读