单链表问题(反转、是否有环、删除结尾第N个节点、合并两个sortlist、找到交点)

1.时间复杂度O(N),内存O(1)的效率下实现单链表的翻转public static TreeNode revers(TreeNode head){ TreeNode temp,first,second; first=head; second=head.next; while(second!=null){ temp=second.next; second.next=...
阅读(1126) 评论(0)

面试总结-百度(1)

百度数据挖掘部门       自我介绍,扯了一些项目方面的东西,就是简历上的,然后开始写代码,最后问你有没有什么问题。题目如下:(1)用两个栈实现一个队列(优化后解)public class QueueImplementByTwoStacks { Stack a=new Stack(); Stack b=new Stack(); public void...
阅读(1204) 评论(2)

【LeetCode从零单排】No96 Unique Binary Search Trees

题目Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ ...
阅读(1009) 评论(0)

【LeetCode从零单排】No129 Sum Root to Leaf Numbers

题目Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum of...
阅读(849) 评论(0)

【LeetCode从零单排】No15 3Sum

题目Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c) must be ...
阅读(764) 评论(0)

苹果系统修复若干办法

在经典系统,可以在重新启动时按Shift键,将第三方的功能扩展关闭,使机子能完成启动,之后再设法修复磁盘错误或功能扩展冲突的问题。重新启动,当所有功能扩展的上载完成后,立即按下Option+Command键,直到出现重建桌面文件的窗口,点击OK,可以重建桌面文件,修复因桌面文件出错引起的问题。即使是正常运行的系统,至少每月重建桌面一次,对系统健康有益无害。  在X系统,重启后立即按Shift键,让...
阅读(598) 评论(0)

【LeetCode从零单排】No 3 Longest Substring Without Repeating Characters

题目Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo...
阅读(925) 评论(0)

【LeetCode从零单排】No 114 Flatten Binary Tree to Linked List

题目Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 ...
阅读(912) 评论(0)

【LeetCode从零单排】No 191.Number of 1 Bits(考察位运算)

题目Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 0000000000...
阅读(3906) 评论(2)

Kmeans、Kmeans++和KNN算法比较

K-Means介绍       K-means算法是聚类分析中使用最广泛的算法之一。它把n个对象根据他们的属性分为k个聚类以便使得所获得的聚类满足:同一聚类中的对象相似度较高;而不同聚类中的对象相似度较小。其聚类过程可以用下图表示:        如图所示,数据样本用圆点表示,每个簇的中心点用叉叉表示。(a)刚开始时是原始数据,杂乱无章,没有label,看起来都一样,都是绿色的。(b)假设数据集可...
阅读(835) 评论(0)

【LeetCode从零单排】No189 .Rotate Array

题目Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many solutions as you can, the...
阅读(1026) 评论(0)

【LeetCode从零单排】No.169 Majority Element(hashmap用法)

题目Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element alwa...
阅读(971) 评论(0)

【LeetCode从零单排】No.160 Intersection of Two Linked Lists

题目Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘ ...
阅读(783) 评论(0)

【LeetCode从零单排】No118 Pascal's Triangle

题目Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]代码public class Solution { public...
阅读(1027) 评论(0)

linux||mac os如何自定义shell命令

博主是goagent忠实用户,但是在mac下每次启动goagent都要cd到proxy的目录下,然后再执行proxy.py文件,非常麻烦,所以博主想到能否自己定义一个shell命令,一健启动goagent,其实也很简单,过程如下。(1)我们在user目录下输入,"-a"是现实隐藏的文件ls -a(2)展现出了很多前边是"."的文件,这种文件在通常情况下是隐藏的hirotekiMacBook-Pro...
阅读(1564) 评论(0)

【LeetCode从零单排】No112 Path Sum

题目Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum = ...
阅读(980) 评论(0)

【LeetCode从零单排】No104 Maximum Depth of Binary Tree

题目Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.代码/** * Definition for binary tree * p...
阅读(988) 评论(0)

【LeetCode从零单排】No102 Binary Tree Level Order Traversal

题目       Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 /...
阅读(1055) 评论(2)

【LeetCode从零单排】No100 Same Tree && No101 Symmetric Tree

题目1.same treeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.2.sym...
阅读(966) 评论(0)

【LeetCode从零单排】No83 Remove Duplicates from Sorted List

题目Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.代码 public static ListNode deleteD...
阅读(908) 评论(0)
21条 共2页1 2 下一页 尾页
    我的微信公众号

    作者公众号:凡人机器学习

    凡人机器学习

    作者新书《机器学习实践应用》
    个人资料
    • 访问:638827次
    • 积分:9068
    • 等级:
    • 排名:千里之外
    • 原创:215篇
    • 转载:33篇
    • 译文:0篇
    • 评论:417条
    博客专栏
    统计