Git Product home page Git Product logo

coding-java's Introduction

coding-java

Solved coding problems from different learning platforms to one place in Java

Different Packages

Name of Package Description
com.algoexpert AlgoExpert's Coding problems
com.algorithms Implementation of well-known algorithms
com.coding.patterns Implementation of leetcode problems with proper separation of respected(used) coding pattern
com.sorting Implementation of all sorting algorithms
com.datastructures Implementation of well-known datastructures

LeetCode problems

NOTE: This repository contains many more problems than listed below (find it according to different coding patterns). I just need to find a time to add it to this list. Feel free to contribute to add/update below list to help all.

No Problem Solution
1 Two Sum Solution
3 Longest Substring Without Repeating Characters Solution
15 3Sum Solution
17 Letter Combinations Of a Phone Number Solution
34 Find First and Last Position of Element in Sorted Array Solution
39 Combination Sum Solution
71 Simplify Path Solution
74 Search a 2D Matrix Solution
91 Decode Ways Solution
121 Best Time to Buy and Sell Stock Solution
122 Best Time to Buy and Sell Stock II Solution
135 Find Minimum in Rotated Sorted Array Solution
136 Single Number Solution
189 Rotate Array Solution
209 Minimum Size Subarray Sum Solution
215 Kth Largest Element in an Array Solution
337 House Robber III Solution
355 Design Twitter Solution
366 Find Leaves of Binary Tree Solution
438 Find All Anagrams in a String Solution
448 Find All Numbers Disappeared in an Array Solution
473 Matchsticks to Square Solution
538 Convert BST to Greater BST Solution
605 Can Place Flowers Solution
680 Valid Palindrome II Solution
682 Baseball Game Solution
695 Max Area of Island Solution
724 Find Pivot Index Solution
739 Daily Temperatures Solution
752 Open the Lock Solution
767 Reorganize String Solution
787 Cheapest Flights Within K Stops Solution
802 Find Eventual Safe States Solution
853 Car Fleet Solution
896 Monotonic Array Solution
901 Online Stock Spanner Solution
909 Snakes and Ladders Solution
1094 Car Pooling Solution
1151 Minimum Swaps To Group All 1's together Solution
1189 Maximum Number of Balloons Solution
1197 Minimum Knight Moves Solution
1209 Remove All Adjacent Duplicates in String II Solution
1260 Shift 2D Grid Solution
1335 Minimum Difficulty of a Job Schedule Solution
1461 Check If a String Contains All Binary Codes of Size K Solution
1507 Reformat Date Solution
1985 Find the Kth Largest Integer in the Array Solution

coding-java's People

Contributors

7mada123 avatar arwanayef avatar chiragmdeekshith avatar coderla avatar dlarge avatar gauravpolekar avatar jyotirmoyvs avatar ktk001 avatar maivantan1992 avatar ndesai15 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

coding-java's Issues

Koko Eating Bananas Answer Incorrect

Currently Answer will fail with below test case:

[805306368,805306368,805306368]
1000000000

I think we need to change count method return type from int to long to make it work.

  private long count(int[] piles, int k) {
        long result = 0;
        for(int pile : piles) {
            result += (pile / k) + (pile % k == 0 ? 0 : 1);
        }
        return result;
    }

Update README.md

Looking for a contributor to update/add more already implemented problem references in README

Runtime Error

Solution code here returns Runtime Error when submitting.
java.util.EmptyStackException
at line 101, java.base/java.util.Stack.peek
at line 27, MinStack.getMin
at line 72, Driver.helperSelectMethod
at line 90, Driver.helper
at line 111, Driver.main

Below code resolves the issue:
class MinStack {

private Stack<int[]> stack = new Stack<>();

public MinStack() {
}

public void push(int val) {
    
    if (stack.isEmpty()) {
        stack.push(new int[]{val, val});
        return;
    }
    int currentMin = stack.peek()[1];
    stack.push(new int[]{val, Math.min(val, currentMin)});
}

public void pop() {
    stack.pop();
}

public int top() {
    return stack.peek()[0];
}

public int getMin() {
    return stack.peek()[1];
}

}

SearchInRotatedSortedArray.java

SearchInRotatedSortedArray.java fails for data:

int result = searchInRotatedSortedArray.search( new int[] { 5, 1, 3 }, 2 );
Assert.assertEquals( result, -1 );

It does not return and times out

Code on line 30:

 left = mid - 1;

should be changed to

 left = mid + 1;

Contribute to com.companies

Hello,

Looking for a contributor to contribute to com.companies package. Intention of this package to include most frequently asked questions in companies like FAANG or any other company that can help others. Feel free to contribute to this package by creating a package on a name of company & include code implementation.

Set Up CI/CD Process

Looking for a simple CI process to validate source code on every merge to master. So that we don't include any buggy code to repository.

AlienDictionary does not work on https://www.lintcode.com/problem/892/

I do not have premium access to AlienDictonary on leetcode. I think this solution is for leetcode.

The wording of the question on lintcode is different to the wording of the question on leetcode (I think).

The lintcode wording on https://www.lintcode.com/problem/892/ includes:

  "There may be multiple valid order of letters, return the smallest in normal lexicographical order."

The Java AlienDictionary solution does not cater for this.

The code looks like:

StringBuilder sortedOrder = new StringBuilder();

while (!sources.isEmpty()) {
        Character vertex = sources.remove();
        sortedOrder.append(vertex);
        for (char c: graph.get(vertex)) {
            inDegree.put(c, inDegree.get(c) - 1);
            if (inDegree.get(c) == 0) {
                sources.add(c);
            }
        }
    }

Notice there is no sorting going on with the StringBuilder

I think that the main problem you have is that on:

 needcode.io blind75 Advanced Graph - Alien Dictionary

the Alien Dictionary link goes to:

 https://www.lintcode.com/problem/892/

while the Java Solution is for leetcode which is locked and is only available for premium members.

I think it will help others if this is somehow conveyed to the readers of needcode.io, blind75, Advanced Graph - Alien Dictionary

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.