1、树的层序遍历

使用两个List 数组 或者 两个queue队列,交替进行,将遍历到的一层放在第一个里面,之后再将遍历到的第二层放在第二个里面。

2、将一个无符号整数的二进制表示形式逆向输出

需要将int n(每次向右移一位)的每一位从右向左与1相与(int 1每次向左移动一位),存储结果每次向左移动一位(若 n的当前位为1,则将answer与1相或),直到n的每一位都被遍历到。

3、求一个无符号整数的二进制表示中,1的个数

可以利用2中的方法,每次将整数n的当前位与1相与,若结果为1,则count+1,直到n的所有位都被遍历到为止。

java中移位运算符就是在二进制的基础上对数字进行平移。按照平移的方向和填充数字的规则分为三种:<<(左移)、>>(带符号右移)和>>>(无符号右移)。

4、对于一个整型数组 int[] nums,求其所有数字连接成为一个整数字符串后,得到的字符串结果的最大值

利用java中自带的 Arrays.sort() 方法,对字符串数组进行排序(将整型数组转换为字符串数组),由于这种排序不是简单的比较大小,而是比较出两个字符串连接后的排序结果使得两者的连接字符串最大。因此,需要改写 compare方法, Comparator<String> comp=new Comparator<String>(){重写compare方法}; 最后将排序得到的字符串数组从高位到低位进行连接后输出。

5、List<T> list=new ArrayList<T>(); Queue<T> queue=new LinkedList<T>(); 在java中,List和Queue都是容器

Leetcode笔记(整理中.......)的更多相关文章

  1. log4j 使用笔记整理中

    Log4j由三个重要的组件构成:日志信息的优先级,日志信息的输出目的地,日志信息的输出格式. 日志信息的常用的优先级从高到低有ERROR.WARN. INFO.DEBUG,分别用来指定这条日志信息的重 ...

  2. Leetcode 笔记 36 - Sudoku Solver

    题目链接:Sudoku Solver | LeetCode OJ Write a program to solve a Sudoku puzzle by filling the empty cells ...

  3. Leetcode 笔记 35 - Valid Soduko

    题目链接:Valid Sudoku | LeetCode OJ Determine if a Sudoku is valid, according to: Sudoku Puzzles - The R ...

  4. Linux学习历程(持续更新整理中)

    1.文件目录操作命令 (1) ls   显示文件和目录列表 a ls -l  显示文件的详细信息 b ls -a 列出当前目录的所有文件,包含隐藏文件. c stat '目录/文件'   显示指定目录 ...

  5. Leetcode 笔记 113 - Path Sum II

    题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...

  6. Leetcode 笔记 112 - Path Sum

    题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...

  7. Leetcode 笔记 110 - Balanced Binary Tree

    题目链接:Balanced Binary Tree | LeetCode OJ Given a binary tree, determine if it is height-balanced. For ...

  8. Leetcode 笔记 100 - Same Tree

    题目链接:Same Tree | LeetCode OJ Given two binary trees, write a function to check if they are equal or ...

  9. Leetcode 笔记 99 - Recover Binary Search Tree

    题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...

  10. Leetcode 笔记 98 - Validate Binary Search Tree

    题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...

随机推荐

  1. MATLAB小波包的分解与重构

    该文章用来直观上先感受一下小波包的分解与重构   例1 有一个信号,变量名为wave,随便找一个信号load进来就行了. t=wpdec(wave,3,'dmey'); t2 = wpjoin(t,[ ...

  2. (转)看穿机器学习(W-GAN模型)的黑箱

        本文转自:http://www.360doc.com/content/17/0212/11/35919193_628410589.shtml#   看穿机器学习(W-GAN模型)的黑箱 201 ...

  3. log4j2打印Mybatis执行的SQL语句及SQL语句的执行时间

    http://blog.csdn.net/zjq852533445/article/details/78320012

  4. OpenLayers中的球面墨卡托投影

    最近看OpenLayers,研究到地图投影时找到官方的文档,就翻译了一下,由于英文能力差,翻译不好的地方,请看原文 原文地址:http://docs.openlayers.org/library/sp ...

  5. hdu 6170 Two strings dp

    Two strings Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Prob ...

  6. Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

    解决方法: 如果安装的是GPU版本 如果你有一个GPU,你不应该关心AVX的支持,因为大多数昂贵的操作将被分派到一个GPU设备上(除非明确地设置).在这种情况下,您可以简单地忽略此警告: import ...

  7. synchronized和volatile

    迄今为止,看到的最清楚的一篇: https://zhuanlan.zhihu.com/p/29866981 volatile https://zhuanlan.zhihu.com/p/34362413

  8. VC.判断双字节字符集前导字节集(IsDBCSLeadByte)

    ZC:这是 WIndows API 函数 1.“BOOL IsDBCSLeadByte( char );” 判断 某字节是否在 双字节字符集的前导字节集中 ZC:可以判断  如 汉字.日文.韩文等 Z ...

  9. VC_窗口exe_printf信息

    1. #include <io.h> #include <fcntl.h> #include <stdio.h> 2. void InitConsoleWindow ...

  10. R语言多层绘图

    #########################################################第一种实现方法close.screen(all.screens = T)split.s ...