프로그래머스

public class Solution { public int solution(int num) { int answer = 0; long temp = num; while(temp != 1) { ++answer; temp = temp % 2 == 0 ? temp / 2 : temp * 3 + 1; if(answer > 500) { return -1; } } return answer; } }
using System; public class Solution { public int solution(int[] num_list) { int first = 0; int second = 0; for (int i = 0; i < num_list.Length; i++) { if (num_list[i] % 2 == 0) first = (int)(10 * first) + (num_list[i]); else second = (int)(10 * second) + (num_list[i]); } return first + second; } }
이거도 다시 풀기 !!! 💻 using System; public class Solution { public int solution(int[] numbers, int k) { int answer = numbers[2 * (k - 1) % numbers.Length]; return answer; } }
💻 using System; public class Solution { public int solution(string[] order) { int answer = 0; for(int i = 0; i < order.Length; i++) { if(order[i].Contains("latte")) answer += 5000; else answer += 4500; } return answer; } }
💻 using System; public class Example { public static void Main() { Console.WriteLine("!@#$%^&*(\\'\"?:;"); } } 이스케이프 문자 백슬러시로 감싸줘야함 \ + \' + \
이거 다시 풀기 !!! 💻 using System; public class Solution { public int solution(int[] array) { int answer = 0; int num = 0; for(int i = 0; i 0) { if(num % 10 == 7) { answer++; } num /= 10; } } return answer; } }
💻 using System; public class Solution { public int solution(string s) { int answer = 0; string[] arr = s.Split(" "); for(int i = 0; i < arr.Length; i++) { if(arr[i] == "Z") { answer -= int.Parse(arr[i - 1]); continue; } answer += int.Parse(arr[i]); } return answer; } }
💻 using System; public class Solution { public int solution(string before, string after) { int answer = 0; char[] b = before.ToCharArray(); char[] a = after.ToCharArray(); Array.Sort(b); Array.Sort(a); string bbb = new string(b); string aaa = new string(a); if(bbb.Equals(aaa)) answer = 1; else answer = 0; return answer; } }
💻 using System; public class Solution { public string solution(string my_string, int num1, int num2) { string answer = ""; char[] arr = my_string.ToCharArray(); char ch; ch = arr[num1]; arr[num1] = arr[num2]; arr[num2] = ch; answer = string.Concat(arr); return answer; } }
💻 using System; public class Solution { public int solution(int hp) { return (hp / 5) + ((hp % 5) / 3) + ((hp % 5) % 3); } }
suniverse
'프로그래머스' 태그의 글 목록