leetcode

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AvailableLanguage = map[string]string{
		"cpp":  "C++",
		"java": "Java",
		"py":   "Python",
		"ts":   "TypeScript",
		"sql":  "MySQL",
		"sh":   "Shell",
	}
)
View Source
var (
	ErrLanguageNotSupported = errors.New("language is not supported")
)
View Source
var (
	ErrProblemNotFound = errors.New("problem cannot be found")
)
View Source
var (
	ErrUserNotExists = errors.New("user not found")
)

Functions

func ErrUnableToGetSolution

func ErrUnableToGetSolution(problemID int32, language string) error

func FormatContestLevel

func FormatContestLevel(level string) string

func FormatContestRating

func FormatContestRating(rating uint16) string

func FormatGlobalRanking

func FormatGlobalRanking(rank uint64) string

func ValidLanguage

func ValidLanguage(language string) bool

Types

type Contest

type Contest struct {
	ProblemsSolved      uint8
	FinishTimeInSeconds uint16
	Rating              uint16
	Ranking             uint64
	Metadata            ContestMetadata
}

type ContestMetadata

type ContestMetadata struct {
	StartTime     uint64
	Title         string
	TotalProblems uint8
}

type LanguageStats

type LanguageStats struct {
	Name           string
	ProblemsSolved uint64
}

type Leetcode

type Leetcode struct {
	Problems interface {
		GetByID(int32) (*Problem, error)
		GetToday() (*Problem, error)
	}
	Solutions interface {
		GetByID(int32, string) (*Solution, error)
	}
	Profiles interface {
		GetByUsername(string) (*Profile, error)
	}
	UserContestInfo interface {
		GetByUsername(string) (*UserContestInfo, error)
	}
	Stats interface {
		GetByUsername(string) (*Stats, error)
	}
	Submissions interface {
		GetByUsername(string) ([]*Submission, error)
	}
}

func New

func New() *Leetcode

type Problem

type Problem struct {
	Title      string
	TitleSlug  string
	ID         int32
	PaidOnly   bool
	Difficulty string
	AcRate     float64
	Topics     []Topic
}

type ProblemService

type ProblemService struct {
	// contains filtered or unexported fields
}

func (*ProblemService) GetByID

func (s *ProblemService) GetByID(problemID int32) (*Problem, error)

func (*ProblemService) GetToday

func (s *ProblemService) GetToday() (*Problem, error)

type ProblemStats

type ProblemStats struct {
	Difficulty     string
	ProblemsSolved uint64
	Total          uint64
	Beat           float64
}

type Profile

type Profile struct {
	Username      string
	RealName      string
	Bio           string
	GlobalRanking uint64
	ContestLevel  string
	Country       string
	School        string
	Skills        []string
	SocialURL     SocialURl
}

type ProfileService

type ProfileService struct {
	// contains filtered or unexported fields
}

func (*ProfileService) GetByUsername

func (s *ProfileService) GetByUsername(username string) (*Profile, error)

type SocialURl

type SocialURl struct {
	Github   string
	X        string
	Linkedin string
}

type Solution

type Solution struct {
	ProblemID int32
	Language  string
	Content   string
}

type SolutionService

type SolutionService struct {
	// contains filtered or unexported fields
}

func (*SolutionService) GetByID

func (s *SolutionService) GetByID(problemID int32, language string) (*Solution, error)

type Stats

type Stats struct {
	Languages []LanguageStats
	Problems  [3]ProblemStats
}

type StatsService

type StatsService struct {
	// contains filtered or unexported fields
}

func (*StatsService) GetByUsername

func (s *StatsService) GetByUsername(username string) (*Stats, error)

type Submission

type Submission struct {
	ProblemTitle string
	AcTime       uint64
}

type SubmissionsService

type SubmissionsService struct {
	// contains filtered or unexported fields
}

func (*SubmissionsService) GetByUsername

func (s *SubmissionsService) GetByUsername(username string) ([]*Submission, error)

type Topic

type Topic struct {
	Name string
	Slug string
	ID   string
}

type UserContestInfo

type UserContestInfo struct {
	AttendedContestsCount uint64
	Rating                uint16
	GlobalRanking         uint64
	TopPercentage         float64
	ContestLevel          string
	AttendedContests      []Contest
}

type UserContestInfoService

type UserContestInfoService struct {
	// contains filtered or unexported fields
}

func (*UserContestInfoService) GetByUsername

func (s *UserContestInfoService) GetByUsername(username string) (*UserContestInfo, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL