Code Monkey home page Code Monkey logo

ctci-go's Introduction

Cracking the Coding Interview in Go

Solving programming questions from "Cracking the Coding Interview 6th Edition" by Gayle Laakmann McDowell. In Go.

Chapter 1: Arrays and Strings

# Problem Tested Solved
1.1 Is Unique tests
1.2 Check Permutation tests
1.3 URLify tests
1.4 Palindrome Permutation tests
1.5 One Away tests
1.6 String Compression tests
1.7 Rotate Matrix tests
1.8 Zero Matrix tests
1.9 String Rotation tests

Chapter 2: Linked List

# Problem Tested Solved
2.1 Remove Sups tests
2.2 Return kth to Last tests
2.3 Delete Middle Node tests
2.4 Partition tests
2.5 Sum Lists tests
2.6 Palindrome tests
2.7 Intersection tests
2.8 Loop Detection tests

Chapter 3: Stacks and Queues

Stack implementation (with Linked List as a storage); tests

Queue implementation (with Linked List as a storage); tests

Fixed (capped) Stack implementation (with Linked List as a storage); tests

# Problem Tested Solved
3.1 Three in one tests
3.2 Stack Min tests
3.3 Stack of Plates tests
3.4 Queue via Stacks tests
3.5 Sort Stack tests
3.6 Animal Shelter tests

ctci-go's People

Contributors

ele7ija avatar krlv 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

Watchers

 avatar  avatar

ctci-go's Issues

Chapter 3: Stacks and Queues tasks

  • Stack implementation
  • Queue implementation
  • 3.1 Three in One
  • 3.2 Stack Min
  • 3.3 Stack of Plates
  • 3.4 Queue via Stacks
  • 3.5 Sort Stack
  • 3.6 Animal Shelter

Q1.1: add bit-vector solution

Hi, I have written a solution that doesn't use additional data structures and has O(n) complexity.

Cannot make a PR tho because it's forbidden.

Anyway, I'll attach the code below since it's dead simple.

// IsUniqueBits determines if a string has all unique chars (only works for ASCII)
// This solution doesn't utilize any additional data structures and has O(n) time complexity
func IsUniqueBits(s string) bool {

	s = strings.ToLower(s)
	var vector int32
	sBytes := []byte(s) // only for ASCII
	for _, sByte := range sBytes {
		index := sByte - 'a'
		mask := int32(1 << index)
		if (vector & mask) == mask {
			return false
		}
		vector = vector | mask
	}
	return true
}

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.