{"id":22513860,"url":"https://github.com/emahtab/first-bad-version","last_synced_at":"2026-01-07T14:05:28.665Z","repository":{"id":79525509,"uuid":"446092052","full_name":"eMahtab/first-bad-version","owner":"eMahtab","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-09T14:00:00.000Z","size":2,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T01:41:29.527Z","etag":null,"topics":["binary-search","leetcode"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eMahtab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-09T13:11:36.000Z","updated_at":"2022-01-09T14:00:24.000Z","dependencies_parsed_at":"2023-05-10T17:15:40.297Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/first-bad-version","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eMahtab/first-bad-version","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Ffirst-bad-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Ffirst-bad-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Ffirst-bad-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Ffirst-bad-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/first-bad-version/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Ffirst-bad-version/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28235811,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2026-01-07T02:00:05.975Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary-search","leetcode"],"created_at":"2024-12-07T03:14:44.481Z","updated_at":"2026-01-07T14:05:28.623Z","avatar_url":"https://github.com/eMahtab.png","language":null,"readme":"# First bad version\n## https://leetcode.com/problems/first-bad-version\n\n# Implementation 1 : Naive(Brute Force) Time Limit Exceeded O(n)\n```java\n/* The isBadVersion API is defined in the parent class VersionControl.\n      boolean isBadVersion(int version); */\n\npublic class Solution extends VersionControl {\n    public int firstBadVersion(int n) {\n        for(int i = 1; i \u003c= n; i++) {\n            if(isBadVersion(i))\n                return i;\n        }\n        return -1;\n    }\n}\n```\n\n# Implementation 2 : Binary Search  O(logn)\n```java\n/* The isBadVersion API is defined in the parent class VersionControl.\n      boolean isBadVersion(int version); */\n\npublic class Solution extends VersionControl {\n    public int firstBadVersion(int n) {\n        int left = 1;\n        int right = n;\n        while(left \u003c right) {\n            int mid = left + (right-left)/2;\n            if(!isBadVersion(mid)) {\n                left = mid+1;\n            } else {\n                right = mid;\n            }\n        }\n        return left;\n    }\n}\n```\n\n# References :\nhttps://leetcode.com/problems/first-bad-version/solution\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Ffirst-bad-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Ffirst-bad-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Ffirst-bad-version/lists"}