Skip to content

Instantly share code, notes, and snippets.

View abdulateef's full-sized avatar

Abdulateef abdulateef

  • sekat technologies
  • Lagos Nigeria
View GitHub Profile
@abdulateef
abdulateef / reverse.java
Last active May 14, 2021 14:33
Given an array, A, of N integers, print A's elements in reverse order as a single line of space-separated numbers.
import java.util.Scanner;
public class Reverse{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// System.out.println("Enter the size of the array");
int n = input.nextInt();
int[] arr = new int[n];
// System.out.println("Enter array values");
for(int i=0; i<n; i++){
@abdulateef
abdulateef / String.java
Created June 18, 2016 08:02
Given a string,S , of length that is indexed from 0 to N-1 , print its even-indexed and odd-indexed characters as space-separated strings on a single line . Note:0 is considered to be an even index.
import java.util.Scanner;
public class Day6{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int n = input.nextInt();
input.nextLine();
String[] words = new String[n];
@abdulateef
abdulateef / phonebook.java
Created June 20, 2016 07:55
Given names and phone numbers, assemble a phone book that maps friends' names to their respective phone numbers. You will then be given an unknown number of names to query your phone book for; for each name queried, print the associated entry from your phone book (in the form name=phonenumber ) or NOT FOUND if there is no entry for .name
//Day8
import java.util.*;
import java.io.*;
class Solution{
public static void main(String []argh)
{
Map<String,Long> phonebook = new java.util.HashMap<>();
Scanner in = new Scanner(System.in);
int n = in.nextInt();
@abdulateef
abdulateef / factorial.java
Created June 20, 2016 08:21
Write a factorial function that takes a positive integer, N as a parameter and prints the result of N! ( N factorial).
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static int factorial(int n)//factorial method
{
if (n == 0)
@abdulateef
abdulateef / binary.java
Last active November 23, 2017 19:39
Given a base- 10 integer, n , convert it to binary (base-2). Then find and print the base- 10 integer denoting the maximum number of consecutive 1's in n's binary representation.
import java.util.Scanner;
public class Binary
{
public static String convertToBinary(int decnumber)
{
String binaryString = " ";
if (decnumber > 0)
{
binaryString = Integer.toBinaryString(decnumber);
@abdulateef
abdulateef / HourGlass
Last active October 17, 2020 19:30
Solution to Calculate the hourglass sum for every hourglass in A, then print the maximum hourglass sum.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution
{
public static void main(String[] args)
@abdulateef
abdulateef / WordCount.cs
Last active August 5, 2016 10:32
how to count the occurrence of a word in a text file using c#
public static void WordCount(string word, string path)
{
int index;
int occurrence = 0;
try
{
StreamReader reader = new StreamReader(path);
using(reader)
import java.util.Scanner;
import jdk.nashorn.internal.parser.TokenType;
public class ConditionStatement {
public static void main(String [] args){
/// scanner to read input name and number
///though name not neccessary
///happy coding.....
Scanner input = new Scanner(System.in);
System.out.println("Enter your Name");
String name = input.next();
@abdulateef
abdulateef / MaximumDraw
Last active November 1, 2016 12:05
Jim is off to a party and is searching for a matching pair of socks. His drawer is filled with socks, each pair of a different color. In its worst case scenario, how many socks (x) should Jim remove from his drawer until he finds a matching pair?
using System;
using System.Collections.Generic;
using System.IO;
class Solution {
static void Main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */
// Console.WriteLine("Enter the Nmber of Test Case");
int Size = int.Parse(Console.ReadLine());
int[] input = new int[Size];
int i;