{"id":22513931,"url":"https://github.com/emahtab/count-and-say","last_synced_at":"2026-02-05T20:05:25.593Z","repository":{"id":79525374,"uuid":"258472141","full_name":"eMahtab/count-and-say","owner":"eMahtab","description":"Count and say","archived":false,"fork":false,"pushed_at":"2020-04-24T10:03:37.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-20T00:19:10.274Z","etag":null,"topics":["leetcode","problem-solving"],"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":"2020-04-24T09:51:22.000Z","updated_at":"2020-04-24T10:03:40.000Z","dependencies_parsed_at":"2023-05-10T17:00:34.147Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/count-and-say","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eMahtab/count-and-say","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fcount-and-say","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fcount-and-say/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fcount-and-say/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fcount-and-say/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/count-and-say/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fcount-and-say/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29132567,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T19:36:52.185Z","status":"ssl_error","status_checked_at":"2026-02-05T19:35:40.941Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["leetcode","problem-solving"],"created_at":"2024-12-07T03:15:06.497Z","updated_at":"2026-02-05T20:05:25.562Z","avatar_url":"https://github.com/eMahtab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Count and say\n## https://leetcode.com/problems/count-and-say\n\nThe count-and-say sequence is the sequence of integers with the first five terms as following:\n```\n1.     1\n2.     11\n3.     21\n4.     1211\n5.     111221\n```\n\n```\n1 is read off as \"one 1\" or 11.\n11 is read off as \"two 1s\" or 21.\n21 is read off as \"one 2, then one 1\" or 1211.\n```\n\nGiven an integer n where 1 ≤ n ≤ 30, generate the nth term of the count-and-say sequence. You can do so recursively, in other words from the previous member read off the digits, counting the number of digits in groups of the same digit.\n\nNote: Each term of the sequence of integers will be represented as a string.\n```\nExample 1:\n\nInput: 1\nOutput: \"1\"\nExplanation: This is the base case.\n\nExample 2:\n\nInput: 4\nOutput: \"1211\"\nExplanation: For n = 3 the term was \"21\" in which we have two groups \"2\" and \"1\", \n\"2\" can be read as \"12\" which means frequency = 1 and value = 2, the same way \"1\"\nis read as \"11\", so the answer is the concatenation of \"12\" and \"11\" which is \"1211\".\n```\n# Implementation :\n\n```java\nclass Solution {\n    public String countAndSay(int n) {\n        String number = \"1\";\n        for(int i = 1; i \u003c n; i++) {\n            number = say(number);\n        }\n        return number;\n    }\n    \n    private String say(String s) {\n        int num = Character.getNumericValue(s.charAt(0));\n        int lastSeen = num;\n        int count = 1;\n        String str = \"\";\n        int i = 1;\n        for(; i \u003c s.length(); i++){\n            if(Character.getNumericValue(s.charAt(i)) == lastSeen)\n                count++;\n            else {\n                str = str + count + lastSeen;\n                count = 1;\n                lastSeen = Character.getNumericValue(s.charAt(i));\n            }\n        }\n        str = str + count + lastSeen;\n        return str;\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fcount-and-say","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Fcount-and-say","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fcount-and-say/lists"}