Skip to content
This repository has been archived by the owner on Jan 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #472 from deadshotsb/master
Browse files Browse the repository at this point in the history
Implementation of Sliding window in java
  • Loading branch information
NullDev authored Oct 3, 2020
2 parents b66fe78 + a8bc3f2 commit c75b1f4
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Java/sliding_window.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/******************************************************************************
This code is developed by Sombit Bose
This program uses sliding window and modulo
opoerator for classifying fizz, buzz and fizz_buzz.
*******************************************************************************/

import java.util.*;
public class Main
{
public static void main(String[] args) {
int start_3 = 1, start_5 = 1, end_3 = 3, end_5 = 5;
Set<Integer> fizz = new HashSet<Integer>();
Set<Integer> buzz = new HashSet<Integer>();
Set<Integer> fizz_buzz = new HashSet<Integer>();
while (end_3 < 100 && end_5 < 100) {
if (end_3 == end_5)
fizz_buzz.add(end_3);
else {
fizz.add(end_3);
if (end_5 % 15 != 0)
buzz.add(end_5);
}
end_3 += 3; start_3 += 3;
if (end_3 > end_5) {
end_5 += 5; start_5 += 5;
}
}
System.out.println("The list of fizz numbers\n" + fizz);
System.out.println("The list of buzz numbers\n" + buzz);
System.out.println("The list of fizz buzz numbers\n" + fizz_buzz);
}
}

0 comments on commit c75b1f4

Please sign in to comment.