Skip to content

msSarriman/Algorithmic-Problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A collection of Various Java Programms


  • 00_SmallestRectangleByArea
    Given a set of points (class Points{ double x,y; }), find the smallest rectangle by area.
  • 01_FindThreeSmallestInArray
    Find the 3 smallest elements in an array.
  • 02_FindUniqueLinesInFiles
    Given a list of files, find all the unique lines that are contained in all those files.
  • 03_SortedMatrixLookUp
    Given a matrix[m x n] where every element is smaller than the elements with bigger m or n, find if a given element exists in the matrix, in Linear Time.
  • 04_FindNearestShop
    Given N shop coordinates on a 2d plane, find the nearest shop from a man whose coordinates are given.
  • 05_RemoveDuplicateLines
    Given a text file, remove all duplicate lines.
  • 06_FindPermutationsAtString
    A string consists of '0', '1', and '?'. The question mark can be either a '0' or a '1'. Find all possible combinations for a string.
  • 07_FindLongestSubsequence
    Given two integer arrays, find the longest common subsequence. e.g. a = [1, 5, 2, 6, 3, 7], b = [5, 6, 7, 1, 2, 3], return [1, 2, 3] or [5, 6, 7]
  • 08_ProgramsTimeSchedule
    Write a program to find if a given program can be executed or not. A program's schedule, is represented by P1(10, 5), where 10 is the starting time and 5 is the duration. A program can be scheduled, if it's schedule is not overlapping any other already scheduled programs.
  • 09_LonelyPixel
    Given an N x M image with black pixels and white pixels, if a pixel is the only one in its color throughout its entire row and column, then it is a lonely pixel. Find the number of lonely pixels in black from the image. (O(NM))
  • 10_BraceExpansion
    Brace Expansion,Given a string, perfrom the brace expansion,For example,Input: s = "a{d,c,b}e",output: {ade , ace , abe}
  • 11_SortWithoutApi
    Write a program to sort a string without using a Java API. I/P: "a390testai", O/P:"039aaiest"
  • 12_ReturnUniqueItemsList
    Write a function to return a copy of a list with duplicates removed
  • 13_SimpleInterpreter
    Write a Java program that is a mini-interpreter for a toy programming language that allows the following:
    1. The use of variables that consist of a single letter (e.g. A, a, ...)
    2. The use of whole numbers: ( e.g. -1, -20, 0, 1, 200)
    3. Assignment (=): ( e.g. A = B, A = 10, )
    4. Addition of exactly two elements (variables or constants) (+) : ( e.g. C = A + B, D = 1 + A, ... )
    5. The ability to "return" a value when a single variable or constant is on a line by itself ( e.g. A, B, 10)
    Your program will take as input a program in the toy programming language such as:
    A = 2
    B = 8
    C = A + B
    C
    and return the return value of the toy program, in this case, the value 10
  • 14_Knapsack-Like Problem
    Given two Lists of Lists of numbers (List<List<Integer>>>, or a(b)), and an integer X,
    where b List has two elements, key @index 0 and value @index 1,
    find the best b pairs (can be more than one and elements of pairs must belong to different lists),
    which are their value summary is closest to X (but not bigger than X).
    The lists are unsorted.
  • 15_FlattenDictionary
    A dictionary is a type of data structure that is supported natively in all major interpreted languages such as JavaScript, Python, Ruby and PHP, where it’s known as an Object, Dictionary, Hash and Array, respectively. In simple terms, a dictionary is a collection of unique keys and their values. The values can typically be of any primitive type (i.e an integer, boolean, double, string etc) or other dictionaries (dictionaries can be nested). However, for this exercise assume that values are either an integer, a string or another dictionary.
    Given a dictionary dict, write a function flattenDictionary that returns a flattened version of it .
    If you’re using a compiled language such Java, C++, C#, Swift and Go, you may want to use a Map/Dictionary/Hash Table that maps strings (keys) to a generic type (e.g. Object in Java, AnyObject in Swift etc.) to allow nested dictionaries.
    If a certain key is empty, it should be excluded from the output (see e in the example below).

Under Construction

-- Coming soon

About

A collection of Various Algorithmic Problems --- Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages