GithubHelp home page GithubHelp logo

balachandraraju / byte-by-byte-solutions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samgh/byte-by-byte-solutions

0.0 2.0 0.0 27 KB

Coding interview questions and solutions

Home Page: http://www.byte-by-byte.com

C++ 6.63% Java 93.37%

byte-by-byte-solutions's Introduction

Byte by Byte Solutions

Byte by Byte is a coding interview prep website that provides many practice interview questions as well as detailed explanations. This repo contains working, tested code for the solutions on Byte by Byte.

Contributing

I would love to compile solutions to all of the problems here, as well as offer solutions in different languages. Currently we only have Java solutions but Python, C, or any other languages would be most welcome. Just create a pull request with your changes. And make sure your code includes at least a few tests!

Index of Questions

  • Priority Queue (Github)
    Implement a Priority Queue.
  • 0-1 Knapsack (Github)
    Given a list of items with values and weights, as well as a max weight, find the maximum value you can generate from items where the sum of the weights is less than the max.
  • Matrix Product (Github)
    Given a matrix, find the path from top left to bottom right with the greatest product by moving only down and right.
  • Find Duplicates (Github)
    Given an array of integers where each value 1 <= x <= len(array), write a function that finds all the duplicates in the array.
  • Integer to Roman Numeral (Github)
    Given an integer, write a function to return its roman numeral representation.
  • Autocomplete (Github)
    Write an autocomplete class that returns all dictionary words with a given prefix.
  • Linked List Cycle (Github)
    Given a linked list, determine whether it contains a cycle.
  • Build Order (Github)
    Given a list of packages that need to be built and the dependencies for each package, determine a valid order in which to build the packages.
  • Consecutive Array (Github)
    Given an unsorted array, find the length of the longest sequence of consecutive numbers in the array.
  • Zero Matrix (Github)
    Given a boolean matrix, update it so that if any cell is true, all the cells in that row and column are true.
  • Random Binary Tree (Github)
    Implement a binary tree with a method getRandomNode() that returns a random node.
  • Two Missing Numbers (Github)
    Given an array containing all the numbers from 1 to n except two, find the two missing numbers.
  • Shortest Path
    Given a directed graph, find the shortest path between two nodes if one exists.
  • Square Submatrix
    Given a 2D array of 1s and 0s, find the largest square subarray of all 1s.
  • Random Linked List
    Given a linked list where each node has two pointers, one to the next node and one to a random node in the list, clone the linked list.
  • Big Int Mod
    Given a list of bytes a, each representing one byte of a larger integer (ie. {0x12, 0x34, 0x56, 0x78} represents the integer 0x12345678), and an integer b, find a % b.
  • Merge K Arrays
    Given k sorted arrays, merge them into a single sorted array.
  • Dedup Linked List
    Given an unsorted linked list, write a function to remove all the duplicates.
  • Lowest Common Ancestor
    Given two nodes in a binary tree, write a function to find the lowest common ancestor.
  • String Deletion
    Given a string and a dictionary HashSet, write a function to determine the minimum number of characters to delete to make a word.
  • Sum
    Given two integers, write a function to sum the numbers without using any arithmetic operators.
  • Reverse Stack
    Given a stack, reverse the items without creating any additional data structures.
  • Swap Variables
    Given two integers, write a function that swaps them without using any temporary variables.
  • Matrix Search
    Given an n x m array where all rows and columns are in sorted order, write a function to determine whether the array contains an element x.
  • Clock Angle
    Given two integers, an hour and a minute, write a function to calculate the angle between the two hands on a clock representing that time.
  • Fibonacci
    Given an integer n, write a function to compute the nth Fibonacci number.
  • Tree to Doubly Linked List
    Given a tree, write a function to convert it into a circular doubly linked list from left to right by only modifying the existing pointers.
  • Line Intersection
    Given two lines on a Cartesian plane, write a function to determine whether or not the lines intersect.
  • Longest Consecutive Branch
    Given a tree, write a function to find the length of the longest branch of nodes in increasing consecutive order.
  • Sort Stacks
    Given a stack, sort the elements in the stack using one additional stack.
  • Print Reversed List
    Given a linked list, write a function that prints the nodes of the list in reverse order.
  • Longest Common Substring
    Given two strings, write a function that returns the longest common substring.
  • Stack from Queues
    Implement a LIFO stack with basic functionality (push and pop) using FIFO queues to store the data.
  • Balanced Binary Tree
    Given a binary tree, write a function to determine whether the tree is balanced.
  • Gray Code
    Given two integers, write a function to determine whether or not their binary representations differ by a single bit.
  • Merge Arrays
    Given 2 sorted arrays, A and B, where A is long enough to hold the contents of A and B, write a function to copy the contents of B into A without using any buffer or additional memory.
  • Zero Sum Subarray
    Given an array, write a function to find any subarray that sums to zero, if one exists.
  • Three Sum
    Given a list of integers, write a function that returns all sets of 3 numbers in the list, a, b, and c, so that a + b + c == 0.
  • Rotate Bits
    Given a number, write a function to rotate the bits (ie circular shift).
  • Palindromes
    Given a linked list, write a function to determine whether the list is a palindrome.
  • Permutations
    Write a function that returns all permutations of a given list.
  • N Stacks Implement N > 0 stacks using a single array to store all stack data (you may use auxiliary arrays in your stack object, but all of the objects in all of the stacks must be in the same array). No stack should be full unless the entire array is full.
  • Tree Level Order
    Given a tree, write a function that prints out the nodes of the tree in level order.
  • Split Linked List
    Given a linked list, write a function to split the list into two equal halves.
  • Kth Most Frequest String
    Given a list of strings, write a function to get the kth most frequently occurring string.
  • String Compression
    Given a string, write a function to compress it by shortening every sequence of the same character to that character followed by the number of repetitions. If the compressed string is longer than the original, you should return the original string.
  • Anagrams
    Given two strings, write a function to determine whether they are anagrams.
  • Binary Search Tree Verification
    Given a binary tree, write a function to test if the tree is a binary search tree.
  • Max Stack
    Implement a LIFO stack that has a push(), pop(), and max() function, where max() returns the maximum value in the stack. All of these functions should run in O(1) time.
  • Number of Ones in Binary
    Given an integer, write a function to compute the number of ones in the binary representation of the number.
  • Smallest Change
    Given an input amount of change x, write a function to determine the minimum number of coins required to make that amount of change.
  • Nth-to-last Element (Github)
    Given a linked list, and an input n, write a function that returns the nth-to-last element of the linked list.
  • FizzBuzz
    Output numbers from 1 to x. If the number is divisible by 3, replace it with “Fizz”. If it is divisible by 5, replace it with “Buzz”. If it is divisible by 3 and 5 replace it with “FizzBuzz”.

byte-by-byte-solutions's People

Contributors

arkogupta avatar samgh avatar

Watchers

 avatar  avatar

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.