
java
文章平均质量分 64
逃离ntydr
这个作者很懒,什么都没留下…
展开
-
关于二进制的算法
二进制中1的个数输入一个整数 n ,输出该数32位二进制表示中1的个数。其中负数用补码表示。public int NumberOf1(int n) { int count=0; while(n!=0){ count++; n=n&(n-1); } return count; } 如果一个整数不为0,那么这个整数至少有一位是1。如果我们把这个整数减1,那么原来处在整数原创 2021-09-28 09:11:14 · 411 阅读 · 0 评论 -
Divide and Conquer15
标题原创 2021-07-03 11:14:38 · 87 阅读 · 0 评论 -
Duplicate Calculation in Recursion14
Duplicate Calculation in RecursionMemoization is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again. (Source: wikipedia原创 2021-06-30 18:36:31 · 131 阅读 · 0 评论 -
redis笔记整理
NoSql:not noly sql泛指非关系型数据库特点:方便扩展大数据量高性能数据类型是多样性的,不需事先设计数据库NoSql四大分类:kv键值对 redis文档型数据库列存储数据库图关系数据库redis:remote dictionary server远程服务字典定义:c语言编写,支持网络,可基于内存可持久化的日志型,kv数据库特性:多样的数据类型持久化集群事务有16个数据库,默认使用第0个redis的单线程的,但速度还是快的redis是将所有的数据全部放在内存原创 2021-06-29 15:12:50 · 100 阅读 · 0 评论 -
Principle of Recursion13
Principle of Recursion原创 2021-06-26 11:12:31 · 91 阅读 · 0 评论 -
Conclusion12
ConclusionConstruct Binary Tree from Inorder and Postorder TraversalGiven two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of the same tree, construct and return the原创 2021-06-25 19:50:05 · 96 阅读 · 0 评论 -
Solve Tree Problems Recursively11
Solve Tree Problems RecursivelyMaximum Depth of Binary TreeA binary tree’s maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.class Solution { int max=0; private void maximum_depth(TreeN原创 2021-06-15 17:18:14 · 84 阅读 · 0 评论 -
Binary Tree Preorder Traversal10
a原创 2021-06-14 09:44:34 · 97 阅读 · 0 评论 -
Doubly Linked List09
Doubly Linked ListDesign Doubly Linked ListDesign your implementation of the linked list. You can choose to use a singly or doubly linked list.A node in a singly linked list should have two attributes: val and next. val is the value of the current node,原创 2021-06-10 11:35:53 · 141 阅读 · 0 评论 -
Reverse Linked List08
Reverse Linked ListGiven the head of a singly linked list, reverse the list, and return the reversed list.原创 2021-06-10 09:48:31 · 85 阅读 · 0 评论 -
single linked list&Two Pointer Technique
single linked list原创 2021-06-01 17:54:45 · 80 阅读 · 0 评论 -
Conclusion
ConclusionHeight CheckerA school is trying to take an annual photo of all the students. The students are asked to stand in a single file line in non-decreasing order by height. Let this ordering be represented by the integer array expected where expected原创 2021-05-31 08:27:45 · 116 阅读 · 0 评论 -
in-Place Operations
in-Place OperationsReplace Elements with Greatest Element on Right Sidepublic int[] replaceElements(int[] arr) { for (int i=0;i<arr.length;i++){ int Gnum=-1; for (int j=i+1;j<arr.length;j++){ if(arr[j原创 2021-05-27 12:53:08 · 117 阅读 · 0 评论 -
Searching for Items in an Array
ArrayCheck If N and Its Double ExistGiven an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M).public boolean checkIfExist(int[] arr) { boolean flag=false; for (int a :原创 2021-05-26 09:45:10 · 85 阅读 · 0 评论 -
Deleting Items Froms an Array
ArrayRemove ElementGiven an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.T原创 2021-05-25 17:36:09 · 105 阅读 · 0 评论 -
Inserting Items Into an Array
ArrayDuplicate ZerosGiven a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right.Note that elements beyond the length of the original array are not written.public void duplicateZeros(int[]原创 2021-05-24 12:11:56 · 94 阅读 · 0 评论 -
Introduction01
ArrayMax Consecutive OnesGiven a binary array nums, return the maximum number of consecutive 1’s in the array. public int findMaxConsecutiveOnes(int[] nums) { int count = 0; int[] result =new int[nums.length]; int原创 2021-05-23 16:26:39 · 137 阅读 · 0 评论