Loading

随笔分类 -  数据结构与算法

摘要:异和异或 认识异或 int a = 7; // 此时a的二进制是 0111 int b = 13; // 此时b的二进制是 1101 那么此刻我们把 a 异或 b 会的到 10 0 1 1 1 1 1 0 1 1 0 1 0 官方点来说是 相同为0 不同为1 简单来记 就是直接想加 不用进位 和同或 阅读全文
posted @ 2022-01-18 21:22 Pen9 阅读(108) 评论(0) 推荐(0)
摘要:Convert Binary Number in a Linked List to Integer Given head which is a reference node to a singly-linked list. The value of each node in the linked l 阅读全文
posted @ 2021-09-23 14:36 Pen9 阅读(41) 评论(0) 推荐(0)
摘要:面试题 02.02. Kth Node From End of List LCCI Implement an algorithm to find the kth to last element of a singly linked list. Return the value of the elem 阅读全文
posted @ 2021-09-22 11:25 Pen9 阅读(40) 评论(0) 推荐(0)
摘要:剑指 Offer 24. 反转链表 定义一个函数,输入一个链表的头节点,反转该链表并输出反转后链表的头节点。 示例: 输入: 1->2->3->4->5->NULL 输出: 5->4->3->2->1->NULL 限制: 0 ⇐ 节点个数 ⇐ 5000 /** * Definition for si 阅读全文
posted @ 2021-09-22 11:21 Pen9 阅读(38) 评论(0) 推荐(0)
摘要:剑指 Offer 06. 从尾到头打印链表 输入一个链表的头节点,从尾到头反过来返回每个节点的值(用数组返回)。 示例 1: 输入:head = [1,3,2] 输出:[2,3,1] 限制: 0 ⇐ 链表长度 ⇐ 10000 /** * Definition for singly-linked li 阅读全文
posted @ 2021-09-22 11:15 Pen9 阅读(32) 评论(0) 推荐(0)
摘要:704. Binary Search Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in num 阅读全文
posted @ 2021-09-19 15:27 Pen9 阅读(44) 评论(0) 推荐(0)
摘要:Title Description 20. Valid Parentheses Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string 阅读全文
posted @ 2021-09-19 15:20 Pen9 阅读(40) 评论(0) 推荐(0)