Skip to content

Commit 5920760

Browse files
committed
Number of set bits in all numbers from 1 to n
Number of set bits in all numbers from 1 to n
1 parent 2a2afe1 commit 5920760

File tree

5 files changed

+41
-16
lines changed

5 files changed

+41
-16
lines changed

.project

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<projects>
66
</projects>
77
<buildSpec>
8+
<buildCommand>
9+
<name>org.python.pydev.PyDevBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
813
<buildCommand>
914
<name>org.eclipse.jdt.core.javabuilder</name>
1015
<arguments>
@@ -13,5 +18,6 @@
1318
</buildSpec>
1419
<natures>
1520
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.python.pydev.pythonNature</nature>
1622
</natures>
1723
</projectDescription>

.pydevproject

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?eclipse-pydev version="1.0"?><pydev_project>
3+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
4+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
5+
</pydev_project>

bin/.gitignore

-15
Original file line numberDiff line numberDiff line change
@@ -1,16 +1 @@
1-
/chapter01introduction/
2-
/chapter02recursionandbacktracking/
3-
/chapter03linkedlists/
4-
/chapter04stacks/
5-
/chapter05queues/
6-
/chapter06trees/
7-
/chapter07priorityqueues/
8-
/chapter08disjointsets/
9-
/chapter10sorting/
10-
/chapter11searching/
11-
/chapter12selectionalgorithms/
12-
/chapter15stringalgorithms/
13-
/chapter17greedyalgorithms/
14-
/chapter18divideandconquer/
15-
/chapter19dynamicprogramming/
161
/chapter21miscconcepts/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*Copyright (c) Dec 22, 2014 CareerMonk Publications and others.
2+
* E-Mail : [email protected]
3+
* Creation Date : 2015-01-10 06:15:46
4+
* Last modification : 2006-05-31
5+
by : Narasimha Karumanchi
6+
* File Name : CheckEndian.java
7+
* Book Title : Data Structures And Algorithms Made In Java
8+
* Warranty : This software is provided "as is" without any
9+
* warranty; without even the implied warranty of
10+
* merchantability or fitness for a particular purpose.
11+
*
12+
*/
13+
14+
15+
package chapter21miscconcepts;
16+
17+
public class CountNumberofSetbitsin1toN {
18+
public int countNumberofSetbitsin1toN(int n) {
19+
long i = 0, j, count = 0;
20+
for (i = 1; i<=n; i++){
21+
j = i;
22+
while(j>0) {
23+
count++;
24+
j = j & (j - 1);
25+
}
26+
}
27+
return count;
28+
}
29+
}

src/chapter21miscconcepts/SquareMatrixRotationByOneElement.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int[][] rotateByOneElementClockwise(int[][] matrix) {
2828
// move left
2929
roataedMatrix[i][j-1] = matrix[i][j];
3030
} else if(i+j<=n-1 && i>j){
31-
// move top
31+
// move up
3232
roataedMatrix[i-1][j] = matrix[i][j];
3333
} else if(i+j>=n-1 && i<j) {
3434
// move down

0 commit comments

Comments
 (0)