
做算法防痴呆
每天一个算法题,防止老年痴呆症。
本人非计算机科班,如果谬误,还请大家直言不讳。
JayXu6888
这个作者很懒,什么都没留下…
展开
-
5 Happy Number
Write an algorithm to determine if a number n is “happy”. A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number e原创 2020-05-12 21:11:26 · 205 阅读 · 0 评论 -
3 Single Number
Given a non-empty array of integers, every element appears twice except for one. Find that single one. Note: your algorithm should have a linear runtime complexity. could you implement it without usin...原创 2020-05-07 19:03:34 · 169 阅读 · 0 评论 -
2 产品经理找first bad Version
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the...原创 2020-05-07 05:30:52 · 130 阅读 · 0 评论 -
1 【链表】输入一个链表,输出该链表中倒数第k个结点。
Day1. 输入一个链表,输出该链表中倒数第k个结点。 代码 public class ListNode { int val; ListNode next = null; ListNode(int val) { this.val = val; } } /** * 先搞一个stack,把所有的listNode都放进去,看看stack的大小的1/2是...原创 2020-05-06 01:43:21 · 268 阅读 · 0 评论