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 / QuicksortInPlace.cs
Last active November 5, 2016 12:55
Quicksort In-Place Solution in c#
using System;
using System.Collections.Generic;
using System.IO;
class Solution {
static void Main(String[] args)
{
int N = Convert.ToInt32(Console.ReadLine());
string[] arr_temp = Console.ReadLine().Split(' ');
int[] list1 = Array.ConvertAll(arr_temp,Int32.Parse);
Solution.quickSortInPlace(list1);
@abdulateef
abdulateef / InsertionSort2.cs
Created November 4, 2016 17:46
Hanker Rank Insertion Sort - Part 2 Solution in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Algorithms
{
class InsertionSort2
{
@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;
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 / 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)
@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 / 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 / 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 / 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();